diff --git a/src/main/java/net/onrc/onos/datagrid/web/IntentResource.java b/src/main/java/net/onrc/onos/datagrid/web/IntentResource.java
index 416ab76..0d50865 100755
--- a/src/main/java/net/onrc/onos/datagrid/web/IntentResource.java
+++ b/src/main/java/net/onrc/onos/datagrid/web/IntentResource.java
@@ -5,11 +5,12 @@
 package net.onrc.onos.datagrid.web;
 
 import java.io.IOException;
-import java.util.Collection;
 import java.util.Iterator;
 import net.onrc.onos.datagrid.IDatagridService;
 import net.onrc.onos.intent.ConstrainedShortestPathIntent;
 import net.onrc.onos.intent.ShortestPathIntent;
+import net.onrc.onos.intent.IntentOperation;
+import net.onrc.onos.intent.IntentMap;
 import net.onrc.onos.ofcontroller.networkgraph.INetworkGraphService;
 import net.onrc.onos.ofcontroller.networkgraph.NetworkGraph;
 import net.onrc.onos.registry.controller.IControllerRegistryService;
@@ -20,39 +21,67 @@
 import org.restlet.resource.Post;
 import org.restlet.resource.ServerResource;
 import org.codehaus.jackson.map.ObjectMapper;
-import org.slf4j.LoggerFactory;
 import net.floodlightcontroller.util.MACAddress;
-import net.onrc.onos.ofcontroller.networkgraph.Port;
-import net.onrc.onos.ofcontroller.networkgraph.Switch;
 import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.Input;
 import com.esotericsoftware.kryo.io.Output;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
