in server/apps/cli/src/main/java/org/apache/james/cli/ServerCmd.java [235:383]
private void executeCommand(String[] arguments, CmdType cmdType, PrintStream printStream) throws Exception {
switch (cmdType) {
case ADDUSER:
probe.addUser(arguments[1], arguments[2]);
break;
case REMOVEUSER:
probe.removeUser(arguments[1]);
break;
case LISTUSERS:
print(probe.listUsers(), printStream);
break;
case ADDDOMAIN:
probe.addDomain(arguments[1]);
break;
case REMOVEDOMAIN:
probe.removeDomain(arguments[1]);
break;
case CONTAINSDOMAIN:
if (probe.containsDomain(arguments[1])) {
printStream.println(arguments[1] + " exists");
} else {
printStream.println(arguments[1] + " does not exists");
}
break;
case LISTDOMAINS:
print(probe.listDomains(), printStream);
break;
case ADDDOMAINMAPPING:
probe.addDomainMapping(arguments[1], arguments[2]);
break;
case REMOVEDOMAINMAPPING:
probe.removeDomainMapping(arguments[1], arguments[2]);
break;
case LISTDOMAINMAPPINGS:
Mappings domainMappings = probe.listDomainMappings(arguments[1]);
print(domainMappings.asStrings(), printStream);
break;
case LISTMAPPINGS:
print(probe.listMappings(), printStream);
break;
case LISTUSERDOMAINMAPPINGS:
Mappings userDomainMappings = probe.listUserDomainMappings(arguments[1], arguments[2]);
print(userDomainMappings.asStrings(), printStream);
break;
case ADDADDRESSMAPPING:
probe.addAddressMapping(arguments[1], arguments[2], arguments[3]);
break;
case REMOVEADDRESSMAPPING:
probe.removeAddressMapping(arguments[1], arguments[2], arguments[3]);
break;
case ADDREGEXMAPPING:
probe.addRegexMapping(arguments[1], arguments[2], arguments[3]);
break;
case REMOVEREGEXMAPPING:
probe.removeRegexMapping(arguments[1], arguments[2], arguments[3]);
break;
case SETPASSWORD:
probe.setPassword(arguments[1], arguments[2]);
break;
case COPYMAILBOX:
mailboxProbe.copyMailbox(arguments[1], arguments[2]);
break;
case DELETEUSERMAILBOXES:
mailboxProbe.deleteUserMailboxesNames(arguments[1]);
break;
case CREATEMAILBOX:
mailboxProbe.createMailbox(arguments[1], arguments[2], arguments[3]);
break;
case LISTUSERMAILBOXES:
Collection<String> mailboxes = mailboxProbe.listUserMailboxes(arguments[1]);
print(mailboxes.toArray(String[]::new), printStream);
break;
case DELETEMAILBOX:
mailboxProbe.deleteMailbox(arguments[1], arguments[2], arguments[3]);
break;
case IMPORTEML:
mailboxProbe.importEmlFileToMailbox(arguments[1], arguments[2], arguments[3], arguments[4]);
break;
case GETSTORAGEQUOTA:
printStorageQuota(arguments[1], quotaProbe.getStorageQuota(arguments[1]), printStream);
break;
case GETMESSAGECOUNTQUOTA:
printMessageQuota(arguments[1], quotaProbe.getMessageCountQuota(arguments[1]), printStream);
break;
case GETQUOTAROOT:
printStream.println("Quota Root: " + quotaProbe.getQuotaRoot(arguments[1], arguments[2], arguments[3]));
break;
case GETMAXSTORAGEQUOTA:
printStream.println("Storage space allowed for Quota Root "
+ arguments[1]
+ ": "
+ formatStorageValue(quotaProbe.getMaxStorage(arguments[1])));
break;
case GETMAXMESSAGECOUNTQUOTA:
printStream.println("MailboxMessage count allowed for Quota Root " + arguments[1] + ": " + formatMessageValue(quotaProbe.getMaxMessageCount(arguments[1])));
break;
case SETMAXSTORAGEQUOTA:
quotaProbe.setMaxStorage(arguments[1], parseQuotaSize(arguments[2]));
break;
case SETMAXMESSAGECOUNTQUOTA:
quotaProbe.setMaxMessageCount(arguments[1], parseQuotaCount(arguments[2]));
break;
case SETGLOBALMAXSTORAGEQUOTA:
quotaProbe.setGlobalMaxStorage(parseQuotaSize(arguments[1]));
break;
case SETGLOBALMAXMESSAGECOUNTQUOTA:
quotaProbe.setGlobalMaxMessageCount(parseQuotaCount(arguments[1]));
break;
case GETGLOBALMAXSTORAGEQUOTA:
printStream.println("Global Maximum Storage Quota: " + formatStorageValue(quotaProbe.getGlobalMaxStorage()));
break;
case GETGLOBALMAXMESSAGECOUNTQUOTA:
printStream.println("Global Maximum message count Quota: " + formatMessageValue(quotaProbe.getGlobalMaxMessageCount()));
break;
case REINDEXMAILBOX:
mailboxProbe.reIndexMailbox(arguments[1], arguments[2], arguments[3]);
break;
case REINDEXALL:
mailboxProbe.reIndexAll();
break;
case SETSIEVEQUOTA:
sieveProbe.setSieveQuota(Size.parse(arguments[1]).asBytes());
break;
case SETSIEVEUSERQUOTA:
sieveProbe.setSieveQuota(arguments[1], Size.parse(arguments[2]).asBytes());
break;
case GETSIEVEQUOTA:
printStream.println("Storage space allowed for Sieve scripts by default: "
+ formatStorageValue(sieveProbe.getSieveQuota()));
break;
case GETSIEVEUSERQUOTA:
printStream.println("Storage space allowed for "
+ arguments[1]
+ " Sieve scripts: "
+ formatStorageValue(sieveProbe.getSieveQuota(arguments[1])));
break;
case REMOVESIEVEQUOTA:
sieveProbe.removeSieveQuota();
break;
case REMOVESIEVEUSERQUOTA:
sieveProbe.removeSieveQuota(arguments[1]);
break;
case ADDACTIVESIEVESCRIPT:
sieveProbe.addActiveSieveScriptFromFile(arguments[1], arguments[2], arguments[3]);
break;
default:
throw new UnrecognizedCommandException(cmdType.getCommand());
}
}