Skip to content

Commit

Permalink
MAILBOX-279: Mailbox interface supports setMailboxId and its refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Quynh Nguyen committed Dec 7, 2016
1 parent ec03688 commit ee3fe49
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
Expand Up @@ -22,6 +22,7 @@


import org.apache.james.mailbox.hbase.HBaseId; import org.apache.james.mailbox.hbase.HBaseId;
import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.model.SimpleMailboxACL;
import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.Mailbox;
Expand Down Expand Up @@ -64,8 +65,9 @@ public HBaseId getMailboxId() {
return mailboxId; return mailboxId;
} }


public void setMailboxId(HBaseId mailboxId) { @Override
this.mailboxId = mailboxId; public void setMailboxId(MailboxId mailboxId) {
this.mailboxId = (HBaseId)mailboxId;
} }
/* /*
* (non-Javadoc) * (non-Javadoc)
Expand Down
Expand Up @@ -27,6 +27,7 @@
import org.apache.james.mailbox.jcr.JCRImapConstants; import org.apache.james.mailbox.jcr.JCRImapConstants;
import org.apache.james.mailbox.jcr.Persistent; import org.apache.james.mailbox.jcr.Persistent;
import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.model.SimpleMailboxACL;
import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.Mailbox;
Expand Down Expand Up @@ -198,10 +199,7 @@ public boolean equals(Object obj) {
return true; return true;
} }


/* @Override
* (non-Javadoc)
* @see org.apache.james.mailbox.store.mail.model.Mailbox#getMailboxId()
*/
public JCRId getMailboxId() { public JCRId getMailboxId() {
if (isPersistent()) { if (isPersistent()) {
try { try {
Expand All @@ -213,6 +211,10 @@ public JCRId getMailboxId() {
return null; return null;
} }


@Override
public void setMailboxId(MailboxId mailboxId) {

}
/* /*
* (non-Javadoc) * (non-Javadoc)
* @see org.apache.james.mailbox.store.mail.model.Mailbox#getNamespace() * @see org.apache.james.mailbox.store.mail.model.Mailbox#getNamespace()
Expand Down
Expand Up @@ -29,6 +29,7 @@


import org.apache.james.mailbox.jpa.JPAId; import org.apache.james.mailbox.jpa.JPAId;
import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.model.SimpleMailboxACL;
import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.Mailbox;
Expand Down Expand Up @@ -118,6 +119,10 @@ public JPAId getMailboxId() {
return JPAId.of(mailboxId); return JPAId.of(mailboxId);
} }


@Override
public void setMailboxId(MailboxId mailboxId) {
this.mailboxId = ((JPAId)mailboxId).getRawId();
}
/** /**
* @see org.apache.james.mailbox.store.mail.model.Mailbox#getName() * @see org.apache.james.mailbox.store.mail.model.Mailbox#getName()
*/ */
Expand Down
Expand Up @@ -606,12 +606,16 @@ public void notOperatorShouldReverseMatching() throws Exception {
} }


private final class SimpleMailbox implements Mailbox { private final class SimpleMailbox implements Mailbox {
private final TestId id; private TestId id;


public SimpleMailbox(long id) { public SimpleMailbox(long id) {
this.id = TestId.of(id); this.id = TestId.of(id);
} }


public void setMailboxId(MailboxId id) {
this.id = (TestId)id;
}

public TestId getMailboxId() { public TestId getMailboxId() {
return id; return id;
} }
Expand Down
Expand Up @@ -25,7 +25,7 @@
* Models long term mailbox data. * Models long term mailbox data.
*/ */
public interface Mailbox { public interface Mailbox {

void setMailboxId(MailboxId id);
/** /**
* Gets the unique mailbox ID. * Gets the unique mailbox ID.
* @return mailbox id * @return mailbox id
Expand Down
Expand Up @@ -138,7 +138,9 @@ public int hashCode() {
final int PRIME = 31; final int PRIME = 31;
int result = 1; int result = 1;
result = PRIME * result + namespace.hashCode(); result = PRIME * result + namespace.hashCode();
result = PRIME * result + user.hashCode(); if (user != null) {
result = PRIME * result + user.hashCode();
}
result = PRIME * result + name.hashCode(); result = PRIME * result + name.hashCode();
return result; return result;
} }
Expand All @@ -151,7 +153,7 @@ public String toString() {
return namespace + ":" + user + ":" + name; return namespace + ":" + user + ":" + name;
} }



@Override
public void setMailboxId(MailboxId id) { public void setMailboxId(MailboxId id) {
this.id = id; this.id = id;
} }
Expand Down
Expand Up @@ -37,6 +37,7 @@
import org.apache.james.mailbox.MessageUid; import org.apache.james.mailbox.MessageUid;
import org.apache.james.mailbox.mock.MockMailboxSession; import org.apache.james.mailbox.mock.MockMailboxSession;
import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MessageResult; import org.apache.james.mailbox.model.MessageResult;
import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.model.SimpleMailboxACL;
import org.apache.james.mailbox.model.UpdatedFlags; import org.apache.james.mailbox.model.UpdatedFlags;
Expand Down Expand Up @@ -113,6 +114,10 @@ public MailboxACL getACL() {
public void setACL(MailboxACL acl) { public void setACL(MailboxACL acl) {
} }


@Override
public void setMailboxId(MailboxId id) {
}

}; };


@Before @Before
Expand Down

0 comments on commit ee3fe49

Please sign in to comment.