Rest API and Services for TopoSwitch
diff --git a/build.xml b/build.xml
index 349b683..aa8b593 100644
--- a/build.xml
+++ b/build.xml
@@ -52,8 +52,8 @@
     <patternset id="lib">
         <include name="logback-classic-1.0.0.jar"/>
         <include name="logback-core-1.0.0.jar"/>
-        <include name="jackson-core-asl-1.8.6.jar"/>
-        <include name="jackson-mapper-asl-1.8.6.jar"/>
+        <include name="jackson-core-asl-1.9.11.jar"/>
+        <include name="jackson-mapper-asl-1.9.11.jar"/>
         <include name="slf4j-api-1.6.4.jar"/>
         <include name="org.restlet-2.1-RC1.jar"/>
         <include name="org.restlet.ext.jackson-2.1-RC1.jar"/>
diff --git a/src/main/java/net/floodlightcontroller/core/INetMapTopologyService.java b/src/main/java/net/floodlightcontroller/core/INetMapTopologyService.java
index da00e0f..f0c7f7f 100644
--- a/src/main/java/net/floodlightcontroller/core/INetMapTopologyService.java
+++ b/src/main/java/net/floodlightcontroller/core/INetMapTopologyService.java
@@ -2,15 +2,16 @@
 
 import java.util.List;
 
+import net.floodlightcontroller.core.ISwitchStorage.ISwitchObject;
 import net.floodlightcontroller.routing.Link;
 import net.floodlightcontroller.topology.NodePortTuple;
 
 public interface INetMapTopologyService extends INetMapService {
 
 	public interface ITopoSwitchService {
-		List<String> GetActiveSwitches();
-		List<String> GetAllSwitches();
-		List<String> GetInactiveSwitches();
+		Iterable<ISwitchObject> GetActiveSwitches();
+		Iterable<ISwitchObject> GetAllSwitches();
+		Iterable<ISwitchObject> GetInactiveSwitches();
 		List<String> GetPortsOnSwitch(String dpid);
 	}
 	
@@ -24,7 +25,7 @@
 	}
 	
 	public interface ITopoRouteService {
-		List<NodePortTuple> GetShortestpath(NodePortTuple src, NodePortTuple dest);
+		List<NodePortTuple> GetShortestPath(NodePortTuple src, NodePortTuple dest);
 		Boolean RouteExists(NodePortTuple src, NodePortTuple dest);
 	}
 	
diff --git a/src/main/java/net/floodlightcontroller/core/ISwitchStorage.java b/src/main/java/net/floodlightcontroller/core/ISwitchStorage.java
index 8060c4d..28e6a5d 100644
--- a/src/main/java/net/floodlightcontroller/core/ISwitchStorage.java
+++ b/src/main/java/net/floodlightcontroller/core/ISwitchStorage.java
@@ -3,15 +3,67 @@
 import java.util.Collection;
 import java.util.List;
 
+import org.codehaus.jackson.annotate.JsonAutoDetect;
+import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.codehaus.jackson.map.ser.StdSerializers;
 import org.openflow.protocol.OFPhysicalPort;
 
