CORD Subscriber GUI - Added a little logging.

Change-Id: I96f674008cd8e6b3d7b3f517444a5ef9fd8b761c
diff --git a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/CordModelCache.java b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/CordModelCache.java
index f897979..789737b 100644
--- a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/CordModelCache.java
+++ b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/CordModelCache.java
@@ -29,6 +29,8 @@
 import org.onosproject.cord.gui.model.UserFactory;
 import org.onosproject.cord.gui.model.XosFunction;
 import org.onosproject.cord.gui.model.XosFunctionDescriptor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.List;
 import java.util.Map;
@@ -50,6 +52,8 @@
     private int subscriberId;
     private Bundle currentBundle;
 
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
     // NOTE: use a tree map to maintain sorted order by user ID
     private final Map<Integer, SubscriberUser> userMap =
             new TreeMap<Integer, SubscriberUser>();
@@ -59,6 +63,7 @@
      * initializing it with basic bundle, and fetching the list of users.
      */
     CordModelCache() {
+        log.info("Initialize model cache");
         subscriberId = XosManager.INSTANCE.initDemoSubscriber();
         currentBundle = new Bundle(BundleFactory.BASIC_BUNDLE);
         initUsers();
@@ -80,6 +85,7 @@
             //       memento in which to store the level.
             SubscriberUser su = createUser(id, name, mac, level);
             userMap.put(id, su);
+            log.info("..caching user {} (id:{})", name, id);
         }
     }
 
@@ -108,6 +114,7 @@
      * @throws IllegalArgumentException if bundle ID is unknown
      */
     public void setCurrentBundle(String bundleId) {
+        log.info("set new bundle : {}", bundleId);
         BundleDescriptor bd = BundleFactory.bundleFromId(bundleId);
         currentBundle = new Bundle(bd);
         // update the user mementos
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 e856270..f3007e7 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
@@ -42,6 +42,8 @@
     private static final int TEST_XOS_SERVER_PORT = 8000;
     private static final String URI_RS = "/rs/";
     private static final String URI_SUBSCRIBER = "/rs/subscriber/%d/";
+    private static final String BUNDLE_URI_FORMAT = "services/%s/%s/";
+
 
     private final XosManagerRestUtils xosUtilsRs =
             new XosManagerRestUtils(TEST_XOS_SERVER_ADDRESS,
@@ -52,8 +54,6 @@
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
-    private int demoId;
-
     /**
      * No instantiation (except via unit test).
      */
@@ -76,7 +76,7 @@
         }
 
         ObjectNode obj = (ObjectNode) node;
-        demoId = obj.get("id").asInt();
+        int demoId = obj.get("id").asInt();
         log.info("Using DEMO subscriber ID {}.", demoId);
 
         String uri = String.format(URI_SUBSCRIBER, demoId);
@@ -114,14 +114,15 @@
      * @param bundle new bundle to set
      */
     public void setNewBundle(Bundle bundle) {
-        log.info("\n>> Set New Bundle : " + bundle.descriptor().id());
+        log.info(">> Set New Bundle : {}", bundle.descriptor().id());
 
-        String uriFmt = "services/%s/%s";
         Set<XosFunctionDescriptor> inBundle = bundle.descriptor().functions();
         for (XosFunctionDescriptor xfd: XosFunctionDescriptor.values()) {
             // 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 uri = String.format(BUNDLE_URI_FORMAT, xfd.id(),
+                                           inBundle.contains(xfd));
+                log.info("XOS-URI: {}", uri);
                 String result = xosUtils.putRest(uri);
                 // TODO: convert JSON result to object and check (if we care)
             }
@@ -136,10 +137,11 @@
      * @param user user (containing function state)
      */
     public void apply(XosFunction func, SubscriberUser user) {
-        log.info("\n>> Apply : " + func + " for " + user);
+        log.info(">> Apply : {} for {}", func, user);
 
         String uriPrefix = "users/" + user.id() + "/";
         String uri = uriPrefix + func.xosUrlApply(user);
+        log.info("XOS-URI: {}", uri);
         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/UrlFilterFunction.java b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/UrlFilterFunction.java
index 0c06b10..e26935d 100644
--- a/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/UrlFilterFunction.java
+++ b/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/UrlFilterFunction.java
@@ -27,6 +27,7 @@
 public class UrlFilterFunction extends DefaultXosFunction {
 
     private static final String LEVEL = "level";
+    private static final String URI_PATTERN = "%s/%s/";
 
     /**
      * Denotes the URL filtering levels available. From most restrictive
@@ -87,6 +88,6 @@
     public String xosUrlApply(SubscriberUser user) {
         XosFunctionDescriptor xfd = XosFunctionDescriptor.URL_FILTER;
         UrlFilterMemento memo = (UrlFilterMemento) user.getMemento(xfd);
-        return xfd.id() + "/" + memo.level();
+        return String.format(URI_PATTERN, xfd.id(), memo.level());
     }
 }