PathIntentInstaller: avoiding calls to Resource Store when unnecessary

Change-Id: I846ca543f922063ddc67a06353f43c590bd57d96
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/PathIntentInstaller.java b/core/net/src/main/java/org/onosproject/net/intent/impl/PathIntentInstaller.java
index b90be50..b29bb08 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/PathIntentInstaller.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/PathIntentInstaller.java
@@ -114,10 +114,8 @@
 
     @Override
     public List<FlowRuleBatchOperation> uninstall(PathIntent intent) {
-        LinkResourceAllocations allocatedResources = resourceService.getAllocations(intent.id());
-        if (allocatedResources != null) {
-            resourceService.releaseResources(allocatedResources);
-        }
+        deallocateResources(intent);
+
         TrafficSelector.Builder builder =
                 DefaultTrafficSelector.builder(intent.selector());
         Iterator<Link> links = intent.path().links().iterator();
@@ -167,4 +165,20 @@
         LinkResourceRequest request = builder.build();
         return request.resources().isEmpty() ? null : resourceService.requestResources(request);
     }
+
+    /**
+     * Deallocate resources held by an intent.
+     *
+     * @param intent intent to deallocate resources for
+     */
+    private void deallocateResources(PathIntent intent) {
+        if (intent.constraints().isEmpty()) {
+            return;
+        }
+
+        LinkResourceAllocations allocatedResources = resourceService.getAllocations(intent.id());
+        if (allocatedResources != null) {
+            resourceService.releaseResources(allocatedResources);
+        }
+    }
 }