exclude application id from rest client

Change-Id: I57b4bc616aff42250f836c7e6692c9e6c0605b0c
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 7a2cdd9..2fc78f0 100755
--- a/src/main/java/net/onrc/onos/datagrid/web/IntentResource.java
+++ b/src/main/java/net/onrc/onos/datagrid/web/IntentResource.java
@@ -36,6 +36,8 @@
  */
 public class IntentResource extends ServerResource {
     private final static Logger log = LoggerFactory.getLogger(IntentResource.class);
+    // TODO need to assign proper application id.
+    private final String APPLN_ID = "1";
 
     private class IntentStatus {
         String intentId;
@@ -76,8 +78,7 @@
         IPathCalcRuntimeService pathRuntime = (IPathCalcRuntimeService)getContext()
                 .getAttributes().get(IPathCalcRuntimeService.class.getCanonicalName());
         if (pathRuntime == null) {
-            log.debug("Failed to get path calc runtime");
-            System.out.println("Failed to get path calc runtime");
+            log.warn("Failed to get path calc runtime");
             return "";
         }
         String reply = "";
@@ -112,17 +113,20 @@
         Collection<Intent> intents = intentMap.getAllIntents();
         if (!intents.isEmpty()) {
             if ((intentId != null )) {
-                Intent intent = intentMap.getIntent(intentId);
+                String applnIntentId = APPLN_ID + ":" + intentId;
+                Intent intent = intentMap.getIntent(applnIntentId);
                 if (intent != null) {
                     ObjectNode node = mapper.createObjectNode();
-                    node.put("intent_id", intent.getId());
+                    node.put("intent_id", intentId);
                     node.put("status", intent.getState().toString());
                     arrayNode.add(node);
                 }
             } else {
                 for (Intent intent : intents) {
                     ObjectNode node = mapper.createObjectNode();
-                    node.put("intent_id", intent.getId());
+                    String applnIntentId = intent.getId();
+                    intentId = applnIntentId.split(":")[1];
+                    node.put("intent_id", intentId);
                     node.put("status", intent.getState().toString());
                     arrayNode.add(node);
                 }
@@ -156,10 +160,10 @@
         return mapper.writeValueAsString(arrayNode);
     }
 
-    private void appendIntentStatus(String status, final String applnIntentId, 
+    private void appendIntentStatus(String status, final String intentId, 
             ObjectMapper mapper, ArrayNode arrayNode) throws IOException {
         ObjectNode node = mapper.createObjectNode();
-        node.put("intent_id", applnIntentId);
+        node.put("intent_id", intentId);
         node.put("status", status);
         arrayNode.add(node);
     }
@@ -168,13 +172,14 @@
         String intentType = (String)fields.get("intent_type");
         String intentOp = (String)fields.get("intent_op");
         String status = null;
+        String applnIntentId = APPLN_ID + ":" + (String)fields.get("intent_id");
         
         IntentOperation.Operator operation = IntentOperation.Operator.ADD;
         if ((intentOp.equals("remove"))) {
             operation = IntentOperation.Operator.REMOVE;
         }
         if (intentType.equals("shortest_intent_type")) {
-            ShortestPathIntent spi = new ShortestPathIntent((String) fields.get("intent_id"),
+            ShortestPathIntent spi = new ShortestPathIntent(applnIntentId,
                     Long.decode((String) fields.get("srcSwitch")),
                     (long) fields.get("srcPort"),
                     MACAddress.valueOf((String) fields.get("srcMac")).toLong(),
@@ -184,7 +189,7 @@
             operations.add(new IntentOperation(operation, spi));
             status = (spi.getState()).toString();
         } else {
-            ConstrainedShortestPathIntent cspi = new ConstrainedShortestPathIntent((String) fields.get("intent_id"),
+            ConstrainedShortestPathIntent cspi = new ConstrainedShortestPathIntent(applnIntentId,
                     Long.decode((String) fields.get("srcSwitch")),
                     (long) fields.get("srcPort"),
                     MACAddress.valueOf((String) fields.get("srcMac")).toLong(),
diff --git a/web/rest-intent/add-get-intent.rb b/web/rest-intent/add-get-intent.rb
index 6b88447..ea3a506 100644
--- a/web/rest-intent/add-get-intent.rb
+++ b/web/rest-intent/add-get-intent.rb
@@ -30,9 +30,6 @@
   opts.on('-t', '--max_intents max_intents', 'max. number of intents') do |max_intents|
     options[:max_intents] = max_intents
   end
-  opts.on('-l', '--application application_id', 'set application id') do |appl_id|
-    options[:application_id] = appl_id.to_i
-  end
   opts.on('-i', '--intent_id intent_id', 'global intent id') do |id|
     options[:intent_id] = id.to_i
   end
@@ -72,7 +69,7 @@
 
 class Intent
   attr_reader :switches, :ports, :intent_id
-  attr_reader :application_id, :intent_type, :intent_op
+  attr_reader :intent_type, :intent_op
   attr_reader :random_intent, :server, :port
   attr_reader :bulk_limit
 
@@ -142,7 +139,7 @@
 
   def post intents
     json_data = intents.to_json
-    #response = RestClient.post "http://#{@server}:#{@port}/wm/onos/datagrid/#{intent_op}/intents/json", json_data, :content_type => :json, :accept => :json
+    response = RestClient.post "http://#{@server}:#{@port}/wm/onos/datagrid/#{intent_op}/intents/json", json_data, :content_type => :json, :accept => :json
     puts response
   end
 
@@ -152,8 +149,6 @@
     @ports = (1..(max_switches - 1)).to_a
     @intent_id = options[:intent_id]
     @intent_id ||= 1
-    @application_id = options[:application_id]
-    @application_id ||= 1
     @intent_type = options[:intent_type]
     @intent_op = options[:intent_op]
     @intent_op ||= "add"
@@ -176,7 +171,7 @@
       dst_port = sw_set.index(src_switch)
       dst_port = dst_port + 1
       intent = {
-        :intent_id => "#{@application_id}:#{@intent_id}",
+        :intent_id => "#{@intent_id}",
         :intent_type => @intent_type,
         :intent_op => @intent_op,
         :srcSwitch => src_switch.to_s,