james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r922148 - in /james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr: ./ mail/ mail/model/ user/ user/model/
Date Fri, 12 Mar 2010 05:32:01 GMT
Author: norman
Date: Fri Mar 12 05:32:01 2010
New Revision: 922148

URL: http://svn.apache.org/viewvc?rev=922148&view=rev
Log:
Some more cosmetic changes related to IMAP-93

Added:
    james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRUtils.java
Modified:
    james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/JCRMailboxMapper.java
    james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRHeader.java
    james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRMailbox.java
    james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRProperty.java
    james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/user/JCRSubscriptionMapper.java
    james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/user/model/JCRSubscription.java

Added: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRUtils.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRUtils.java?rev=922148&view=auto
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRUtils.java (added)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRUtils.java Fri Mar 12
05:32:01 2010
@@ -0,0 +1,42 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+package org.apache.james.imap.jcr;
+
+import org.apache.jackrabbit.util.Text;
+
+public class JCRUtils implements JCRImapConstants{
+
+	public static String createPath(String... subNodes) {
+		StringBuffer pathBuf = new StringBuffer();
+		
+		for (int i = 0; i < subNodes.length; i++ ) {
+			String path = subNodes[i];
+			if (path.startsWith(PROPERTY_PREFIX) == false) {
+				pathBuf.append(PROPERTY_PREFIX);
+			}
+			pathBuf.append(Text.escapeIllegalJcrChars(path));
+			
+			if (i +1 != subNodes.length) {
+				pathBuf.append(NODE_DELIMITER);
+			}
+		}
+        return pathBuf.toString();
+		
+	}
+}

Modified: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/JCRMailboxMapper.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/JCRMailboxMapper.java?rev=922148&r1=922147&r2=922148&view=diff
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/JCRMailboxMapper.java
(original)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/JCRMailboxMapper.java
Fri Mar 12 05:32:01 2010
@@ -33,6 +33,7 @@ import org.apache.commons.logging.Log;
 import org.apache.jackrabbit.util.Text;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.jcr.JCRImapConstants;
+import org.apache.james.imap.jcr.JCRUtils;
 import org.apache.james.imap.jcr.mail.model.JCRMailbox;
 import org.apache.james.imap.mailbox.MailboxNotFoundException;
 import org.apache.james.imap.mailbox.StorageException;
@@ -45,11 +46,11 @@ import org.apache.james.imap.store.trans
  * 
  * 
  */
