You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/03/09 10:04:18 UTC
svn commit: r920742 - in /james/imap/trunk:
jcr/src/main/java/org/apache/james/imap/jcr/
jcr/src/main/java/org/apache/james/imap/jcr/mail/
jcr/src/main/java/org/apache/james/imap/jcr/mail/model/
jcr/src/main/java/org/apache/james/imap/jcr/user/ jcr/src...
Author: norman
Date: Tue Mar 9 09:04:17 2010
New Revision: 920742
URL: http://svn.apache.org/viewvc?rev=920742&view=rev
Log:
work in progress for JCR implementation of imap storage (IMAP-93)
Added:
james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRImapConstants.java
james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxManager.java
james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRSubscriptionManager.java
james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/
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/store/src/main/java/org/apache/james/imap/store/mail/model/AbstractComparableHeader.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/AbstractComparableProperty.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/user/JCRSubscriptionMapper.java
james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/user/model/JCRSubscription.java
james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAHeader.java
james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAProperty.java
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/SimpleHeader.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreSubscriptionManager.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Header.java
james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Property.java
Added: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRImapConstants.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRImapConstants.java?rev=920742&view=auto
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRImapConstants.java (added)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRImapConstants.java Tue Mar 9 09:04:17 2010
@@ -0,0 +1,36 @@
+/****************************************************************
+ * 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;
+
+/**
+ * Constants for JCR
+ *
+ */
+public interface JCRImapConstants {
+
+ /**
+ * Delimiter for Nodes
+ */
+ public static final String NODE_DELIMITER = "/";
+
+ /**
+ * Prefix for all imap related properties
+ */
+ public static final String PROPERTY_PREFIX ="imap:";
+}
Added: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxManager.java?rev=920742&view=auto
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxManager.java (added)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRMailboxManager.java Tue Mar 9 09:04:17 2010
@@ -0,0 +1,71 @@
+/****************************************************************
+ * 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 javax.jcr.Session;
+
+import org.apache.james.imap.mailbox.MailboxException;
+import org.apache.james.imap.store.Authenticator;
+import org.apache.james.imap.store.StoreMailbox;
+import org.apache.james.imap.store.StoreMailboxManager;
+import org.apache.james.imap.store.Subscriber;
+import org.apache.james.imap.store.mail.MailboxMapper;
+import org.apache.james.imap.store.mail.model.Mailbox;
+import org.apache.james.imap.store.transaction.TransactionalMapper;
+
+/**
+ * JCR implementation of a MailboxManager
+ *
+ *
+ */
+public class JCRMailboxManager extends StoreMailboxManager{
+
+ private final Session session;
+
+ public JCRMailboxManager(final Authenticator authenticator, final Subscriber subscriber, final Session session) {
+ super(authenticator, subscriber);
+ this.session = session;
+ }
+
+ @Override
+ protected StoreMailbox createMailbox(Mailbox mailboxRow) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected MailboxMapper createMailboxMapper() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void doCreate(String namespaceName) throws MailboxException {
+ final Mailbox mailbox = new org.apache.james.imap.jcr.mail.model.JCRMailbox(namespaceName, randomUidValidity());
+ final MailboxMapper mapper = createMailboxMapper();
+ mapper.execute(new TransactionalMapper.Transaction(){
+
+ public void run() throws MailboxException {
+ mapper.save(mailbox);
+ }
+
+ });
+ }
+
+}
Added: james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRSubscriptionManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRSubscriptionManager.java?rev=920742&view=auto
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRSubscriptionManager.java (added)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/JCRSubscriptionManager.java Tue Mar 9 09:04:17 2010
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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 javax.jcr.Session;
+
+import org.apache.james.imap.jcr.user.JCRSubscriptionMapper;
+import org.apache.james.imap.jcr.user.model.JCRSubscription;
+import org.apache.james.imap.store.StoreSubscriptionManager;
+import org.apache.james.imap.store.user.SubscriptionMapper;
+import org.apache.james.imap.store.user.model.Subscription;
+
+/**
+ * JCR implementation of a SubscriptionManager
+ *
+ *
+ */
+public class JCRSubscriptionManager extends StoreSubscriptionManager{
+
+ private final Session session;
+
+ public JCRSubscriptionManager(final Session session) {
+ super();
+
+ this.session = session;
+ }
+
+ @Override
+ protected SubscriptionMapper createMapper() {
+ JCRSubscriptionMapper mapper = new JCRSubscriptionMapper(session);
+ return mapper;
+ }
+
+ @Override
+ protected Subscription createSubscription(String user, String mailbox) {
+ return new JCRSubscription(user, mailbox);
+ }
+
+}
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=920742&r1=920741&r2=920742&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 Tue Mar 9 09:04:17 2010
@@ -24,7 +24,9 @@ import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+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.mailbox.MailboxNotFoundException;
import org.apache.james.imap.mailbox.StorageException;
import org.apache.james.imap.store.mail.MailboxMapper;
@@ -34,88 +36,106 @@ import org.apache.james.imap.store.trans
/**
* JCR implementation of a MailboxMapper
*
- *
+ *
*/
-public class JCRMailboxMapper extends NonTransactionalMapper implements MailboxMapper{
+public class JCRMailboxMapper extends NonTransactionalMapper implements MailboxMapper {
+
+ private final static String WILDCARD = "*";
+ private final Session session;
+ private final String PATH = "mailboxes";
+
+ public JCRMailboxMapper(Session session) {
+ this.session = session;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.MailboxMapper#countMailboxesWithName(java.lang.String)
+ */
+ public long countMailboxesWithName(String name) throws StorageException {
+ String nodeName = Text.unescapeIllegalJcrChars(name);
+
+ try {
+ boolean found = session.getRootNode().hasNode(PATH + JCRImapConstants.NODE_DELIMITER + nodeName);
+ if (found) {
+ return 1;
+ }
+ } catch (PathNotFoundException e) {
+ // not found
+ } catch (RepositoryException e) {
+ throw new StorageException(HumanReadableText.COUNT_FAILED, e);
+ }
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.james.imap.store.mail.MailboxMapper#delete(org.apache.james
+ * .imap.store.mail.model.Mailbox)
+ */
+ public void delete(Mailbox mailbox) throws StorageException {
+ String nodeName = Text.unescapeIllegalJcrChars(mailbox.getName());
+ try {
+ session.getRootNode().getNode(PATH + JCRImapConstants.NODE_DELIMITER + nodeName).remove();
+ } catch (PathNotFoundException e) {
+ // mailbox does not exists..
+ } catch (RepositoryException e) {
+ throw new StorageException(HumanReadableText.DELETED_FAILED, e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.james.imap.store.mail.MailboxMapper#deleteAll()
+ */
+ public void deleteAll() throws StorageException {
+ try {
+ session.getRootNode().getNode(PATH).remove();
+ session.save();
+
+ } catch (PathNotFoundException e) {
+ // nothing todo
+ } catch (RepositoryException e) {
+ throw new StorageException(HumanReadableText.DELETED_FAILED, e);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.apache.james.imap.store.mail.MailboxMapper#existsMailboxStartingWith
+ * (java.lang.String)
+ */
+ public boolean existsMailboxStartingWith(String mailboxName) throws StorageException {
+ try {
+ return session.getRootNode().getNodes(PATH + JCRImapConstants.NODE_DELIMITER + Text.unescapeIllegalJcrChars(mailboxName) + WILDCARD).hasNext();
+ } catch (RepositoryException e) {
+ throw new StorageException(HumanReadableText.SEARCH_FAILED, e);
+ }
+ }
+
+ public Mailbox findMailboxById(long mailboxId) throws StorageException, MailboxNotFoundException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Mailbox findMailboxByName(String name) throws StorageException, MailboxNotFoundException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Mailbox> findMailboxWithNameLike(String name) throws StorageException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void save(Mailbox mailbox) throws StorageException {
+ // TODO Auto-generated method stub
- private final static String WILDCARD = "*";
- private final Session session;
- private final String PATH = "mailboxes";
-
- public JCRMailboxMapper(Session session) {
- this.session = session;
- }
-
-
- public long countMailboxesWithName(String name) throws StorageException {
- // TODO Auto-generated method stub
- return 0;
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.james.imap.store.mail.MailboxMapper#delete(org.apache.james.imap.store.mail.model.Mailbox)
- */
- public void delete(Mailbox mailbox) throws StorageException {
- try {
- session.getRootNode().getNode(PATH + "/" +mailbox.getName()).remove();
- } catch (PathNotFoundException e) {
- // mailbox does not exists..
- } catch (RepositoryException e) {
- throw new StorageException(HumanReadableText.DELETED_FAILED, e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.james.imap.store.mail.MailboxMapper#deleteAll()
- */
- public void deleteAll() throws StorageException {
- try {
- session.getRootNode().getNode(PATH).remove();
- session.save();
-
- } catch (PathNotFoundException e) {
- // nothing todo
- } catch (RepositoryException e) {
- throw new StorageException(HumanReadableText.DELETED_FAILED, e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.apache.james.imap.store.mail.MailboxMapper#existsMailboxStartingWith(java.lang.String)
- */
- public boolean existsMailboxStartingWith(String mailboxName)
- throws StorageException {
- try {
- return session.getRootNode().getNodes(PATH + "/" + mailboxName + WILDCARD).hasNext();
- } catch (RepositoryException e) {
- throw new StorageException(HumanReadableText.SEARCH_FAILED, e);
- }
- }
-
- public Mailbox findMailboxById(long mailboxId) throws StorageException,
- MailboxNotFoundException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Mailbox findMailboxByName(String name) throws StorageException,
- MailboxNotFoundException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public List<Mailbox> findMailboxWithNameLike(String name)
- throws StorageException {
- // TODO Auto-generated method stub
- return null;
- }
-
- public void save(Mailbox mailbox) throws StorageException {
- // TODO Auto-generated method stub
-
- }
+ }
}
Added: 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=920742&view=auto
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRHeader.java (added)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRHeader.java Tue Mar 9 09:04:17 2010
@@ -0,0 +1,112 @@
+/****************************************************************
+ * 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.mail.model;
+
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+
+import org.apache.james.imap.jcr.JCRImapConstants;
+import org.apache.james.imap.store.mail.model.AbstractComparableHeader;
+import org.apache.james.imap.store.mail.model.Header;
+
+/**
+ * JCR implementation of a Header
+ *
+ *
+ */
+public class JCRHeader extends AbstractComparableHeader{
+
+ public final static String FIELDNAME_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "fieldName";
+ public final static String VALUE_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "value";
+ public final static String LINENUMBER_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "lineNumber";
+
+ private final String fieldName;
+ private final String value;
+ private final int lineNumber;
+
+ public JCRHeader(final String fieldName, final String value, final int lineNumber) {
+ this.fieldName = fieldName;
+ this.value = value;
+ this.lineNumber = lineNumber;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Header#getFieldName()
+ */
+ public String getFieldName() {
+ return fieldName;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Header#getLineNumber()
+ */
+ public int getLineNumber() {
+ return lineNumber;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Header#getValue()
+ */
+ public String getValue() {
+ return value;
+ }
+
+
+ /**
+ * Create a JCRHeader from the given Node
+ *
+ * @param node
+ * @return jcrHeader
+ * @throws PathNotFoundException
+ * @throws RepositoryException
+ */
+ public static JCRHeader from(Node node) throws PathNotFoundException, RepositoryException {
+ String name = node.getProperty(FIELDNAME_PROPERTY).getString();
+ String value = node.getProperty(VALUE_PROPERTY).getString();
+ int number = new Long(node.getProperty(LINENUMBER_PROPERTY).getLong()).intValue();
+ return new JCRHeader(name, value, number);
+ }
+
+ /**
+ * Copy all value of the given Header to the node
+ *
+ * @param node
+ * @param header
+ * @return node
+ * @throws ValueFormatException
+ * @throws VersionException
+ * @throws LockException
+ * @throws ConstraintViolationException
+ * @throws RepositoryException
+ */
+ public static Node copy(Node node, Header header) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ node.setProperty(FIELDNAME_PROPERTY, header.getFieldName());
+ node.setProperty(VALUE_PROPERTY, header.getValue());
+ node.setProperty(LINENUMBER_PROPERTY, header.getLineNumber());
+ return node;
+ }
+}
Added: 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=920742&view=auto
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRMailbox.java (added)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRMailbox.java Tue Mar 9 09:04:17 2010
@@ -0,0 +1,142 @@
+/****************************************************************
+ * 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.mail.model;
+
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+
+import org.apache.james.imap.jcr.JCRImapConstants;
+import org.apache.james.imap.store.mail.model.Mailbox;
+
+
+/**
+ * JCR implementation of a 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";
+
+ private long id = -1;
+ private String name;
+ private final long uidValidity;
+ private long lastUid = 0;
+
+ public JCRMailbox(final long id, final String name, final long uidValidity, final long lastUid) {
+ this.id = id;
+ this.name = name;
+ this.uidValidity = uidValidity;
+ this.lastUid = lastUid;
+ }
+
+ public JCRMailbox( final String name, final long uidValidity) {
+ this.name = name;
+ this.uidValidity = uidValidity;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#consumeUid()
+ */
+ public void consumeUid() {
+ lastUid++;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#getLastUid()
+ */
+ public long getLastUid() {
+ return lastUid;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#getMailboxId()
+ */
+ public long getMailboxId() {
+ return id;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#getUidValidity()
+ */
+ public long getUidValidity() {
+ return uidValidity;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Mailbox#setName(java.lang.String)
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Create a JCRMailbox from the given Node
+ *
+ * @param node
+ * @return jcrMailbox
+ * @throws ValueFormatException
+ * @throws PathNotFoundException
+ * @throws RepositoryException
+ */
+ public static JCRMailbox from(Node node) throws ValueFormatException, PathNotFoundException, RepositoryException {
+ long id = node.getProperty(ID_PROPERTY).getLong();
+ String name = node.getProperty(NAME_PROPERTY).getString();
+ long uidValidity = node.getProperty(UIDVALIDITY_PROPERTY).getLong();
+ long lastUid = node.getProperty(LASTUID_PROPERTY).getLong();
+
+ return new JCRMailbox(id, name, uidValidity, lastUid);
+ }
+
+ /**
+ * Copy the mailbox to the given Node
+ *
+ * @param node
+ * @param mailbox
+ * @return node
+ * @throws ValueFormatException
+ * @throws VersionException
+ * @throws LockException
+ * @throws ConstraintViolationException
+ * @throws RepositoryException
+ */
+ public static Node copy(Node node, Mailbox mailbox) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ node.setProperty(ID_PROPERTY, mailbox.getMailboxId());
+ node.setProperty(NAME_PROPERTY, mailbox.getName());
+ node.setProperty(UIDVALIDITY_PROPERTY, mailbox.getUidValidity());
+ node.setProperty(LASTUID_PROPERTY, mailbox.getLastUid());
+ return node;
+ }
+}
Added: 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=920742&view=auto
==============================================================================
--- james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRProperty.java (added)
+++ james/imap/trunk/jcr/src/main/java/org/apache/james/imap/jcr/mail/model/JCRProperty.java Tue Mar 9 09:04:17 2010
@@ -0,0 +1,124 @@
+/****************************************************************
+ * 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.mail.model;
+
+import javax.jcr.Node;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.RepositoryException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.lock.LockException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.version.VersionException;
+
+import org.apache.james.imap.jcr.JCRImapConstants;
+import org.apache.james.imap.store.mail.model.AbstractComparableProperty;
+
+/**
+ * JCR implementation of a Property
+ *
+ */
+public class JCRProperty extends AbstractComparableProperty<JCRProperty>{
+
+ public final static String NAMESPACE_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "namespace";
+ public final static String LOCALNAME_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "localName";
+ public final static String VALUE_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "value";
+ public final static String ORDER_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "order";
+
+ private final String namespace;
+ private final String localName;
+ private final String value;
+ private final int order;
+
+ public JCRProperty(final String namespace, final String localName, final String value, final int order) {
+ this.namespace = namespace;
+ this.localName = localName;
+ this.value = value;
+ this.order = order;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.AbstractComparableProperty#getOrder()
+ */
+ public int getOrder() {
+ return order;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Property#getLocalName()
+ */
+ public String getLocalName() {
+ return localName;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Property#getNamespace()
+ */
+ public String getNamespace() {
+ return namespace;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.mail.model.Property#getValue()
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * Create a JCRProperty from the given node
+ *
+ * @param node
+ * @return property
+ * @throws ValueFormatException
+ * @throws PathNotFoundException
+ * @throws RepositoryException
+ */
+ public static JCRProperty from(Node node) throws ValueFormatException, PathNotFoundException, RepositoryException {
+ String namespace = node.getProperty(NAMESPACE_PROPERTY).getString();
+ int order = new Long(node.getProperty(ORDER_PROPERTY).getLong()).intValue();
+ String localname = node.getProperty(LOCALNAME_PROPERTY).getString();
+ String value = node.getProperty(VALUE_PROPERTY).getString();
+ return new JCRProperty(namespace, localname, value, order);
+ }
+
+ /**
+ * Copy all value of the given Property to the node
+ *
+ * @param node
+ * @param property
+ * @return node
+ * @throws ValueFormatException
+ * @throws VersionException
+ * @throws LockException
+ * @throws ConstraintViolationException
+ * @throws RepositoryException
+ */
+ public static Node copy(Node node, AbstractComparableProperty<?> property) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException {
+ node.setProperty(NAMESPACE_PROPERTY, property.getNamespace());
+ node.setProperty(ORDER_PROPERTY, property.getOrder());
+ node.setProperty(LOCALNAME_PROPERTY, property.getLocalName());
+ node.setProperty(VALUE_PROPERTY, property.getValue());
+ return 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=920742&r1=920741&r2=920742&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 Tue Mar 9 09:04:17 2010
@@ -27,7 +27,9 @@ import javax.jcr.PathNotFoundException;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+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.user.model.JCRSubscription;
import org.apache.james.imap.mailbox.SubscriptionException;
import org.apache.james.imap.store.transaction.NonTransactionalMapper;
@@ -55,7 +57,7 @@ public class JCRSubscriptionMapper exten
*/
public void delete(Subscription subscription) throws SubscriptionException {
try {
- Node node = session.getRootNode().getNode(PATH + "/" + subscription.getUser() + "/" + subscription.getMailbox());
+ Node node = session.getRootNode().getNode(PATH + JCRImapConstants.NODE_DELIMITER + getPath(subscription.getUser(), subscription.getMailbox()));
node.remove();
session.save();
} catch (PathNotFoundException e) {
@@ -73,7 +75,7 @@ public class JCRSubscriptionMapper exten
public Subscription findFindMailboxSubscriptionForUser(String user,
String mailbox) throws SubscriptionException {
try {
- Node node = session.getRootNode().getNode(PATH + "/" + user + "/" + mailbox);
+ Node node = session.getRootNode().getNode(PATH + JCRImapConstants.NODE_DELIMITER + getPath(user, mailbox));
return JCRSubscription.from(node);
} catch (PathNotFoundException e) {
return null;
@@ -90,7 +92,7 @@ public class JCRSubscriptionMapper exten
throws SubscriptionException {
List<Subscription> subList = new ArrayList<Subscription>();
try {
- Node node = session.getRootNode().getNode(PATH + "/" + user);
+ Node node = session.getRootNode().getNode(PATH + JCRImapConstants.NODE_DELIMITER + Text.escapeIllegalJcrChars(user));
NodeIterator nodeIt = node.getNodes("*");
while(nodeIt.hasNext()) {
subList.add(JCRSubscription.from(nodeIt.nextNode()));
@@ -111,7 +113,7 @@ public class JCRSubscriptionMapper exten
public void save(Subscription subscription) throws SubscriptionException {
String username = subscription.getUser();
String mailbox = subscription.getMailbox();
- String nodename = username + "/" + mailbox;
+ String nodename = getPath(username,mailbox);
try {
Node node = session.getRootNode().getNode(PATH);
Node subNode;
@@ -126,6 +128,10 @@ public class JCRSubscriptionMapper exten
throw new SubscriptionException(HumanReadableText.SAVE_FAILED, e);
}
}
+
+ 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=920742&r1=920741&r2=920742&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 Tue Mar 9 09:04:17 2010
@@ -27,6 +27,7 @@ import javax.jcr.lock.LockException;
import javax.jcr.nodetype.ConstraintViolationException;
import javax.jcr.version.VersionException;
+import org.apache.james.imap.jcr.JCRImapConstants;
import org.apache.james.imap.store.user.model.Subscription;
@@ -40,8 +41,8 @@ public class JCRSubscription implements
private final String username;
- public final static String USERNAME_PROPERTY = "username";
- public final static String MAILBOX_PROPERTY = "mailbox";
+ public final static String USERNAME_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "username";
+ public final static String MAILBOX_PROPERTY = JCRImapConstants.PROPERTY_PREFIX + "mailbox";
public JCRSubscription(String username, String mailbox) {
this.username = username;
Modified: james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAHeader.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAHeader.java?rev=920742&r1=920741&r2=920742&view=diff
==============================================================================
--- james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAHeader.java (original)
+++ james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAHeader.java Tue Mar 9 09:04:17 2010
@@ -24,10 +24,11 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import org.apache.james.imap.store.mail.model.AbstractComparableHeader;
import org.apache.james.imap.store.mail.model.Header;
@Entity(name="Header")
-public class JPAHeader implements Comparable<Header>, Header {
+public class JPAHeader extends AbstractComparableHeader {
private static final String TOSTRING_SEP = " ";
@@ -120,11 +121,4 @@ public class JPAHeader implements Compar
return retValue;
}
- /**
- * Natural sort is mailbox, (message) UID then line number
- */
- public int compareTo(final Header header) {
- final int result = lineNumber - header.getLineNumber();
- return result;
- }
}
Modified: james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAProperty.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAProperty.java?rev=920742&r1=920741&r2=920742&view=diff
==============================================================================
--- james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAProperty.java (original)
+++ james/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/model/JPAProperty.java Tue Mar 9 09:04:17 2010
@@ -23,10 +23,11 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
+import org.apache.james.imap.store.mail.model.AbstractComparableProperty;
import org.apache.james.imap.store.mail.model.Property;
@Entity(name="Property")
-public class JPAProperty implements Property, Comparable<JPAProperty> {
+public class JPAProperty extends AbstractComparableProperty<JPAProperty> {
@Id @GeneratedValue private long id;
@@ -148,8 +149,4 @@ public class JPAProperty implements Prop
return result;
}
-
- public int compareTo(JPAProperty o) {
- return this.line - o.line;
- }
}
Modified: james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/SimpleHeader.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/SimpleHeader.java?rev=920742&r1=920741&r2=920742&view=diff
==============================================================================
--- james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/SimpleHeader.java (original)
+++ james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/SimpleHeader.java Tue Mar 9 09:04:17 2010
@@ -19,9 +19,9 @@
package org.apache.james.imap.inmemory;
-import org.apache.james.imap.store.mail.model.Header;
+import org.apache.james.imap.store.mail.model.AbstractComparableHeader;
-public class SimpleHeader implements Header {
+public class SimpleHeader extends AbstractComparableHeader {
public String field;
public int lineNumber;
@@ -53,8 +53,4 @@ public class SimpleHeader implements Hea
public String getValue() {
return value;
}
-
- public int compareTo(Header o) {
- return getLineNumber() - o.getLineNumber();
- }
}
\ No newline at end of file
Modified: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java?rev=920742&r1=920741&r2=920742&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java (original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreMailboxManager.java Tue Mar 9 09:04:17 2010
@@ -24,6 +24,7 @@ import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.Random;
@@ -75,17 +76,46 @@ public abstract class StoreMailboxManage
this.delimiter = delimiter;
}
+ /**
+ * Create a StoreMailbox for the given Mailbox
+ *
+ * @param mailboxRow
+ * @return storeMailbox
+ */
protected abstract StoreMailbox createMailbox(Mailbox mailboxRow);
+ /**
+ * Create the MailboxMapper which should get used
+ *
+ * @return mailboxMapper
+ */
protected abstract MailboxMapper createMailboxMapper();
+ /**
+ * Create a Mailbox for the given namespace and store it to the underlying storage
+ *
+ * @param namespaceName
+ * @throws MailboxException
+ */
protected abstract void doCreate(String namespaceName) throws MailboxException;
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#getMailbox(java.lang.String, org.apache.james.imap.mailbox.MailboxSession)
+ */
public org.apache.james.imap.mailbox.Mailbox getMailbox(String mailboxName, MailboxSession session)
throws MailboxException {
return doGetMailbox(mailboxName);
}
+ /**
+ * Get the Mailbox for the given name. If non is found a MailboxException will get thrown
+ *
+ * @param mailboxName the name of the mailbox to return
+ * @return mailbox the mailbox for the given name
+ * @throws MailboxException get thrown if no Mailbox could be found for the given name
+ */
private StoreMailbox doGetMailbox(String mailboxName) throws MailboxException {
synchronized (mailboxes) {
final MailboxMapper mapper = createMailboxMapper();
@@ -108,6 +138,10 @@ public abstract class StoreMailboxManage
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#createMailbox(java.lang.String, org.apache.james.imap.mailbox.MailboxSession)
+ */
public void createMailbox(String namespaceName, MailboxSession mailboxSession)
throws MailboxException {
getLog().debug("createMailbox " + namespaceName);
@@ -146,6 +180,10 @@ public abstract class StoreMailboxManage
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#deleteMailbox(java.lang.String, org.apache.james.imap.mailbox.MailboxSession)
+ */
public void deleteMailbox(final String mailboxName, final MailboxSession session)
throws MailboxException {
session.getLog().info("deleteMailbox " + mailboxName);
@@ -171,6 +209,10 @@ public abstract class StoreMailboxManage
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#renameMailbox(java.lang.String, java.lang.String, org.apache.james.imap.mailbox.MailboxSession)
+ */
public void renameMailbox(final String from, final String to, final MailboxSession session)
throws MailboxException {
final Log log = getLog();
@@ -215,6 +257,11 @@ public abstract class StoreMailboxManage
}
}
+ /**
+ * Generate an return the next uid validity
+ *
+ * @return uidValidity
+ */
protected int randomUidValidity() {
return Math.abs(random.nextInt());
}
@@ -232,6 +279,10 @@ public abstract class StoreMailboxManage
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#copyMessages(org.apache.james.imap.mailbox.MessageRange, java.lang.String, java.lang.String, org.apache.james.imap.mailbox.MailboxSession)
+ */
public void copyMessages(MessageRange set, String from, String to,
MailboxSession session) throws MailboxException {
StoreMailbox toMailbox = doGetMailbox(to);
@@ -239,6 +290,10 @@ public abstract class StoreMailboxManage
fromMailbox.copyTo(set, toMailbox, session);
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#search(org.apache.james.imap.mailbox.MailboxQuery, org.apache.james.imap.mailbox.MailboxSession)
+ */
public List<MailboxMetaData> search(final MailboxQuery mailboxExpression, MailboxSession session)
throws MailboxException {
final char localWildcard = mailboxExpression.getLocalWildcard();
@@ -289,6 +344,10 @@ public abstract class StoreMailboxManage
return mapper.existsMailboxStartingWith(name + delimiter);
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#mailboxExists(java.lang.String, org.apache.james.imap.mailbox.MailboxSession)
+ */
public boolean mailboxExists(String mailboxName, MailboxSession session) throws MailboxException {
synchronized (mailboxes) {
final MailboxMapper mapper = createMailboxMapper();
@@ -307,6 +366,11 @@ public abstract class StoreMailboxManage
}
}
+ /**
+ * Delete every Mailbox which exists
+ *
+ * @throws MailboxException
+ */
public void deleteEverything() throws MailboxException {
final MailboxMapper mapper = createMailboxMapper();
mapper.execute(new TransactionalMapper.Transaction() {
@@ -319,21 +383,40 @@ public abstract class StoreMailboxManage
});
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#createSystemSession(java.lang.String, org.apache.commons.logging.Log)
+ */
public MailboxSession createSystemSession(String userName, Log log) {
return createSession(userName, log);
}
- @SuppressWarnings("unchecked")
+ /**
+ * Create Session
+ *
+ * @param userName
+ * @param log
+ * @return session
+ */
private SimpleMailboxSession createSession(String userName, Log log) {
- return new SimpleMailboxSession(randomId(), userName, log, delimiter, Collections.EMPTY_LIST);
+ return new SimpleMailboxSession(randomId(), userName, log, delimiter, new ArrayList<Locale>());
}
+ /**
+ * Generate and return the next id to use
+ *
+ * @return id
+ */
protected long randomId() {
return random.nextLong();
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#resolve(java.lang.String, java.lang.String)
+ */
public String resolve(final String userName, String mailboxPath) {
if (mailboxPath.charAt(0) != delimiter) {
mailboxPath = delimiter + mailboxPath;
@@ -343,30 +426,57 @@ public abstract class StoreMailboxManage
return result;
}
+ /**
+ * Log in the user with the given userid and password
+ *
+ * @param userid the username
+ * @param passwd the password
+ * @return success true if login success false otherwise
+ */
public boolean login(String userid, String passwd) {
return authenticator.isAuthentic(userid, passwd);
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#subscribe(org.apache.james.imap.mailbox.MailboxSession, java.lang.String)
+ */
public void subscribe(MailboxSession session, String mailbox)
throws SubscriptionException {
subscriber.subscribe(session.getUser().getUserName(), mailbox);
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#subscriptions(org.apache.james.imap.mailbox.MailboxSession)
+ */
public Collection<String> subscriptions(MailboxSession session) throws SubscriptionException {
return subscriber.subscriptions(session.getUser().getUserName());
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#unsubscribe(org.apache.james.imap.mailbox.MailboxSession, java.lang.String)
+ */
public void unsubscribe(MailboxSession session, String mailbox)
throws SubscriptionException {
subscriber.unsubscribe(session.getUser().getUserName(), mailbox);
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#addListener(java.lang.String, org.apache.james.imap.mailbox.MailboxListener, org.apache.james.imap.mailbox.MailboxSession)
+ */
public void addListener(String mailboxName, MailboxListener listener, MailboxSession session) throws MailboxException {
final StoreMailbox mailbox = doGetMailbox(mailboxName);
mailbox.addListener(listener);
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#login(java.lang.String, java.lang.String, org.apache.commons.logging.Log)
+ */
public MailboxSession login(String userid, String passwd, Log log) throws BadCredentialsException, MailboxException {
if (login(userid, passwd)) {
return createSession(userid, log);
@@ -375,6 +485,10 @@ public abstract class StoreMailboxManage
}
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.mailbox.MailboxManager#logout(org.apache.james.imap.mailbox.MailboxSession, boolean)
+ */
public void logout(MailboxSession session, boolean force) throws MailboxException {
// fine
}
Modified: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreSubscriptionManager.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreSubscriptionManager.java?rev=920742&r1=920741&r2=920742&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreSubscriptionManager.java (original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/StoreSubscriptionManager.java Tue Mar 9 09:04:17 2010
@@ -39,8 +39,17 @@ public abstract class StoreSubscriptionM
super();
}
+ /**
+ * Create the SubscriptionMapper to use
+ *
+ * @return mapper
+ */
protected abstract SubscriptionMapper createMapper();
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.Subscriber#subscribe(java.lang.String, java.lang.String)
+ */
public void subscribe(final String user, final String mailbox) throws SubscriptionException {
final SubscriptionMapper mapper = createMapper();
try {
@@ -62,8 +71,19 @@ public abstract class StoreSubscriptionM
}
+ /**
+ * Create Subscription for the given user and mailbox
+ *
+ * @param user
+ * @param mailbox
+ * @return subscription
+ */
protected abstract Subscription createSubscription(final String user, final String mailbox);
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.Subscriber#subscriptions(java.lang.String)
+ */
public Collection<String> subscriptions(final String user) throws SubscriptionException {
final SubscriptionMapper mapper = createMapper();
final List<Subscription> subscriptions = mapper.findSubscriptionsForUser(user);
@@ -74,6 +94,10 @@ public abstract class StoreSubscriptionM
return results;
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.imap.store.Subscriber#unsubscribe(java.lang.String, java.lang.String)
+ */
public void unsubscribe(final String user, final String mailbox) throws SubscriptionException {
final SubscriptionMapper mapper = createMapper();
try {
@@ -90,7 +114,5 @@ public abstract class StoreSubscriptionM
} catch (MailboxException e) {
throw (SubscriptionException) e;
}
-
-
}
}
Added: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/AbstractComparableHeader.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/AbstractComparableHeader.java?rev=920742&view=auto
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/AbstractComparableHeader.java (added)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/AbstractComparableHeader.java Tue Mar 9 09:04:17 2010
@@ -0,0 +1,34 @@
+/****************************************************************
+ * 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.store.mail.model;
+
+/**
+ * Abstract base class for Header implementations which implements the compare
+ *
+ */
+public abstract class AbstractComparableHeader implements Header{
+
+ /**
+ * Natural sort is mailbox, (message) UID then line number
+ */
+ public int compareTo(final Header header) {
+ final int result = getLineNumber()- header.getLineNumber();
+ return result;
+ }
+}
Added: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/AbstractComparableProperty.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/AbstractComparableProperty.java?rev=920742&view=auto
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/AbstractComparableProperty.java (added)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/AbstractComparableProperty.java Tue Mar 9 09:04:17 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.store.mail.model;
+
+/**
+ * Abstract base class for Property implementations which implements the compare of Properties
+ *
+ *
+ */
+public abstract class AbstractComparableProperty<P extends AbstractComparableProperty<P>> implements Property, Comparable<P>{
+
+
+ /**
+ * Gets the order of this property.
+ * @return order of this property
+ */
+ public abstract int getOrder();
+
+ /*
+ * (non-Javadoc)
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ public int compareTo(P o) {
+ return getOrder() - o.getOrder();
+ }
+}
Modified: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Header.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Header.java?rev=920742&r1=920741&r2=920742&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Header.java (original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Header.java Tue Mar 9 09:04:17 2010
@@ -18,12 +18,32 @@
****************************************************************/
package org.apache.james.imap.store.mail.model;
+/**
+ *
+ * Email Header
+ *
+ */
public interface Header extends Comparable<Header> {
+ /**
+ * Return the name of the Header field
+ *
+ * @return fieldName
+ */
public abstract String getFieldName();
+ /**
+ * Return the line number of the Header
+ *
+ * @return lineNumber
+ */
public abstract int getLineNumber();
+ /**
+ * Return the value of the Header
+ *
+ * @return value
+ */
public abstract String getValue();
}
\ No newline at end of file
Modified: james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Property.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Property.java?rev=920742&r1=920741&r2=920742&view=diff
==============================================================================
--- james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Property.java (original)
+++ james/imap/trunk/store/src/main/java/org/apache/james/imap/store/mail/model/Property.java Tue Mar 9 09:04:17 2010
@@ -18,6 +18,7 @@
****************************************************************/
package org.apache.james.imap.store.mail.model;
+
/**
* <p>Values a namespaced property.</p>
* <p>
@@ -55,4 +56,6 @@ public interface Property {
* @return not null
*/
public String getValue();
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org