CORD Subscriber GUI - Added CDN function. Added backend boolean to filter out 'internet' when talking to XOS.

Change-Id: I076b9966c38589636968eef3dcaa203ba57f4eba
diff --git a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/XosManager.java b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/XosManager.java
index 4264e6b..20b1baf 100644
--- a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/XosManager.java
+++ b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/XosManager.java
@@ -59,9 +59,12 @@
         String uriFmt = subId(subscriberId) + "services/%s/%s";
         Set<XosFunctionDescriptor> inBundle = bundle.descriptor().functions();
         for (XosFunctionDescriptor xfd: XosFunctionDescriptor.values()) {
-            String uri = String.format(uriFmt, xfd.id(), inBundle.contains(xfd));
-            String result = xosUtils.putRest(uri);
-            // TODO: convert JSON result to object and check (if we care)
+            // only process the functions that have a real back-end on XOS
+            if (xfd.backend()) {
+                String uri = String.format(uriFmt, xfd.id(), inBundle.contains(xfd));
+                String result = xosUtils.putRest(uri);
+                // TODO: convert JSON result to object and check (if we care)
+            }
         }
     }
 
diff --git a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionDescriptor.java b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionDescriptor.java
index b2362c0..8ed4666 100644
--- a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionDescriptor.java
+++ b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionDescriptor.java
@@ -26,30 +26,45 @@
      */
     INTERNET("internet",
              "Internet",
-             "Basic internet connectivity."),
+             "Basic internet connectivity.",
+             false),
 
     /**
      * Firewall function.
      */
     FIREWALL("firewall",
              "Firewall",
-             "Normal firewall protection."),
+             "Normal firewall protection.",
+             true),
 
     /**
      * URL Filtering function (parental controls).
      */
     URL_FILTER("url_filter",
                "Parental Control",
-               "Variable levels of URL filtering.");
+               "Variable levels of URL filtering.",
+               true),
+
+    /**
+     * Content Distribution function.
+     */
+    CDN("cdn",
+        "CDN",
+        "Content Distribution Network service.",
+        true);
+
 
     private final String id;
     private final String displayName;
     private final String description;
+    private final boolean backend;
 
-    XosFunctionDescriptor(String id, String displayName, String description) {
+    XosFunctionDescriptor(String id, String displayName, String description,
+                          boolean backend) {
         this.id = id;
         this.displayName = displayName;
         this.description = description;
+        this.backend = backend;
     }
 
     /**
@@ -79,4 +94,13 @@
         return description;
     }
 
+    /**
+     * Returns true if this function is supported by the XOS backend.
+     *
+     * @return true if backend function exists
+     */
+    public boolean backend() {
+        return backend;
+    }
+
 }
diff --git a/apps/demo/cord-gui/src/test/org/onosproject/cord/gui/model/XosFunctionDescriptorTest.java b/apps/demo/cord-gui/src/test/org/onosproject/cord/gui/model/XosFunctionDescriptorTest.java
index fd8cb8b..022c397 100644
--- a/apps/demo/cord-gui/src/test/org/onosproject/cord/gui/model/XosFunctionDescriptorTest.java
+++ b/apps/demo/cord-gui/src/test/org/onosproject/cord/gui/model/XosFunctionDescriptorTest.java
@@ -19,8 +19,7 @@
 
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.*;
 import static org.onosproject.cord.gui.model.XosFunctionDescriptor.*;
 
 /**
@@ -30,7 +29,7 @@
 
     @Test
     public void numberOfFunctions() {
-        assertEquals("unexpected constant count", 3, values().length);
+        assertEquals("unexpected constant count", 4, values().length);
     }
 
     @Test
@@ -38,6 +37,7 @@
         assertEquals("wrong id", "internet", INTERNET.id());
         assertEquals("wrong display", "Internet", INTERNET.displayName());
         assertTrue("wrong desc", INTERNET.description().startsWith("Basic"));
+        assertFalse("wrong backend", INTERNET.backend());
     }
 
     @Test
@@ -45,12 +45,22 @@
         assertEquals("wrong id", "firewall", FIREWALL.id());
         assertEquals("wrong display", "Firewall", FIREWALL.displayName());
         assertTrue("wrong desc", FIREWALL.description().startsWith("Normal"));
+        assertTrue("wrong backend", FIREWALL.backend());
     }
 
     @Test
-    public void urlFiltering() {
+    public void urlFilter() {
         assertEquals("wrong id", "url_filter", URL_FILTER.id());
         assertEquals("wrong display", "Parental Control", URL_FILTER.displayName());
         assertTrue("wrong desc", URL_FILTER.description().startsWith("Variable"));
+        assertTrue("wrong backend", URL_FILTER.backend());
+    }
+
+    @Test
+    public void cdn() {
+        assertEquals("wrong id", "cdn", CDN.id());
+        assertEquals("wrong display", "CDN", CDN.displayName());
+        assertTrue("wrong desc", CDN.description().startsWith("Content"));
+        assertTrue("wrong backend", CDN.backend());
     }
 }