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 no...@apache.org on 2011/05/04 22:55:32 UTC
svn commit: r1099606 - in
/james/server/trunk/cli/src/main/java/org/apache/james/cli: ServerCmd.java
probe/impl/JmxServerProbe.java type/CmdType.java
Author: norman
Date: Wed May 4 20:55:32 2011
New Revision: 1099606
URL: http://svn.apache.org/viewvc?rev=1099606&view=rev
Log:
Add more comments to james cli. Part of JAMES-1179
Modified:
james/server/trunk/cli/src/main/java/org/apache/james/cli/ServerCmd.java
james/server/trunk/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java
james/server/trunk/cli/src/main/java/org/apache/james/cli/type/CmdType.java
Modified: james/server/trunk/cli/src/main/java/org/apache/james/cli/ServerCmd.java
URL: http://svn.apache.org/viewvc/james/server/trunk/cli/src/main/java/org/apache/james/cli/ServerCmd.java?rev=1099606&r1=1099605&r2=1099606&view=diff
==============================================================================
--- james/server/trunk/cli/src/main/java/org/apache/james/cli/ServerCmd.java (original)
+++ james/server/trunk/cli/src/main/java/org/apache/james/cli/ServerCmd.java Wed May 4 20:55:32 2011
@@ -20,6 +20,10 @@ package org.apache.james.cli;
import java.io.IOException;
import java.io.PrintStream;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
@@ -150,6 +154,48 @@ public class ServerCmd {
printUsage();
System.exit(1);
}
+ } else if (CmdType.LISTMAPPINGS.equals(cmdType)) {
+ if (cmdType.hasCorrectArguments(arguments.length)) {
+ sCmd.print(probe.listMappings(), System.out);
+ } else {
+ printUsage();
+ System.exit(1);
+ }
+ } else if (CmdType.LISTUSERDOMAINMAPPINGS.equals(cmdType)) {
+ if (cmdType.hasCorrectArguments(arguments.length)) {
+ sCmd.print(probe.listUserDomainMappings(arguments[1], arguments[2]).toArray(new String[0]), System.out);
+ } else {
+ printUsage();
+ System.exit(1);
+ }
+ } else if (CmdType.ADDADDRESSMAPPING.equals(cmdType)) {
+ if (cmdType.hasCorrectArguments(arguments.length)) {
+ probe.addAddressMapping(arguments[1], arguments[2], arguments[3]);
+ } else {
+ printUsage();
+ System.exit(1);
+ }
+ } else if (CmdType.REMOVEADDRESSMAPPING.equals(cmdType)) {
+ if (cmdType.hasCorrectArguments(arguments.length)) {
+ probe.removeAddressMapping(arguments[1], arguments[2], arguments[3]);
+ } else {
+ printUsage();
+ System.exit(1);
+ }
+ } else if (CmdType.ADDREGEXMAPPING.equals(cmdType)) {
+ if (cmdType.hasCorrectArguments(arguments.length)) {
+ probe.addRegexMapping(arguments[1], arguments[2], arguments[3]);
+ } else {
+ printUsage();
+ System.exit(1);
+ }
+ } else if (CmdType.REMOVEREGEXMAPPING.equals(cmdType)) {
+ if (cmdType.hasCorrectArguments(arguments.length)) {
+ probe.removeRegexMapping(arguments[1], arguments[2], arguments[3]);
+ } else {
+ printUsage();
+ System.exit(1);
+ }
} else {
System.err.println("Unrecognized command: " + cmdName + ".");
printUsage();
@@ -183,6 +229,21 @@ public class ServerCmd {
out.println();
}
+ public void print(Map<String,Collection<String>> map, PrintStream out) {
+ if (map == null)
+ return;
+
+ Iterator<Entry<String, Collection<String>>> entries = map.entrySet().iterator();
+ while(entries.hasNext()) {
+ Entry<String, Collection<String>> entry = entries.next();
+ out.print(entry.getKey());
+ out.print("=");
+ out.println(entry.getValue().toString());
+ }
+ out.println();
+ }
+
+
/*
* Prints usage information to stdout.
*/
@@ -195,9 +256,12 @@ public class ServerCmd {
+ "adddomain <domainname>%n"
+ "removedomain <domainname>%n"
+ "listdomains%n"
- // + "addMapping <address|regex> <user> <domain> <fromaddress|regexstring>%n"
- // + "removeMapping <address|regex> <user> <domain> <fromaddress|regexstring>%n"
- // + "listMappings [<user> <domain>]%n"
+ + "addAddressMapping <user> <domain> <fromaddress>%n"
+ + "removeAddressMapping <user> <domain> <fromaddress>%n"
+ + "addRegexMapping <user> <domain> <regex>%n"
+ + "removeRegexMapping <user> <domain> <regex>%n"
+ + "listuserdomainmappings <user> <domain>%n"
+ + "listmappings%n"
);
String usage = String.format("java %s --host <arg> <command>%n", ServerCmd.class.getName());
hf.printHelp(usage, "", options, header);
Modified: james/server/trunk/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java
URL: http://svn.apache.org/viewvc/james/server/trunk/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java?rev=1099606&r1=1099605&r2=1099606&view=diff
==============================================================================
--- james/server/trunk/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java (original)
+++ james/server/trunk/cli/src/main/java/org/apache/james/cli/probe/impl/JmxServerProbe.java Wed May 4 20:55:32 2011
@@ -39,7 +39,7 @@ public class JmxServerProbe implements S
// TODO: Move this to somewhere else
private final static String DOMAINLIST_OBJECT_NAME = "org.apache.james:type=component,name=domainlist";
- private final static String VIRTUALUSERTABLE_OBJECT_NAME = "org.apache.james:type=component,name=virtualusertable";
+ private final static String VIRTUALUSERTABLE_OBJECT_NAME = "org.apache.james:type=component,name=recipientrewritetable";
private final static String USERSREPOSITORY_OBJECT_NAME = "org.apache.james:type=component,name=usersrepository";
private MBeanServerConnection mbeanServerConn;
Modified: james/server/trunk/cli/src/main/java/org/apache/james/cli/type/CmdType.java
URL: http://svn.apache.org/viewvc/james/server/trunk/cli/src/main/java/org/apache/james/cli/type/CmdType.java?rev=1099606&r1=1099605&r2=1099606&view=diff
==============================================================================
--- james/server/trunk/cli/src/main/java/org/apache/james/cli/type/CmdType.java (original)
+++ james/server/trunk/cli/src/main/java/org/apache/james/cli/type/CmdType.java Wed May 4 20:55:32 2011
@@ -27,8 +27,13 @@ public enum CmdType {
LISTUSERS("listusers", 1),
ADDDOMAIN("adddomain", 2),
REMOVEDOMAIN("removedomain", 2),
- LISTDOMAINS("listdomains", 1);
-
+ LISTDOMAINS("listdomains", 1),
+ LISTMAPPINGS("listmappings", 1),
+ LISTUSERDOMAINMAPPINGS("listuserdomainmappings", 3),
+ ADDADDRESSMAPPING("addaddressmapping", 4),
+ REMOVEADDRESSMAPPING("removeaddressmapping", 4),
+ ADDREGEXMAPPING("addregexmapping", 4),
+ REMOVEREGEXMAPPING("removeregexmapping", 4);
private String command;
private int arguments;
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org