modify deploy rule bug 23/18423/1
authorShiwei Tian <tian.shiwei@zte.com.cn>
Thu, 12 Oct 2017 03:08:02 +0000 (11:08 +0800)
committerShiwei Tian <tian.shiwei@zte.com.cn>
Thu, 12 Oct 2017 03:08:02 +0000 (11:08 +0800)
Issue-ID: HOLMES-44

Change-Id: Ib8ae03aee13144638c64978d97be2caff709c038
Signed-off-by: Shiwei Tian <tian.shiwei@zte.com.cn>
rulemgt/src/main/java/org/onap/holmes/rulemgt/wrapper/RuleMgtWrapper.java

index 856171b..5c2a428 100644 (file)
@@ -73,10 +73,17 @@ public class RuleMgtWrapper {
         if (ruleTemp != null) {\r
             throw new CorrelationException("A rule with the same name already exists.");\r
         }\r
+        \r
         String packageName = deployRule2Engine(correlationRule);\r
         DmaapService.loopControlNames.put(packageName, ruleCreateRequest.getLoopControlName());\r
         correlationRule.setPackageName(packageName);\r
-        CorrelationRule result = correlationRuleDao.saveRule(correlationRule);\r
+        CorrelationRule result = null;\r
+        try {\r
+            result = correlationRuleDao.saveRule(correlationRule);\r
+        } catch (CorrelationException e) {\r
+            engineWarpper.deleteRuleFromEngine(packageName);\r
+            throw new CorrelationException(e.getMessage());\r
+        }\r
         RuleAddAndUpdateResponse ruleAddAndUpdateResponse = new RuleAddAndUpdateResponse();\r
         ruleAddAndUpdateResponse.setRuleId(result.getRid());\r
         return ruleAddAndUpdateResponse;\r