Revision: 9e00d71fbff8
Author: [email protected] <[email protected]>
Date: Wed Jul 4 07:17:53 2012
Log: Issue 2: Client side validation of Shell Commands and help screen
http://code.google.com/p/jss7/source/detail?r=9e00d71fbff8
Added:
/hardware/cli/pom.xml
/hardware/cli/src/main/java/org/mobicents/ss7/management/console/impl/LinksetCommandHandler.java
/hardware/cli/src/main/resources/archive-files/org.mobicents.ss7.management.console.CommandHandler
Modified:
/hardware/pom.xml
=======================================
--- /dev/null
+++ /hardware/cli/pom.xml Wed Jul 4 07:17:53 2012
@@ -0,0 +1,39 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.mobicents.protocols.ss7.hardware</groupId>
+ <artifactId>mobicents-hardware</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>cli</artifactId>
+ <name>Mobicents SS7 :: Hardware :: ${pom.artifactId}</name>
+
+ <dependencies>
+ <!-- <dependency> <groupId>log4j</groupId>
<artifactId>log4j</artifactId>
+ <version>${log4j.version}</version> </dependency> -->
+ <!-- MTP3 -->
+ <dependency>
+
<groupId>org.mobicents.protocols.ss7.management</groupId>
+ <artifactId>shell</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>${pom.artifactId}-${pom.version}</finalName>
+ <resources>
+ <resource>
+
<directory>src/main/resources/archive-files</directory>
+ <targetPath>META-INF/services</targetPath>
+ </resource>
+ </resources>
+ </build>
+</project>
=======================================
--- /dev/null
+++
/hardware/cli/src/main/java/org/mobicents/ss7/management/console/impl/LinksetCommandHandler.java
Wed Jul 4 07:17:53 2012
@@ -0,0 +1,103 @@
+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;
+
+/**
+ * @author amit bhayani
+ *
+ */
+public class LinksetCommandHandler extends CommandHandlerWithHelp {
+
+ private final List<CommandLineCompleter> completion;
+
+ public LinksetCommandHandler() {
+ 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;
+ }
+ // 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);
+ }
+
+ /*
+ * (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)
+ *
+ * @see
+ * org.mobicents.ss7.management.console.CommandHandler#isValid(java.lang
+ * .String)
+ */
+ @Override
+ public void handle(CommandContext ctx, String commandLine) {
+ // TODO Validate command
+ String[] commands = commandLine.split(" ");
+ ctx.sendMessage(commandLine);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ *
org.mobicents.ss7.management.console.CommandHandler#isAvailable(org.mobicents
+ * .ss7.management.console.CommandContext)
+ */
+ @Override
+ public boolean isAvailable(CommandContext ctx) {
+ if (!ctx.isControllerConnected()) {
+ ctx.printLine("The command is not available in the current context.
Please connnect first");
+ return false;
+ }
+ return true;
+ }
+
+}
=======================================
--- /dev/null
+++
/hardware/cli/src/main/resources/archive-files/org.mobicents.ss7.management.console.CommandHandler
Wed Jul 4 07:17:53 2012
@@ -0,0 +1,1 @@
+org.mobicents.ss7.management.console.impl.LinksetCommandHandler
=======================================
--- /hardware/pom.xml Wed Jul 4 07:10:07 2012
+++ /hardware/pom.xml Wed Jul 4 07:17:53 2012
@@ -22,6 +22,7 @@
<modules>
<module>linkset</module>
+ <module>cli</module>
<module>dahdi</module>
<module>dialogic</module>
</modules>