Revision: 16070
Author: [email protected]
Date: Mon Dec 27 09:29:37 2010
Log: implemented delete link/linkset
http://code.google.com/p/mobicents/source/detail?r=16070
Modified:
/trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLink.java
/trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLinkset.java
/trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLinksetFactory.java
/trunk/protocols/ss7/hardware/dialogic/java/src/main/java/org/mobicents/ss7/hardware/dialogic/oam/DialogicLinkset.java
/trunk/protocols/ss7/hardware/dialogic/java/src/main/java/org/mobicents/ss7/hardware/dialogic/oam/DialogicLinksetFactory.java
/trunk/protocols/ss7/hardware/m3ua/src/main/java/org/mobicents/ss7/m3ua/oam/M3UALinkset.java
/trunk/protocols/ss7/hardware/m3ua/src/main/java/org/mobicents/ss7/m3ua/oam/M3UALinksetFactory.java
=======================================
---
/trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLink.java
Mon Dec 27 04:35:56 2010
+++
/trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLink.java
Mon Dec 27 09:29:37 2010
@@ -36,8 +36,11 @@
public DahdiLink() {
}
- public DahdiLink(String linkName) {
+ public DahdiLink(String linkName, int span, int channelID, int code) {
super(linkName);
+ this.span = span;
+ this.channelID = channelID;
+ this.code = code;
}
@Override
=======================================
---
/trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLinkset.java
Mon Dec 27 04:35:56 2010
+++
/trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLinkset.java
Mon Dec 27 09:29:37 2010
@@ -8,14 +8,15 @@
import javolution.xml.XMLFormat;
import javolution.xml.stream.XMLStreamException;
+import org.mobicents.ss7.linkset.oam.LinkState;
import org.mobicents.protocols.ss7.mtp.Mtp3;
import org.mobicents.protocols.ss7.mtp.Mtp3Listener;
import org.mobicents.ss7.linkset.oam.Link;
import org.mobicents.ss7.linkset.oam.LinkMode;
+import org.mobicents.ss7.linkset.oam.LinkOAMMessages;
import org.mobicents.ss7.linkset.oam.Linkset;
import org.mobicents.ss7.linkset.oam.LinksetMode;
import org.mobicents.ss7.linkset.oam.LinksetState;
-import org.mobicents.ss7.linkset.oam.LinkOAMMessages;
/**
*
@@ -70,28 +71,70 @@
* Operations
*/
@Override
- public boolean addLink(String linkName, ByteBuffer byteBuffer) {
-
- if (links.containsKey(linkName)) {
- byteBuffer.put(LinkOAMMessages.LINK_ALREADY_EXIST);
- return FALSE;
+ public void createLink(String[] options) throws Exception {
+
+ // the command looks like "linkset link create span 1 code 1
channel 1
+ // linkset1 link1"
+ if (options.length != 11) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
}
- DahdiLink link = new DahdiLink(linkName);
+ String option = options[3];
+
+ if (option == null || option.compareTo("span") != 0) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+
+ int span = Integer.parseInt(options[4]);
+
+ option = options[5];
+ if (option == null || option.compareTo("code") != 0) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+
+ int code = Integer.parseInt(options[6]);
+
+ option = options[7];
+ if (option == null || option.compareTo("channel") != 0) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+
+ int channel = Integer.parseInt(options[8]);
+
+ option = options[10]; // Link name
+ if (option == null) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
+
+ if (links.containsKey(option)) {
+ throw new Exception(LinkOAMMessages.LINK_ALREADY_EXIST);
+ }
+
+ DahdiLink link = new DahdiLink(option, span, channel, code);
link.setLinkSet(this);
- this.links.put(linkName, link);
-
- // Send back success message
- byteBuffer.put(LinkOAMMessages.LINK_SUCCESSFULLY_ADDED);
- return TRUE;
-
+ this.links.put(option, link);
+
+ }
+
+ @Override
+ public void deleteLink(String linkName) throws Exception {
+ Link link = this.links.get(linkName);
+ if(link == null){
+ throw new Exception(LinkOAMMessages.LINK_DOESNT_EXIST);
+ }
+
+ if(link.getState() == LinkState.AVAILABLE){
+ throw new Exception(LinkOAMMessages.CANT_DELETE_LINK);
+ }
+
+ this.links.remove(linkName);
}
@Override
public boolean noShutdown(ByteBuffer byteBuffer) {
if (this.state == LinksetState.AVAILABLE) {
- byteBuffer.put(LinkOAMMessages.LINKSET_ALREADY_ACTIVE);
+ //byteBuffer.put(LinkOAMMessages.LINKSET_ALREADY_ACTIVE);
return FALSE;
}
@@ -112,7 +155,7 @@
return TRUE;
}
- byteBuffer.put(LinkOAMMessages.LINKSET_NO_LINKS_CONFIGURED);
+ //byteBuffer.put(LinkOAMMessages.LINKSET_NO_LINKS_CONFIGURED);
return FALSE;
}
=======================================
---
/trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLinksetFactory.java
Mon Dec 27 04:35:56 2010
+++
/trunk/protocols/ss7/hardware/dahdi/java/src/main/java/org/mobicents/ss7/hardware/dahdi/oam/DahdiLinksetFactory.java
Mon Dec 27 09:29:37 2010
@@ -1,5 +1,6 @@
package org.mobicents.ss7.hardware.dahdi.oam;
+import org.mobicents.ss7.linkset.oam.LinkOAMMessages;
import org.mobicents.ss7.linkset.oam.Linkset;
import org.mobicents.ss7.linkset.oam.LinksetFactory;
@@ -21,70 +22,40 @@
}
@Override
- public Linkset createLinkset(String[] options) {
-
- // opc 1 dpc 2 ni 3 linkset1
- if (options.length < 7) {
- return null;
+ public Linkset createLinkset(String[] options) throws Exception {
+
+ // the expected command is "linkset create dahdi opc 1 dpc 2 ni 3
+ // linkset1". We know length is 10
+ if (options.length != 10) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
}
- String option = null;
- int i = 0;
- while (i < 7 && ((option = options[i]) == null)) {
- i++;
- }
-
- // If offset + command length is not equal to options length
- if (i + 7 != options.length) {
- return null;
- }
+ String option = options[3];
// If first option is not OPC
if (option.compareTo("opc") != 0) {
return null;
}
- i++;
- int opc;
- try {
- opc = Integer.parseInt(options[i]);
- } catch (NumberFormatException e) {
- return null;
- }
-
- i++;
-
- if (options[i].compareTo("dpc") != 0) {
- return null;
+ int opc = Integer.parseInt(options[4]);
+
+ if (options[5].compareTo("dpc") != 0) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
}
- i++;
-
- int dpc;
- try {
- dpc = Integer.parseInt(options[i]);
- } catch (NumberFormatException e) {
- return null;
+ int dpc = Integer.parseInt(options[6]);
+
+ if (options[7].compareTo("ni") != 0) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
}
- i++;
-
- if (options[i].compareTo("ni") != 0) {
- return null;
- }
-
- i++;
-
- int ni;
- try {
- ni = Integer.parseInt(options[i]);
- } catch (NumberFormatException e) {
- return null;
- }
-
- i++;
-
- String name = options[i];
+ int ni = Integer.parseInt(options[8]);
+
+ String name = options[9];
+
+ if (name == null) {
+ throw new Exception(LinkOAMMessages.INVALID_COMMAND);
+ }
return new DahdiLinkset(name, opc, dpc, ni);
}
=======================================
---
/trunk/protocols/ss7/hardware/dialogic/java/src/main/java/org/mobicents/ss7/hardware/dialogic/oam/DialogicLinkset.java
Mon Dec 27 04:35:56 2010
+++
/trunk/protocols/ss7/hardware/dialogic/java/src/main/java/org/mobicents/ss7/hardware/dialogic/oam/DialogicLinkset.java
Mon Dec 27 09:29:37 2010
@@ -31,18 +31,13 @@
@Override
public boolean noShutdown(ByteBuffer byteBuffer) {
if (this.state == LinksetState.AVAILABLE) {
- byteBuffer.put(LinkOAMMessages.LINKSET_ALREADY_ACTIVE);
+ //byteBuffer.put(LinkOAMMessages.LINKSET_ALREADY_ACTIVE);
return FALSE;
}
// TODO Start Dialogic Linkset
return FALSE;
}
-
- @Override
- public boolean addLink(String linkName, ByteBuffer byteBuffer) {
- return FALSE;
- }
/**
* Stream implementation methods
@@ -65,5 +60,15 @@
// TODO Auto-generated method stub
return 0;
}
+
+ @Override
+ public void createLink(String[] arg0) throws Exception {
+ throw new Exception(LinkOAMMessages.NOT_IMPLEMENTED);
+ }
+
+ @Override
+ public void deleteLink(String arg0) throws Exception {
+ throw new Exception(LinkOAMMessages.NOT_IMPLEMENTED);
+ }
}
=======================================
---
/trunk/protocols/ss7/hardware/dialogic/java/src/main/java/org/mobicents/ss7/hardware/dialogic/oam/DialogicLinksetFactory.java
Mon Dec 27 04:35:56 2010
+++
/trunk/protocols/ss7/hardware/dialogic/java/src/main/java/org/mobicents/ss7/hardware/dialogic/oam/DialogicLinksetFactory.java
Mon Dec 27 09:29:37 2010
@@ -1,5 +1,6 @@
package org.mobicents.ss7.hardware.dialogic.oam;
+import org.mobicents.ss7.linkset.oam.LinkOAMMessages;
import org.mobicents.ss7.linkset.oam.Linkset;
import org.mobicents.ss7.linkset.oam.LinksetFactory;
@@ -22,8 +23,8 @@
}
@Override
- public Linkset createLinkset(String[] options) {
- return null;
+ public Linkset createLinkset(String[] options) throws Exception {
+ throw new Exception(LinkOAMMessages.NOT_IMPLEMENTED);
}
}
=======================================
---
/trunk/protocols/ss7/hardware/m3ua/src/main/java/org/mobicents/ss7/m3ua/oam/M3UALinkset.java
Mon Dec 27 04:35:56 2010
+++
/trunk/protocols/ss7/hardware/m3ua/src/main/java/org/mobicents/ss7/m3ua/oam/M3UALinkset.java
Mon Dec 27 09:29:37 2010
@@ -59,16 +59,11 @@
/**
* Operations
*/
-
- @Override
- public boolean addLink(String linkName, ByteBuffer byteBuffer) {
- return FALSE;
- }
@Override
public boolean noShutdown(ByteBuffer byteBuffer) {
if (this.state == LinksetState.AVAILABLE) {
- byteBuffer.put(LinkOAMMessages.LINKSET_ALREADY_ACTIVE);
+ //byteBuffer.put(LinkOAMMessages.LINKSET_ALREADY_ACTIVE);
return FALSE;
}
@@ -124,5 +119,15 @@
// TODO Auto-generated method stub
return 0;
}
+
+ @Override
+ public void createLink(String[] arg0) throws Exception {
+ throw new Exception(LinkOAMMessages.NOT_IMPLEMENTED);
+ }
+
+ @Override
+ public void deleteLink(String arg0) throws Exception {
+ throw new Exception(LinkOAMMessages.NOT_IMPLEMENTED);
+ }
}
=======================================
---
/trunk/protocols/ss7/hardware/m3ua/src/main/java/org/mobicents/ss7/m3ua/oam/M3UALinksetFactory.java
Mon Dec 27 04:35:56 2010
+++
/trunk/protocols/ss7/hardware/m3ua/src/main/java/org/mobicents/ss7/m3ua/oam/M3UALinksetFactory.java
Mon Dec 27 09:29:37 2010
@@ -1,5 +1,6 @@
package org.mobicents.ss7.m3ua.oam;
+import org.mobicents.ss7.linkset.oam.LinkOAMMessages;
import org.mobicents.ss7.linkset.oam.Linkset;
import org.mobicents.ss7.linkset.oam.LinksetFactory;
@@ -22,8 +23,8 @@
}
@Override
- public Linkset createLinkset(String[] options) {
- return null;
+ public Linkset createLinkset(String[] options)throws Exception {
+ throw new Exception(LinkOAMMessages.NOT_IMPLEMENTED);
}
}