Author: rdonkin
Date: Tue Jan 6 12:53:21 2009
New Revision: 732114
URL: http://svn.apache.org/viewvc?rev=732114&view=rev
Log:
Factor out interfaces for mappers.
Added:
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPASubscriptionManager.java
(contents, props changed)
- copied, changed from r732097,
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/SubscriptionManager.java
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/mail/
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/mail/MailboxMapper.java
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/mail/MessageMapper.java
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/user/
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/user/SubscriptionMapper.java
Removed:
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/SubscriptionManager.java
Modified:
james/protocols/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/jpa/JPAHostSystem.java
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailbox.java
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailboxManager.java
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMailboxMapper.java
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMessageMapper.java
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/user/JPASubscriptionMapper.java
Modified:
james/protocols/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/jpa/JPAHostSystem.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/jpa/JPAHostSystem.java?rev=732114&r1=732113&r2=732114&view=diff
==============================================================================
---
james/protocols/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/jpa/JPAHostSystem.java
(original)
+++
james/protocols/imap/trunk/deployment/src/test/java/org/apache/james/imap/functional/jpa/JPAHostSystem.java
Tue Jan 6 12:53:21 2009
@@ -30,7 +30,7 @@
import org.apache.james.imap.functional.SimpleMailboxManagerProvider;
import org.apache.james.imap.functional.jpa.user.InMemoryUserManager;
import org.apache.james.imap.jpa.JPAMailboxManager;
-import org.apache.james.imap.jpa.SubscriptionManager;
+import org.apache.james.imap.jpa.JPASubscriptionManager;
import org.apache.james.imap.main.DefaultImapDecoderFactory;
import org.apache.james.imap.processor.main.DefaultImapProcessorFactory;
import org.apache.james.test.functional.HostSystem;
@@ -61,7 +61,7 @@
userManager = new InMemoryUserManager();
final EntityManagerFactory entityManagerFactory =
OpenJPAPersistence.getEntityManagerFactory(properties);
- mailboxManager = new JPAMailboxManager(userManager, new
SubscriptionManager(entityManagerFactory), entityManagerFactory);
+ mailboxManager = new JPAMailboxManager(userManager, new
JPASubscriptionManager(entityManagerFactory), entityManagerFactory);
SimpleMailboxManagerProvider provider = new
SimpleMailboxManagerProvider();
final DefaultImapProcessorFactory defaultImapProcessorFactory = new
DefaultImapProcessorFactory();
Modified:
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailbox.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailbox.java?rev=732114&r1=732113&r2=732114&view=diff
==============================================================================
---
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailbox.java
(original)
+++
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailbox.java
Tue Jan 6 12:53:21 2009
@@ -53,6 +53,8 @@
import org.apache.james.imap.mailbox.util.FetchGroupImpl;
import org.apache.james.imap.mailbox.util.UidChangeTracker;
import org.apache.james.imap.mailbox.util.UidRange;
+import org.apache.james.imap.store.mail.MailboxMapper;
+import org.apache.james.imap.store.mail.MessageMapper;
public class JPAMailbox extends AbstractLogEnabled implements
org.apache.james.imap.mailbox.Mailbox {
@@ -75,7 +77,7 @@
}
public int getMessageCount(MailboxSession mailboxSession) throws
MailboxException {
- final JPAMessageMapper messageMapper = createMessageMapper();
+ final MessageMapper messageMapper = createMessageMapper();
return (int) messageMapper.countMessagesInMailbox(mailboxId);
}
@@ -102,7 +104,7 @@
final Flags flags = mimeMessage.getFlags();
final List<Header> headers = headers(mailboxId, uid,
mimeMessage);
final Message message = new Message(mailboxId, uid,
internalDate, size, flags, body, headers);
- final JPAMessageMapper mapper = createMessageMapper();
+ final MessageMapper mapper = createMessageMapper();
mapper.begin();
mapper.save(message);
@@ -120,8 +122,8 @@
}
}
- private JPAMessageMapper createMessageMapper() {
- final JPAMessageMapper mapper = new
JPAMessageMapper(entityManagerFactory.createEntityManager());
+ private MessageMapper createMessageMapper() {
+ final MessageMapper mapper = new
JPAMessageMapper(entityManagerFactory.createEntityManager());
return mapper;
}
@@ -154,7 +156,7 @@
}
private Mailbox reserveNextUid() throws MailboxException {
- final JPAMailboxMapper mapper = createMailboxMapper();
+ final MailboxMapper mapper = createMailboxMapper();
final Mailbox mailbox = mapper.consumeNextUid(mailboxId);
return mailbox;
}
@@ -162,7 +164,7 @@
public Iterator getMessages(final MessageRange set, FetchGroup fetchGroup,
MailboxSession mailboxSession) throws MailboxException {
UidRange range = uidRangeForMessageSet(set);
- final JPAMessageMapper messageMapper = createMessageMapper();
+ final MessageMapper messageMapper = createMessageMapper();
final List<Message> rows = new
ArrayList<Message>(messageMapper.findInMailbox(set, mailboxId));
return getMessages(fetchGroup, range, rows);
}
@@ -207,7 +209,7 @@
}
public long[] recent(boolean reset, MailboxSession mailboxSession) throws
MailboxException {
- final JPAMessageMapper mapper = createMessageMapper();
+ final MessageMapper mapper = createMessageMapper();
mapper.begin();
final List<Message> messages =
mapper.findRecentMessagesInMailbox(mailboxId);
final long[] results = new long[messages.size()];
@@ -227,7 +229,7 @@
public MessageResult getFirstUnseen(FetchGroup fetchGroup,
MailboxSession mailboxSession) throws MailboxException {
try {
- final JPAMessageMapper messageMapper = createMessageMapper();
+ final MessageMapper messageMapper = createMessageMapper();
final List<Message> messageRows =
messageMapper.findUnseenMessagesInMailboxOrderByUid(mailboxId);
final Iterator<Message> it = messageRows.iterator();
final MessageResult result;
@@ -246,7 +248,7 @@
}
public int getUnseenCount(MailboxSession mailboxSession) throws
MailboxException {
- final JPAMessageMapper messageMapper = createMessageMapper();
+ final MessageMapper messageMapper = createMessageMapper();
final int count = (int)
messageMapper.countUnseenMessagesInMailbox(mailboxId);
return count;
}
@@ -258,7 +260,7 @@
private Iterator doExpunge(final MessageRange set, FetchGroup fetchGroup)
throws MailboxException {
- final JPAMessageMapper mapper = createMessageMapper();
+ final MessageMapper mapper = createMessageMapper();
mapper.begin();
final List<Message> messages =
mapper.findMarkedForDeletionInMailbox(set, mailboxId);
final long[] uids = uids(messages);
@@ -296,7 +298,7 @@
private Iterator doSetFlags(Flags flags, boolean value, boolean replace,
final MessageRange set, FetchGroup fetchGroup,
MailboxSession mailboxSession) throws MailboxException {
- final JPAMessageMapper mapper = createMessageMapper();
+ final MessageMapper mapper = createMessageMapper();
mapper.begin();
final List<Message> messages = mapper.findInMailbox(set, mailboxId);
UidRange uidRange = uidRangeForMessageSet(set);
@@ -352,18 +354,18 @@
}
private Mailbox getMailboxRow() throws MailboxException {
- final JPAMailboxMapper mapper = createMailboxMapper();
+ final MailboxMapper mapper = createMailboxMapper();
return mapper.findMailboxById(mailboxId);
}
- private JPAMailboxMapper createMailboxMapper() {
+ private MailboxMapper createMailboxMapper() {
final JPAMailboxMapper mapper = new
OpenJPAMailboxMapper(entityManagerFactory.createEntityManager());
return mapper;
}
public Iterator search(SearchQuery query, FetchGroup fetchGroup,
MailboxSession mailboxSession) throws MailboxException {
- final JPAMessageMapper messageMapper = createMessageMapper();
+ final MessageMapper messageMapper = createMessageMapper();
final List<Message> messages = messageMapper.searchMailbox(mailboxId,
query);
final List<Message> filteredMessages = new
ArrayList<Message>(messages.size());
for (Message message:messages) {
@@ -395,7 +397,7 @@
public void copyTo(MessageRange set, JPAMailbox toMailbox, MailboxSession
session) throws MailboxException {
try {
- final JPAMessageMapper mapper = createMessageMapper();
+ final MessageMapper mapper = createMessageMapper();
mapper.begin();
List<Message> rows = mapper.findInMailbox(set, mailboxId);
Modified:
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailboxManager.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailboxManager.java?rev=732114&r1=732113&r2=732114&view=diff
==============================================================================
---
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailboxManager.java
(original)
+++
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPAMailboxManager.java
Tue Jan 6 12:53:21 2009
@@ -45,6 +45,7 @@
import org.apache.james.imap.mailbox.MessageRange;
import org.apache.james.imap.mailbox.SubscriptionException;
import org.apache.james.imap.mailbox.util.ListResultImpl;
+import org.apache.james.imap.store.mail.MailboxMapper;
public class JPAMailboxManager extends AbstractLogEnabled implements
MailboxManager {
@@ -72,7 +73,7 @@
private JPAMailbox doGetMailbox(String mailboxName) throws
MailboxException {
synchronized (mailboxes) {
- final JPAMailboxMapper mapper = createMailboxMapper();
+ final MailboxMapper mapper = createMailboxMapper();
Mailbox mailboxRow = mapper.findMailboxByName(mailboxName);
if (mailboxRow == null) {
@@ -132,7 +133,7 @@
private void doCreate(String namespaceName) throws MailboxException {
Mailbox mailbox = new Mailbox(namespaceName,
Math.abs(random.nextInt()));
- final JPAMailboxMapper mapper = createMailboxMapper();
+ final MailboxMapper mapper = createMailboxMapper();
mapper.begin();
mapper.save(mailbox);
mapper.commit();
@@ -143,7 +144,7 @@
getLog().info("deleteMailbox " + mailboxName);
synchronized (mailboxes) {
// TODO put this into a serilizable transaction
- final JPAMailboxMapper mapper = createMailboxMapper();
+ final MailboxMapper mapper = createMailboxMapper();
mapper.begin();
Mailbox mr = mapper.findMailboxByName(mailboxName);
if (mr == null) {
@@ -167,7 +168,7 @@
throw new MailboxExistsException(to);
}
- final JPAMailboxMapper mapper = createMailboxMapper();
+ final MailboxMapper mapper = createMailboxMapper();
mapper.begin();
// TODO put this into a serilizable transaction
final Mailbox mailbox = mapper.findMailboxByName(from);
@@ -233,7 +234,7 @@
HIERARCHY_DELIMITER).replace(freeWildcard, SQL_WILDCARD_CHAR)
.replace(localWildcard, SQL_WILDCARD_CHAR);
- final JPAMailboxMapper mapper = createMailboxMapper();
+ final MailboxMapper mapper = createMailboxMapper();
final List<Mailbox> mailboxes = mapper.findMailboxWithNameLike(search);
final List<ListResult> listResults = new
ArrayList<ListResult>(mailboxes.size());
for (Mailbox mailbox: mailboxes) {
@@ -255,7 +256,7 @@
public boolean mailboxExists(String mailboxName) throws MailboxException {
synchronized (mailboxes) {
- final JPAMailboxMapper mapper = createMailboxMapper();
+ final MailboxMapper mapper = createMailboxMapper();
final long count = mapper.countMailboxesWithName(mailboxName);
if (count == 0) {
mailboxes.remove(mailboxName);
@@ -271,14 +272,14 @@
}
public void deleteEverything() throws MailboxException {
- final JPAMailboxMapper mapper = createMailboxMapper();
+ final MailboxMapper mapper = createMailboxMapper();
mapper.begin();
mapper.deleteAll();
mapper.commit();
mailboxes.clear();
}
- private JPAMailboxMapper createMailboxMapper() {
+ private MailboxMapper createMailboxMapper() {
final JPAMailboxMapper mapper = new
OpenJPAMailboxMapper(entityManagerFactory.createEntityManager());
return mapper;
}
Copied:
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPASubscriptionManager.java
(from r732097,
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/SubscriptionManager.java)
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPASubscriptionManager.java?p2=james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPASubscriptionManager.java&p1=james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/SubscriptionManager.java&r1=732097&r2=732114&rev=732114&view=diff
==============================================================================
---
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/SubscriptionManager.java
(original)
+++
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPASubscriptionManager.java
Tue Jan 6 12:53:21 2009
@@ -28,23 +28,24 @@
import org.apache.james.imap.jpa.user.JPASubscriptionMapper;
import org.apache.james.imap.jpa.user.model.Subscription;
import org.apache.james.imap.mailbox.SubscriptionException;
+import org.apache.james.imap.store.user.SubscriptionMapper;
/**
* Manages subscriptions.
*/
-public class SubscriptionManager implements Subscriber {
+public class JPASubscriptionManager implements Subscriber {
private static final int INITIAL_SIZE = 32;
private final EntityManagerFactory factory;
- public SubscriptionManager(final EntityManagerFactory factory) {
+ public JPASubscriptionManager(final EntityManagerFactory factory) {
super();
this.factory = factory;
}
public void subscribe(final String user, final String mailbox) throws
SubscriptionException {
try {
- final JPASubscriptionMapper mapper = new
JPASubscriptionMapper(factory.createEntityManager());
+ final SubscriptionMapper mapper = createMapper();
mapper.begin();
final Subscription subscription =
mapper.findFindMailboxSubscriptionForUser(user, mailbox);
@@ -58,9 +59,14 @@
}
}
+ private SubscriptionMapper createMapper() {
+ final JPASubscriptionMapper mapper = new
JPASubscriptionMapper(factory.createEntityManager());
+ return mapper;
+ }
+
public Collection<String> subscriptions(final String user) throws
SubscriptionException {
try {
- final JPASubscriptionMapper mapper = new
JPASubscriptionMapper(factory.createEntityManager());
+ final SubscriptionMapper mapper = createMapper();
final List<Subscription> subscriptions =
mapper.findSubscriptionsForUser(user);
final Collection<String> results = new
HashSet<String>(INITIAL_SIZE);
for (Subscription subscription:subscriptions) {
@@ -74,7 +80,7 @@
public void unsubscribe(final String user, final String mailbox) throws
SubscriptionException {
try {
- final JPASubscriptionMapper mapper = new
JPASubscriptionMapper(factory.createEntityManager());
+ final SubscriptionMapper mapper = createMapper();
mapper.begin();
final Subscription subscription =
mapper.findFindMailboxSubscriptionForUser(user, mailbox);
Propchange:
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/JPASubscriptionManager.java
------------------------------------------------------------------------------
svn:mergeinfo =
Modified:
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMailboxMapper.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMailboxMapper.java?rev=732114&r1=732113&r2=732114&view=diff
==============================================================================
---
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMailboxMapper.java
(original)
+++
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMailboxMapper.java
Tue Jan 6 12:53:21 2009
@@ -28,16 +28,20 @@
import org.apache.james.imap.jpa.mail.model.Mailbox;
import org.apache.james.imap.mailbox.MailboxNotFoundException;
import org.apache.james.imap.mailbox.StorageException;
+import org.apache.james.imap.store.mail.MailboxMapper;
/**
* Data access management for mailbox.
*/
-public abstract class JPAMailboxMapper extends Mapper {
+public abstract class JPAMailboxMapper extends Mapper implements MailboxMapper
{
public JPAMailboxMapper(EntityManager entityManager) {
super(entityManager);
}
+ /**
+ * @see
org.apache.james.imap.jpa.mail.MailboxMapper#save(org.apache.james.imap.jpa.mail.model.Mailbox)
+ */
public void save(Mailbox mailbox) throws StorageException {
try {
entityManager.persist(mailbox);
@@ -46,6 +50,9 @@
}
}
+ /**
+ * @see
org.apache.james.imap.jpa.mail.MailboxMapper#findMailboxByName(java.lang.String)
+ */
public Mailbox findMailboxByName(String name) throws StorageException,
MailboxNotFoundException {
try {
return (Mailbox)
entityManager.createNamedQuery("findMailboxByName").setParameter("nameParam",
name).getSingleResult();
@@ -57,6 +64,9 @@
}
}
+ /**
+ * @see
org.apache.james.imap.jpa.mail.MailboxMapper#delete(org.apache.james.imap.jpa.mail.model.Mailbox)
+ */
public void delete(Mailbox mailbox) throws StorageException {
try {
entityManager.remove(mailbox);
@@ -65,6 +75,9 @@
}
}
+ /**
+ * @see
org.apache.james.imap.jpa.mail.MailboxMapper#findMailboxWithNameLike(java.lang.String)
+ */
@SuppressWarnings("unchecked")
public List<Mailbox> findMailboxWithNameLike(String name) throws
StorageException {
try {
@@ -74,6 +87,9 @@
}
}
+ /**
+ * @see org.apache.james.imap.jpa.mail.MailboxMapper#deleteAll()
+ */
public void deleteAll() throws StorageException {
try {
entityManager.createNamedQuery("deleteAll").executeUpdate();
@@ -82,6 +98,9 @@
}
}
+ /**
+ * @see
org.apache.james.imap.jpa.mail.MailboxMapper#countMailboxesWithName(java.lang.String)
+ */
public long countMailboxesWithName(String name) throws StorageException {
try {
return (Long)
entityManager.createNamedQuery("countMailboxesWithName").setParameter("nameParam",
name).getSingleResult();
@@ -90,6 +109,9 @@
}
}
+ /**
+ * @see org.apache.james.imap.jpa.mail.MailboxMapper#findMailboxById(long)
+ */
public Mailbox findMailboxById(long mailboxId) throws StorageException,
MailboxNotFoundException {
try {
return (Mailbox)
entityManager.createNamedQuery("findMailboxById").setParameter("idParam",
mailboxId).getSingleResult();
@@ -100,6 +122,9 @@
}
}
+ /**
+ * @see org.apache.james.imap.jpa.mail.MailboxMapper#consumeNextUid(long)
+ */
public Mailbox consumeNextUid(long mailboxId) throws StorageException,
MailboxNotFoundException {
try {
return doConsumeNextUid(mailboxId);
Modified:
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMessageMapper.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMessageMapper.java?rev=732114&r1=732113&r2=732114&view=diff
==============================================================================
---
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMessageMapper.java
(original)
+++
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/mail/JPAMessageMapper.java
Tue Jan 6 12:53:21 2009
@@ -29,13 +29,17 @@
import org.apache.james.imap.mailbox.StorageException;
import org.apache.james.imap.mailbox.SearchQuery.Criterion;
import org.apache.james.imap.mailbox.SearchQuery.NumericRange;
+import org.apache.james.imap.store.mail.MessageMapper;
-public class JPAMessageMapper extends Mapper {
+public class JPAMessageMapper extends Mapper implements MessageMapper {
public JPAMessageMapper(EntityManager entityManager) {
super(entityManager);
}
+ /* (non-Javadoc)
+ * @see
org.apache.james.imap.jpa.mail.MessageMapper#findInMailbox(org.apache.james.imap.mailbox.MessageRange,
long)
+ */
public List<Message> findInMailbox(MessageRange set, long mailboxId)
throws StorageException {
try {
final List<Message> results;
@@ -90,6 +94,9 @@
return
entityManager.createNamedQuery("findMessagesInMailbox").setParameter("idParam",
mailboxId).getResultList();
}
+ /**
+ * @see
org.apache.james.imap.jpa.mail.MessageMapper#findMarkedForDeletionInMailbox(org.apache.james.imap.mailbox.MessageRange,
long)
+ */
public List<Message> findMarkedForDeletionInMailbox(final MessageRange
set, final long mailboxId) throws StorageException {
try {
final List<Message> results;
@@ -144,6 +151,9 @@
.setParameter("toParam", to).getResultList();
}
+ /**
+ * @see
org.apache.james.imap.jpa.mail.MessageMapper#countMessagesInMailbox(long)
+ */
public long countMessagesInMailbox(long mailboxId) throws StorageException
{
try {
return (Long)
entityManager.createNamedQuery("countMessagesInMailbox").setParameter("idParam",
mailboxId).getSingleResult();
@@ -152,6 +162,9 @@
}
}
+ /**
+ * @see
org.apache.james.imap.jpa.mail.MessageMapper#countUnseenMessagesInMailbox(long)
+ */
public long countUnseenMessagesInMailbox(long mailboxId) throws
StorageException {
try {
return (Long)
entityManager.createNamedQuery("countUnseenMessagesInMailbox").setParameter("idParam",
mailboxId).getSingleResult();
@@ -160,6 +173,9 @@
}
}
+ /**
+ * @see org.apache.james.imap.jpa.mail.MessageMapper#searchMailbox(long,
org.apache.james.imap.mailbox.SearchQuery)
+ */
@SuppressWarnings("unchecked")
public List<Message> searchMailbox(long mailboxId, SearchQuery query)
throws StorageException {
try {
@@ -197,6 +213,9 @@
return jql;
}
+ /**
+ * @see
org.apache.james.imap.jpa.mail.MessageMapper#delete(org.apache.james.imap.jpa.mail.model.Message)
+ */
public void delete(Message message) throws StorageException {
try {
entityManager.remove(message);
@@ -205,6 +224,9 @@
}
}
+ /**
+ * @see
org.apache.james.imap.jpa.mail.MessageMapper#findUnseenMessagesInMailboxOrderByUid(long)
+ */
@SuppressWarnings("unchecked")
public List<Message> findUnseenMessagesInMailboxOrderByUid(final long
mailboxId) throws StorageException {
try {
@@ -214,6 +236,9 @@
}
}
+ /**
+ * @see
org.apache.james.imap.jpa.mail.MessageMapper#findRecentMessagesInMailbox(long)
+ */
@SuppressWarnings("unchecked")
public List<Message> findRecentMessagesInMailbox(final long mailboxId)
throws StorageException {
try {
@@ -223,6 +248,9 @@
}
}
+ /**
+ * @see
org.apache.james.imap.jpa.mail.MessageMapper#save(org.apache.james.imap.jpa.mail.model.Message)
+ */
public void save(Message message) throws StorageException {
try {
entityManager.persist(message);
Modified:
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/user/JPASubscriptionMapper.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/user/JPASubscriptionMapper.java?rev=732114&r1=732113&r2=732114&view=diff
==============================================================================
---
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/user/JPASubscriptionMapper.java
(original)
+++
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/jpa/user/JPASubscriptionMapper.java
Tue Jan 6 12:53:21 2009
@@ -24,11 +24,12 @@
import javax.persistence.NoResultException;
import org.apache.james.imap.jpa.user.model.Subscription;
+import org.apache.james.imap.store.user.SubscriptionMapper;
/**
* Maps data access logic to JPA operations.
*/
-public class JPASubscriptionMapper {
+public class JPASubscriptionMapper implements SubscriptionMapper {
private final EntityManager entityManager;
public JPASubscriptionMapper(final EntityManager entityManager) {
@@ -36,20 +37,22 @@
this.entityManager = entityManager;
}
+ /* (non-Javadoc)
+ * @see org.apache.james.imap.jpa.user.SubscriptionManager#begin()
+ */
public void begin() {
entityManager.getTransaction().begin();
}
+ /* (non-Javadoc)
+ * @see org.apache.james.imap.jpa.user.SubscriptionManager#commit()
+ */
public void commit() {
entityManager.getTransaction().commit();
}
- /**
- * Finds any subscriptions for a given user to the given mailbox.
- * @param user not null
- * @param mailbox not null
- * @return <code>Subscription</code>,
- * or null when the user is not subscribed to the given mailbox
+ /* (non-Javadoc)
+ * @see
org.apache.james.imap.jpa.user.SubscriptionManager#findFindMailboxSubscriptionForUser(java.lang.String,
java.lang.String)
*/
public Subscription findFindMailboxSubscriptionForUser(final String user,
final String mailbox) {
try {
@@ -60,27 +63,23 @@
}
}
- /**
- * Saves the given subscription.
- * @param subscription not null
+ /* (non-Javadoc)
+ * @see
org.apache.james.imap.jpa.user.SubscriptionManager#save(org.apache.james.imap.jpa.user.model.Subscription)
*/
public void save(Subscription subscription) {
entityManager.persist(subscription);
}
- /**
- * Finds subscriptions for the given user.
- * @param user not null
- * @return not null
+ /* (non-Javadoc)
+ * @see
org.apache.james.imap.jpa.user.SubscriptionManager#findSubscriptionsForUser(java.lang.String)
*/
@SuppressWarnings("unchecked")
public List<Subscription> findSubscriptionsForUser(String user) {
return (List<Subscription>)
entityManager.createNamedQuery("findSubscriptionsForUser").setParameter("userParam",
user).getResultList();
}
- /**
- * Deletes the given subscription.
- * @param subscription not null
+ /* (non-Javadoc)
+ * @see
org.apache.james.imap.jpa.user.SubscriptionManager#delete(org.apache.james.imap.jpa.user.model.Subscription)
*/
public void delete(Subscription subscription) {
entityManager.remove(subscription);
Added:
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/mail/MailboxMapper.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/mail/MailboxMapper.java?rev=732114&view=auto
==============================================================================
---
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/mail/MailboxMapper.java
(added)
+++
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/mail/MailboxMapper.java
Tue Jan 6 12:53:21 2009
@@ -0,0 +1,54 @@
+/****************************************************************
+ * 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;
+
+import java.util.List;
+
+import org.apache.james.imap.jpa.mail.model.Mailbox;
+import org.apache.james.imap.mailbox.MailboxNotFoundException;
+import org.apache.james.imap.mailbox.StorageException;
+
+public interface MailboxMapper {
+ public abstract void begin() throws StorageException;
+
+ public abstract void commit() throws StorageException;
+
+ public abstract void save(Mailbox mailbox) throws StorageException;
+
+ public abstract Mailbox findMailboxByName(String name)
+ throws StorageException, MailboxNotFoundException;
+
+ public abstract void delete(Mailbox mailbox) throws StorageException;
+
+ @SuppressWarnings("unchecked")
+ public abstract List<Mailbox> findMailboxWithNameLike(String name)
+ throws StorageException;
+
+ public abstract void deleteAll() throws StorageException;
+
+ public abstract long countMailboxesWithName(String name)
+ throws StorageException;
+
+ public abstract Mailbox findMailboxById(long mailboxId)
+ throws StorageException, MailboxNotFoundException;
+
+ public abstract Mailbox consumeNextUid(long mailboxId)
+ throws StorageException, MailboxNotFoundException;
+
+}
\ No newline at end of file
Added:
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/mail/MessageMapper.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/mail/MessageMapper.java?rev=732114&view=auto
==============================================================================
---
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/mail/MessageMapper.java
(added)
+++
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/mail/MessageMapper.java
Tue Jan 6 12:53:21 2009
@@ -0,0 +1,63 @@
+/****************************************************************
+ * 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;
+
+import java.util.List;
+
+import org.apache.james.imap.jpa.mail.model.Message;
+import org.apache.james.imap.mailbox.MessageRange;
+import org.apache.james.imap.mailbox.SearchQuery;
+import org.apache.james.imap.mailbox.StorageException;
+
+public interface MessageMapper {
+
+ public abstract void begin() throws StorageException;
+
+ public abstract void commit() throws StorageException;
+
+ public abstract List<Message> findInMailbox(MessageRange set, long
mailboxId)
+ throws StorageException;
+
+ public abstract List<Message> findMarkedForDeletionInMailbox(
+ final MessageRange set, final long mailboxId)
+ throws StorageException;
+
+ public abstract long countMessagesInMailbox(long mailboxId)
+ throws StorageException;
+
+ public abstract long countUnseenMessagesInMailbox(long mailboxId)
+ throws StorageException;
+
+ @SuppressWarnings("unchecked")
+ public abstract List<Message> searchMailbox(long mailboxId,
+ SearchQuery query) throws StorageException;
+
+ public abstract void delete(Message message) throws StorageException;
+
+ @SuppressWarnings("unchecked")
+ public abstract List<Message> findUnseenMessagesInMailboxOrderByUid(
+ final long mailboxId) throws StorageException;
+
+ @SuppressWarnings("unchecked")
+ public abstract List<Message> findRecentMessagesInMailbox(
+ final long mailboxId) throws StorageException;
+
+ public abstract void save(Message message) throws StorageException;
+
+}
\ No newline at end of file
Added:
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/user/SubscriptionMapper.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/user/SubscriptionMapper.java?rev=732114&view=auto
==============================================================================
---
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/user/SubscriptionMapper.java
(added)
+++
james/protocols/imap/trunk/jpa/src/main/java/org/apache/james/imap/store/user/SubscriptionMapper.java
Tue Jan 6 12:53:21 2009
@@ -0,0 +1,61 @@
+/****************************************************************
+ * 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.user;
+
+import java.util.List;
+
+import org.apache.james.imap.jpa.user.model.Subscription;
+
+public interface SubscriptionMapper {
+
+ public abstract void begin();
+
+ public abstract void commit();
+
+ /**
+ * Finds any subscriptions for a given user to the given mailbox.
+ * @param user not null
+ * @param mailbox not null
+ * @return <code>Subscription</code>,
+ * or null when the user is not subscribed to the given mailbox
+ */
+ public abstract Subscription findFindMailboxSubscriptionForUser(
+ final String user, final String mailbox);
+
+ /**
+ * Saves the given subscription.
+ * @param subscription not null
+ */
+ public abstract void save(Subscription subscription);
+
+ /**
+ * Finds subscriptions for the given user.
+ * @param user not null
+ * @return not null
+ */
+ @SuppressWarnings("unchecked")
+ public abstract List<Subscription> findSubscriptionsForUser(String user);
+
+ /**
+ * Deletes the given subscription.
+ * @param subscription not null
+ */
+ public abstract void delete(Subscription subscription);
+
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]