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 bt...@apache.org on 2017/10/04 09:28:28 UTC
[05/29] james-project git commit: JAMES-2169 Introduce
MailboxPath::forUser to simplify MailboxPath handling
JAMES-2169 Introduce MailboxPath::forUser to simplify MailboxPath handling
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/8a1c4c7f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/8a1c4c7f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/8a1c4c7f
Branch: refs/heads/master
Commit: 8a1c4c7f66f8193804fa10ce14acc220dfa8ed98
Parents: 2a23a97
Author: benwa <bt...@linagora.com>
Authored: Mon Oct 2 10:21:41 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Wed Oct 4 16:19:50 2017 +0700
----------------------------------------------------------------------
.../apache/james/mailbox/model/MailboxPath.java | 75 +++++++++++---------
1 file changed, 41 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/8a1c4c7f/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
index 0f538ae..1da70bc 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
@@ -30,6 +30,47 @@ import com.google.common.collect.ImmutableList;
* The path to a mailbox.
*/
public class MailboxPath {
+ /**
+ * Return a {@link MailboxPath} which represent the INBOX of the given
+ * session
+ *
+ * @param session
+ * @return inbox
+ */
+ public static MailboxPath inbox(MailboxSession session) {
+ return new MailboxPath(session.getPersonalSpace(), session.getUser().getUserName(), MailboxConstants.INBOX);
+ }
+
+ /**
+ * Create a {@link MailboxPath} by parsing the given full mailboxname (which included the namespace)
+ *
+ * @param session
+ * @param fullmailboxname
+ * @return path
+ */
+ public static MailboxPath parse(MailboxSession session, String fullmailboxname) {
+ char delimiter = session.getPathDelimiter();
+ int i = fullmailboxname.indexOf(delimiter);
+ String namespace = fullmailboxname.substring(0, i);
+ String mailbox = fullmailboxname.substring(i + 1, fullmailboxname.length());
+ String username = null;
+ if (namespace == null || namespace.trim().equals("")) {
+ namespace = MailboxConstants.USER_NAMESPACE;
+ }
+ if (namespace.equals(session.getPersonalSpace())) {
+ username = session.getUser().getUserName();
+ }
+ return new MailboxPath(namespace, username, mailbox);
+
+ }
+
+ /**
+ * Create a {@link MailboxPath} in the prive namespace of the specified user
+ */
+ public static MailboxPath forUser(String username, String mailboxName) {
+ return new MailboxPath(MailboxConstants.USER_NAMESPACE, username, mailboxName);
+
+ }
private String namespace;
private String user;
@@ -195,38 +236,4 @@ public class MailboxPath {
return namespace + delimiter + name;
}
- /**
- * Return a {@link MailboxPath} which represent the INBOX of the given
- * session
- *
- * @param session
- * @return inbox
- */
- public static MailboxPath inbox(MailboxSession session) {
- return new MailboxPath(session.getPersonalSpace(), session.getUser().getUserName(), MailboxConstants.INBOX);
- }
-
- /**
- * Create a {@link MailboxPath} by parsing the given full mailboxname (which included the namespace)
- *
- * @param session
- * @param fullmailboxname
- * @return path
- */
- public static MailboxPath parse(MailboxSession session, String fullmailboxname) {
- char delimiter = session.getPathDelimiter();
- int i = fullmailboxname.indexOf(delimiter);
- String namespace = fullmailboxname.substring(0, i);
- String mailbox = fullmailboxname.substring(i + 1, fullmailboxname.length());
- String username = null;
- if (namespace == null || namespace.trim().equals("")) {
- namespace = MailboxConstants.USER_NAMESPACE;
- }
- if (namespace.equals(session.getPersonalSpace())) {
- username = session.getUser().getUserName();
- }
- return new MailboxPath(namespace, username, mailbox);
-
- }
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org