summaryrefslogtreecommitdiffstats
path: root/rulemgt
diff options
context:
space:
mode:
author6092002067 <wu.youbo@zte.com.cn>2017-03-24 11:17:32 +0800
committer6092002067 <wu.youbo@zte.com.cn>2017-03-24 15:35:29 +0800
commit40f54b8acefce59ecbd9e9fde60e062373243982 (patch)
treeb048db2b81089ebf7ebdd6493274de657f4c6367 /rulemgt
parent3f7413a52908cc06c4a0b91df6f9a219a06ff11d (diff)
Fix modify rules of faultv2.0.0release/mercury
Issue-ID: HOLMES-52 Change-Id: I93115414570d118f4a1d88c2b1a612d4a44d2811 Signed-off-by: youbowu <wu.youbo@zte.com.cn>
Diffstat (limited to 'rulemgt')
-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);