summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapper.java2
-rw-r--r--rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDao.java5
-rw-r--r--rulemgt/src/main/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapper.java11
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java2
4 files changed, 13 insertions, 7 deletions
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapper.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapper.java
index cdae89e..8e9055b 100644
--- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapper.java
+++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapper.java
@@ -64,7 +64,7 @@ public class EngineWrapper {
log.info("Call delete rule rest interface in engine successfully.");
return true;
} else {
- throw new CorrelationException(I18nProxy.ENGINE_DELETE_RULE_FAILED);
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DELETE_RULE_FAILED);
}
}
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDao.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDao.java
index d77cc09..487684e 100644
--- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDao.java
+++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDao.java
@@ -118,7 +118,10 @@ public class CorrelationRuleQueryDao {
}
}
whereSql = whereSql.trim();
- return whereSql.substring(0, whereSql.length() - "AND".length());
+ if(!"WHERE".equals(whereSql)){
+ return whereSql.substring(0, whereSql.length() - "AND".length());
+ }
+ return "";
} catch (Exception e) {
throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED, e);
}
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapper.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapper.java
index afd80b1..58d461f 100644
--- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapper.java
+++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapper.java
@@ -100,8 +100,8 @@ public class RuleMgtWrapper {
if (oldCorrelationRule.getEnabled() == RuleMgtConstant.STATUS_RULE_OPEN) {
engineWarpper.deleteRuleFromEngine(oldCorrelationRule.getPackageName());
}
+ newCorrelationRule.setPackageName(deployRule2Engine(newCorrelationRule));
correlationRuleDao.updateRule(newCorrelationRule);
- deployRule2Engine(newCorrelationRule);
return ruleChangeResponse;
}
@@ -155,11 +155,12 @@ public class RuleMgtWrapper {
String tempContent = ruleCreateRequest.getContent();
CorrelationRule correlationRule = new CorrelationRule();
String ruleId = "rule_" + System.currentTimeMillis();
+ String description = ruleCreateRequest.getDescription() == null ? "" : ruleCreateRequest.getDescription();
correlationRule.setRid(ruleId);
if (tempContent != null) {
correlationRule.setContent(tempContent.trim());
}
- correlationRule.setDescription(ruleCreateRequest.getDescription());
+ correlationRule.setDescription(description);
correlationRule.setCreateTime(new Date());
correlationRule.setUpdateTime(new Date());
correlationRule.setName(ruleCreateRequest.getRuleName());
@@ -176,9 +177,10 @@ public class RuleMgtWrapper {
private CorrelationRule convertRuleUpdateRequest2CorrelationRule(String modifier,
RuleUpdateRequest ruleUpdateRequest, String ruleName) throws CorrelationException {
CorrelationRule correlationRule = new CorrelationRule();
+ String description = ruleUpdateRequest.getDescription() == null ? "" : ruleUpdateRequest.getDescription();
correlationRule.setRid(ruleUpdateRequest.getRuleId());
correlationRule.setContent(ruleUpdateRequest.getContent());
- correlationRule.setDescription(ruleUpdateRequest.getDescription());
+ correlationRule.setDescription(description);
correlationRule.setEnabled(ruleUpdateRequest.getEnabled());
correlationRule.setUpdateTime(new Date());
correlationRule.setModifier(modifier);
@@ -211,9 +213,10 @@ public class RuleMgtWrapper {
List<RuleResult4API> ruleResult4APIs = new ArrayList<RuleResult4API>();
for (CorrelationRule correlationRule : correlationRules) {
RuleResult4API ruleResult4API = new RuleResult4API();
+ String description = correlationRule.getDescription() == null ? "" : correlationRule.getDescription();
ruleResult4API.setRuleId(correlationRule.getRid());
ruleResult4API.setRuleName(correlationRule.getName());
- ruleResult4API.setDescription(correlationRule.getDescription());
+ ruleResult4API.setDescription(description);
ruleResult4API.setContent(correlationRule.getContent());
ruleResult4API.setCreateTime(correlationRule.getCreateTime());
ruleResult4API.setCreator(correlationRule.getCreator());
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java
index fe7696b..38afa47 100644
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java
+++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java
@@ -129,7 +129,7 @@ public class EngineWrapperTest {
@Test
public void deleteRuleFromEngine_http_status_not_ok() throws Exception {
thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.ENGINE_DELETE_RULE_FAILED);
+ thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_DELETE_RULE_FAILED);
EasyMock.expect(engineServiceMock.delete(EasyMock.anyObject(String.class)))
.andReturn(response);