Author: btellier Date: Thu Jul 9 07:41:33 2015 New Revision: 1690000 URL: http://svn.apache.org/r1690000 Log: JAMES-1584 Command to create a mailbox
Modified: james/server/trunk/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java james/server/trunk/container/cli/src/main/java/org/apache/james/cli/type/CmdType.java james/server/trunk/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java james/server/trunk/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagementMBean.java Modified: james/server/trunk/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java URL: http://svn.apache.org/viewvc/james/server/trunk/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java?rev=1690000&r1=1689999&r2=1690000&view=diff ============================================================================== --- james/server/trunk/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java (original) +++ james/server/trunk/container/cli/src/main/java/org/apache/james/cli/ServerCmd.java Thu Jul 9 07:41:33 2015 @@ -228,6 +228,13 @@ public class ServerCmd { printUsage(); System.exit(1); } + } else if (CmdType.CREATEMAILBOX.equals(cmdType)) { + if (cmdType.hasCorrectArguments(arguments.length)) { + probe.createMailbox(arguments[1], arguments[2], arguments[3]); + } else { + printUsage(); + System.exit(1); + } } else { System.err.println("Unrecognized command: " + cmdName + "."); printUsage(); @@ -292,7 +299,8 @@ public class ServerCmd { "listuserdomainmappings <user> <domain>%n" + // "listmappings%n" + // "copymailbox <srcbean> <dstbean>%n" + // - "deleteusermailboxes <user>%n" // + "deleteusermailboxes <user>%n" + // + "createmailbox <namespace> <user> <name>%n" ); String usage = String.format("java %s --host <arg> <command>%n", ServerCmd.class.getName()); hf.printHelp(usage, "", options, header); Modified: james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java URL: http://svn.apache.org/viewvc/james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java?rev=1690000&r1=1689999&r2=1690000&view=diff ============================================================================== --- james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java (original) +++ james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/ServerProbe.java Thu Jul 9 07:41:33 2015 @@ -191,4 +191,13 @@ public interface ServerProbe extends Clo * @throws Exception */ void deleteUserMailboxesNames(String user) throws Exception; + + /** + * Create a mailbox + * + * @param namespace Namespace of the created mailbox + * @param user User of the created mailbox + * @param name Name of the created mailbox + */ + void createMailbox(String namespace, String user, String name); } Modified: james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java URL: http://svn.apache.org/viewvc/james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java?rev=1690000&r1=1689999&r2=1690000&view=diff ============================================================================== --- james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java (original) +++ james/server/trunk/container/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java Thu Jul 9 07:41:33 2015 @@ -198,4 +198,9 @@ public class JmxServerProbe implements S public void deleteUserMailboxesNames(String user) throws Exception { mailboxManagerManagement.deleteMailboxes(user); } + + @Override + public void createMailbox(String namespace, String user, String name) { + mailboxManagerManagement.createMailbox(namespace, user, name); + } } Modified: james/server/trunk/container/cli/src/main/java/org/apache/james/cli/type/CmdType.java URL: http://svn.apache.org/viewvc/james/server/trunk/container/cli/src/main/java/org/apache/james/cli/type/CmdType.java?rev=1690000&r1=1689999&r2=1690000&view=diff ============================================================================== --- james/server/trunk/container/cli/src/main/java/org/apache/james/cli/type/CmdType.java (original) +++ james/server/trunk/container/cli/src/main/java/org/apache/james/cli/type/CmdType.java Thu Jul 9 07:41:33 2015 @@ -37,7 +37,8 @@ public enum CmdType { REMOVEREGEXMAPPING("removeregexmapping", 4), // SETPASSWORD("setpassword", 3), // COPYMAILBOX("copymailbox", 3), // - DELETEUSERMAILBOXES("deleteusermailboxes", 2) // + DELETEUSERMAILBOXES("deleteusermailboxes", 2), // + CREATEMAILBOX("createmailbox", 4) ; private final String command; private final int arguments; Modified: james/server/trunk/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java URL: http://svn.apache.org/viewvc/james/server/trunk/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java?rev=1690000&r1=1689999&r2=1690000&view=diff ============================================================================== --- james/server/trunk/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java (original) +++ james/server/trunk/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java Thu Jul 9 07:41:33 2015 @@ -126,6 +126,16 @@ public class MailboxManagerManagement ex return boxes; } + @Override + public void createMailbox(String namespace, String user, String name) { + try { + MailboxSession session = mailboxManager.createSystemSession(user, log); + mailboxManager.createMailbox(new MailboxPath(namespace, user, name), session); + } catch (Exception e) { + throw new RuntimeException("Unable to create mailbox", e); + } + } + private List<MailboxMetaData> retrieveAllUserMailboxes(String username, MailboxSession session) throws MailboxException { return mailboxManager.search( new MailboxQuery(new MailboxPath(MailboxConstants.USER_NAMESPACE, username, ""), Modified: james/server/trunk/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagementMBean.java URL: http://svn.apache.org/viewvc/james/server/trunk/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagementMBean.java?rev=1690000&r1=1689999&r2=1690000&view=diff ============================================================================== --- james/server/trunk/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagementMBean.java (original) +++ james/server/trunk/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagementMBean.java Thu Jul 9 07:41:33 2015 @@ -40,4 +40,13 @@ public interface MailboxManagerManagemen * @return mailboxes */ List<String> listMailboxes(String username); + + /** + * Create a mailbox + * + * @param namespace Namespace of the created mailbox + * @param user User of the created mailbox + * @param name Name of the created mailbox + */ + void createMailbox(String namespace,String user, String name); } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org