+import org.codehaus.jackson.node.ArrayNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * 
  * @author nickkaranatsios
  */
 public class IntentResource extends ServerResource {
-
-    private final static org.slf4j.Logger log = LoggerFactory
-	    .getLogger(IntentResource.class);
+    private final static Logger log = LoggerFactory.getLogger(IntentResource.class);
     private final String sep = ":";
     private IdBlock idBlock = null;
     private long nextIdBlock = 0;
 
+    private class IntentStatus {
+        String intentId;
+        boolean status;
+        
+        public IntentStatus() {}
+        
+        public IntentStatus(String intentId, boolean status) {
+            this.intentId = intentId;
+            this.status = status;
+        }
+        
+        public String getIntentId() {
+            return intentId;
+        }
+        
+        public void setIntentId(String intentId) {
+            this.intentId = intentId;
+        }
+        
+        public boolean getStatus() {
+            return status;
+        }
+        
+        public void setStatus(boolean status) {
+            this.status = status;
+        }
+    }
+    
     @Post("json")
-    public void store(String jsonFlowIntent) {
+    public String store(String jsonFlowIntent) throws IOException {
 	IDatagridService datagridService = (IDatagridService) getContext()
 		.getAttributes().get(IDatagridService.class.getCanonicalName());
 	if (datagridService == null) {
 	    log.debug("FlowIntentResource ONOS Datagrid Service not found");
-	    return;
+	    return "";
 	}
 	INetworkGraphService networkGraphService = (INetworkGraphService) getContext()
 		.getAttributes().get(
 			INetworkGraphService.class.getCanonicalName());
 	NetworkGraph graph = networkGraphService.getNetworkGraph();
-
+        String reply = "";
 	ObjectMapper mapper = new ObjectMapper();
 	JsonNode jNode = null;
 	try {
@@ -68,84 +97,99 @@
 
 	if (jNode != null) {
 	    Kryo kryo = new Kryo();
-	    parseJsonNode(kryo, jNode.getElements(), datagridService);
+	    reply = parseJsonNode(kryo, jNode.getElements(), datagridService);
 	    // datagridService.registerIntent(intents);
 	}
+        return reply;
     }
 
-    private void parseJsonNode(Kryo kryo, Iterator<JsonNode> nodes,
-	    IDatagridService datagridService) {
-	StringBuilder sb = new StringBuilder();
-	sb.ensureCapacity(256);
-
+    private String parseJsonNode(Kryo kryo, Iterator<JsonNode> nodes,
+	    IDatagridService datagridService) throws IOException {
+        LinkedList<IntentOperation> operations = new LinkedList<>();
+        ObjectMapper mapper = new ObjectMapper();
+        ArrayNode arrayNode = mapper.createArrayNode();
 	while (nodes.hasNext()) {
 	    JsonNode node = nodes.next();
 	    if (node.isObject()) {
-		JsonNode data = null;
+		JsonNode data;
 		Iterator<String> fieldNames = node.getFieldNames();
-		String intentId = null;
-		String pathTypeName = null;
-		long srcSwitch = 0, dstSwitch = 0;
-		String srcMac = null, dstMac = null;
-		long srcPort = 0, dstPort = 0;
-		Double bandwidth = null;
+                Map<String, Object> fields = new HashMap<>();
 		while (fieldNames.hasNext()) {
 		    String fieldName = fieldNames.next();
 		    data = node.get(fieldName);
-		    if (fieldName.equals("type")) {
-			if (data != null) {
-			    System.out.println("type is not null "
-				    + data.getTextValue());
-			    // uuid = setPathIntentId();
-			    pathTypeName = data.getTextValue();
-			    setPathIntentType(pathTypeName, sb);
-			}
-		    } else if (fieldName.equals("intentId")) {
-			intentId = data.getTextValue();
-		    } else if (fieldName.equals("srcSwitch")) {
-			srcSwitch = Long.decode(data.getTextValue());
-		    } else if (fieldName.equals("dstSwitch")) {
-			dstSwitch = Long.decode(data.getTextValue());
-		    } else if (fieldName.equals("srcMac")) {
-			srcMac = data.getTextValue();
-		    } else if (fieldName.equals("dstMac")) {
-			dstMac = data.getTextValue();
-		    } else if (fieldName.equals("srcPort")) {
-			srcPort = data.getLongValue();
-		    } else if (fieldName.equals("dstPort")) {
-			dstPort = data.getLongValue();
-		    } else if (fieldName.equals("bandwidth")) {
-			bandwidth = data.getDoubleValue();
-		    }
+                    parseFields(data, fieldName, fields);
 		}
-		if (pathTypeName.equals("shortest-path")) {
-		    ShortestPathIntent spi = new ShortestPathIntent(intentId, 
-                            srcSwitch, 
-                            srcPort, 
-                            MACAddress.valueOf(srcMac).toLong(), 
-                            dstSwitch, 
-                            dstPort,
-			    MACAddress.valueOf(dstMac).toLong());
-		    sb.append(toBytes(kryo, spi));
-
-		} else {
-		    ConstrainedShortestPathIntent cspi = new ConstrainedShortestPathIntent(intentId, 
-                            srcSwitch, 
-                            srcPort, 
-                            MACAddress.valueOf(srcMac).toLong(), dstSwitch,
-			    dstPort, MACAddress.valueOf(dstMac).toLong(),
-			    bandwidth);
-		    sb.append(toBytes(kryo, cspi));
-
-		}
-		System.out.println("constructed node " + sb.toString());
+                System.out.println("recv fields " + fields);
+                boolean status = processIntent(fields, operations);
+                appendIntentStatus(status, (String)fields.get("intent_id"), mapper, arrayNode);
 		// datagridService.registerIntent(Long.toString(uuid),
 		// sb.toString().getBytes());
-		sb.delete(0, sb.length());
 	    }
 	}
+        IntentMap intents = new IntentMap();
+        intents.executeOperations(operations);
+        return mapper.writeValueAsString(arrayNode);
+        
     }
 
+    private void appendIntentStatus(boolean status, final String applnIntentId, 
+            ObjectMapper mapper, ArrayNode arrayNode) throws IOException {
+        String intentId = applnIntentId.split(":")[1];
+        String boolStr = Boolean.TRUE.toString();
+        if (status == false) {
+            boolStr = Boolean.FALSE.toString();
+        }
+        String jsonString = "{\"intent_id\":" + intentId + "," + "\"status\":" + boolStr + "}";
+        JsonNode parsedNode = mapper.readValue(jsonString, JsonNode.class);
+        arrayNode.add(parsedNode);
+    }
+    
+    private boolean processIntent(Map<String, Object> fields, LinkedList<IntentOperation> operations) {
+        String intentType = (String)fields.get("intent_type");
+        boolean status = false;
+        
+        if (intentType.equals("shortest_intent_type")) {
+            ShortestPathIntent spi = new ShortestPathIntent((String) fields.get("intent_id"),
+                    Long.decode((String) fields.get("srcSwitch")),
+                    (long) fields.get("srcPort"),
+                    MACAddress.valueOf((String) fields.get("srcMac")).toLong(),
+                    Long.decode((String) fields.get("dstSwitch")),
+                    (long) fields.get("dstPort"),
+                    MACAddress.valueOf((String) fields.get("dstMac")).toLong());
+            operations.add(new IntentOperation(IntentOperation.Operator.ADD, spi));
+            status = true;
+        } else {
+            ConstrainedShortestPathIntent cspi = new ConstrainedShortestPathIntent((String) fields.get("intent_id"),
+                    Long.decode((String) fields.get("srcSwitch")),
+                    (long) fields.get("srcPort"),
+                    MACAddress.valueOf((String) fields.get("srcMac")).toLong(),
+                    Long.decode((String) fields.get("dstSwitch")),
+                    (long) fields.get("dstPort"),
+                    MACAddress.valueOf((String) fields.get("dstMac")).toLong(),
+                    (double) fields.get("bandwidth"));
+            operations.add(new IntentOperation(IntentOperation.Operator.ADD, cspi));
+            status = true;
+        }
+        return status;
+    }
+
+    private void parseFields(JsonNode node, String fieldName, Map<String, Object> fields) {
+        if ((node.isTextual())) {
+            System.out.println("textual fieldname = " + fieldName);
+            fields.put(fieldName, node.getTextValue());
+        } else if ((node.isInt())) {
+            System.out.println("int fieldname = " + fieldName);
+            fields.put(fieldName, (long)node.getIntValue());
+        } else if (node.isDouble()) {
+            System.out.println("double fieldname = " + fieldName);
+            fields.put(fieldName, node.getDoubleValue());
+        } else if ((node.isLong())) {
+            System.out.println("long fieldname = " + fieldName);
+            fields.put(fieldName, node.getLongValue());
+        }
+    }
+    
+    @Deprecated
     private long setPathIntentId() {
 	long uuid = 0;
 	if (idBlock == null || nextIdBlock + 1 == idBlock.getSize()) {
@@ -164,12 +208,13 @@
 	return uuid;
     }
 
-    private void setPathIntentType(final String pathIntentType, StringBuilder sb) {
+    @Deprecated
+    private void setIntentType(final String intentType, StringBuilder sb) {
 	String canonicalName = null;
-	if (pathIntentType.equals("shortest-path")) {
+	if (intentType.equals("shortest-path")) {
 	    canonicalName = ShortestPathIntent.class.getCanonicalName();
 	    sb.append(ShortestPathIntent.class.getCanonicalName());
-	} else if (pathIntentType.equals("constrained-shortest-path")) {
+	} else if (intentType.equals("constrained-shortest-path")) {
 	    canonicalName = ShortestPathIntent.class.getCanonicalName();
 	}
 	sb.append(canonicalName);
@@ -181,6 +226,7 @@
 		IControllerRegistryService.class.getCanonicalName());
     }
 
+    @Deprecated
     private byte[] toBytes(Kryo kryo, Object value) {
 	Output output = new Output(1024);
         kryo.writeObject(output, value);
