Added back end of 'show policy', removed unicode from 'show tunnel detail'
diff --git a/cli/cli/c_actions.py b/cli/cli/c_actions.py
index 23959c3..20a8b11 100755
--- a/cli/cli/c_actions.py
+++ b/cli/cli/c_actions.py
@@ -2131,8 +2131,8 @@
                                'subnetIp'         : subnetIp,
                                })
         entries = combResult
-
-    if 'showtunnel' in data  and (data['showtunnel'] == 'tunnel' or data['showtunnel'] == 'details'):
+    #raise error.ArgumentValidationError('\n\n\n %s' % (data))
+    if 'showtunnel' in data  and (data['showtunnel'] == 'tunnele' or data['detail'] == 'details'):
         #eraise error.ArgumentValidationError('\n\n\n %s' % (entries))
         combResult = []
         tunnelList = entries
@@ -2141,6 +2141,7 @@
             labelStack = remove_unicodes(labelStack)
             tunnelId = tunnel.get('tunnelId')
             dpidGroup = str(tunnel.get('dpidGroup'))
+            dpidGroup= remove_unicodes(dpidGroup)
             policies = tunnel.get('policies')
             #nodes = ''
             #for node in tunnel.get("nodes"):
@@ -2159,18 +2160,35 @@
     if 'showpolicy' in data  and data['showpolicy'] == 'policy':
         #raise error.ArgumentValidationError('\n\n\n %s' % (data))
         combResult = []
-        '''portList = entries
-        for port in portList:
-            portData = port.get("port")
-            name = portData.get("stringAttributes").get('name')
-            portNo = portData.get("portNumber")
-            subnetIp = port.get("subnetIp")
+        portList = entries
+        for policy in portList:
+            policyId = policy.get("policyId")
+            policyType = policy.get("policyType")
+            priority = policy.get("priority")
+            match = policy.get("match")
+            dstIpAddress = match.get('dstIpAddress')['value'] if match.get('dstIpAddress') else '*'
+            dstMacAddress = match.get('dstMacAddress')['value'] if match.get('dstMacAddress') else '*'
+            dstTcpPortNumber = match.get('dstTcpPortNumber') if match.get('dstTcpPortNumber') else '*'
+            etherType = match.get('etherType') if match.get('etherType') else '*'
+            ipProtocolNumber = match.get('ipProtocolNumber') if match.get('ipProtocolNumber') else '*'
+            srcIpAddress = match.get('srcIpAddress')['value'] if match.get('srcIpAddress') else '*'
+            srcMacAddress = match.get('srcMacAddress')['value'] if match.get('srcMacAddress') else '*'
+            srcTcpPortNumber = match.get('srcTcpPortNumber') if match.get('srcTcpPortNumber') else '*'
             combResult.append({
-                               'name'            :name,
-                               'portNo'           : portNo,
-                               'subnetIp'         : subnetIp,
+                               'policyId'        : policyId,
+                               'policyType'      : policyType,
+                               'priority'        : priority,
+                               'dstIpAddress'    : dstIpAddress,
+                               'dstMacAddress'   : dstMacAddress,
+                               'dstTcpPortNumber': dstTcpPortNumber,
+                               'etherType'       : etherType,
+                               'ipProtocolNumber': ipProtocolNumber,
+                               'srcIpAddress'    : srcIpAddress,
+                               'srcMacAddress'   : srcMacAddress,
+                               'srcTcpPortNumber': srcTcpPortNumber,
+                               
                                })
-        entries = combResult'''
+        entries = combResult
 
     if 'realtimestats' in data and 'tabletype' in data and data['realtimestats'] == 'table':
         combResult = []
diff --git a/cli/cli/desc/version200/core.py b/cli/cli/desc/version200/core.py
index edcaf64..6a9f3e9 100755
--- a/cli/cli/desc/version200/core.py
+++ b/cli/cli/desc/version200/core.py
@@ -2429,7 +2429,10 @@
 SHOW_POLICYL_FORMAT = {
     'show_policy' : {
         'field-orderings' : {
-            'default' : [ 'Idx', 'policyId', 'tunnelId', 'flowEntries']
+            'default' : [ 'Idx', 'policyId', 'policyType','priority','dstMacAddress','srcMacAddress',
+                        'dstIpAddress' ,'srcIpAddress', 'dstTcpPortNumber','srcTcpPortNumber',
+                        'etherType', 'ipProtocolNumber',
+                         ]
             },
         },
 }
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
index 8a9ec48..32ec6c1 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/SegmentRoutingManager.java
@@ -964,6 +964,7 @@
             this.match = match;
             this.priority = priority;
             this.tunnelId = tid;
+            this.type = 0;
         }
         public String getPolicyId(){
             return this.policyId;
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyInfo.java b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyInfo.java
new file mode 100644
index 0000000..6b98dcd
--- /dev/null
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyInfo.java
@@ -0,0 +1,35 @@
+package net.onrc.onos.apps.segmentrouting.web;
+
+import net.onrc.onos.core.matchaction.match.PacketMatch;
+
+/**
+ * Contains the policies info of the segment router that
+ * are exposed, through REST API
+ *
+ */
+
+public class SegmentRouterPolicyInfo {
+    private String policyId;
+    private int policyType;
+    private int priority;
+    private PacketMatch match;
+    
+    public SegmentRouterPolicyInfo(String Id,int type, int ppriority,PacketMatch flowEntries){
+        this.policyId = Id;
+        this.policyType = type;
+        this.priority = ppriority;
+        this.match = flowEntries;
+    }
+    public String getPolicyId(){
+        return this.policyId;
+    }
+    public int getPolicyType(){
+        return this.policyType;
+    }
+    public int getPriority(){
+        return this.priority;
+    }
+    public PacketMatch getMatch(){
+        return this.match;
+    }
+}
diff --git a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyResource.java b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyResource.java
index cbea58d..0931dd3 100644
--- a/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyResource.java
+++ b/src/main/java/net/onrc/onos/apps/segmentrouting/web/SegmentRouterPolicyResource.java
@@ -1,8 +1,14 @@
 package net.onrc.onos.apps.segmentrouting.web;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
 
 import net.onrc.onos.apps.segmentrouting.ISegmentRoutingService;
+import net.onrc.onos.apps.segmentrouting.SegmentRoutingManager.PolicyInfo;
+import net.onrc.onos.core.matchaction.match.PacketMatch;
 import net.onrc.onos.core.packet.IPv4;
 import net.onrc.onos.core.util.IPv4Net;
 
@@ -95,9 +101,23 @@
     }
 
     @Get("json")
-    public String getPolicy() {
-        String reply = "success";
+    public Object getPolicy() {
+        ISegmentRoutingService segmentRoutingService =
+                (ISegmentRoutingService) getContext().getAttributes().
+                        get(ISegmentRoutingService.class.getCanonicalName());
+        List<SegmentRouterPolicyInfo> policyList = new ArrayList<SegmentRouterPolicyInfo>();
+        Collection<PolicyInfo> policies = segmentRoutingService.getPoclicyTable();
+        Iterator<PolicyInfo> piI = policies.iterator();
+        while(piI.hasNext()){
+            PolicyInfo policy = piI.next();
+            String policyId = policy.getPolicyId();
+            int priority = policy.getPriority();
+            int policyType = policy.getType();
+            PacketMatch flowEntries = policy.getMatch();
+            SegmentRouterPolicyInfo pInfo = new SegmentRouterPolicyInfo(policyId, policyType, priority, flowEntries);
+            policyList.add(pInfo);
+        }
         log.debug("getPolicy with params");
-        return reply;
+        return policyList;
     }
 }