diff options
-rw-r--r-- | engine-d/pom.xml | 6 | ||||
-rw-r--r-- | engine-d/src/main/java/org/openo/holmes/engine/EngineDActiveApp.java (renamed from engine-d/src/main/java/org/openo/holmes/enginemgt/EngineActiveApp.java) | 6 | ||||
-rw-r--r-- | engine-d/src/main/java/org/openo/holmes/engine/EngineDAppConfig.java (renamed from engine-d/src/main/java/org/openo/holmes/enginemgt/EngineAppConfig.java) | 5 | ||||
-rw-r--r-- | engine-d/src/main/java/org/openo/holmes/engine/db/CorrelationRuleDao.java (renamed from engine-d/src/main/java/org/openo/holmes/enginemgt/db/CorrelationRuleDao.java) | 4 | ||||
-rw-r--r-- | engine-d/src/main/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapper.java (renamed from engine-d/src/main/java/org/openo/holmes/enginemgt/db/mapper/CorrelationRuleMapper.java) | 2 | ||||
-rw-r--r-- | engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java (renamed from engine-d/src/main/java/org/openo/holmes/enginemgt/manager/DroolsEngine.java) | 51 | ||||
-rw-r--r-- | engine-d/src/main/java/org/openo/holmes/engine/request/CompileRuleRequest.java (renamed from engine-d/src/main/java/org/openo/holmes/enginemgt/request/CompileRuleRequest.java) | 2 | ||||
-rw-r--r-- | engine-d/src/main/java/org/openo/holmes/engine/request/DeployRuleRequest.java (renamed from engine-d/src/main/java/org/openo/holmes/enginemgt/request/DeployRuleRequest.java) | 2 | ||||
-rw-r--r-- | engine-d/src/main/java/org/openo/holmes/engine/resources/EngineResources.java (renamed from engine-d/src/main/java/org/openo/holmes/enginemgt/resources/EngineResources.java) | 60 | ||||
-rw-r--r-- | engine-d/src/main/java/org/openo/holmes/engine/response/CorrelationRuleResponse.java (renamed from engine-d/src/main/java/org/openo/holmes/enginemgt/response/CorrelationRuleResponse.java) | 2 | ||||
-rw-r--r-- | engine-d/src/main/java/org/openo/holmes/engine/utils/AlarmUtil.java (renamed from engine-d/src/main/java/org/openo/holmes/enginemgt/utils/AlarmUtil.java) | 2 | ||||
-rw-r--r-- | engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java (renamed from engine-d/src/main/java/org/openo/holmes/enginemgt/wrapper/RuleMgtWrapper.java) | 4 |
12 files changed, 69 insertions, 77 deletions
diff --git a/engine-d/pom.xml b/engine-d/pom.xml index d7ff763..bb055bc 100644 --- a/engine-d/pom.xml +++ b/engine-d/pom.xml @@ -25,8 +25,8 @@ <version>1.1.0-SNAPSHOT</version> </parent> - <artifactId>holmes-engine</artifactId> - <name>holmes-enginemgt-service</name> + <artifactId>holmes-engine-d</artifactId> + <name>holmes-engine-d-service</name> <packaging>jar</packaging> <properties> @@ -163,7 +163,7 @@ implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> - <mainClass>org.openo.holmes.enginemgt.EngineActiveApp + <mainClass>org.openo.holmes.engine.EngineDActiveApp </mainClass> </transformer> </transformers> diff --git a/engine-d/src/main/java/org/openo/holmes/enginemgt/EngineActiveApp.java b/engine-d/src/main/java/org/openo/holmes/engine/EngineDActiveApp.java index ddaed97..24bff21 100644 --- a/engine-d/src/main/java/org/openo/holmes/enginemgt/EngineActiveApp.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/EngineDActiveApp.java @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.openo.holmes.enginemgt; +package org.openo.holmes.engine; import org.openo.dropwizard.ioc.bundle.IOCApplication; -public class EngineActiveApp extends IOCApplication<EngineAppConfig> { +public class EngineDActiveApp extends IOCApplication<EngineDAppConfig> { public static void main(String[] args) throws Exception { - new EngineActiveApp().run(args); + new EngineDActiveApp().run(args); } } diff --git a/engine-d/src/main/java/org/openo/holmes/enginemgt/EngineAppConfig.java b/engine-d/src/main/java/org/openo/holmes/engine/EngineDAppConfig.java index b01d173..8b20ac1 100644 --- a/engine-d/src/main/java/org/openo/holmes/enginemgt/EngineAppConfig.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/EngineDAppConfig.java @@ -13,18 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.openo.holmes.enginemgt; +package org.openo.holmes.engine; import com.fasterxml.jackson.annotation.JsonProperty; import io.dropwizard.Configuration; import io.dropwizard.db.DataSourceFactory; import javax.validation.Valid; import javax.validation.constraints.NotNull; -import lombok.Getter; import org.hibernate.validator.constraints.NotEmpty; import org.openo.holmes.common.config.MQConfig; -public class EngineAppConfig extends Configuration { +public class EngineDAppConfig extends Configuration { @NotEmpty private String defaultName = "Correlation-Rule"; diff --git a/engine-d/src/main/java/org/openo/holmes/enginemgt/db/CorrelationRuleDao.java b/engine-d/src/main/java/org/openo/holmes/engine/db/CorrelationRuleDao.java index 2393417..4370054 100644 --- a/engine-d/src/main/java/org/openo/holmes/enginemgt/db/CorrelationRuleDao.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/db/CorrelationRuleDao.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.openo.holmes.enginemgt.db; +package org.openo.holmes.engine.db; import java.util.List; import org.openo.holmes.common.api.entity.CorrelationRule; -import org.openo.holmes.enginemgt.db.mapper.CorrelationRuleMapper; +import org.openo.holmes.engine.db.mapper.CorrelationRuleMapper; import org.skife.jdbi.v2.sqlobject.Bind; import org.skife.jdbi.v2.sqlobject.SqlQuery; import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper; diff --git a/engine-d/src/main/java/org/openo/holmes/enginemgt/db/mapper/CorrelationRuleMapper.java b/engine-d/src/main/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapper.java index 7d9ed97..4af2980 100644 --- a/engine-d/src/main/java/org/openo/holmes/enginemgt/db/mapper/CorrelationRuleMapper.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/db/mapper/CorrelationRuleMapper.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.openo.holmes.enginemgt.db.mapper; +package org.openo.holmes.engine.db.mapper; import java.sql.ResultSet; import java.sql.SQLException; diff --git a/engine-d/src/main/java/org/openo/holmes/enginemgt/manager/DroolsEngine.java b/engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java index 69fe748..473b929 100644 --- a/engine-d/src/main/java/org/openo/holmes/enginemgt/manager/DroolsEngine.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/manager/DroolsEngine.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.openo.holmes.enginemgt.manager; +package org.openo.holmes.engine.manager; import java.io.StringReader; @@ -21,7 +21,6 @@ import java.util.List; import java.util.Locale; import javax.annotation.PostConstruct; import javax.inject.Inject; -import javax.inject.Singleton; import javax.jms.Connection; import javax.jms.ConnectionFactory; import javax.jms.Destination; @@ -49,13 +48,14 @@ import org.openo.holmes.common.api.entity.CorrelationRule; import org.openo.holmes.common.api.stat.Alarm; import org.openo.holmes.common.config.MQConfig; import org.openo.holmes.common.constant.AlarmConst; +import org.openo.holmes.common.exception.CorrelationException; import org.openo.holmes.common.exception.DbException; import org.openo.holmes.common.exception.EngineException; import org.openo.holmes.common.exception.RuleIllegalityException; import org.openo.holmes.common.utils.ExceptionUtil; import org.openo.holmes.common.utils.I18nProxy; -import org.openo.holmes.enginemgt.request.DeployRuleRequest; -import org.openo.holmes.enginemgt.wrapper.RuleMgtWrapper; +import org.openo.holmes.engine.request.DeployRuleRequest; +import org.openo.holmes.engine.wrapper.RuleMgtWrapper; @Slf4j @Service @@ -167,7 +167,7 @@ public class DroolsEngine { } public synchronized String deployRule(DeployRuleRequest rule, Locale locale) - throws RuleIllegalityException, EngineException { + throws CorrelationException { StringReader reader = new StringReader(rule.getContent()); Resource res = ResourceFactory.newReaderResource(reader); @@ -176,20 +176,31 @@ public class DroolsEngine { kbuilder.add(res, ResourceType.DRL); if (kbuilder.hasErrors()) { - throw new RuleIllegalityException(kbuilder.getErrors().toString()); + + String errorMsg = I18nProxy.getInstance().getValueByArgs(locale, + I18nProxy.ENGINE_CONTENT_ILLEGALITY, + new String[]{kbuilder.getErrors().toString()}); + throw new CorrelationException(errorMsg); } String packageName = kbuilder.getKnowledgePackages().iterator().next().getName(); if (kbase.getKnowledgePackages().contains(packageName)) { - throw new RuleIllegalityException( - I18nProxy.getInstance().getValue(locale, I18nProxy.ENGINE_CONTAINS_PACKAGE)); + + String errorMsg = I18nProxy.getInstance().getValueByArgs(locale, + I18nProxy.ENGINE_CONTENT_ILLEGALITY,new String[]{ + I18nProxy.getInstance().getValue(locale, I18nProxy.ENGINE_CONTAINS_PACKAGE)}); + + throw new CorrelationException(errorMsg); } try { kbase.addKnowledgePackages(kbuilder.getKnowledgePackages()); } catch (Exception e) { - throw new EngineException(e); + + String errorMsg = + I18nProxy.getInstance().getValue(locale, I18nProxy.ENGINE_DEPLOY_RULE_FAILED); + throw new CorrelationException(errorMsg, e); } kbuilder = null; @@ -199,26 +210,30 @@ public class DroolsEngine { } - public synchronized void undeployRule(String packageName) - throws RuleIllegalityException, EngineException { + public synchronized void undeployRule(String packageName, Locale locale) + throws CorrelationException { KnowledgePackage pkg = kbase.getKnowledgePackage(packageName); if (null == pkg) { - throw new RuleIllegalityException(packageName); + String errorMsg = I18nProxy.getInstance().getValueByArgs(locale, + I18nProxy.ENGINE_DELETE_RULE_NULL, + new String[]{packageName}); + throw new CorrelationException(errorMsg); } try { kbase.removeKnowledgePackage(pkg.getName()); } catch (Exception e) { - - throw new EngineException(e); + String errorMsg = I18nProxy.getInstance().getValueByArgs(locale, + I18nProxy.ENGINE_DELETE_RULE_FAILED, new String[]{packageName}); + throw new CorrelationException(errorMsg, e); } } public void compileRule(String content, Locale locale) - throws RuleIllegalityException { + throws CorrelationException { StringReader reader = new StringReader(content); Resource res = ResourceFactory.newReaderResource(reader); @@ -227,7 +242,11 @@ public class DroolsEngine { kbuilder.add(res, ResourceType.DRL); if (kbuilder.hasErrors()) { - throw new RuleIllegalityException(kbuilder.getErrors().toString()); + String errorMsg = I18nProxy.getInstance().getValueByArgs(locale, + I18nProxy.ENGINE_CONTENT_ILLEGALITY, + new String[]{kbuilder.getErrors().toString()}); + log.error(errorMsg); + throw new CorrelationException(errorMsg); } kbuilder = null; } diff --git a/engine-d/src/main/java/org/openo/holmes/enginemgt/request/CompileRuleRequest.java b/engine-d/src/main/java/org/openo/holmes/engine/request/CompileRuleRequest.java index bf056be..692deb5 100644 --- a/engine-d/src/main/java/org/openo/holmes/enginemgt/request/CompileRuleRequest.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/request/CompileRuleRequest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.openo.holmes.enginemgt.request; +package org.openo.holmes.engine.request; import com.fasterxml.jackson.annotation.JsonProperty; import javax.validation.constraints.NotNull; diff --git a/engine-d/src/main/java/org/openo/holmes/enginemgt/request/DeployRuleRequest.java b/engine-d/src/main/java/org/openo/holmes/engine/request/DeployRuleRequest.java index b1d9346..979c5bf 100644 --- a/engine-d/src/main/java/org/openo/holmes/enginemgt/request/DeployRuleRequest.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/request/DeployRuleRequest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.openo.holmes.enginemgt.request; +package org.openo.holmes.engine.request; import com.fasterxml.jackson.annotation.JsonProperty; import javax.validation.constraints.NotNull; diff --git a/engine-d/src/main/java/org/openo/holmes/enginemgt/resources/EngineResources.java b/engine-d/src/main/java/org/openo/holmes/engine/resources/EngineResources.java index 59fb9e3..94fc040 100644 --- a/engine-d/src/main/java/org/openo/holmes/enginemgt/resources/EngineResources.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/resources/EngineResources.java @@ -5,7 +5,7 @@ * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.openo.holmes.enginemgt.resources; +package org.openo.holmes.engine.resources; import com.codahale.metrics.annotation.Timed; @@ -32,15 +32,13 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import lombok.extern.slf4j.Slf4j; import org.jvnet.hk2.annotations.Service; -import org.openo.holmes.common.exception.EngineException; -import org.openo.holmes.common.exception.RuleIllegalityException; +import org.openo.holmes.common.exception.CorrelationException; import org.openo.holmes.common.utils.ExceptionUtil; -import org.openo.holmes.common.utils.I18nProxy; import org.openo.holmes.common.utils.LanguageUtil; -import org.openo.holmes.enginemgt.manager.DroolsEngine; -import org.openo.holmes.enginemgt.request.CompileRuleRequest; -import org.openo.holmes.enginemgt.request.DeployRuleRequest; -import org.openo.holmes.enginemgt.response.CorrelationRuleResponse; +import org.openo.holmes.engine.manager.DroolsEngine; +import org.openo.holmes.engine.request.CompileRuleRequest; +import org.openo.holmes.engine.request.DeployRuleRequest; +import org.openo.holmes.engine.response.CorrelationRuleResponse; @Service @Path("/rule") @@ -66,19 +64,9 @@ public class EngineResources { String packageName = droolsEngine.deployRule(deployRuleRequest, locale); crResponse.setPackageName(packageName); - } catch (RuleIllegalityException ruleIllegalityException) { - - String errorMsg = I18nProxy.getInstance().getValueByArgs(locale, - I18nProxy.ENGINE_CONTENT_ILLEGALITY, - new String[]{ruleIllegalityException.getMessage()}); - log.error(errorMsg); - throw ExceptionUtil.buildExceptionResponse(errorMsg); - } catch (EngineException e) { - - String errorMsg = - I18nProxy.getInstance().getValue(locale, I18nProxy.ENGINE_DEPLOY_RULE_FAILED); - log.error(errorMsg + ":" + e.getMessage()); - throw ExceptionUtil.buildExceptionResponse(errorMsg); + } catch (CorrelationException correlationException) { + log.error(correlationException.getMessage(), correlationException); + throw ExceptionUtil.buildExceptionResponse(correlationException.getMessage()); } return crResponse; @@ -96,21 +84,11 @@ public class EngineResources { try { - droolsEngine.undeployRule(packageName); - - } catch (RuleIllegalityException ruleIllegalityException) { + droolsEngine.undeployRule(packageName, locale); - String errorMsg = I18nProxy.getInstance().getValueByArgs(locale, - I18nProxy.ENGINE_DELETE_RULE_NULL, - new String[]{ruleIllegalityException.getMessage()}); - log.error(errorMsg); - throw ExceptionUtil.buildExceptionResponse(errorMsg); - } catch (EngineException e) { - - String errorMsg = I18nProxy.getInstance().getValueByArgs(locale, - I18nProxy.ENGINE_DELETE_RULE_FAILED, new String[]{packageName}); - log.error(errorMsg + e.getMessage()); - throw ExceptionUtil.buildExceptionResponse(errorMsg); + } catch (CorrelationException correlationException) { + log.error(correlationException.getMessage(), correlationException); + throw ExceptionUtil.buildExceptionResponse(correlationException.getMessage()); } return true; } @@ -127,13 +105,9 @@ public class EngineResources { try { droolsEngine.compileRule(compileRuleRequest.getContent(), locale); - } catch (RuleIllegalityException ruleIllegalityException) { - - String errorMsg = I18nProxy.getInstance().getValueByArgs(locale, - I18nProxy.ENGINE_CONTENT_ILLEGALITY, - new String[]{ruleIllegalityException.getMessage()}); - log.error(errorMsg); - throw ExceptionUtil.buildExceptionResponse(errorMsg); + } catch (CorrelationException correlationException) { + log.error(correlationException.getMessage(), correlationException); + throw ExceptionUtil.buildExceptionResponse(correlationException.getMessage()); } return true; } diff --git a/engine-d/src/main/java/org/openo/holmes/enginemgt/response/CorrelationRuleResponse.java b/engine-d/src/main/java/org/openo/holmes/engine/response/CorrelationRuleResponse.java index 6c9842c..f033a1b 100644 --- a/engine-d/src/main/java/org/openo/holmes/enginemgt/response/CorrelationRuleResponse.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/response/CorrelationRuleResponse.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.openo.holmes.enginemgt.response; +package org.openo.holmes.engine.response; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Getter; diff --git a/engine-d/src/main/java/org/openo/holmes/enginemgt/utils/AlarmUtil.java b/engine-d/src/main/java/org/openo/holmes/engine/utils/AlarmUtil.java index 2d5b5ca..558d97b 100644 --- a/engine-d/src/main/java/org/openo/holmes/enginemgt/utils/AlarmUtil.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/utils/AlarmUtil.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.openo.holmes.enginemgt.utils; +package org.openo.holmes.engine.utils; import java.util.HashMap; import java.util.Map; diff --git a/engine-d/src/main/java/org/openo/holmes/enginemgt/wrapper/RuleMgtWrapper.java b/engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java index 35890ca..34dab1f 100644 --- a/engine-d/src/main/java/org/openo/holmes/enginemgt/wrapper/RuleMgtWrapper.java +++ b/engine-d/src/main/java/org/openo/holmes/engine/wrapper/RuleMgtWrapper.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.openo.holmes.enginemgt.wrapper; +package org.openo.holmes.engine.wrapper; import java.util.List; import javax.inject.Inject; @@ -24,7 +24,7 @@ import org.openo.holmes.common.api.entity.CorrelationRule; import org.openo.holmes.common.exception.DbException; import org.openo.holmes.common.utils.DbDaoUtil; import org.openo.holmes.common.utils.I18nProxy; -import org.openo.holmes.enginemgt.db.CorrelationRuleDao; +import org.openo.holmes.engine.db.CorrelationRuleDao; @Service |