summaryrefslogtreecommitdiffstats
path: root/rulemgt/src/main/java/org/openo
diff options
context:
space:
mode:
authoryoubowu <wu.youbo@zte.com.cn>2017-03-01 14:46:23 +0800
committer6092002067 <wu.youbo@zte.com.cn>2017-03-01 14:46:23 +0800
commit7cbac177f8d733c8a2103b966f51a3afe4c2123c (patch)
tree2839c0dc70ca352ad9d47b42553140368da183ae /rulemgt/src/main/java/org/openo
parentb89572c4c6963ca3d6707e4a21e436bd2309f8ee (diff)
Fix db in rule management problems
Issue-ID:HOLMES-50 Change-Id: Iea2cf3b49dd2019fccc7c0014c0c5a5597d7a9c7 Signed-off-by: youbowu <wu.youbo@zte.com.cn>
Diffstat (limited to 'rulemgt/src/main/java/org/openo')
-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/CorrelationRuleDao.java52
-rw-r--r--rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDao.java1
-rw-r--r--rulemgt/src/main/java/org/openo/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java1
4 files changed, 38 insertions, 18 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 b69e66b..beecdd3 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
@@ -75,7 +75,7 @@ public class EngineWrapper {
try {
httpResponse = engineService.check(correlationCheckRule4Engine);
} catch (Exception e) {
- throw new CorrelationException(I18nProxy.RULE_MANAGEMENT__CALL_CHECK_RULE_REST_FAILED,e);
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_CALL_CHECK_RULE_REST_FAILED,e);
}
if (httpResponse.getStatusLine().getStatusCode() == RuleMgtConstant.RESPONSE_STATUS_OK) {
log.info("Call check rule rest interface in engine successfully.");
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleDao.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleDao.java
index a136d12..aa2cccc 100644
--- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleDao.java
+++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/CorrelationRuleDao.java
@@ -15,7 +15,10 @@
*/
package org.openo.holmes.rulemgt.db;
+import java.util.List;
import org.openo.holmes.common.api.entity.CorrelationRule;
+import org.openo.holmes.common.exception.CorrelationException;
+import org.openo.holmes.common.utils.I18nProxy;
import org.openo.holmes.rulemgt.db.mapper.CorrelationRuleMapper;
import org.skife.jdbi.v2.sqlobject.Bind;
import org.skife.jdbi.v2.sqlobject.BindBean;
@@ -24,10 +27,9 @@ import org.skife.jdbi.v2.sqlobject.SqlQuery;
import org.skife.jdbi.v2.sqlobject.SqlUpdate;
import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
-import java.util.List;
-
@RegisterMapper(CorrelationRuleMapper.class)
public abstract class CorrelationRuleDao {
+
@GetGeneratedKeys
@SqlUpdate("INSERT INTO APLUS_RULE (NAME,DESCRIPTION,ENABLE,TEMPLATEID,ENGINETYPE,CREATOR,UPDATOR,PARAMS,DOMAIN ,CONTENT ,VENDOR,CREATETIME,UPDATETIME,ENGINEID,ISMANUAL,PACKAGE,RID) VALUES (:name,:description,:enabled,:templateID,:engineType,:creator,:modifier,:params,:domain,:content,:vendor,:createTime,:updateTime,:engineId,:isManual,:packageName,:rid)")
protected abstract int addRule(@BindBean CorrelationRule correlationRule);
@@ -45,10 +47,10 @@ public abstract class CorrelationRuleDao {
protected abstract List<CorrelationRule> queryAllRules();
@SqlQuery("SELECT * FROM APLUS_RULE WHERE RID=:rid")
- public abstract CorrelationRule queryRuleByRid(@Bind("rid") String rid);
+ protected abstract CorrelationRule queryRuleById(@Bind("rid") String rid);
@SqlQuery("SELECT * FROM APLUS_RULE WHERE NAME=:name")
- public abstract CorrelationRule queryRuleByName(@Bind("name") String name);
+ protected abstract CorrelationRule queryRuleByName(@Bind("name") String name);
private void deleteRule2DbInner(CorrelationRule correlationRule) {
String name = correlationRule.getName() != null ? correlationRule.getName().trim() : "";
@@ -60,26 +62,46 @@ public abstract class CorrelationRuleDao {
}
}
- public CorrelationRule saveRule(CorrelationRule correlationRule) {
- addRule(correlationRule);
- return correlationRule;
+ public CorrelationRule saveRule(CorrelationRule correlationRule) throws CorrelationException {
+ try {
+ addRule(correlationRule);
+ return correlationRule;
+ } catch (Exception e) {
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
+ }
}
- public void updateRule(CorrelationRule correlationRule){
- updateRuleByRid(correlationRule);
+ public void updateRule(CorrelationRule correlationRule) throws CorrelationException {
+ try {
+ updateRuleByRid(correlationRule);
+ } catch (Exception e) {
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
+ }
}
- public void deleteRule(CorrelationRule correlationRule) {
- deleteRule2DbInner(correlationRule);
+ public void deleteRule(CorrelationRule correlationRule) throws CorrelationException {
+ try {
+ deleteRule2DbInner(correlationRule);
+ } catch (Exception e) {
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
+ }
}
- public CorrelationRule getRuleByRid(String rid) {
- return queryRuleByRid(rid);
+ public CorrelationRule queryRuleByRid(String rid) throws CorrelationException {
+ try {
+ return queryRuleById(rid);
+ } catch (Exception e) {
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
+ }
}
- public CorrelationRule queryRuleByRuleName(String name) {
- return queryRuleByName(name);
+ public CorrelationRule queryRuleByRuleName(String name) throws CorrelationException {
+ try {
+ return queryRuleByName(name);
+ } catch (Exception e) {
+ throw new CorrelationException(I18nProxy.RULE_MANAGEMENT_DB_ERROR);
+ }
}
}
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 224f861..075da00 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
@@ -78,7 +78,6 @@ public class CorrelationRuleQueryDao {
correlationRule.setModifier((String) value.get("updator"));
correlationRule.setUpdateTime((Date) value.get("updateTime"));
correlationRule.setParams((Properties) value.get("params"));
- correlationRule.setDomain((String) value.get("domain"));
correlationRule.setContent((String) value.get("content"));
correlationRule.setVendor((String) value.get("vendor"));
correlationRule.setPackageName((String) value.get("package"));
diff --git a/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java b/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java
index a8b114d..437e0dd 100644
--- a/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java
+++ b/rulemgt/src/main/java/org/openo/holmes/rulemgt/db/mapper/CorrelationRuleMapper.java
@@ -39,7 +39,6 @@ public class CorrelationRuleMapper implements ResultSetMapper<CorrelationRule> {
correlationRule.setModifier(resultSet.getString("updator"));
correlationRule.setUpdateTime(resultSet.getDate("updateTime"));
correlationRule.setParams((Properties)resultSet.getObject("params"));
- correlationRule.setDomain(resultSet.getString("domain"));
correlationRule.setContent(resultSet.getString("content"));
correlationRule.setVendor(resultSet.getString("vendor"));
correlationRule.setPackageName(resultSet.getString("package"));