package net.floodlightcontroller.prediction;

import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;

import org.restlet.resource.Get;
import org.restlet.resource.Post;
import org.restlet.resource.ServerResource;

public class TopologyGraphResource extends ServerResource {
	@Get("json")
    public String retrieve() throws FileNotFoundException, UnsupportedEncodingException {
		INetTopologyService pihr = (INetTopologyService)getContext().getAttributes().get(INetTopologyService.class.getCanonicalName());
        return pihr.getTopologyGraph("json");
    }
	
	@Post
	public String store(String in) {
		INetTopologyService pihr = (INetTopologyService)getContext().getAttributes().get(INetTopologyService.class.getCanonicalName());
        return pihr.getTopologyGraph(in);
	}
	
}

@@ -50,85 +50,29 @@
 ort 
-java.io.FileNotFoundException;%0Aimport java.io.UnsupportedEncodingException
+org.json.JSONObject
 ;%0A
-%0A
 impo
@@ -179,16 +179,100 @@
 ource;%0A%0A
+import java.io.FileNotFoundException;%0Aimport java.io.UnsupportedEncodingException;%0A%0A
 public c
@@ -666,36 +666,39 @@
 TopologyService 
-pihr
+service
  = (INetTopology
@@ -789,49 +789,244 @@
 ));%0A
-        return pihr.getTopologyGraph(in);
+%09%09try %7B%0A%09%09%09JSONObject jp = new JSONObject(in);%0A%09%09%09String type = jp.getString(%22type%22);%0A%09%09%09return service.getTopologyGraph(type);%0A%09%09%7D%0A%09%09catch(Exception e)%7B%0A%09%09%09System.out.println(e.getMessage());%0A%09%09%09return %22%7B %5C%22status%5C%22 : %5C%22err%5C%22 %7D%5Cn%22;%0A%09%09%7D
 %0A%09%7D%0A

Create the POST route handler