+import com.tinkerpop.blueprints.Direction;
+import com.tinkerpop.frames.Adjacency;
+import com.tinkerpop.frames.Incidence;
+import com.tinkerpop.frames.Property;
+
 public interface ISwitchStorage extends INetMapStorage {
 	
 	public enum SwitchState {
 		INACTIVE,
 		ACTIVE
 	}
+
+	public interface ISwitchObject {
+		
+		@JsonProperty("dpid")
+		@Property("dpid")
+		public String getDPID();
+		
+		@JsonProperty("state")
+		@Property("state")
+		public String getState();
+		
+		@JsonIgnore
+		@Property("type")
+		public String getType();
+		
+		@JsonProperty("ports")
+		@Adjacency(label="on")
+		public Iterable<IPortObject> getPorts();
+	}
 	
+	public interface IPortObject {
+		
+		@JsonProperty("state")
+		@Property("state")
+		public int getState();
+		
+		@JsonIgnore
+		@Property("type")
+		public String getType();
+		
+		@JsonProperty("number")
+		@Property("number")
+		public Short getNumber();
+		
+		@JsonProperty("desc")
+		@Property("desc")
+		public String getDesc();
+		
+		@JsonIgnore
+		@Incidence(label="on",direction = Direction.IN)
+		public ISwitchObject getSwitch();
+	}
 	/*
 	 * Update the switch details
 	 */
@@ -49,9 +101,9 @@
 	 */
 	public void deletePort(String dpid, String portName);
 	
-	public List<String> getActiveSwitches();
-	public List<String> getAllSwitches();
-	public List<String> getInactiveSwitches();
+	public Iterable<ISwitchObject> getActiveSwitches();
+	public Iterable<ISwitchObject> getAllSwitches();
+	public Iterable<ISwitchObject> getInactiveSwitches();
 	
 	/*
 	 * Initialize
diff --git a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
index be33659..dbb985e 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
@@ -19,6 +19,7 @@
 import com.tinkerpop.blueprints.TransactionalGraph.Conclusion;
 import com.tinkerpop.blueprints.Edge;
 import com.tinkerpop.blueprints.Vertex;
+import com.tinkerpop.frames.FramedGraph;
 import net.floodlightcontroller.core.ISwitchStorage;
 
 public class SwitchStorageImpl implements ISwitchStorage {
@@ -198,15 +199,19 @@
 	}
 
 	@Override
-	public List<String> getActiveSwitches() {
+	public Iterable<ISwitchObject> getActiveSwitches() {
 		// TODO Add unit test
-		List<String> switches = new ArrayList<String>();
-    	for (Vertex V : graph.getVertices("type","switch")) {
-    		if (V.getProperty("state").equals(SwitchState.ACTIVE.toString())) {
-    		     switches.add((String) V.getProperty("dpid"));
-    		}
-    	}
-		return switches;
+		FramedGraph<TitanGraph> fg = new FramedGraph<TitanGraph>(graph);
+		Iterable<ISwitchObject> switches =  fg.getVertices("type","switch",ISwitchObject.class);
+		List<ISwitchObject> activeSwitches = new ArrayList<ISwitchObject>();
+		
+		for (ISwitchObject sw: switches) {
+			if(sw.getState().equals(SwitchState.ACTIVE.toString())) {
+				activeSwitches.add(sw);
+			}
+		}
+  
+		return activeSwitches;
 	}
 
 	@Override
@@ -227,25 +232,32 @@
 	}
 
 	@Override
-	public List<String> getAllSwitches() {
+	public Iterable<ISwitchObject> getAllSwitches() {
 		// TODO Auto-generated method stub
-		List<String> switches = new ArrayList<String>();
-    	for (Vertex V : graph.getVertices("type","switch")) {
-    		switches.add((String) V.getProperty("dpid"));
-    	}
+		FramedGraph<TitanGraph> fg = new FramedGraph<TitanGraph>(graph);
+		Iterable<ISwitchObject> switches =  fg.getVertices("type","switch",ISwitchObject.class);
+
+		for (ISwitchObject sw: switches) {
+			log.debug("switch: {}", sw.getDPID());
+		}
+
 		return switches;
 	}
 
 	@Override
-	public List<String> getInactiveSwitches() {
+	public Iterable<ISwitchObject> getInactiveSwitches() {
 		// TODO Auto-generated method stub
-		List<String> switches = new ArrayList<String>();
-    	for (Vertex V : graph.getVertices("type","switch")) {
-    		if (V.getProperty("state").equals(SwitchState.INACTIVE.toString())) {
-    		     switches.add((String) V.getProperty("dpid"));
-    		}
-    	}
-		return switches;
+		FramedGraph<TitanGraph> fg = new FramedGraph<TitanGraph>(graph);
+		Iterable<ISwitchObject> switches =  fg.getVertices("type","switch",ISwitchObject.class);
+
+		List<ISwitchObject> inActiveSwitches = new ArrayList<ISwitchObject>();
+		
+		for (ISwitchObject sw: switches) {
+			if(sw.getState().equals(SwitchState.INACTIVE.toString())) {
+				inActiveSwitches.add(sw);
+			}
+		}
+		return inActiveSwitches;
 	}
 
 	
diff --git a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImplStubs.java b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImplStubs.java
deleted file mode 100644
index 88f94db..0000000
--- a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImplStubs.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * 
- */
-package net.floodlightcontroller.core.internal;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.openflow.protocol.OFPhysicalPort;
-
-import net.floodlightcontroller.core.ISwitchStorage;
-
-/**
- * @author pankaj
- *
- */
-public class SwitchStorageImplStubs implements ISwitchStorage {
-
-
-	/* (non-Javadoc)
-	 * @see net.floodlightcontroller.core.ISwitchStorage#addPort(long, org.openflow.protocol.OFPhysicalPort)
-	 */
-	@Override
-	public void addPort(String dpid, OFPhysicalPort port) {
-		// TODO Auto-generated method stub
-
-	}
-
-	/* (non-Javadoc)
-	 * @see net.floodlightcontroller.core.ISwitchStorage#getPorts(long)
-	 */
-	@Override
-	public Collection<OFPhysicalPort> getPorts(long dpid) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	/* (non-Javadoc)
-	 * @see net.floodlightcontroller.core.ISwitchStorage#getPort(long, short)
-	 */
-	@Override
-	public OFPhysicalPort getPort(String dpid, short portnum) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	/* (non-Javadoc)
-	 * @see net.floodlightcontroller.core.ISwitchStorage#getPort(long, java.lang.String)
-	 */
-	@Override
-	public OFPhysicalPort getPort(String dpid, String portName) {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	/* (non-Javadoc)
-	 * @see net.floodlightcontroller.core.ISwitchStorage#addSwitch(long)
-	 */
-	@Override
-	public void addSwitch(String dpid) {
-		// TODO Auto-generated method stub
-
-	}
-
-	/* (non-Javadoc)
-	 * @see net.floodlightcontroller.core.ISwitchStorage#deleteSwitch(long)
-	 */
-	@Override
-	public void deleteSwitch(String dpid) {
-		// TODO Auto-generated method stub
-
-	}
-
-	/* (non-Javadoc)
-	 * @see net.floodlightcontroller.core.ISwitchStorage#deletePort(long, short)
-	 */
-	@Override
-	public void deletePort(String dpid, short port) {
-		// TODO Auto-generated method stub
-
-	}
-
-	/* (non-Javadoc)
-	 * @see net.floodlightcontroller.core.ISwitchStorage#deletePort(long, java.lang.String)
-	 */
-	@Override
-	public void deletePort(String dpid, String portName) {
-		// TODO Auto-generated method stub
-
-	}
-
-	/* (non-Javadoc)
-	 * @see net.floodlightcontroller.core.ISwitchStorage#init(java.lang.String)
-	 */
-	@Override
-	public void init(String conf) {
-		// TODO Auto-generated method stub
-
-	}
-
-	@Override
-	public void update(String dpid, SwitchState state, DM_OPERATION op) {
-		// TODO Auto-generated method stub
-		
-	}
-
-	@Override
-	public List<String> getActiveSwitches() {
-		return null;
-		// TODO Auto-generated method stub
-		
-	}
-
-	@Override
-	public List<String> getAllSwitches() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	@Override
-	public List<String> getInactiveSwitches() {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-}
diff --git a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
index 99f291d..0edc35e 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/TopoSwitchServiceImpl.java
@@ -3,6 +3,7 @@
 import java.util.List;
 
 import net.floodlightcontroller.core.INetMapTopologyService.ITopoSwitchService;
+import net.floodlightcontroller.core.ISwitchStorage.ISwitchObject;
 
 public class TopoSwitchServiceImpl implements ITopoSwitchService {
 	
@@ -19,19 +20,19 @@
 	SwitchStorageImpl swStore = store.get();
 	
 	@Override
-	public List<String> GetActiveSwitches() {
+	public Iterable<ISwitchObject> GetActiveSwitches() {
 		// TODO Auto-generated method stub
 		return swStore.getActiveSwitches();
 	}
 
 	@Override
-	public List<String> GetAllSwitches() {
+	public Iterable<ISwitchObject> GetAllSwitches() {
 		// TODO Auto-generated method stub
 		return swStore.getAllSwitches();
 	}
 
 	@Override
-	public List<String> GetInactiveSwitches() {
+	public Iterable<ISwitchObject> GetInactiveSwitches() {
 		// TODO Auto-generated method stub
 		return swStore.getInactiveSwitches();
 	}
diff --git a/src/main/java/net/floodlightcontroller/core/web/TopoSwitchesResource.java b/src/main/java/net/floodlightcontroller/core/web/TopoSwitchesResource.java
index a73b0b4..11dbcb1 100644
--- a/src/main/java/net/floodlightcontroller/core/web/TopoSwitchesResource.java
+++ b/src/main/java/net/floodlightcontroller/core/web/TopoSwitchesResource.java
@@ -2,6 +2,7 @@
 
 import java.util.Iterator;
 
+import net.floodlightcontroller.core.ISwitchStorage.ISwitchObject;
 import net.floodlightcontroller.core.internal.TopoSwitchServiceImpl;
 
 import org.restlet.resource.Get;
@@ -10,18 +11,18 @@
 public class TopoSwitchesResource extends ServerResource {
 	
 	@Get("json")
-	public Iterator<String> retrieve() {
+	public Iterator<ISwitchObject> retrieve() {
 		TopoSwitchServiceImpl impl = new TopoSwitchServiceImpl();
 		
 		String filter = (String) getRequestAttributes().get("filter");
 		
 		if (filter.equals("active")) {
-			return (Iterator<String>) impl.GetActiveSwitches().iterator();
+			return (Iterator<ISwitchObject>) impl.GetActiveSwitches().iterator();
 		}
 		if (filter.equals("inactive")) {
-			return (Iterator<String>) impl.GetInactiveSwitches().iterator();
+			return (Iterator<ISwitchObject>) impl.GetInactiveSwitches().iterator();
 		}
-		return (Iterator<String>) impl.GetAllSwitches().iterator();				
+		return (Iterator<ISwitchObject>) impl.GetAllSwitches().iterator();				
 	}
 
 }
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/ILinkStorage.java b/src/main/java/net/floodlightcontroller/linkdiscovery/ILinkStorage.java
index a764227..eb2fac9 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/ILinkStorage.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/ILinkStorage.java
@@ -42,9 +42,12 @@
 	 *  If only dpid is set all links associated with Switch are retrieved
 	 */
 	public List<Link> getLinks(Long dpid, short port);
+	public List<Link> getLinks(String dpid);
+	public List<Link> getActiveLinks();
 	
 	/*
 	 * Init with Storage conf
 	 */
 	public void init(String conf);
+
 }
diff --git a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
index 249d626..70d93c9 100644
--- a/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/linkdiscovery/internal/LinkStorageImpl.java
@@ -207,4 +207,16 @@
 		
 	}
 
+	@Override
+	public List<Link> getLinks(String dpid) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public List<Link> getActiveLinks() {
+		// TODO Auto-generated method stub
+		
+		return null;
+	}
+
 }
diff --git a/web/restapi3.py b/web/restapi3.py
index e1b1c04..546f2a7 100755
--- a/web/restapi3.py
+++ b/web/restapi3.py
@@ -13,7 +13,7 @@
 ## Global Var ##
 RestIP="127.0.0.1"
 RestPort=8182
-DBName="onos-network-map"
+DBName="Cassandra-Netmap"
 
 DEBUG=1
 pp = pprint.PrettyPrinter(indent=4)
@@ -198,8 +198,8 @@
 
   switches_ = []
   for v in parsedResult:
-    if v.has_key('dpid'):
-#    if v.has_key('dpid') and str(v['state']) == "ACTIVE":#;if you want only ACTIVE nodes
+#    if v.has_key('dpid'):
+    if v.has_key('dpid') and str(v['state']) == "ACTIVE":#;if you want only ACTIVE nodes
       dpid = str(v['dpid'])
       state = str(v['state'])
       sw = {}