-public class JCRMailboxMapper extends NonTransactionalMapper implements MailboxMapper {
+public class JCRMailboxMapper extends NonTransactionalMapper implements MailboxMapper,JCRImapConstants
{
 
     private final static String WILDCARD = "*";
     private final Session session;
-    private final String PATH = "mailboxes";
+    private final String PATH = PROPERTY_PREFIX + "mailboxes";
     private Log logger;
 
     public JCRMailboxMapper(final Session session, final Log logger) {
@@ -68,7 +69,7 @@ public class JCRMailboxMapper extends No
         String nodeName = Text.unescapeIllegalJcrChars(name);
 
         try {
-            boolean found = session.getRootNode().hasNode(PATH + JCRImapConstants.NODE_DELIMITER
+ nodeName);
+            boolean found = session.getRootNode().hasNode(JCRUtils.createPath(PATH, nodeName));
             if (found) {
                 return 1;
             }
@@ -90,7 +91,7 @@ public class JCRMailboxMapper extends No
     public void delete(Mailbox mailbox) throws StorageException {
         String nodeName = Text.unescapeIllegalJcrChars(mailbox.getName());
         try {
-            session.getRootNode().getNode(PATH + JCRImapConstants.NODE_DELIMITER + nodeName).remove();
+            session.getRootNode().getNode(JCRUtils.createPath(PATH, nodeName)).remove();
         } catch (PathNotFoundException e) {
             // mailbox does not exists..
         } catch (RepositoryException e) {
@@ -124,7 +125,7 @@ public class JCRMailboxMapper extends No
      */
     public boolean existsMailboxStartingWith(String mailboxName) throws StorageException
{
         try {
-            return session.getRootNode().getNodes(PATH + JCRImapConstants.NODE_DELIMITER
+ Text.unescapeIllegalJcrChars(mailboxName) + WILDCARD).hasNext();
+            return session.getRootNode().getNodes(JCRUtils.createPath(PATH,  mailboxName)
+ WILDCARD).hasNext();
         } catch (RepositoryException e) {
             throw new StorageException(HumanReadableText.SEARCH_FAILED, e);
         }
@@ -138,7 +139,7 @@ public class JCRMailboxMapper extends No
     public Mailbox findMailboxById(long mailboxId) throws StorageException, MailboxNotFoundException
{
         try {
             QueryManager manager = session.getWorkspace().getQueryManager();
-            String queryString = session.getRootNode().getPath() + JCRImapConstants.NODE_DELIMITER
+ PATH + "//element(" + mailboxId + ")," + JCRMailbox.ID_PROPERTY + ")";
+            String queryString = JCRUtils.createPath(session.getRootNode().getPath(), PATH)
+ "//element(" + mailboxId + ")," + JCRMailbox.ID_PROPERTY + ")";
             Query query = manager.createQuery(queryString, Query.XPATH);
 
             NodeIterator nodes = query.execute().getNodes();
@@ -163,7 +164,7 @@ public class JCRMailboxMapper extends No
      */
     public Mailbox findMailboxByName(String name) throws StorageException, MailboxNotFoundException
{
         try {
-            Node node = session.getRootNode().getNode(PATH + JCRImapConstants.NODE_DELIMITER
+ name);
+            Node node = session.getRootNode().getNode(JCRUtils.createPath(PATH, name));
             return JCRMailbox.from(node);
         } catch (PathNotFoundException e) {
             throw new MailboxNotFoundException(name);
@@ -182,7 +183,7 @@ public class JCRMailboxMapper extends No
     public List<Mailbox> findMailboxWithNameLike(String name) throws StorageException
{
         List<Mailbox> mailboxList = new ArrayList<Mailbox>();
         try {
-            NodeIterator it = session.getRootNode().getNodes(PATH + JCRImapConstants.NODE_DELIMITER
+ WILDCARD + name + WILDCARD);
+            NodeIterator it = session.getRootNode().getNodes(PATH + NODE_DELIMITER + WILDCARD
+ name + WILDCARD);
             while (it.hasNext()) {
                 mailboxList.add(JCRMailbox.from(it.nextNode()));
             }
@@ -202,7 +203,7 @@ public class JCRMailboxMapper extends No
      * imap.store.mail.model.Mailbox)
      */
     public void save(Mailbox mailbox) throws StorageException {
-        String nodePath = PATH + JCRImapConstants.NODE_DELIMITER + Text.unescapeIllegalJcrChars(mailbox.getName());
+        String nodePath = JCRUtils.createPath(PATH,mailbox.getName());
         try {
             Node node;
             if (session.getRootNode().hasNode(nodePath)) {

Modified: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRHeader.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRHeader.java?rev=922148&r1=922147&r2=922148&view=diff
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRHeader.java
(original)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRHeader.java
Fri Mar 12 05:32:01 2010
@@ -20,6 +20,7 @@ package org.apache.james.imap.jcr.mail.m
 
 import javax.jcr.Node;
 import javax.jcr.RepositoryException;
+import javax.mail.Header;
 
 import org.apache.commons.logging.Log;
 import org.apache.james.imap.jcr.IsPersistent;
@@ -27,15 +28,15 @@ import org.apache.james.imap.jcr.JCRImap
 import org.apache.james.imap.store.mail.model.AbstractComparableHeader;
 
 /**
- * JCR implementation of a Header
+ * JCR implementation of a {@link Header}
  * 
  *
  */
 public class JCRHeader extends AbstractComparableHeader implements JCRImapConstants, IsPersistent{
 
-    public final static String FIELDNAME_PROPERTY = PROPERTY_PREFIX + "fieldName";
-    public final static String VALUE_PROPERTY = PROPERTY_PREFIX + "value";
-    public final static String LINENUMBER_PROPERTY = PROPERTY_PREFIX + "lineNumber";
+    public final static String FIELDNAME_PROPERTY = PROPERTY_PREFIX + "headerFieldName";
+    public final static String VALUE_PROPERTY = PROPERTY_PREFIX + "headerFalue";
+    public final static String LINENUMBER_PROPERTY = PROPERTY_PREFIX + "headerLineNumber";
 
     private String fieldName;
     private String value;

Modified: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRMailbox.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRMailbox.java?rev=922148&r1=922147&r2=922148&view=diff
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRMailbox.java
(original)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRMailbox.java
Fri Mar 12 05:32:01 2010
@@ -31,14 +31,14 @@ import org.apache.james.imap.store.mail.
 
 
 /**
- * JCR implementation of a Mailbox
+ * JCR implementation of a {@link Mailbox}
  */
 public class JCRMailbox implements Mailbox{
 
-    public final static String ID_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "id";
-    public final static String NAME_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "name";
-    public final static String UIDVALIDITY_PROPERTY = JCRImapConstants.PROPERTY_PREFIX +
"uidValidity";
-    public final static String LASTUID_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "lastUid";
+    public final static String ID_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "mailboxId";
+    public final static String NAME_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "mailboxName";
+    public final static String UIDVALIDITY_PROPERTY = JCRImapConstants.PROPERTY_PREFIX +
"mailboxUidValidity";
+    public final static String LASTUID_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "mailboxLastUid";
 
     private long id = -1;
     private String name;

Modified: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRProperty.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRProperty.java?rev=922148&r1=922147&r2=922148&view=diff
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRProperty.java
(original)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRProperty.java
Fri Mar 12 05:32:01 2010
@@ -26,7 +26,12 @@ import org.apache.james.imap.jcr.IsPersi
 import org.apache.james.imap.jcr.JCRImapConstants;
 
 import org.apache.james.imap.store.mail.model.AbstractComparableProperty;
+import org.apache.james.imap.store.mail.model.Property;
 
+/**
+ * JCR implementation of {@link Property}
+ *
+ */
 public class JCRProperty extends AbstractComparableProperty<JCRProperty> implements
JCRImapConstants, IsPersistent {
 
     private Node node;

Modified: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/user/JCRSubscriptionMapper.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/user/JCRSubscriptionMapper.java?rev=922148&r1=922147&r2=922148&view=diff
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/user/JCRSubscriptionMapper.java
(original)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/user/JCRSubscriptionMapper.java
Fri Mar 12 05:32:01 2010
@@ -28,10 +28,10 @@ import javax.jcr.RepositoryException;
 import javax.jcr.Session;
 
 import org.apache.commons.logging.Log;
-import org.apache.jackrabbit.util.Text;
 import org.apache.james.imap.api.display.HumanReadableText;
 import org.apache.james.imap.jcr.IsPersistent;
 import org.apache.james.imap.jcr.JCRImapConstants;
+import org.apache.james.imap.jcr.JCRUtils;
 import org.apache.james.imap.jcr.user.model.JCRSubscription;
 import org.apache.james.imap.mailbox.SubscriptionException;
 import org.apache.james.imap.store.transaction.NonTransactionalMapper;
@@ -44,11 +44,11 @@ import org.apache.james.imap.store.user.
  * ends in a "real" action
  * 
  */
-public class JCRSubscriptionMapper extends NonTransactionalMapper implements SubscriptionMapper
{
+public class JCRSubscriptionMapper extends NonTransactionalMapper implements SubscriptionMapper,
JCRImapConstants {
 
     private final Session session;
     private final Log log;
-    private final static String PATH = "subscriptions";
+    private final static String PATH = PROPERTY_PREFIX + "subscriptions";
 
     public JCRSubscriptionMapper(final Session session, final Log log) {
         this.session = session;
@@ -88,7 +88,7 @@ public class JCRSubscriptionMapper exten
      */
     public Subscription findFindMailboxSubscriptionForUser(String user, String mailbox) throws
SubscriptionException {
         try {
-            Node node = session.getRootNode().getNode(PATH + JCRImapConstants.NODE_DELIMITER
+ getPath(user, mailbox));
+            Node node = session.getRootNode().getNode(JCRUtils.createPath(PATH, user, mailbox));
             return new JCRSubscription(node, log);
         } catch (PathNotFoundException e) {
             return null;
@@ -107,7 +107,7 @@ public class JCRSubscriptionMapper exten
     public List<Subscription> findSubscriptionsForUser(String user) throws SubscriptionException
{
         List<Subscription> subList = new ArrayList<Subscription>();
         try {
-            Node node = session.getRootNode().getNode(PATH + JCRImapConstants.NODE_DELIMITER
+ Text.escapeIllegalJcrChars(user));
+            Node node = session.getRootNode().getNode(JCRUtils.createPath(PATH , user));
             NodeIterator nodeIt = node.getNodes("*");
             while (nodeIt.hasNext()) {
                 subList.add(new JCRSubscription(nodeIt.nextNode(), log));
@@ -131,7 +131,7 @@ public class JCRSubscriptionMapper exten
     public void save(Subscription subscription) throws SubscriptionException {
         String username = subscription.getUser();
         String mailbox = subscription.getMailbox();
-        String nodename = getPath(username, mailbox);
+        String nodename = JCRUtils.createPath(username, mailbox);
         try {
             Node node = session.getRootNode().getNode(PATH);
             Node subNode;
@@ -150,8 +150,4 @@ public class JCRSubscriptionMapper exten
         }
     }
 
-    private String getPath(String username, String mailbox) {
-        return Text.escapeIllegalJcrChars(username) + JCRImapConstants.NODE_DELIMITER + Text.escapeIllegalJcrChars(mailbox);
-    }
-
 }

Modified: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/user/model/JCRSubscription.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/user/model/JCRSubscription.java?rev=922148&r1=922147&r2=922148&view=diff
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/user/model/JCRSubscription.java
(original)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/user/model/JCRSubscription.java
Fri Mar 12 05:32:01 2010
@@ -28,12 +28,12 @@ import org.apache.james.imap.jcr.JCRImap
 import org.apache.james.imap.store.user.model.Subscription;
 
 /**
- * JCR implementation of a Subscription
+ * JCR implementation of a {@link Subscription}
  * 
  */
 public class JCRSubscription implements Subscription, IsPersistent, JCRImapConstants {
-    public final static String USERNAME_PROPERTY = PROPERTY_PREFIX + "username";
-    public final static String MAILBOX_PROPERTY = PROPERTY_PREFIX  + "mailbox";
+    public final static String USERNAME_PROPERTY = PROPERTY_PREFIX + "subscriptionUsername";
+    public final static String MAILBOX_PROPERTY = PROPERTY_PREFIX  + "subscriptionMailbox";
     
     private Node node;
     private final Log log;



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message