Revision: 4a0bbb0dc077
Author: [email protected] <[email protected]>
Date: Thu Aug 9 04:36:11 2012
Log: Issue 2:CLI help screen, TAB Completion feature
http://code.google.com/p/jss7/source/detail?r=4a0bbb0dc077
Added:
/management/shell/src/main/java/org/mobicents/ss7/management/console/AbstractCommandHandler.java
/management/shell/src/main/java/org/mobicents/ss7/management/console/Tree.java
/management/shell/src/main/resources/help/history_clear.txt
/management/shell/src/main/resources/help/history_disable.txt
/management/shell/src/main/resources/help/history_enable.txt
/management/shell/src/test/java/org/mobicents/ss7/management/console/TreeTest.java
Modified:
/hardware/cli/pom.xml
/hardware/cli/src/main/java/org/mobicents/ss7/management/console/impl/LinksetCommandHandler.java
/m3ua/cli/m3ua/pom.xml
/m3ua/cli/m3ua/src/main/java/org/mobicents/ss7/management/console/impl/M3UACommandHandler.java
/m3ua/cli/sctp/pom.xml
/m3ua/cli/sctp/src/main/java/org/mobicents/ss7/management/console/impl/SctpCommandHandler.java
/m3ua/cli/sctp/src/main/resources/archive-files/org.mobicents.ss7.management.console.CommandHandler
/m3ua/cli/sctp/src/main/resources/help/sctp.txt
/m3ua/cli/sctp/src/main/resources/help/sctp_association_create.txt
/m3ua/cli/sctp/src/main/resources/help/sctp_association_destroy.txt
/m3ua/cli/sctp/src/main/resources/help/sctp_association_show.txt
/m3ua/cli/sctp/src/main/resources/help/sctp_server_create
/m3ua/cli/sctp/src/main/resources/help/sctp_server_create.txt
/m3ua/cli/sctp/src/main/resources/help/sctp_server_destroy.txt
/m3ua/cli/sctp/src/main/resources/help/sctp_server_show.txt
/m3ua/cli/sctp/src/main/resources/help/sctp_server_start.txt
/m3ua/cli/sctp/src/main/resources/help/sctp_server_stop.txt
/management/shell/src/main/java/org/mobicents/ss7/management/console/CommandHandlerWithHelp.java
/management/shell/src/main/java/org/mobicents/ss7/management/console/ConnectHandler.java
/management/shell/src/main/java/org/mobicents/ss7/management/console/DisconnectHandler.java
/management/shell/src/main/java/org/mobicents/ss7/management/console/ExitHandler.java
/management/shell/src/main/java/org/mobicents/ss7/management/console/HistoryHandler.java
/management/shell/src/main/resources/help/connect.txt
/sccp/sccp-cli/pom.xml
/sccp/sccp-cli/src/main/java/org/mobicents/ss7/management/console/impl/SccpCommandHandler.java
=======================================
--- /dev/null
+++
/management/shell/src/main/java/org/mobicents/ss7/management/console/AbstractCommandHandler.java
Thu Aug 9 04:36:11 2012
@@ -0,0 +1,143 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.ss7.management.console;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.mobicents.ss7.management.console.Tree.Node;
+
+/**
+ * @author amit bhayani
+ *
+ */
+public abstract class AbstractCommandHandler implements CommandHandler {
+
+ public static final int CONNECT_MANDATORY_FLAG = 1;
+ public static final int DISCONNECT_MANDATORY_FLAG = 2;
+ public static final int DOESNT_CARE_CONNECT_DISCONNECT_FLAG = 0;
+
+ private final List<CommandLineCompleter> completion;
+ private final Tree tree;
+
+ // Variable to indicate that tab completion should show commands only
when
+ // CLI is connected or disconnected or doesn't care
+ private final int connectFlag;
+
+ /**
+ *
+ */
+ public AbstractCommandHandler(Tree tree, final int connectFlag) {
+ this.tree = tree;
+ this.connectFlag = connectFlag;
+ this.completion = new ArrayList<CommandLineCompleter>();
+ final Node node = this.tree.getTopNode();
+ final String data = node.getData();
+ CommandLineCompleter commandLineCompleter = new
CommandLineCompleter() {
+
+ @Override
+ public int complete(CommandContext ctx, String buffer, int cursor,
List<String> candidates) {
+
+ if (connectFlag == CONNECT_MANDATORY_FLAG
&& !ctx.isControllerConnected()) {
+ return 0;
+ } else if (connectFlag == DISCONNECT_MANDATORY_FLAG &&
ctx.isControllerConnected()) {
+ return 0;
+ }
+
+ if (buffer.equals("")) {
+ candidates.add(data);
+ } else {
+ addCompletionrecursively(buffer,
candidates, node);
+ }
+ return 0;
+ }
+
+ };
+
+ this.completion.add(commandLineCompleter);
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.mobicents.ss7.management.console.CommandHandler#handles(java.lang
+ * .String)
+ */
+ @Override
+ public boolean handles(String command) {
+ if (command.startsWith(this.tree.getTopNode().getData())) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean addCompletionrecursively(String buffer, List<String>
candidates, Node parentNode) {
+ String command = parentNode.getCommand();
+ String trimmedBuffer = buffer.trim();
+ if (command.equals(trimmedBuffer)) {
+ // If command is exactly what user has typed on CLI,
show all
+ // possible children
+ List<Node> children = parentNode.getChildren();
+
+ if (children.size() == 1) {
+ // If there is only one child, directly print
it rather than
+ // showing option
+ candidates.add(children.get(0).getCommand());
+ return true;
+ } else {
+ for (Node n : children) {
+ candidates.add(n.getData());
+ }
+ }
+ return true;
+ } else if (command.startsWith(buffer)) {
+ // If user has type partial command, complete it
+ candidates.add(command);
+ return true;
+ }
+
+ // None of the above conditions matched; lets check for child
+ // recursively
+ List<Node> children = parentNode.getChildren();
+ for (Node n : children) {
+ if (addCompletionrecursively(buffer, candidates, n)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.mobicents.ss7.management.console.CommandHandler#
+ * getCommandLineCompleterList()
+ */
+ @Override
+ public List<CommandLineCompleter> getCommandLineCompleterList() {
+ return this.completion;
+ }
+
+}
=======================================
--- /dev/null
+++
/management/shell/src/main/java/org/mobicents/ss7/management/console/Tree.java
Thu Aug 9 04:36:11 2012
@@ -0,0 +1,97 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.ss7.management.console;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author amit bhayani
+ *
+ */
+public class Tree {
+ private Node root;
+
+ public Tree(String rootData) {
+ root = new Node(rootData);
+ }
+
+ public Node getTopNode() {
+ return this.root;
+ }
+
+ public class Node {
+ private String data;
+ private Node parent;
+ private List<Node> children;
+
+ /**
+ * @param data
+ */
+ public Node(String data) {
+ super();
+ this.data = data;
+ this.children = new ArrayList<Node>();
+ }
+
+ /**
+ * @return the data
+ */
+ public String getData() {
+ return data;
+ }
+
+ public Node addChild(String childData) {
+ Node child = new Node(childData);
+ child.parent = this;
+ this.children.add(child);
+ return child;
+ }
+
+ public List<Node> getChildren() {
+ return this.children;
+ }
+
+ public Node getParent() {
+ return this.parent;
+ }
+
+ /**
+ * Returns the full command for this {@link Node}. For example consider
below tree, when getCommand() is called on Node111, it returns "Node1
Node11 Node111"
+ * Node1
+ * |_Node11
+ * |_Node111
+ * |_Node12
+ *
+ * @return
+ */
+ public String getCommand() {
+ StringBuffer command = new StringBuffer(this.data);
+ Node parent = this.parent;
+ while (parent != null) {
+ command.insert(0, parent.getData() + " ");
+ parent = parent.getParent();
+ }
+ return command.toString();
+ }
+ }// end of Node
+}
=======================================
--- /dev/null
+++ /management/shell/src/main/resources/help/history_clear.txt Thu Aug 9
04:36:11 2012
@@ -0,0 +1,16 @@
+SYNOPSIS
+
+ history [disable|enable|clear]
+
+DESCRIPTION
+
+ Manipulates the command (and operation request) history expansion.
+ Without arguments prints the in-memory history of commands and
operations
+ previously executed and a status whether the history expansion is
enabled or disabled.
+
+ARGUMENTS
+
+ disable - will disable history expansion (but will not clear the
previously recorded history);
+ enable - will re-enable history expansion (starting from the last
recorded command before
+ the history expansion was disabled);
+ clear - will clear the in-memory history (but not the file one).
=======================================
--- /dev/null
+++ /management/shell/src/main/resources/help/history_disable.txt Thu Aug
9 04:36:11 2012
@@ -0,0 +1,16 @@
+SYNOPSIS
+
+ history [disable|enable|clear]
+
+DESCRIPTION
+
+ Manipulates the command (and operation request) history expansion.
+ Without arguments prints the in-memory history of commands and
operations
+ previously executed and a status whether the history expansion is
enabled or disabled.
+
+ARGUMENTS
+
+ disable - will disable history expansion (but will not clear the
previously recorded history);
+ enable - will re-enable history expansion (starting from the last
recorded command before
+ the history expansion was disabled);
+ clear - will clear the in-memory history (but not the file one).
=======================================
--- /dev/null
+++ /management/shell/src/main/resources/help/history_enable.txt Thu Aug 9
04:36:11 2012
@@ -0,0 +1,16 @@
+SYNOPSIS
+
+ history [disable|enable|clear]
+
+DESCRIPTION
+
+ Manipulates the command (and operation request) history expansion.
+ Without arguments prints the in-memory history of commands and
operations
+ previously executed and a status whether the history expansion is
enabled or disabled.
+
+ARGUMENTS
+
+ disable - will disable history expansion (but will not clear the
previously recorded history);
+ enable - will re-enable history expansion (starting from the last
recorded command before
+ the history expansion was disabled);
+ clear - will clear the in-memory history (but not the file one).
=======================================
--- /dev/null
+++
/management/shell/src/test/java/org/mobicents/ss7/management/console/TreeTest.java
Thu Aug 9 04:36:11 2012
@@ -0,0 +1,60 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.mobicents.ss7.management.console;
+
+import java.io.IOException;
+
+import org.mobicents.ss7.management.console.Tree.Node;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.*;
+/**
+ * @author abhayani
+ *
+ */
+public class TreeTest {
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Test
+ public void testMessage() throws IOException {
+ Tree tree = new Tree("history");
+ tree.getTopNode().addChild("enable");
+ tree.getTopNode().addChild("disable");
+
+ assertEquals("history", tree.getTopNode().getCommand());
+
+ Node enable = tree.getTopNode().getChildren().get(0);
+ assertEquals("history enable", enable.getCommand());
+
+ Node disable = tree.getTopNode().getChildren().get(1);
+ assertEquals(disable.getCommand(), "history disable");
+ }
+}
=======================================
--- /hardware/cli/pom.xml Sat Jul 7 04:56:10 2012
+++ /hardware/cli/pom.xml Thu Aug 9 04:36:11 2012
@@ -34,6 +34,10 @@
<directory>src/main/resources/archive-files</directory>
<targetPath>META-INF/services</targetPath>
</resource>
+ <resource>
+ <directory>src/main/resources/help</directory>
+ <targetPath>help</targetPath>
+ </resource>
</resources>
</build>
<profiles>
=======================================
---
/hardware/cli/src/main/java/org/mobicents/ss7/management/console/impl/LinksetCommandHandler.java
Wed Jul 4 07:17:53 2012
+++
/hardware/cli/src/main/java/org/mobicents/ss7/management/console/impl/LinksetCommandHandler.java
Thu Aug 9 04:36:11 2012
@@ -1,11 +1,30 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.mobicents.ss7.management.console.impl;
-import java.util.ArrayList;
-import java.util.List;
-
import org.mobicents.ss7.management.console.CommandContext;
import org.mobicents.ss7.management.console.CommandHandlerWithHelp;
-import org.mobicents.ss7.management.console.CommandLineCompleter;
+import org.mobicents.ss7.management.console.Tree;
+import org.mobicents.ss7.management.console.Tree.Node;
/**
* @author amit bhayani
@@ -13,62 +32,26 @@
*/
public class LinksetCommandHandler extends CommandHandlerWithHelp {
- private final List<CommandLineCompleter> completion;
+ static final Tree commandTree = new Tree("linkset");
+ static {
+ Node parent = commandTree.getTopNode();
+ Node create = parent.addChild("create");
+ Node delete = parent.addChild("delete");
+ Node activate = parent.addChild("activate");
+ Node deactivate = parent.addChild("deactivate");
+ Node show = parent.addChild("show");
- public LinksetCommandHandler() {
- this.completion = new ArrayList<CommandLineCompleter>();
+ Node link = parent.addChild("link");
+ link.addChild("create");
+ link.addChild("delete");
+ link.addChild("activate");
+ link.addChild("deactivate");
- CommandLineCompleter commandLineCompleter = new
CommandLineCompleter() {
- @Override
- public int complete(CommandContext ctx, String buffer, int cursor,
List<String> candidates) {
+ };
- if (!ctx.isControllerConnected()) {
- return 0;
- }
- // very simple completor
- if (buffer.equals("") || buffer.equals("l") || buffer.equals("li") ||
buffer.equals("lin") || buffer.equals("link") || buffer.equals("links")
- || buffer.equals("linkse")) {
- candidates.add("linkset");
- } else if (buffer.equals("linkset") ||
buffer.equals("linkset ")) {
- candidates.add("create");
- candidates.add("delete");
- candidates.add("activate");
- candidates.add("deactivate");
- candidates.add("link");
- }
-
- return 0;
- }
- };
-
- this.completion.add(commandLineCompleter);
+ public LinksetCommandHandler() {
+ super(commandTree, CONNECT_MANDATORY_FLAG);
}
-
- /*
- * (non-Javadoc)
- *
- * @see
- *
org.mobicents.ss7.management.console.CommandHandler#getCompletionList()
- */
- @Override
- public List<CommandLineCompleter> getCommandLineCompleterList() {
- return this.completion;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.mobicents.ss7.management.console.CommandHandler#handles(java.lang
- * .String)
- */
- @Override
- public boolean handles(String command) {
- if (command.startsWith("linkset")) {
- return true;
- }
- return false;
- }
/*
* (non-Javadoc)
@@ -80,7 +63,12 @@
@Override
public void handle(CommandContext ctx, String commandLine) {
// TODO Validate command
- String[] commands = commandLine.split(" ");
+
+ if (commandLine.contains("--help")) {
+ this.printHelp(commandLine, ctx);
+ return;
+ }
+
ctx.sendMessage(commandLine);
}
=======================================
--- /m3ua/cli/m3ua/pom.xml Sat Jul 7 04:56:10 2012
+++ /m3ua/cli/m3ua/pom.xml Thu Aug 9 04:36:11 2012
@@ -34,6 +34,10 @@
<directory>src/main/resources/archive-files</directory>
<targetPath>META-INF/services</targetPath>
</resource>
+ <resource>
+ <directory>src/main/resources/help</directory>
+ <targetPath>help</targetPath>
+ </resource>
</resources>
</build>
<profiles>
=======================================
---
/m3ua/cli/m3ua/src/main/java/org/mobicents/ss7/management/console/impl/M3UACommandHandler.java
Tue Jul 3 02:19:00 2012
+++
/m3ua/cli/m3ua/src/main/java/org/mobicents/ss7/management/console/impl/M3UACommandHandler.java
Thu Aug 9 04:36:11 2012
@@ -1,3 +1,24 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.mobicents.ss7.management.console.impl;
import java.util.ArrayList;
@@ -6,6 +27,8 @@
import org.mobicents.ss7.management.console.CommandContext;
import org.mobicents.ss7.management.console.CommandHandlerWithHelp;
import org.mobicents.ss7.management.console.CommandLineCompleter;
+import org.mobicents.ss7.management.console.Tree;
+import org.mobicents.ss7.management.console.Tree.Node;
/**
* @author amit bhayani
@@ -13,75 +36,33 @@
*/
public class M3UACommandHandler extends CommandHandlerWithHelp {
- private final List<CommandLineCompleter> completion;
+ static final Tree commandTree = new Tree("m3ua");
+ static {
+ Node parent = commandTree.getTopNode();
+ Node as = parent.addChild("as");
+ as.addChild("create");
+ as.addChild("destroy");
+ as.addChild("add");
+ as.addChild("remove");
+ as.addChild("show");
- public M3UACommandHandler() {
- this.completion = new ArrayList<CommandLineCompleter>();
+ Node asp = parent.addChild("asp");
+ asp.addChild("create");
+ asp.addChild("destroy");
+ asp.addChild("start");
+ asp.addChild("stop");
+ asp.addChild("show");
- CommandLineCompleter commandLineCompleter = new
CommandLineCompleter() {
- @Override
- public int complete(CommandContext ctx, String buffer, int cursor,
List<String> candidates) {
+ Node route = parent.addChild("route");
+ route.addChild("add");
+ route.addChild("remove");
+ route.addChild("show");
- if (!ctx.isControllerConnected()) {
- return 0;
- }
- // very simple completor
- if (buffer.equals("") || buffer.equals("m") || buffer.equals("m3") ||
buffer.equals("m3u")) {
- candidates.add("m3ua");
- } else if (buffer.equals("m3ua") ||
buffer.equals("m3ua ")) {
- candidates.add("as");
- candidates.add("asp");
- candidates.add("route");
- } else if (buffer.equals("m3ua as") ||
buffer.equals("m3ua as ")) {
- candidates.add("create");
- candidates.add("destroy");
- candidates.add("show");
- candidates.add("add");
- candidates.add("remove");
- } else if (buffer.equals("m3ua asp") ||
buffer.equals("m3ua asp ")) {
- candidates.add("create");
- candidates.add("destroy");
- candidates.add("show");
- candidates.add("start");
- candidates.add("stop");
- } else if (buffer.equals("m3ua route") || buffer.equals("m3ua
route ")) {
- candidates.add("add");
- candidates.add("remove");
- candidates.add("show");
- }
+ };
- return 0;
- }
- };
-
- this.completion.add(commandLineCompleter);
+ public M3UACommandHandler() {
+ super(commandTree, CONNECT_MANDATORY_FLAG);
}
-
- /*
- * (non-Javadoc)
- *
- * @see
- *
org.mobicents.ss7.management.console.CommandHandler#getCompletionList()
- */
- @Override
- public List<CommandLineCompleter> getCommandLineCompleterList() {
- return this.completion;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.mobicents.ss7.management.console.CommandHandler#handles(java.lang
- * .String)
- */
- @Override
- public boolean handles(String command) {
- if (command.startsWith("m3ua")) {
- return true;
- }
- return false;
- }
/*
* (non-Javadoc)
@@ -93,7 +74,12 @@
@Override
public void handle(CommandContext ctx, String commandLine) {
// TODO Validate command
- String[] commands = commandLine.split(" ");
+
+ if (commandLine.contains("--help")) {
+ this.printHelp(commandLine, ctx);
+ return;
+ }
+
ctx.sendMessage(commandLine);
}
=======================================
--- /m3ua/cli/sctp/pom.xml Sat Jul 7 04:56:10 2012
+++ /m3ua/cli/sctp/pom.xml Thu Aug 9 04:36:11 2012
@@ -34,6 +34,10 @@
<directory>src/main/resources/archive-files</directory>
<targetPath>META-INF/services</targetPath>
</resource>
+ <resource>
+ <directory>src/main/resources/help</directory>
+ <targetPath>help</targetPath>
+ </resource>
</resources>
</build>
<profiles>
@@ -76,5 +80,5 @@
</plugins>
</build>
</profile>
- </profiles>
+ </profiles>
</project>
=======================================
---
/m3ua/cli/sctp/src/main/java/org/mobicents/ss7/management/console/impl/SctpCommandHandler.java
Tue Jul 3 02:19:00 2012
+++
/m3ua/cli/sctp/src/main/java/org/mobicents/ss7/management/console/impl/SctpCommandHandler.java
Thu Aug 9 04:36:11 2012
@@ -1,11 +1,30 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.mobicents.ss7.management.console.impl;
-import java.util.ArrayList;
-import java.util.List;
-
import org.mobicents.ss7.management.console.CommandContext;
import org.mobicents.ss7.management.console.CommandHandlerWithHelp;
-import org.mobicents.ss7.management.console.CommandLineCompleter;
+import org.mobicents.ss7.management.console.Tree;
+import org.mobicents.ss7.management.console.Tree.Node;
/**
* @author amit bhayani
@@ -13,67 +32,26 @@
*/
public class SctpCommandHandler extends CommandHandlerWithHelp {
- private final List<CommandLineCompleter> completion;
+ static final Tree commandTree = new Tree("sctp");
+ static {
+ Node parent = commandTree.getTopNode();
+ Node server = parent.addChild("server");
+ server.addChild("create");
+ server.addChild("destroy");
+ server.addChild("start");
+ server.addChild("stop");
+ server.addChild("show");
- public SctpCommandHandler() {
- this.completion = new ArrayList<CommandLineCompleter>();
+ Node association = parent.addChild("association");
+ association.addChild("create");
+ association.addChild("destroy");
+ association.addChild("show");
- CommandLineCompleter commandLineCompleter = new
CommandLineCompleter() {
- @Override
- public int complete(CommandContext ctx, String buffer, int cursor,
List<String> candidates) {
+ };
- if (!ctx.isControllerConnected()) {
- return 0;
- }
- // very simple completor
- if (buffer.equals("") || buffer.equals("s") || buffer.equals("sc") ||
buffer.equals("sct")) {
- candidates.add("sctp");
- } else if (buffer.equals("sctp") ||
buffer.equals("sctp ")) {
- candidates.add("server");
- candidates.add("association");
- } else if (buffer.equals("sctp s") || buffer.equals("sctp se") ||
buffer.equals("sctp ser") || buffer.equals("sctp serv")
- || buffer.equals("sctp serve"))
{
- candidates.add("sctp server");
- } else if (buffer.equals("sctp server") || buffer.equals("sctp
server ")) {
- candidates.add("create");
- candidates.add("destroy");
- candidates.add("start");
- candidates.add("stop");
- candidates.add("show");
- }
-
- return 0;
- }
- };
-
- this.completion.add(commandLineCompleter);
+ public SctpCommandHandler() {
+ super(commandTree, CONNECT_MANDATORY_FLAG);
}
-
- /*
- * (non-Javadoc)
- *
- * @see
- *
org.mobicents.ss7.management.console.CommandHandler#getCompletionList()
- */
- @Override
- public List<CommandLineCompleter> getCommandLineCompleterList() {
- return this.completion;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.mobicents.ss7.management.console.CommandHandler#handles(java.lang
- * .String)
- */
- @Override
- public boolean handles(String command) {
- if (command.startsWith("sctp")) {
- return true;
- }
- return false;
- }
/*
* (non-Javadoc)
@@ -85,7 +63,12 @@
@Override
public void handle(CommandContext ctx, String commandLine) {
// TODO Validate command
- String[] commands = commandLine.split(" ");
+
+ if (commandLine.contains("--help")) {
+ this.printHelp(commandLine, ctx);
+ return;
+ }
+
ctx.sendMessage(commandLine);
}
=======================================
---
/management/shell/src/main/java/org/mobicents/ss7/management/console/CommandHandlerWithHelp.java
Tue Jul 3 02:19:47 2012
+++
/management/shell/src/main/java/org/mobicents/ss7/management/console/CommandHandlerWithHelp.java
Thu Aug 9 04:36:11 2012
@@ -1,18 +1,75 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.mobicents.ss7.management.console;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.util.List;
+
+import org.mobicents.ss7.management.console.Tree.Node;
/**
* @author amit bhayani
*
*/
-public abstract class CommandHandlerWithHelp implements CommandHandler {
+public abstract class CommandHandlerWithHelp extends
AbstractCommandHandler {
- protected void printHelp(String filename, CommandContext ctx) {
- InputStream helpInput =
SecurityActions.getClassLoader(CommandHandlerWithHelp.class).getResourceAsStream(filename);
+ /**
+ * @param tree
+ */
+ public CommandHandlerWithHelp(Tree tree, final int connectFlag) {
+ super(tree, connectFlag);
+ Node topNode = tree.getTopNode();
+
+ if (topNode.getChildren().size() > 0) {
+ // add --help only if there is atleast 1 child. Else
for top command
+ // --help is any way added
+ addHelpToLastNode(topNode);
+ }
+
+ topNode.addChild("--help");
+
+ }
+
+ private void addHelpToLastNode(Node node) {
+ List<Node> children = node.getChildren();
+ if (children.size() == 0) {
+ // If this is last Node in the branch we add --help
+ node.addChild("--help");
+ } else {
+ for (Node n : children) {
+ addHelpToLastNode(n);
+ }
+ }
+ }
+
+ protected void printHelp(String commandLine, CommandContext ctx) {
+
+ String fileName = commandLine.trim().replaceAll(" --help", "");
+ fileName = "help/" + fileName.replace(" ", "_") + ".txt";
+
+ InputStream helpInput =
SecurityActions.getClassLoader(CommandHandlerWithHelp.class).getResourceAsStream(fileName);
if (helpInput != null) {
BufferedReader reader = new BufferedReader(new
InputStreamReader(helpInput));
try {
@@ -31,7 +88,7 @@
}
}
} else {
- ctx.printLine("Failed to locate command description " +
filename);
+ ctx.printLine("Failed to locate command description " +
fileName);
}
}
}
=======================================
---
/management/shell/src/main/java/org/mobicents/ss7/management/console/ConnectHandler.java
Tue Jul 3 02:19:47 2012
+++
/management/shell/src/main/java/org/mobicents/ss7/management/console/ConnectHandler.java
Thu Aug 9 04:36:11 2012
@@ -21,70 +21,20 @@
*/
package org.mobicents.ss7.management.console;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author amit bhayani
*
*/
public class ConnectHandler extends CommandHandlerWithHelp {
- private final List<CommandLineCompleter> completion;
+ static final Tree commandTree = new Tree("connect");
/**
*
*/
public ConnectHandler() {
-
- this.completion = new ArrayList<CommandLineCompleter>();
-
- CommandLineCompleter commandLineCompleter = new
CommandLineCompleter() {
-
- @Override
- public int complete(CommandContext ctx, String buffer, int cursor,
List<String> candidates) {
-
- if (ctx.isControllerConnected()) {
- return 0;
- }
-
- if (buffer.equals("") || buffer.equals("c") || buffer.equals("co") ||
buffer.equals("con") || buffer.equals("conn") || buffer.equals("conne")
- || buffer.equals("connec")) {
- candidates.add("connect");
- }
- return 0;
- }
-
- };
-
- this.completion.add(commandLineCompleter);
+ super(commandTree, DISCONNECT_MANDATORY_FLAG);
}
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.mobicents.ss7.management.console.CommandHandler#handles(java.lang
- * .String)
- */
- @Override
- public boolean handles(String command) {
- if (command.startsWith("connect")) {
- return true;
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.mobicents.ss7.management.console.CommandHandler#
- * getCommandLineCompleterList()
- */
- @Override
- public List<CommandLineCompleter> getCommandLineCompleterList() {
- return this.completion;
- }
/*
* (non-Javadoc)
@@ -112,10 +62,21 @@
@Override
public void handle(CommandContext ctx, String commandLine) {
// TODO Validate command
+
+ if (commandLine.contains("--help")) {
+ this.printHelp(commandLine, ctx);
+ return;
+ }
+
String[] commands = commandLine.split(" ");
if (commands.length == 1) {
ctx.connectController(null, -1);
+ } else if (commands.length == 2) {
+ if (commandLine.contains("--help")) {
+ this.printHelp("help/connect.txt", ctx);
+ return;
+ }
} else if (commands.length == 3) {
String host = commands[1];
try {
=======================================
---
/management/shell/src/main/java/org/mobicents/ss7/management/console/DisconnectHandler.java
Tue Jul 3 02:19:47 2012
+++
/management/shell/src/main/java/org/mobicents/ss7/management/console/DisconnectHandler.java
Thu Aug 9 04:36:11 2012
@@ -21,70 +21,20 @@
*/
package org.mobicents.ss7.management.console;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* @author abhayani
*
*/
public class DisconnectHandler extends CommandHandlerWithHelp {
- private final List<CommandLineCompleter> completion;
+ static final Tree commandTree = new Tree("disconnect");
/**
*
*/
public DisconnectHandler() {
-
- this.completion = new ArrayList<CommandLineCompleter>();
-
- CommandLineCompleter commandLineCompleter = new
CommandLineCompleter() {
-
- @Override
- public int complete(CommandContext ctx, String buffer, int cursor,
List<String> candidates) {
-
- if (!ctx.isControllerConnected()) {
- return 0;
- }
-
- if (buffer.equals("") || buffer.equals("d") || buffer.equals("di") ||
buffer.equals("dis") || buffer.equals("disc") || buffer.equals("disco")
- || buffer.equals("discon") || buffer.equals("disconn") ||
buffer.equals("disconne") || buffer.equals("disconnec")) {
- candidates.add("disconnect");
- }
- return 0;
- }
-
- };
-
- this.completion.add(commandLineCompleter);
+ super(commandTree, CONNECT_MANDATORY_FLAG);
}
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.mobicents.ss7.management.console.CommandHandler#handles(java.lang
- * .String)
- */
- @Override
- public boolean handles(String command) {
- if (command.startsWith("disconnect")) {
- return true;
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.mobicents.ss7.management.console.CommandHandler#
- * getCommandLineCompleterList()
- */
- @Override
- public List<CommandLineCompleter> getCommandLineCompleterList() {
- return this.completion;
- }
/*
* (non-Javadoc)
@@ -111,11 +61,21 @@
*/
@Override
public void handle(CommandContext ctx, String commandLine) {
+ if (commandLine.contains("--help")) {
+ this.printHelp(commandLine, ctx);
+ return;
+ }
+
String[] commands = commandLine.split(" ");
if (commands.length == 1) {
ctx.sendMessage("disconnect");
ctx.disconnectController();
+ } else if (commands.length == 2) {
+ if (commandLine.contains("--help")) {
+ this.printHelp("help/disconnect.txt", ctx);
+ return;
+ }
} else {
ctx.printLine("Invalid command.");
}
=======================================
---
/management/shell/src/main/java/org/mobicents/ss7/management/console/ExitHandler.java
Tue Jul 3 02:19:47 2012
+++
/management/shell/src/main/java/org/mobicents/ss7/management/console/ExitHandler.java
Thu Aug 9 04:36:11 2012
@@ -21,8 +21,6 @@
*/
package org.mobicents.ss7.management.console;
-import java.util.ArrayList;
-import java.util.List;
/**
* @author amit bhayani
@@ -30,57 +28,13 @@
*/
public class ExitHandler extends CommandHandlerWithHelp {
- private final List<CommandLineCompleter> completion;
+ static final Tree commandTree = new Tree("exit");
/**
*
*/
public ExitHandler() {
- this.completion = new ArrayList<CommandLineCompleter>();
-
- CommandLineCompleter commandLineCompleter = new
CommandLineCompleter() {
-
- @Override
- public int complete(CommandContext ctx, String buffer, int cursor,
List<String> candidates) {
- if (ctx.isControllerConnected()) {
- return 0;
- }
-
- if (buffer.equals("") || buffer.equals("e") || buffer.equals("ex") ||
buffer.equals("exi")) {
- candidates.add("exit");
- }
- return 0;
- }
-
- };
-
- this.completion.add(commandLineCompleter);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.mobicents.ss7.management.console.CommandHandler#handles(java.lang
- * .String)
- */
- @Override
- public boolean handles(String command) {
- if (command.startsWith("exit")) {
- return true;
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.mobicents.ss7.management.console.CommandHandler#
- * getCommandLineCompleterList()
- */
- @Override
- public List<CommandLineCompleter> getCommandLineCompleterList() {
- return this.completion;
+ super(commandTree, DISCONNECT_MANDATORY_FLAG);
}
/*
=======================================
---
/management/shell/src/main/java/org/mobicents/ss7/management/console/HistoryHandler.java
Tue Jul 3 02:19:47 2012
+++
/management/shell/src/main/java/org/mobicents/ss7/management/console/HistoryHandler.java
Thu Aug 9 04:36:11 2012
@@ -21,69 +21,31 @@
*/
package org.mobicents.ss7.management.console;
-import java.util.ArrayList;
import java.util.List;
+import org.mobicents.ss7.management.console.Tree.Node;
+
/**
* @author amit bhayani
*
*/
public class HistoryHandler extends CommandHandlerWithHelp {
- private final List<CommandLineCompleter> completion;
+ static final Tree commandTree = new Tree("history");
+ static {
+ Node parent = commandTree.getTopNode();
+ parent.addChild("enable");
+ parent.addChild("disable");
+ parent.addChild("clear");
+ };
/**
*
*/
public HistoryHandler() {
- this.completion = new ArrayList<CommandLineCompleter>();
+ super(commandTree, DOESNT_CARE_CONNECT_DISCONNECT_FLAG);
- CommandLineCompleter commandLineCompleter = new
CommandLineCompleter() {
-
- @Override
- public int complete(CommandContext ctx, String buffer, int cursor,
List<String> candidates) {
- if (buffer.equals("") || buffer.equals("h") || buffer.equals("hi") ||
buffer.equals("his") || buffer.equals("hist") || buffer.equals("histo")
- || buffer.equals("histor")) {
- candidates.add("history");
- } else if (buffer.equals("history") ||
buffer.equals("history ")) {
- candidates.add("clear");
- candidates.add("enable");
- candidates.add("disable");
- candidates.add("--help");
- }
- return 0;
- }
-
- };
-
- this.completion.add(commandLineCompleter);
}
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.mobicents.ss7.management.console.CommandHandler#handles(java.lang
- * .String)
- */
- @Override
- public boolean handles(String command) {
- if (command.startsWith("history")) {
- return true;
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.mobicents.ss7.management.console.CommandHandler#
- * getCommandLineCompleterList()
- */
- @Override
- public List<CommandLineCompleter> getCommandLineCompleterList() {
- return this.completion;
- }
/*
* (non-Javadoc)
@@ -106,16 +68,17 @@
*/
@Override
public void handle(CommandContext ctx, String commandLine) {
+
+ if (commandLine.contains("--help")) {
+ this.printHelp(commandLine, ctx);
+ return;
+ }
+
String[] commands = commandLine.split(" ");
if (commands.length == 1) {
this.printHistory(ctx);
} else if (commands.length == 2) {
- if (commandLine.contains("--help")) {
- this.printHelp("help/history.txt", ctx);
- return;
- }
-
String argument = commands[1];
if ("clear".equals(argument)) {
ctx.getHistory().clear();
@@ -126,6 +89,8 @@
} else {
ctx.printLine("Invalid command.");
}
+ } else {
+ ctx.printLine("Invalid command.");
}
}
=======================================
--- /management/shell/src/main/resources/help/connect.txt Tue Aug 7
23:03:18 2012
+++ /management/shell/src/main/resources/help/connect.txt Thu Aug 9
04:36:11 2012
@@ -5,7 +5,8 @@
connect <host-ip> <host-port>
DESCRIPTION
- This command is used to connect the Shell to a managed instance. The
parameters host-ip and host-port are optional. If you do not specify them,
the shell will attempt connecting to 127.0.0.1:3435.
+ This command is used to connect the Shell to a managed instance. The
parameters host-ip and
+ host-port are optional. If you do not specify them, the shell will
attempt connecting to 127.0.0.1:3435.
PARAMETERS
=======================================
--- /sccp/sccp-cli/pom.xml Sat Jul 7 04:56:10 2012
+++ /sccp/sccp-cli/pom.xml Thu Aug 9 04:36:11 2012
@@ -34,6 +34,10 @@
<directory>src/main/resources/archive-files</directory>
<targetPath>META-INF/services</targetPath>
</resource>
+ <resource>
+ <directory>src/main/resources/help</directory>
+ <targetPath>help</targetPath>
+ </resource>
</resources>
</build>
<profiles>
=======================================
---
/sccp/sccp-cli/src/main/java/org/mobicents/ss7/management/console/impl/SccpCommandHandler.java
Tue Jul 3 02:20:13 2012
+++
/sccp/sccp-cli/src/main/java/org/mobicents/ss7/management/console/impl/SccpCommandHandler.java
Thu Aug 9 04:36:11 2012
@@ -1,11 +1,30 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
package org.mobicents.ss7.management.console.impl;
-import java.util.ArrayList;
-import java.util.List;
-
import org.mobicents.ss7.management.console.CommandContext;
import org.mobicents.ss7.management.console.CommandHandlerWithHelp;
-import org.mobicents.ss7.management.console.CommandLineCompleter;
+import org.mobicents.ss7.management.console.Tree;
+import org.mobicents.ss7.management.console.Tree.Node;
/**
* @author amit bhayani
@@ -13,110 +32,70 @@
*/
public class SccpCommandHandler extends CommandHandlerWithHelp {
- private final List<CommandLineCompleter> completion;
+ static final Tree commandTree = new Tree("sccp");
+ static {
+ Node parent = commandTree.getTopNode();
+ Node sap = parent.addChild("sap");
+ sap.addChild("create");
+ sap.addChild("modify");
+ sap.addChild("delete");
+ sap.addChild("show");
+
+ Node dest = parent.addChild("dest");
+ dest.addChild("create");
+ dest.addChild("modify");
+ dest.addChild("delete");
+ dest.addChild("show");
- public SccpCommandHandler() {
- this.completion = new ArrayList<CommandLineCompleter>();
+ Node rule = parent.addChild("rule");
+ rule.addChild("create");
+ rule.addChild("modify");
+ rule.addChild("delete");
+ rule.addChild("show");
+
+ Node primaryAddress = parent.addChild("primary_add");
+ primaryAddress.addChild("create");
+ primaryAddress.addChild("modify");
+ primaryAddress.addChild("delete");
+ primaryAddress.addChild("show");
+
+ Node secondaryAddress = parent.addChild("backup_add");
+ secondaryAddress.addChild("create");
+ secondaryAddress.addChild("modify");
+ secondaryAddress.addChild("delete");
+ secondaryAddress.addChild("show");
+
+ Node rsp = parent.addChild("rsp");
+ rsp.addChild("create");
+ rsp.addChild("modify");
+ rsp.addChild("delete");
+ rsp.addChild("show");
+
+ Node rss = parent.addChild("rss");
+ rss.addChild("create");
+ rss.addChild("modify");
+ rss.addChild("delete");
+ rss.addChild("show");
+
+ Node lmr = parent.addChild("lmr");
+ lmr.addChild("create");
+ lmr.addChild("modify");
+ lmr.addChild("delete");
+ lmr.addChild("show");
+
+ Node csp = parent.addChild("csp");
+ csp.addChild("create");
+ csp.addChild("modify");
+ csp.addChild("delete");
+ csp.addChild("show");
+
+ Node set = parent.addChild("set");
- CommandLineCompleter commandLineCompleter = new
CommandLineCompleter() {
- @Override
- public int complete(CommandContext ctx, String buffer, int cursor,
List<String> candidates) {
-
- if (!ctx.isControllerConnected()) {
- return 0;
- }
- // very simple completor
- if (buffer.equals("") || buffer.equals("s") || buffer.equals("sc") ||
buffer.equals("scc")) {
- candidates.add("sccp");
- } else if (buffer.equals("sccp") ||
buffer.equals("sccp ")) {
- candidates.add("sap");
- candidates.add("dest");
- candidates.add("rsp");
- candidates.add("rss");
- candidates.add("rule");
- candidates.add("primary_add");
- candidates.add("backup_add");
- candidates.add("lmr");
- candidates.add("csp");
- } else if (buffer.equals("sccp sap") ||
buffer.equals("sccp sap ")) {
- candidates.add("create");
- candidates.add("delete");
- candidates.add("modify");
- candidates.add("show");
- } else if (buffer.equals("sccp dest") ||
buffer.equals("sccp dest ")) {
- candidates.add("create");
- candidates.add("delete");
- candidates.add("modify");
- candidates.add("show");
- } else if (buffer.equals("sccp rsp") ||
buffer.equals("sccp rsp ")) {
- candidates.add("create");
- candidates.add("delete");
- candidates.add("modify");
- candidates.add("show");
- } else if (buffer.equals("sccp rss") ||
buffer.equals("sccp rss ")) {
- candidates.add("create");
- candidates.add("delete");
- candidates.add("modify");
- candidates.add("show");
- } else if (buffer.equals("m3ua rule") ||
buffer.equals("m3ua rule ")) {
- candidates.add("create");
- candidates.add("delete");
- candidates.add("modify");
- candidates.add("show");
- } else if (buffer.equals("m3ua primary_add") || buffer.equals("m3ua
primary_add ")) {
- candidates.add("create");
- candidates.add("delete");
- candidates.add("modify");
- candidates.add("show");
- } else if (buffer.equals("m3ua backup_add") || buffer.equals("m3ua
backup_add ")) {
- candidates.add("create");
- candidates.add("delete");
- candidates.add("modify");
- candidates.add("show");
- } else if (buffer.equals("m3ua lmr") ||
buffer.equals("m3ua lmr ")) {
- candidates.add("create");
- candidates.add("delete");
- candidates.add("modify");
- candidates.add("show");
- } else if (buffer.equals("m3ua csp") ||
buffer.equals("m3ua csp ")) {
- candidates.add("create");
- candidates.add("delete");
- candidates.add("modify");
- candidates.add("show");
- }
-
- return 0;
- }
- };
-
- this.completion.add(commandLineCompleter);
+ };
+
+ public SccpCommandHandler() {
+ super(commandTree, CONNECT_MANDATORY_FLAG);
}
-
- /*
- * (non-Javadoc)
- *
- * @see
- *
org.mobicents.ss7.management.console.CommandHandler#getCompletionList()
- */
- @Override
- public List<CommandLineCompleter> getCommandLineCompleterList() {
- return this.completion;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.mobicents.ss7.management.console.CommandHandler#handles(java.lang
- * .String)
- */
- @Override
- public boolean handles(String command) {
- if (command.startsWith("sccp")) {
- return true;
- }
- return false;
- }
/*
* (non-Javadoc)
@@ -128,7 +107,10 @@
@Override
public void handle(CommandContext ctx, String commandLine) {
// TODO Validate command
- String[] commands = commandLine.split(" ");
+ if (commandLine.contains("--help")) {
+ this.printHelp(commandLine, ctx);
+ return;
+ }
ctx.sendMessage(commandLine);
}