[CORD-313] Handles uncaught exceptions when device is not configured

Includes following minor changes
    - Move DeviceConfiguration and DeviceProperties to config package
    - Create DeviceConfigNotFoundException

Change-Id: I32455d88c712bb65cd7f71dab9472ae003303de2
diff --git a/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index b82752d..787f934 100644
--- a/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -38,6 +38,8 @@
 import org.onosproject.net.config.NetworkConfigRegistry;
 import org.onosproject.net.config.NetworkConfigListener;
 import org.onosproject.net.config.basics.SubjectFactories;
+import org.onosproject.segmentrouting.config.DeviceConfigNotFoundException;
+import org.onosproject.segmentrouting.config.DeviceConfiguration;
 import org.onosproject.segmentrouting.config.SegmentRoutingConfig;
 import org.onosproject.segmentrouting.grouphandler.DefaultGroupHandler;
 import org.onosproject.segmentrouting.grouphandler.NeighborSet;
@@ -553,7 +555,10 @@
 
     private void processLinkAdded(Link link) {
         log.debug("A new link {} was added", link.toString());
-
+        if (!deviceConfiguration.isConfigured(link.src().deviceId())) {
+            log.warn("Source device of this link is not configured.");
+            return;
+        }
         //Irrespective whether the local is a MASTER or not for this device,
         //create group handler instance and push default TTP flow rules.
         //Because in a multi-instance setup, instances can initiate
@@ -596,7 +601,7 @@
 
     private void processDeviceAdded(Device device) {
         log.debug("A new device with ID {} was added", device.id());
-        if (deviceConfiguration == null) {
+        if (deviceConfiguration == null || !deviceConfiguration.isConfigured(device.id())) {
             log.warn("Device configuration uploading. Device {} will be "
                     + "processed after config completes.", device.id());
             return;
@@ -608,14 +613,20 @@
         // to the switch). To handle this, a default-group-handler instance is necessary
         // per switch.
         if (groupHandlerMap.get(device.id()) == null) {
-            DefaultGroupHandler groupHandler = DefaultGroupHandler.
-                    createGroupHandler(device.id(),
-                                       appId,
-                                       deviceConfiguration,
-                                       linkService,
-                                       flowObjectiveService,
-                                       nsNextObjStore,
-                                       subnetNextObjStore);
+            DefaultGroupHandler groupHandler;
+            try {
+                groupHandler = DefaultGroupHandler.
+                        createGroupHandler(device.id(),
+                                           appId,
+                                           deviceConfiguration,
+                                           linkService,
+                                           flowObjectiveService,
+                                           nsNextObjStore,
+                                           subnetNextObjStore);
+            } catch (DeviceConfigNotFoundException e) {
+                log.warn(e.getMessage() + " Aborting processDeviceAdded.");
+                return;
+            }
             groupHandlerMap.put(device.id(), groupHandler);
             // Also, in some cases, drivers may need extra
             // information to process rules (eg. Router IP/MAC); and so, we send
@@ -667,12 +678,20 @@
                 // to the switch). To handle this, a default-group-handler instance is necessary
                 // per switch.
                 if (groupHandlerMap.get(device.id()) == null) {
-                    DefaultGroupHandler groupHandler = DefaultGroupHandler
-                            .createGroupHandler(device.id(), appId,
-                                                deviceConfiguration, linkService,
-                                                flowObjectiveService,
-                                                nsNextObjStore,
-                                                subnetNextObjStore);
+                    DefaultGroupHandler groupHandler;
+                    try {
+                        groupHandler = DefaultGroupHandler.
+                                createGroupHandler(device.id(),
+                                                   appId,
+                                                   deviceConfiguration,
+                                                   linkService,
+                                                   flowObjectiveService,
+                                                   nsNextObjStore,
+                                                   subnetNextObjStore);
+                    } catch (DeviceConfigNotFoundException e) {
+                        log.warn(e.getMessage() + " Aborting configureNetwork.");
+                        return;
+                    }
                     groupHandlerMap.put(device.id(), groupHandler);
 
                     // Also, in some cases, drivers may need extra