Various pseudowire fixes and improvements.

- Co-ordination when creating - removing pseudowires from
  different instances with a use of a DistributedLock.
- Fixed REST API To return json with specific error for
  the single pw instantiation.
- Fixed REST API to return specific error also for pseudowires
  that could not be decoded.
- Minor bug fix to return appropriate error when instantiating
  a pw from the command line that could not be decoded.
- Fixed bug when creating spine-leaf-leaf pseudowire where we observed flows in pending state.
- Improved logging.

Change-Id: I60dd0ebf8af63ca74d18cfe4801d01846641fb7b
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/pwaas/PwaasUtil.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/pwaas/PwaasUtil.java
index 1673cde..ada38f4 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/pwaas/PwaasUtil.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/pwaas/PwaasUtil.java
@@ -32,6 +32,8 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static com.google.common.base.Preconditions.checkArgument;
+
 /**
  * Utility class with static methods that help
  * parse pseudowire related information and also
@@ -63,12 +65,7 @@
         } else if (vlan.equals("") || vlan.equals("None")) {
             return VlanId.vlanId("None");
         } else {
-            try {
-                VlanId newVlan = VlanId.vlanId(vlan);
-                return newVlan;
-            } catch (IllegalArgumentException e) {
-                return null;
-            }
+            return VlanId.vlanId(vlan);
         }
     }
 
@@ -78,11 +75,8 @@
      * @return the L2Mode if input is correct
      */
     public static L2Mode parseMode(String mode) {
-
-        if (!mode.equals("RAW") && !mode.equals("TAGGED")) {
-            return null;
-        }
-
+        checkArgument(mode.equals("RAW") || mode.equals("TAGGED"),
+                      "Invalid pseudowire mode of operation, should be TAGGED or RAW.");
         return L2Mode.valueOf(mode);
     }
 
@@ -93,13 +87,7 @@
      * @throws IllegalArgumentException if label is invalid
      */
     public static MplsLabel parsePWLabel(String label) {
-
-        try {
-            MplsLabel pwLabel = MplsLabel.mplsLabel(label);
-            return pwLabel;
-        } catch (Exception e) {
-            return null;
-        }
+        return MplsLabel.mplsLabel(label);
     }
 
     /**
@@ -109,14 +97,9 @@
      * @return The id of pw as an Integer or null if it failed the conversion.
      */
     public static Integer parsePwId(String id) {
-        try {
-            return Integer.parseInt(id);
-        } catch (Exception e) {
-            return null;
-        }
+        return Integer.parseInt(id);
     }
 
-
     /**
      * Helper method to verify if the tunnel is whether or not
      * supported.