Revision: 16071
Author: [email protected]
Date: Mon Dec 27 09:30:30 2010
Log: [No log message]
http://code.google.com/p/mobicents/source/detail?r=16071
Modified:
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/LinksetListenerImpl.java
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/ShellExecutor.java
=======================================
---
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/LinksetListenerImpl.java
Mon Dec 27 04:51:55 2010
+++
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/LinksetListenerImpl.java
Mon Dec 27 09:30:30 2010
@@ -1,10 +1,15 @@
package org.mobicents.ss7;
+import org.apache.log4j.Logger;
+import org.mobicents.ss7.linkset.oam.LinkOAMMessages;
import org.mobicents.ss7.linkset.oam.LinksetManager;
import org.mobicents.ss7.management.console.LinksetListener;
public class LinksetListenerImpl implements LinksetListener {
+ private static final Logger logger = Logger
+ .getLogger(LinksetListenerImpl.class);
+
private LinksetManager linksetManager = null;
protected LinksetListenerImpl(LinksetManager linksetManager) {
@@ -12,23 +17,50 @@
}
public String execute(String[] options) {
-
- String firstOption = null;
- int i = 0;
- while (i < options.length && (firstOption = options[i]) == null) {
- i++;
- }
-
- if (firstOption == null) {
- return "Invalid Command";
- }
-
- if (firstOption.compareTo("create") == 0) {
- options[i] = null;
- return this.linksetManager.createLinkset(options);
- }
-
- return "Invalid Command";
- }
-
-}
+
+ try {
+ // Atleast 1 option is passed?
+ if (options == null || options.length < 2) {
+ return LinkOAMMessages.INVALID_COMMAND;
+ }
+
+ String firstOption = options[1];
+
+ if (firstOption == null) {
+ return LinkOAMMessages.INVALID_COMMAND;
+ }
+
+ if (firstOption.compareTo("create") == 0) {
+ // Create Linkset
+ return this.linksetManager.createLinkset(options);
+ } else if (firstOption.compareTo("delete") == 0) {
+ // Delete Linkset
+ return this.linksetManager.deleteLinkset(options);
+
+ } else if (firstOption.compareTo("link") == 0) {
+ // Operation for Link
+
+ // Check do we have more options
+ if (options.length < 3) {
+ return LinkOAMMessages.INVALID_COMMAND;
+ }
+
+ // Check if its create or delete
+ firstOption = options[2];
+ if (firstOption == null) {
+ return LinkOAMMessages.INVALID_COMMAND;
+ }
+
+ if (firstOption.compareTo("create") == 0) {
+ return this.linksetManager.createLink(options);
+ } else if (firstOption.compareTo("delete") == 0) {
+ return this.linksetManager.deleteLink(options);
+ }
+ }
+ } catch (Exception e) {
+ logger.error("Error while executing command ", e);
+ return e.toString();
+ }
+ return LinkOAMMessages.INVALID_COMMAND;
+ }
+}
=======================================
---
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/ShellExecutor.java
Mon Dec 27 04:51:55 2010
+++
/trunk/protocols/ss7/service/src/main/java/org/mobicents/ss7/ShellExecutor.java
Mon Dec 27 09:30:30 2010
@@ -132,7 +132,7 @@
.getSubject(options[0]);
if (subject == null) {
chan.send(messageFactory
- .createMessage("Invalid
Command"));
+ .createMessage("Invalid
Subject"));
} else {
// Nullify examined options
options[0] = null;