summaryrefslogtreecommitdiffstats
path: root/engine-d/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'engine-d/src/main/java')
-rw-r--r--engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java24
-rw-r--r--engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java4
2 files changed, 14 insertions, 14 deletions
diff --git a/engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java b/engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java
index 473b929..16ae49c 100644
--- a/engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java
+++ b/engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java
@@ -150,7 +150,9 @@ public class DroolsEngine {
StringReader reader = new StringReader(ruleContent);
Resource res = ResourceFactory.newReaderResource(reader);
- kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ if (kbuilder == null) {
+ kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ }
kbuilder.add(res, ResourceType.DRL);
@@ -161,8 +163,6 @@ public class DroolsEngine {
throw new EngineException(e);
}
- kbuilder = null;
-
ksession.fireAllRules();
}
@@ -171,7 +171,9 @@ public class DroolsEngine {
StringReader reader = new StringReader(rule.getContent());
Resource res = ResourceFactory.newReaderResource(reader);
- kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ if (kbuilder == null) {
+ kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ }
kbuilder.add(res, ResourceType.DRL);
@@ -183,9 +185,9 @@ public class DroolsEngine {
throw new CorrelationException(errorMsg);
}
- String packageName = kbuilder.getKnowledgePackages().iterator().next().getName();
+ KnowledgePackage kpackage = kbuilder.getKnowledgePackages().iterator().next();
- if (kbase.getKnowledgePackages().contains(packageName)) {
+ if (kbase.getKnowledgePackages().contains(kpackage)) {
String errorMsg = I18nProxy.getInstance().getValueByArgs(locale,
I18nProxy.ENGINE_CONTENT_ILLEGALITY,new String[]{
@@ -203,13 +205,10 @@ public class DroolsEngine {
throw new CorrelationException(errorMsg, e);
}
- kbuilder = null;
-
ksession.fireAllRules();
- return packageName;
+ return kpackage.getName();
}
-
public synchronized void undeployRule(String packageName, Locale locale)
throws CorrelationException {
@@ -237,7 +236,9 @@ public class DroolsEngine {
StringReader reader = new StringReader(content);
Resource res = ResourceFactory.newReaderResource(reader);
- kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ if (kbuilder == null) {
+ kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
+ }
kbuilder.add(res, ResourceType.DRL);
@@ -248,7 +249,6 @@ public class DroolsEngine {
log.error(errorMsg);
throw new CorrelationException(errorMsg);
}
- kbuilder = null;
}
public void putRaisedIntoStream(Alarm raiseAlarm) {
diff --git a/engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java b/engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java
index 34dab1f..59110d8 100644
--- a/engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java
+++ b/engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java
@@ -39,8 +39,8 @@ public class RuleMgtWrapper {
List<CorrelationRule> ruleTemp = daoUtil.getJdbiDaoByOnDemand(CorrelationRuleDao.class)
.queryRuleByRuleEnable(enable);
- if (ruleTemp != null) {
- throw new DbException(I18nProxy.RULE_MANAGEMENT_REPEAT_RULE_NAME);
+ if (ruleTemp == null) {
+ throw new DbException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
}
return ruleTemp;
}