summaryrefslogtreecommitdiffstats
path: root/holmes-actions
diff options
context:
space:
mode:
Diffstat (limited to 'holmes-actions')
-rw-r--r--holmes-actions/pom.xml112
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/api/AlarmsCorrelationDbService.java33
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/api/AlarmsCorrelationMqService.java39
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/api/entity/AlarmsCorrelation.java53
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/api/entity/AlarmsCorrelationFilter.java38
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/api/entity/CorrelationResult.java43
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/api/entity/CorrelationRule.java61
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/api/stat/Alarm.java322
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/api/stat/AplusData.java43
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/api/stat/AplusResult.java66
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/constant/AlarmConst.java117
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/constant/MicroServiceConst.java28
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/db/AlarmCorrelationQueryDao.java57
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/db/AlarmsCorrelationDao.java36
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/db/mapper/AlarmsCorrelationMapper.java86
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/exception/CallException.java26
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/exception/DataFormatException.java26
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/exception/DbException.java28
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/exception/EngineException.java32
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/exception/RuleIllegalityException.java32
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-en-US.json29
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-zh-CN.json25
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-operationcode-i18n-en-US.json87
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-operationcode-i18n-zh-CN.json87
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/utils/DateForJsonSerializer.java37
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/utils/DbDaoUtil.java93
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/utils/JacksonUtil.java55
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/utils/JudgeNullUtil.java49
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/utils/LanguageUtil.java53
-rw-r--r--holmes-actions/src/main/java/org/openo/holmes/common/utils/UserUtil.java35
30 files changed, 1828 insertions, 0 deletions
diff --git a/holmes-actions/pom.xml b/holmes-actions/pom.xml
new file mode 100644
index 0000000..e8725f3
--- /dev/null
+++ b/holmes-actions/pom.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2017 ZTE Corporation. Licensed under the Apache License, Version
+ 2.0 (the "License"); 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
+ Unless required by applicable law or agreed to in writing, software distributed
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
+ OR CONDITIONS OF ANY KIND, either express or implied. See the License for
+ the specific language governing permissions and limitations under the License. -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.openo.holmes</groupId>
+ <artifactId>holmes-actions-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </parent>
+
+ <name>holmes-actions-service</name>
+ <packaging>jar</packaging>
+ <artifactId>holmes-actions</artifactId>
+ <dependencies>
+ <!--<dependency>-->
+ <!--<groupId>org.openo.common-services.common-utilities</groupId>-->
+ <!--<artifactId>baseservice-i18n</artifactId>-->
+ <!--</dependency>-->
+ <dependency>
+ <groupId>org.antlr</groupId>
+ <artifactId>stringtemplate</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.swagger</groupId>
+ <artifactId>swagger-jersey2-jaxrs</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-jdbi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.quartz-scheduler</groupId>
+ <artifactId>quartz</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.hamcrest</groupId>
+ <artifactId>hamcrest-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>io.dropwizard</groupId>
+ <artifactId>dropwizard-jdbi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.poi</groupId>
+ <artifactId>poi</artifactId>
+ <version>3.10.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jdom</groupId>
+ <artifactId>jdom</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.openo.common-services.common-utilities</groupId>
+ <artifactId>dropwizard-ioc-container</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.properties</include>
+ <include>**/*.json</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.3</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/api/AlarmsCorrelationDbService.java b/holmes-actions/src/main/java/org/openo/holmes/common/api/AlarmsCorrelationDbService.java
new file mode 100644
index 0000000..4057c03
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/api/AlarmsCorrelationDbService.java
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.api;
+
+import java.util.List;
+import org.jvnet.hk2.annotations.Contract;
+import org.openo.holmes.common.api.entity.AlarmsCorrelation;
+import org.openo.holmes.common.api.entity.AlarmsCorrelationFilter;
+import org.openo.holmes.common.exception.DbException;
+
+@Contract
+public interface AlarmsCorrelationDbService {
+
+ public void saveAlarmsCorrelation(AlarmsCorrelation alarmsCorrelation) throws DbException;
+
+ public List<AlarmsCorrelation> queryAlarmsCorrelationByFilter(
+ AlarmsCorrelationFilter alarmsCorrelationFilter) throws DbException;
+
+ public List<AlarmsCorrelation> queryAllAlarmsCorrelation();
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/api/AlarmsCorrelationMqService.java b/holmes-actions/src/main/java/org/openo/holmes/common/api/AlarmsCorrelationMqService.java
new file mode 100644
index 0000000..8d34e3e
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/api/AlarmsCorrelationMqService.java
@@ -0,0 +1,39 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.api;
+
+import org.jvnet.hk2.annotations.Contract;
+import org.openo.holmes.common.api.stat.Alarm;
+
+@Contract
+public interface AlarmsCorrelationMqService {
+
+ public static final String MQ_TOPIC_NAME_ALARMS_CORRELATION =
+ "topic://voss/fm/alarms_correlation";
+
+ public static final String MQ_QUEUE_NAME_ALARMS_CORRELATION =
+ "queue://voss/fm/alarms_correlation";
+
+ public static final String MQ_TOPIC_NAME_ALARM = "topic://voss/fm/alarm";
+
+ public boolean sendMQTopicMsg(String ruleId, long createTimeL, Alarm parentAlarm,
+ Alarm childAlarm);
+
+ public boolean sendMQTopicMsg(Alarm alarm);
+
+ public boolean sendMQQueueMsg(String ruleId, long createTimeL, Alarm parentAlarm,
+ Alarm childAlarm);
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/api/entity/AlarmsCorrelation.java b/holmes-actions/src/main/java/org/openo/holmes/common/api/entity/AlarmsCorrelation.java
new file mode 100644
index 0000000..de1005c
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/api/entity/AlarmsCorrelation.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.api.entity;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Date;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class AlarmsCorrelation {
+
+ @JsonProperty(value = "ruleid")
+ private String ruleId;
+
+ @JsonProperty(value = "ruleinfo")
+ private String ruleInfo;
+
+ @JsonProperty(value = "resulttype")
+ private byte resultType;
+
+ @JsonProperty(value = "createtime")
+ private Date createTime;
+
+ @JsonProperty(value = "parentalarmid")
+ private long parentAlarmId;
+
+ @JsonProperty(value = "childalarmid")
+ private long childAlarmId;
+
+ @JsonProperty(defaultValue = "-1")
+ private long reserve1 = -1;
+
+ @JsonProperty(defaultValue = "-1")
+ private long reserve2 = -1;
+
+ @JsonProperty(defaultValue = "-1")
+ private long reserve3 = -1;
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/api/entity/AlarmsCorrelationFilter.java b/holmes-actions/src/main/java/org/openo/holmes/common/api/entity/AlarmsCorrelationFilter.java
new file mode 100644
index 0000000..bdbc02c
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/api/entity/AlarmsCorrelationFilter.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.api.entity;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class AlarmsCorrelationFilter {
+
+ @JsonProperty(value = "ruleid")
+ private String ruleId;
+
+ @JsonProperty(value = "parentalarmid")
+ private long parentAlarmId;
+
+ @JsonProperty(value = "childalarmid")
+ private long childAlarmId;
+
+ @JsonProperty(value = "where")
+ private String where;
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/api/entity/CorrelationResult.java b/holmes-actions/src/main/java/org/openo/holmes/common/api/entity/CorrelationResult.java
new file mode 100644
index 0000000..da6924b
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/api/entity/CorrelationResult.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.api.entity;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import org.openo.holmes.common.api.stat.Alarm;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@ToString
+public class CorrelationResult {
+
+ @JsonProperty
+ private String ruleId;
+
+ @JsonProperty
+ private long createTimeL;
+
+ @JsonProperty
+ private byte resultType;
+
+ @JsonProperty
+ private Alarm[] affectedAlarms;
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/api/entity/CorrelationRule.java b/holmes-actions/src/main/java/org/openo/holmes/common/api/entity/CorrelationRule.java
new file mode 100644
index 0000000..4524d39
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/api/entity/CorrelationRule.java
@@ -0,0 +1,61 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.api.entity;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.Date;
+import java.util.Properties;
+import lombok.Getter;
+import lombok.Setter;
+
+@Getter
+@Setter
+public class CorrelationRule {
+
+ @JsonProperty(value = "ruleid")
+ private String rid;
+ @JsonProperty(value = "rulename")
+ private String name;
+ @JsonProperty
+ private String description;
+ @JsonProperty
+ private int enabled;
+ @JsonProperty
+ private int templateID;
+ private String engineId;
+ @JsonProperty
+ private String engineType;
+ @JsonProperty
+ private String creator;
+ @JsonProperty
+ private String modifier;
+ @JsonProperty
+ private Properties params;
+ @JsonProperty
+ private String domain;
+ @JsonProperty
+ private String content;
+ @JsonProperty
+ private int isManual;
+ @JsonProperty
+ private String vendor;
+ @JsonProperty(value = "createtime")
+ private Date createTime;
+ @JsonProperty(value = "updatetime")
+ private Date updateTime;
+ @JsonProperty(value = "package")
+ private String packageName;
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/Alarm.java b/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/Alarm.java
new file mode 100644
index 0000000..71a5d00
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/Alarm.java
@@ -0,0 +1,322 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openo.holmes.common.api.stat;
+
+import java.io.StringReader;
+import java.lang.reflect.Field;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import lombok.Getter;
+import lombok.Setter;
+import org.jdom.Attribute;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+import org.jdom.output.XMLOutputter;
+
+
+@Getter
+@Setter
+public class Alarm implements AplusData, Cloneable {
+
+ public static final byte EVENT_CLEARED_ALARM = 3;
+
+ public static final byte EVENT_CHANGED = 2;
+
+ public static final byte EVENT_CLEARED = 1;
+
+ public static final byte EVENT_RAISED = 0;
+
+ private static final long serialVersionUID = 4520003737132012000L;
+
+ private byte eventType = EVENT_RAISED;
+
+ private long id = 0L;
+
+ private String alarmKey = "";
+
+ private String network = "";
+
+ private String neType = "";
+
+ private String equipType = "";
+
+ private String position1 = "";
+
+ private String subPosition1 = null;
+
+ private String position2 = null;
+
+ private String subPosition2 = null;
+
+ private byte severity = -1;
+
+ private byte alarmType = -1;
+
+ private long probableCause = -1;
+
+ private String specificProblem = null;
+
+ private String additionalText = null;
+
+ private Date raisedTime = new Date();
+
+ private Date raisedServerTime = new Date();
+
+ private Date clearedTime = null;
+
+ private final Date clearedServerTime = null;
+
+ private String region = null;
+
+ private String site = null;
+
+ private String aid = null;
+
+ private short systemType = -1;
+
+ private boolean rootAlarmFlag = false;
+
+ private int linkId = -1;
+
+ private int nodeIdx = -1;
+
+ private Set<Integer> linkIds = new HashSet<Integer>();
+
+ private HashMap<String, Integer> priorityMap = new HashMap<String, Integer>();
+
+ private HashMap<String, Integer> rootAlarmTypeMap = new HashMap<String, Integer>();
+
+ private int rootAlarmType = -1;
+
+ private boolean keyAlarmFlag = false;
+
+ private int keyAlarmType = -1;
+
+ private int networkLevel = -1;
+
+ private int linkType = -1;
+
+ private int centerType;
+
+ private final Map<Integer, Integer> linkIdNodeIdxMap = new HashMap<Integer, Integer>();
+
+ public void addLinkIdNodeIdx(int linkId, int index) {
+ linkIdNodeIdxMap.put(linkId, index);
+ }
+
+ /**
+ * Comparison of the location of different links: 999 the same link: the location of the node
+ * number less than otherIdIdx in the location of the number (in the otherIdIdx upstream):-1,
+ * the same link: the node position number is equal to the number of position in the otherIdIdx
+ * (in the same site otherIdIdx):0, the same link: the node location number is greater than the
+ * number of locations in otherIdIdx (otherIdIdx) with the site):1,
+ */
+ public int CompareLinkPosition(Map<Integer, Integer> otherIdIdx) {
+ Set<Integer> myIdSet = new HashSet<Integer>();
+ myIdSet.addAll(this.linkIdNodeIdxMap.keySet());
+ myIdSet.retainAll(otherIdIdx.keySet());
+
+ if (myIdSet.isEmpty()) {
+ return 999;
+ }
+
+ for (int tempLinkId : myIdSet) {
+ return this.linkIdNodeIdxMap.get(tempLinkId) - otherIdIdx.get(tempLinkId);
+ }
+ return 999;
+ }
+
+ public Map<Integer, Integer> getLinkIdNodeIdx() {
+ return this.linkIdNodeIdxMap;
+ }
+
+ public boolean containNode(int linkId, int index) {
+ if (linkIdNodeIdxMap.containsKey(linkId) && linkIdNodeIdxMap.get(linkId) == index) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public byte getDataType() {
+ return APLUS_EVENT;
+ }
+
+ @Override
+ public String toString() {
+ final String nullStr = "<null>";
+
+ Element el = new Element("Alarm");
+ el.setAttribute("id", String.valueOf(id));
+ el.setAttribute("aid", String.valueOf(aid));
+ el.setAttribute("alarmKey", String.valueOf(alarmKey));
+ el.setAttribute("eventType", String.valueOf(eventType));
+ el.setAttribute("region", region == null ? nullStr : region);
+ el.setAttribute("site", site == null ? nullStr : site);
+ el.setAttribute("network", network);
+ el.setAttribute("neType", neType);
+ el.setAttribute("equipType", equipType);
+ el.setAttribute("position1", position1);
+ el.setAttribute("subPosition1", subPosition1 == null ? nullStr : subPosition1);
+ el.setAttribute("position2", position2 == null ? nullStr : position2);
+ el.setAttribute("subPosition2", subPosition2 == null ? nullStr : subPosition2);
+ el.setAttribute("severity", String.valueOf(severity));
+ el.setAttribute("alarmType", String.valueOf(alarmType));
+ el.setAttribute("probableCause", String.valueOf(probableCause));
+ el.setAttribute("specificProblem", specificProblem == null ? nullStr : specificProblem);
+ el.setAttribute("additionalText", additionalText == null ? nullStr : additionalText);
+ el.setAttribute("raisedTime", String.valueOf(raisedTime.getTime()));
+ el.setAttribute("raisedServerTime", String.valueOf(raisedServerTime.getTime()));
+ if (clearedTime != null) {
+ el.setAttribute("clearedTime", String.valueOf(clearedTime.getTime()));
+ }
+ if (clearedServerTime != null) {
+ el.setAttribute("clearedServerTime", String.valueOf(clearedServerTime.getTime()));
+ }
+
+ return new XMLOutputter().outputString(el);
+ }
+
+ public static Alarm valueOf(String xmlString) {
+ Element element = null;
+ try {
+ StringReader sb = new StringReader(xmlString);
+ element = new SAXBuilder().build(sb).getRootElement();
+ sb.close();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ Alarm alarm = new Alarm();
+ @SuppressWarnings("unchecked")
+ List<Attribute> list = element.getAttributes();
+ for (Attribute attr : list) {
+ String attrName = attr.getName();
+ try {
+ Field field = Alarm.class.getDeclaredField(attrName);
+ if (!attrName.endsWith("Time")) {
+ String type = field.getType().getSimpleName();
+ if (type.equals("byte")) {
+ field.set(alarm, Byte.parseByte(attr.getValue()));
+ } else if (type.equals("long")) {
+ field.set(alarm, Long.parseLong(attr.getValue()));
+ } else if (type.equals("String")) {
+ field.set(alarm, attr.getValue());
+ } else {
+ throw new RuntimeException("unknow attr type: " + type.toString());
+ }
+ } else {
+ Date date = new Date();
+ date.setTime(Long.parseLong(attr.getValue()));
+ field.set(alarm, date);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ return alarm;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.getAlarmKey().hashCode();
+ }
+
+ @Override
+ public boolean equals(Object arg0) {
+ if (arg0 == null) {
+ return false;
+ }
+ return this.alarmKey.equals(((Alarm) arg0).getAlarmKey());
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ super.clone();
+
+ Alarm alarm = new Alarm();
+
+ alarm.setEventType(this.getEventType());
+
+ alarm.setAid(this.getAid());
+ alarm.setId(this.getId());
+ alarm.setAlarmKey(this.getAlarmKey());
+
+ alarm.setNetwork(this.getNetwork());
+ alarm.setEquipType(this.getEquipType());
+ alarm.setNeType(this.getNeType());
+ alarm.setPosition1(this.getPosition1());
+ alarm.setSubPosition1(this.getSubPosition1());
+ alarm.setPosition2(this.getPosition2());
+ alarm.setSubPosition2(this.getSubPosition2());
+ alarm.setRegion(this.getRegion());
+ alarm.setSite(this.getSite());
+
+ alarm.setSeverity(this.getSeverity());
+ alarm.setAlarmType(this.getAlarmType());
+ alarm.setSystemType(this.getSystemType());
+ alarm.setSpecificProblem(this.getSpecificProblem());
+ alarm.setAdditionalText(this.getAdditionalText());
+ alarm.setProbableCause(this.getProbableCause());
+
+ alarm.setRaisedTime(this.getRaisedTime());
+ alarm.setRaisedServerTime(this.getRaisedServerTime());
+ alarm.setClearedTime(this.getClearedTime());
+
+ return alarm;
+ }
+
+ @Override
+ public String getObjectId() {
+ return String.valueOf(id);
+ }
+
+ public void addLinkIds(int linkId) {
+ linkIds.add(linkId);
+ }
+
+
+ public boolean containsPriority(String ruleId) {
+ if (priorityMap.keySet().contains(ruleId)) {
+ return true;
+ }
+ return false;
+ }
+
+ public int getPriority(String ruleId) {
+ Integer priority = this.priorityMap.get(ruleId);
+ if (priority == null) {
+ priority = 0;
+ }
+ return priority;
+ }
+
+ public int getRootAlarmType(String ruleId) {
+ Integer rootAlarmType = this.rootAlarmTypeMap.get(ruleId);
+ if (rootAlarmType == null) {
+ rootAlarmType = -1;
+ }
+ return rootAlarmType;
+ }
+
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/AplusData.java b/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/AplusData.java
new file mode 100644
index 0000000..ce95a8d
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/AplusData.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.api.stat;
+
+import java.io.Serializable;
+
+public interface AplusData extends Serializable {
+
+ /**
+ * The data to be analyzed with aging characteristics - 0
+ */
+ byte APLUS_EVENT = 0;
+
+ /**
+ * The data to be analyzed without aging characteristics - 1
+ */
+ byte APLUS_FACT = 1;
+
+
+ /**
+ * @see #APLUS_EVENT
+ * @see #APLUS_FACT
+ */
+ byte getDataType();
+
+ /**
+ * @return String
+ */
+ String getObjectId();
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/AplusResult.java b/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/AplusResult.java
new file mode 100644
index 0000000..53c6729
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/api/stat/AplusResult.java
@@ -0,0 +1,66 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.api.stat;
+
+import java.io.Serializable;
+
+public interface AplusResult extends Serializable {
+
+ /**
+ * Derived new alarm type - 0
+ */
+ byte APLUS_RAISED = 0;
+
+ /**
+ * Correlation alarm, root-child alarm - 1
+ */
+ byte APLUS_CORRELATION = 1;
+
+ /**
+ * cleared
+ */
+ byte APLUS_CLEAR = 2;
+
+
+ int getId();
+
+ void setId(int id);
+
+ String getRuleInfo();
+
+ void setRuleInfo(String ruleInfo);
+
+ String getRuleType();
+
+ void setRuleType(String ruleType);
+
+ void setRuleId(String ruleId);
+
+ String getRuleId();
+
+ long getCreateTime();
+
+ void setCreateTime(long createTime);
+
+ byte getResultType();
+
+ void setResultType(byte resultType);
+
+ Alarm[] getAffectedAlarms();
+
+ void setAffectedAlarms(Alarm[] affectedAlarms);
+
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/constant/AlarmConst.java b/holmes-actions/src/main/java/org/openo/holmes/common/constant/AlarmConst.java
new file mode 100644
index 0000000..b0d0b48
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/constant/AlarmConst.java
@@ -0,0 +1,117 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.constant;
+
+public interface AlarmConst {
+
+ public static final String MQ_QUEUE_NAME_EMF_UP = "queue://zenap/fm/emf_up";
+
+ public static final String MQ_TOPIC_NAME_EMF_DOWN = "topic://zenap/fm/emf_down";
+
+ public static final String MQ_TOPIC_NAME_NORTH_UP = "topic://zenap/fm/north_up";
+
+ public static final String MQ_TOPIC_NAME_ALARM_RULE = "topic://zenap/fm/alarm_rule";
+
+ public static final String INTERNAL_MQ_QUEUE_NAME_HISTORY_ALARM_2_DB = "queue://zenap/fm/historyalarm2DB";
+
+ public static final String MQ_SELECTOR_KEY = "nf";
+
+ public static final String MQ_EMF_DOWN_MSG_FILTER_KEY = "type";
+
+ public static final String MQ_EMF_UP_MSG_FILTER_KEY = "type";
+
+ public static final String INTERNAL_MQ_EMF_UP_ACKALARM_MSG_FILTER_VALUE = "ACK";
+
+ public static final String MQ_EMF_DOWN_CLEARALARM_MSG_FILTER_VALUE = "CLEAR";
+
+ public static final String MQ_EMF_UP_CLEARALARM_MSG_FILTER_VALUE = "CLEAR";
+
+ public static final String MQ_EMF_UP_CHANGEALARM_MSG_FILTER_VALUE = "CHANGE";
+
+ public static final String MQ_EMF_UP_RAISEALARM_MSG_FILTER_VALUE = "RAISE";
+
+ public static final String INTERNAL_MQ_CLEARALARM_2_DB_FILTER_VALUE = "CLEAR";
+
+ public static final String COMETD_MESSAGE_TOPIC = "cometd2Client";
+
+ public static final String COMETD_MESSAGE_CHANEL = "/broadcast_channel/alarm_cometd_chanel";
+
+ public static final String COMETD_NF_COUNTER_CHANEL = "/nf_counter_cometd_chanel";
+
+ public static final String COMETD_PROMPTING_RULE_CHANEL = "/prompting_rule_cometd_chanel";
+
+ public static final String COMETD_MASK_RULE_MESSAGE_FILTER_KEY = "mask_rule";
+
+ public static final String COMETD_CLEAR_ALARM_MESSAGE_FILTER_KEY = "clear_alarm";
+
+ public static final String COMETD_ACK_ALARM_MESSAGE_FILTER_KEY = "ack_alarm";
+
+ public static final String COMETD_HISTORY_ALARM_ACK_STATE_MESSAGE_FILTER_KEY = "history_alarm_ack";
+
+ public static final String CACHE_ACTIVE_ALARM_KEY = "TAG_ACTIVE_ALARM";
+
+ public static final String CACHE_ALARM_CODE_KEY = "TAG_ALARM_CODE";
+
+ public static final String CACHE_ALARM_RESTYPE_AND_RESVERSION_KEY = "TAG_ALARM_RESTYPE_AND_RESVERSION";
+
+ public static final String CACHE_ALARM_REASON_KEY = "TAG_ALARM_REASON";
+
+ public static final String CACHE_ALARM_MAIN_KEY = "TAG_ALARM_MAIN";
+
+ public static final short STATUS_ENABLE = 0;
+
+ public static final short STATUS_DISABLE = 1;
+
+ public static final short STATUS_DELETED = 2;
+
+ public static final short UNDEFINE_LEVEL = 0;
+
+ public static final short CRITICA_LEVEL = 1;
+
+ public static final short MAJOR_LEVEL = 2;
+
+ public static final short MINOR_LEVEL = 3;
+
+ public static final short WARNING_LEVEL = 4;
+
+ public static final String I18N_EN = "en";
+
+ public static final String I18N_ZH = "zh";
+
+ public static final String ZH_CN = "zh_CN";
+
+ public static final String EN_US = "en_US";
+
+ public static final String EXECUTE_TIMER = "0 0 0 */1 * ? ";
+
+ public static final String COMMON_EM_RESTYPE = "common_em";
+
+ public static final String EM_LOCATION = "em";
+
+ public static final String BASE_MOC = "em";
+
+ public static final String SYSTEM_ID = "SystemId";
+
+ public static final String ADMIN = "admin";
+
+ public static final long UNDEFINE_ALARM_CODE = -1;
+
+ // for rule code
+ public static final long FORWARD_FAILED_ALARM_CODE = 1028L;
+
+ public static long ACTIVE_PERSISTING_RULE_CODE = 1017L;
+ public static long UNACKNOWLEDGED_PERSISTING_RULE_CODE = 1018L;
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/constant/MicroServiceConst.java b/holmes-actions/src/main/java/org/openo/holmes/common/constant/MicroServiceConst.java
new file mode 100644
index 0000000..c0f5d5e
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/constant/MicroServiceConst.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.constant;
+
+public interface MicroServiceConst {
+
+ public static final String CORRELATION_ENGINE = "correlation-engine";
+
+ public static final String VERSION = "v1";
+
+ public static final String ENGINE_PATH = "/api/correlation-engine/v1/rule";
+
+ public static final String CORRELATION_ENGINE_SERVICE_NAME = CORRELATION_ENGINE;
+
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/db/AlarmCorrelationQueryDao.java b/holmes-actions/src/main/java/org/openo/holmes/common/db/AlarmCorrelationQueryDao.java
new file mode 100644
index 0000000..3e8bfc8
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/db/AlarmCorrelationQueryDao.java
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.db;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.jvnet.hk2.annotations.Service;
+import org.openo.holmes.common.api.entity.AlarmsCorrelation;
+import org.skife.jdbi.v2.Query;
+
+import org.openo.holmes.common.db.mapper.AlarmsCorrelationMapper;
+import org.openo.holmes.common.utils.DbDaoUtil;
+
+import lombok.extern.slf4j.Slf4j;
+
+@Service
+@Slf4j
+public class AlarmCorrelationQueryDao {
+
+ @Inject
+ private DbDaoUtil dbDaoUtil;
+
+ @Inject
+ private AlarmsCorrelationMapper mapper;
+
+ private final static String SELECT_TABLE_SQL = "SELECT * FROM APLUS_CORRELATION ";
+
+ public List<AlarmsCorrelation> queryByFilter(String where) {
+ List<AlarmsCorrelation> alarmsCorrelations = new ArrayList<AlarmsCorrelation>();
+ StringBuilder querySql = new StringBuilder(SELECT_TABLE_SQL).append(where);
+ log.info("Query alarm correlation table! Sql:[" + querySql + "].");
+ Query<Map<String, Object>> query = dbDaoUtil.getHandle().createQuery(querySql.toString());
+ List<Map<String, Object>> dbDataMaps = query.list();
+ for (Map<String, Object> map : dbDataMaps) {
+ alarmsCorrelations.add(mapper.getAlarmCorrelationByMap(map));
+ }
+ log.info("Success to query alarm correlation table! total count:[" + dbDataMaps.size() + "].");
+ return alarmsCorrelations;
+ }
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/db/AlarmsCorrelationDao.java b/holmes-actions/src/main/java/org/openo/holmes/common/db/AlarmsCorrelationDao.java
new file mode 100644
index 0000000..43c8bf2
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/db/AlarmsCorrelationDao.java
@@ -0,0 +1,36 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.db;
+
+import java.util.List;
+
+import org.openo.holmes.common.api.entity.AlarmsCorrelation;
+import org.skife.jdbi.v2.sqlobject.BindBean;
+import org.skife.jdbi.v2.sqlobject.SqlQuery;
+import org.skife.jdbi.v2.sqlobject.SqlUpdate;
+import org.skife.jdbi.v2.sqlobject.customizers.RegisterMapper;
+
+import org.openo.holmes.common.db.mapper.AlarmsCorrelationMapper;
+
+@RegisterMapper(AlarmsCorrelationMapper.class)
+public interface AlarmsCorrelationDao {
+
+ @SqlUpdate("INSERT INTO APLUS_CORRELATION (ruleId,ruleInfo,resultType,createTime,parentAlarmId,childAlarmId,reserve1,reserve2,reserve3) values(:ruleId,:ruleInfo,:resultType,:createTime,:parentAlarmId,:childAlarmId,:reserve1,:reserve2,:reserve3)")
+ public abstract void save(@BindBean AlarmsCorrelation aplusCorrelation);
+
+ @SqlQuery("SELECT * FROM APLUS_CORRELATION")
+ public abstract List<AlarmsCorrelation> queryAll();
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/db/mapper/AlarmsCorrelationMapper.java b/holmes-actions/src/main/java/org/openo/holmes/common/db/mapper/AlarmsCorrelationMapper.java
new file mode 100644
index 0000000..2fc2968
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/db/mapper/AlarmsCorrelationMapper.java
@@ -0,0 +1,86 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.db.mapper;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Date;
+import java.util.Map;
+
+import org.jvnet.hk2.annotations.Service;
+import org.openo.holmes.common.api.entity.AlarmsCorrelation;
+import org.skife.jdbi.v2.StatementContext;
+import org.skife.jdbi.v2.tweak.ResultSetMapper;
+
+@Service
+public class AlarmsCorrelationMapper implements ResultSetMapper<AlarmsCorrelation> {
+
+ private final static String RULE_ID = "ruleId";
+ private final static String RULE_INFO = "ruleInfo";
+ private final static String RESULT_TYPE = "resultType";
+ private final static String CREATE_TIME = "createTime";
+ private final static String PARENT_ALARM_ID = "parentAlarmId";
+ private final static String CHILD_ALARM_ID = "childAlarmId";
+ private final static String RESERVE1 = "reserve1";
+ private final static String RESERVE2 = "reserve2";
+ private final static String RESERVE3 = "reserve3";
+
+ @Override
+ public AlarmsCorrelation map(int i, ResultSet resultSet, StatementContext statementContext)
+ throws SQLException {
+ AlarmsCorrelation aplusCorrelation = new AlarmsCorrelation();
+ aplusCorrelation.setRuleId(resultSet.getString(RULE_ID));
+ aplusCorrelation.setRuleInfo(resultSet.getString(RULE_INFO));
+ aplusCorrelation.setResultType(resultSet.getByte(RESULT_TYPE));
+ aplusCorrelation.setCreateTime(resultSet.getDate(CREATE_TIME));
+ aplusCorrelation.setParentAlarmId(resultSet.getLong(PARENT_ALARM_ID));
+ aplusCorrelation.setChildAlarmId(resultSet.getLong(CHILD_ALARM_ID));
+ aplusCorrelation.setReserve1(resultSet.getLong(RESERVE1));
+ aplusCorrelation.setReserve2(resultSet.getLong(RESERVE2));
+ aplusCorrelation.setReserve3(resultSet.getLong(RESERVE3));
+ return aplusCorrelation;
+ }
+
+ public AlarmsCorrelation getAlarmCorrelationByMap(Map<String, Object> map) {
+ AlarmsCorrelation aplusCorrelation = new AlarmsCorrelation();
+ aplusCorrelation.setRuleId(getStringValue4Map(map, RULE_ID));
+ aplusCorrelation.setRuleInfo(getStringValue4Map(map, RULE_INFO));
+ aplusCorrelation.setResultType(getByteValue4Map(map, RESULT_TYPE, -1));
+ aplusCorrelation.setCreateTime((Date) map.get(CREATE_TIME));
+ aplusCorrelation.setParentAlarmId(getLongValue4Map(map, PARENT_ALARM_ID, -1));
+ aplusCorrelation.setChildAlarmId(getLongValue4Map(map, CHILD_ALARM_ID, -1));
+ aplusCorrelation.setReserve1(getLongValue4Map(map, RESERVE1, -1));
+ aplusCorrelation.setReserve2(getLongValue4Map(map, RESERVE2, -1));
+ aplusCorrelation.setReserve3(getLongValue4Map(map, RESERVE3, -1));
+ return aplusCorrelation;
+ }
+
+ private String getStringValue4Map(Map<String, Object> map, String key) {
+ Object value = map.get(key);
+ return value == null ? "" : String.valueOf(value);
+ }
+
+ private long getLongValue4Map(Map<String, Object> map, String key, long defaultValue) {
+ Object value = map.get(key);
+ return value == null ? defaultValue : Long.valueOf(String.valueOf(value));
+ }
+
+ private byte getByteValue4Map(Map<String, Object> map, String key, int defaultValue) {
+ Object value = map.get(key);
+ return value == null ? Byte.valueOf(String.valueOf(defaultValue))
+ : Byte.valueOf(String.valueOf(value));
+ }
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/exception/CallException.java b/holmes-actions/src/main/java/org/openo/holmes/common/exception/CallException.java
new file mode 100644
index 0000000..fe32b26
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/exception/CallException.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.exception;
+
+public class CallException extends Exception {
+ public CallException(String msg, Exception e) {
+ super(msg, e);
+ }
+
+ public CallException(String msg) {
+ super(msg);
+ }
+} \ No newline at end of file
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/exception/DataFormatException.java b/holmes-actions/src/main/java/org/openo/holmes/common/exception/DataFormatException.java
new file mode 100644
index 0000000..7fcc3b2
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/exception/DataFormatException.java
@@ -0,0 +1,26 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.exception;
+
+public class DataFormatException extends Exception {
+ public DataFormatException(String msg, Exception e ) {
+ super( msg, e );
+ }
+
+ public DataFormatException(String msg ) {
+ super( msg );
+ }
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/exception/DbException.java b/holmes-actions/src/main/java/org/openo/holmes/common/exception/DbException.java
new file mode 100644
index 0000000..d616481
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/exception/DbException.java
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.exception;
+
+public class DbException extends Exception {
+ private static final long serialVersionUID = 6218393740013925907L;
+
+ public DbException( String msg, Exception e ) {
+ super( msg, e );
+ }
+
+ public DbException( String msg ) {
+ super( msg );
+ }
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/exception/EngineException.java b/holmes-actions/src/main/java/org/openo/holmes/common/exception/EngineException.java
new file mode 100644
index 0000000..d61901d
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/exception/EngineException.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.exception;
+
+public class EngineException extends Exception{
+ public EngineException () {}
+
+ public EngineException(String msg) {
+ super(msg);
+ }
+
+ public EngineException(String msg, Throwable cause){
+ super(msg, cause);
+ }
+
+ public EngineException(Throwable cause){
+ super(cause);
+ }
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/exception/RuleIllegalityException.java b/holmes-actions/src/main/java/org/openo/holmes/common/exception/RuleIllegalityException.java
new file mode 100644
index 0000000..5b1d3bd
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/exception/RuleIllegalityException.java
@@ -0,0 +1,32 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.exception;
+
+public class RuleIllegalityException extends Exception{
+ public RuleIllegalityException() {}
+
+ public RuleIllegalityException(String msg) {
+ super(msg);
+ }
+
+ public RuleIllegalityException(String msg, Throwable cause){
+ super(msg, cause);
+ }
+
+ public RuleIllegalityException(Throwable cause){
+ super(cause);
+ }
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-en-US.json b/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-en-US.json
new file mode 100644
index 0000000..9aa6357
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-en-US.json
@@ -0,0 +1,29 @@
+{
+ "ENGINE_CONTENT_ILLEGALITY": "The rule content have error:{0}",
+ "ENGINE_DEPLOY_RULE_FAILED": "Deploy rule failed",
+ "ENGINE_DELETE_RULE_NULL": "The rule do not exist :{0}",
+ "ENGINE_DELETE_RULE_FAILED": "The rule remove failed :{0}",
+ "ENGINE_INSERT_RULE_CACHE_FAILED": "insert rule failed in cache",
+ "ENGINE_DELETE_RULE_FAILED_FROM_CACHE": "delete rule failed in cache",
+ "ENGINE_CONTAINS_PACKAGE": "Is included in the package name, please amend",
+ "ENGINE_QUERY_CACHE_FAILED": "Failed query cache",
+ "EXCEPTION_DB_RULE_NOT_EXIST_ERROR": "This rule does not exist in the database.",
+ "EXCEPTION_DB_RULE_SAVE_ERROR": "Error saving rule to database",
+ "EXCEPTION_DB_RULE_GET_ERROR": "Error when get rule from database",
+ "EXCEPTION_REQUEST_IS_EMPTY": "The request object is empty",
+ "RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED": "Delete rules from engine call interface failure ",
+ "RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED": "From the rules engine calls the deployment of interface failure",
+ "RULE_MANAGEMENT__CALL_CHECK_RULE_REST_FAILED": "From the rules engine calls the check of interface failure",
+ "RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED": "Create query exception",
+ "RULE_MANAGEMENT_QUERY_RULE_FAILED": "Query rule failed",
+ "RULE_MANAGEMENT_CREATE_RULE_FAILED": "Failed to create rule",
+ "RULE_MANAGEMENT_DELETE_RULE_FAILED": "Delete rule failed",
+ "RULE_MANAGEMENT_UPDATE_RULE_FAILED": "Update rule failed",
+ "RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY": "Request object is empty",
+ "RULE_MANAGEMENT_RULE_NOT_EXIST_DATABASE": "Rule does not exist",
+ "RULE_MANAGEMENT_UNKNOWN_EXCEPTION": "Unknown exception",
+ "RULE_MANAGEMENT_REPEAT_RULE_NAME": "Rule name repetition",
+ "RULE_MANAGEMENT_RULE_NAME_IS_EMPTY": "Rule name is empty",
+ "RULE_MANAGEMENT_DATA_FORMAT_ERROR": "Data format error",
+ "RULE_MANAGEMENT_PARAMETER_ENABLED_ERROR": "Parameter enabled can only be 0 (not enabled) and 1 (enabled)"
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-zh-CN.json b/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-zh-CN.json
new file mode 100644
index 0000000..9ca28fe
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-i18n-zh-CN.json
@@ -0,0 +1,25 @@
+{
+ "ENGINE_CONTENT_ILLEGALITY": "规则内容有误:{0}",
+ "ENGINE_DEPLOY_RULE_FAILED": "部署规则失败",
+ "ENGINE_DELETE_RULE_NULL": "引擎不包含这个规则:{0}",
+ "ENGINE_DELETE_RULE_FAILED": "删除规则失败{0}",
+ "ENGINE_INSERT_RULE_CACHE_FAILED": "插入数据到缓存失败",
+ "ENGINE_DELETE_RULE_FAILED_FROM_CACHE": "从缓存删除数据失败",
+ "ENGINE_CONTAINS_PACKAGE": "package 名字已包含,请修改",
+ "ENGINE_QUERY_CACHE_FAILED":"查询缓存失败",
+ "RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED": "从引擎调用删除规则接口失败",
+ "RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED": "从引擎调用部署规则接口失败",
+ "RULE_MANAGEMENT__CALL_CHECK_RULE_REST_FAILED": "从引擎调用校验规则接口失败",
+ "RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED": "创建查询语句异常",
+ "RULE_MANAGEMENT_QUERY_RULE_FAILED": "查询规则失败",
+ "RULE_MANAGEMENT_CREATE_RULE_FAILED": "创建规则失败",
+ "RULE_MANAGEMENT_DELETE_RULE_FAILED": "删除规则失败",
+ "RULE_MANAGEMENT_UPDATE_RULE_FAILED": "更新规则失败",
+ "RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY":"请求对象为空",
+ "RULE_MANAGEMENT_RULE_NOT_EXIST_DATABASE": "规则不存在",
+ "RULE_MANAGEMENT_UNKNOWN_EXCEPTION": "未知异常",
+ "RULE_MANAGEMENT_REPEAT_RULE_NAME" : "规则名字重复",
+ "RULE_MANAGEMENT_RULE_NAME_IS_EMPTY" : "规则名字为空",
+ "RULE_MANAGEMENT_DATA_FORMAT_ERROR": "数据格式异常",
+ "RULE_MANAGEMENT_PARAMETER_ENABLED_ERROR" : "参数enabled只能为0(未启用)和1(启用)"
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-operationcode-i18n-en-US.json b/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-operationcode-i18n-en-US.json
new file mode 100644
index 0000000..b7d4853
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-operationcode-i18n-en-US.json
@@ -0,0 +1,87 @@
+{
+ "ADD_QUERY_COND":"Add active alarm query condition",
+ "MODIFY_QUERY_COND":"Modify active alarm query condition",
+ "QUERY_ALL_QUERY_COND":"Query all active alarm query conditions",
+ "DELETE_QUERY_COND":"Delete active alarm query condition",
+ "ADD_ALARM_ACK_RULE":"Add active alarm acknowledge rule",
+ "MODIFY_ALARM_ACK_RULE":"Modify active alarm acknowledge rule",
+ "QUERY_ALARM_ACK_RULE":"Query active alarm acknowledge rule",
+ "ADD_FILTER_RULE":"Add alarm filter rule",
+ "MODIFY_FILTER_RULE":"Modify alarm filter rule",
+ "QUERY_FILTER_RULE":"Query alarm filter rule",
+ "ADD_MASK_RULE":"Add mask rule",
+ "MODIFY_MASK_RULE":"Modify mask rule",
+ "ADD_CLEAR_RULE":"Add clear rule",
+ "MODIFY_CLEAR_RULE":"Modify clear rule",
+ "QUERY_CLEAR_RULE":"Query clear rule",
+ "ADD_COUNT_RULE":"Add count rule",
+ "MODIFY_COUNT_RULE":"Modify count rule",
+ "QUERY_COUNT_RULE":"Query count rule",
+ "ADD_DELAY_TIME_RULE":"Add delay time rule",
+ "MODIFY_DELAY_TIME_RULE":"Modify delay time rule",
+ "QUERY_DELAY_TIME_RULE":"Query delay time rule",
+ "ADD_FORWARD_RULE":"Add forward rule",
+ "MODIFY_FORWARD_RULE":"Modify forward rule",
+ "QUERY_FORWARD_RULE":"Query forward rule",
+ "ADD_INTERMITTENT_ALARM_RULE":"Add intermittent alarm rule",
+ "MODIFY_INTERMITTENT_ALARM_RULE":"Modify intermittent alarm rule",
+ "ADD_MERGE_RULE":"Add merge rule",
+ "MODIFY_MERGE_RULE":"Modify merge rule",
+ "QUERY_MERGE_RULE":"Query merge rule",
+ "ADD_NOTIFICATION_FILTER_RULE":"Add notification filter rule",
+ "MODIFY_NOTIFICATION_FILTER_RULE":"Modify notification filter rule",
+ "QUERY_NOTIFICATION_FILTER_RULE":"Query notification filter rule",
+ "ADD_PERSISTING_RULE":"Add persisting rule",
+ "MODIFY_PERSISTING_RULE":"Modify persisting rule",
+ "QUERY_PERSISTING_RULE":"Query persisting rule",
+ "ADD_PROMPTING_RULE":"Add prompting rule",
+ "MODIFY_PROMPTING_RULE":"Modify persisting rule",
+ "QUERY_PROMPTING_RULE":"Query persisting rule",
+ "SUSPEND_RULE":"Suspend rule",
+ "SUSPEND_RULE_FAIL":"Suspend rule failed",
+ "ACTIVATE_RULE":"Activate rule",
+ "ACTIVATE_RULE_FAIL":"activate rule failed",
+ "DELETED_RULE":"Deleted rule",
+ "DELETE_RULE_FAIL":"delete rule failed",
+ "QUERY_RULE_TYPE":"Query rule type",
+ "QUERY_RULE_TYPE_FAIL":"Query rule type failed",
+ "QUERY_RULE_BY_TYPE":"Query all rule by rule types",
+ "QUERY_TIMING_REPORT_RULE":"Query timing report rule",
+ "ADD_TIMING_REPORT_RULE":"Add timing report rule",
+ "MODIFY_TIMING_REPORT_RULE":"Modify timing report rule",
+ "QUERY_TIMING_REPORT_TASK_LOG":"Query timing report task execute log",
+ "DELETED_TIMING_REPORT_RULE":"Deleted timing report rule",
+ "DELETED_TIMING_REPORT_RULE_FAIL":"Deleted timing report rule failed",
+ "ACTIVATE_TIMING_REPORT_RULE":"Activate timing report rule",
+ "ACTIVATE_TIMING_REPORT_RULE_FAIL":"Activate timing report rule failed",
+ "SUSPEND_TIMING_REPORT_RULE":"Suspend timing report rule",
+ "SUSPEND_TIMING_REPORT_RULE_FAIL":"Suspend timing report rule failed",
+ "QUERY_HISTORY_TIMING_REPORT_RULE":"Query history timing report rule",
+ "ADD_HISTORY_TIMING_REPORT_RULE":"Add history timing report rule",
+ "MODIFY_HISTORY_TIMING_REPORT_RULE":"Modify history timing report rule",
+ "DELETED_HISTORY_TIMING_REPORT_RULE":"Deleted history timing report rule",
+ "DELETED_HISTORY_TIMING_REPORT_RULE_FAIL":"Deleted history timing report rule failed",
+ "ACTIVATE_HISTORY_TIMING_REPORT_RULE":"Activate history timing report rule",
+ "ACTIVATE_HISTORY_TIMING_REPORT_RULE_FAIL":"Activate history timing report rule failed",
+ "SUSPEND_HISTORY_TIMING_REPORT_RULE":"Suspend history timing report rule",
+ "SUSPEND_HISTORY_TIMING_REPORT_RULE_FAIL":"Suspend history timing report rule failed",
+ "QUERY_HISTORY_TIMING_REPORT_TASK_LOG":"Query history timing report task execution log",
+ "ADD_HISTORY_ALARM_QUERY_COND":"Add history alarm query condition",
+ "MODIFY_HISTORY_ALARM_QUERY_COND":"Modify history alarm query condition",
+ "QUERY_HISTORY_ALARM_QUERY_COND":"Query history alarm query condition",
+ "DELETED_HISTORY_ALARM_QUERY_COND":"Deleted history alarm query condition",
+ "ADD_NOTIFICATION_QUERY_COND":"Add notification query condition",
+ "MODIFY_NOTIFICATION_QUERY_COND":"Modify notification query condition",
+ "QUERY_NOTIFICATION_QUERY_COND":"Query notification query condition",
+ "DELETED_NOTIFICATION_QUERY_COND":"Deleted notification query condition",
+ "QUERY_BASIC_STATISTIC_TEMPLATE":"Query basic statistic template",
+ "ADD_BASIC_STATISTIC_TEMPLATE":"Add basic statistic template",
+ "MODIFY_BASIC_STATISTIC_TEMPLATE":"Modify basic statistic template",
+ "DELETED_BASIC_STATISTIC_TEMPLATE":"Deleted basic statistic template",
+ "MODIFY_BASIC_STATISTIC_TEMPLATE_AS_DEFAULT":"Modify basic statistic template as default template",
+ "QUERY_BUSY_TIME_STATISTIC_TEMPLATE":"Query busy time statistic template",
+ "ADD_BUSY_TIME_STATISTIC_TEMPLATE":"Add busy time statistic template",
+ "MODIFY_BUSY_TIME_STATISTIC_TEMPLATE":"Modify busy time statistic template",
+ "DELETED_BUSY_TIME_STATISTIC_TEMPLATE":"Deleted busy time statistic template",
+ "MODIFY_BUSY_TIME_STATISTIC_TEMPLATE_AS_DEFAULT":"Modify busy time statistic template as default template"
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-operationcode-i18n-zh-CN.json b/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-operationcode-i18n-zh-CN.json
new file mode 100644
index 0000000..0509c3b
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/i18n/correlation-operationcode-i18n-zh-CN.json
@@ -0,0 +1,87 @@
+{
+ "ADD_QUERY_COND":"添加当前告警查询条件",
+ "MODIFY_QUERY_COND":"修改当前告警查询条件",
+ "QUERY_ALL_QUERY_COND":"查询所有当前告警查询条件",
+ "DELETE_QUERY_COND":"删除当前告警查询条件",
+ "ADD_ALARM_ACK_RULE":"添加当前告警确认规则",
+ "MODIFY_ALARM_ACK_RULE":"修改当前告警确认规则",
+ "QUERY_ALARM_ACK_RULE":"查询当前告警确认规则",
+ "ADD_FILTER_RULE":"添加告警过滤规则",
+ "MODIFY_FILTER_RULE":"修改告警过滤规则",
+ "QUERY_FILTER_RULE":"查询告警过滤规则",
+ "ADD_MASK_RULE":"添加屏蔽规则",
+ "MODIFY_MASK_RULE":"修改屏蔽规则",
+ "ADD_CLEAR_RULE":"添加清除规则",
+ "MODIFY_CLEAR_RULE":"修改清除规则",
+ "QUERY_CLEAR_RULE":"查询清除规则",
+ "ADD_COUNT_RULE":"添加计数规则",
+ "MODIFY_COUNT_RULE":"修改计数规则",
+ "QUERY_COUNT_RULE":"查询计数规则",
+ "ADD_DELAY_TIME_RULE":"添加延时规则",
+ "MODIFY_DELAY_TIME_RULE":"修改延时规则",
+ "QUERY_DELAY_TIME_RULE":"查询延时规则",
+ "ADD_FORWARD_RULE":"添加前转规则",
+ "MODIFY_FORWARD_RULE":"修改前转规则",
+ "QUERY_FORWARD_RULE":"查询前转规则",
+ "ADD_INTERMITTENT_ALARM_RULE":"添加闪断规则",
+ "MODIFY_INTERMITTENT_ALARM_RULE":"修改闪断规则",
+ "ADD_MERGE_RULE":"添加归并规则",
+ "MODIFY_MERGE_RULE":"修改归并规则",
+ "QUERY_MERGE_RULE":"查询归并规则",
+ "ADD_NOTIFICATION_FILTER_RULE":"添加通知过滤规则",
+ "MODIFY_NOTIFICATION_FILTER_RULE":"修改通知过滤规则",
+ "QUERY_NOTIFICATION_FILTER_RULE":"查询通知过滤规则",
+ "ADD_PERSISTING_RULE":"添加计时规则",
+ "MODIFY_PERSISTING_RULE":"修改计时规则",
+ "QUERY_PERSISTING_RULE":"查询计时规则",
+ "ADD_PROMPTING_RULE":"添加提示规则",
+ "MODIFY_PROMPTING_RULE":"修改提示规则",
+ "QUERY_PROMPTING_RULE":"查询提示规则",
+ "SUSPEND_RULE":"暂停规则",
+ "SUSPEND_RULE_FAIL":"暂停规则失败",
+ "ACTIVATE_RULE":"激活规则",
+ "ACTIVATE_RULE_FAIL":"激活规则失败",
+ "DELETED_RULE":"删除规则",
+ "DELETE_RULE_FAIL":"删除规则失败",
+ "QUERY_RULE_TYPE":"查询规则类型",
+ "QUERY_RULE_TYPE_FAIL":"查询规则类型失败",
+ "QUERY_RULE_BY_TYPE":"通过规则类型查询所有规则",
+ "QUERY_TIMING_REPORT_RULE":"查询定时输出规则",
+ "ADD_TIMING_REPORT_RULE":"添加定时输出规则",
+ "MODIFY_TIMING_REPORT_RULE":"修改定时输出规则",
+ "QUERY_TIMING_REPORT_TASK_LOG":"查询定时输出任务的执行日志",
+ "DELETED_TIMING_REPORT_RULE":"删除定时输出规则",
+ "DELETED_TIMING_REPORT_RULE_FAIL":"删除定时输出规则失败",
+ "ACTIVATE_TIMING_REPORT_RULE":"激活定时输出规则",
+ "ACTIVATE_TIMING_REPORT_RULE_FAIL":"激活定时输出规则失败",
+ "SUSPEND_TIMING_REPORT_RULE":"暂停定时输出规则",
+ "SUSPEND_TIMING_REPORT_RULE_FAIL":"暂停定时输出规则失败",
+ "QUERY_HISTORY_TIMING_REPORT_RULE":"查询历史定时输出规则",
+ "ADD_HISTORY_TIMING_REPORT_RULE":"添加历史定时输出规则",
+ "MODIFY_HISTORY_TIMING_REPORT_RULE":"修改历史定时输出规则",
+ "DELETED_HISTORY_TIMING_REPORT_RULE":"删除历史定时输出规则",
+ "DELETED_HISTORY_TIMING_REPORT_RULE_FAIL":"删除历史定时输出规则失败",
+ "ACTIVATE_HISTORY_TIMING_REPORT_RULE":"激活历史定时输出规则",
+ "ACTIVATE_HISTORY_TIMING_REPORT_RULE_FAIL":"激活历史定时输出规则失败",
+ "SUSPEND_HISTORY_TIMING_REPORT_RULE":"暂停历史定时输出规则",
+ "SUSPEND_HISTORY_TIMING_REPORT_RULE_FAIL":"暂停历史定时输出规则失败",
+ "QUERY_HISTORY_TIMING_REPORT_TASK_LOG":"查询历史定时输出任务的执行日志",
+ "ADD_HISTORY_ALARM_QUERY_COND":"添加历史告警查询条件",
+ "MODIFY_HISTORY_ALARM_QUERY_COND":"修改历史告警查询条件",
+ "QUERY_HISTORY_ALARM_QUERY_COND":"查询历史告警查询条件",
+ "DELETED_HISTORY_ALARM_QUERY_COND":"删除历史告警查询条件",
+ "ADD_NOTIFICATION_QUERY_COND":"添加通知查询条件",
+ "MODIFY_NOTIFICATION_QUERY_COND":"修改通知查询条件",
+ "QUERY_NOTIFICATION_QUERY_COND":"查询通知查询条件",
+ "DELETED_NOTIFICATION_QUERY_COND":"删除通知查询条件",
+ "QUERY_BASIC_STATISTIC_TEMPLATE":"查询基础统计模板",
+ "ADD_BASIC_STATISTIC_TEMPLATE":"添加基础统计模板",
+ "MODIFY_BASIC_STATISTIC_TEMPLATE":"修改基础统计模板",
+ "DELETED_BASIC_STATISTIC_TEMPLATE":"删除基础统计模板",
+ "MODIFY_BASIC_STATISTIC_TEMPLATE_AS_DEFAULT":"修改基础统计模板为默认模板",
+ "QUERY_BUSY_TIME_STATISTIC_TEMPLATE":"查询忙时统计模板",
+ "ADD_BUSY_TIME_STATISTIC_TEMPLATE":"添加忙时统计模板",
+ "MODIFY_BUSY_TIME_STATISTIC_TEMPLATE":"修改忙时统计模板",
+ "DELETED_BUSY_TIME_STATISTIC_TEMPLATE":"删除忙时统计模板",
+ "MODIFY_BUSY_TIME_STATISTIC_TEMPLATE_AS_DEFAULT":"修改忙时统计模板为默认模板"
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/DateForJsonSerializer.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/DateForJsonSerializer.java
new file mode 100644
index 0000000..fe36d74
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/DateForJsonSerializer.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.utils;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class DateForJsonSerializer extends JsonSerializer < Date > {
+ @Override
+ public void serialize( Date date, JsonGenerator jsonGenerator,
+ SerializerProvider serializerProvider ) throws IOException, JsonProcessingException {
+ if ( date != null ) {
+ SimpleDateFormat formatter = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ss.SSSXXX" );
+ String formattedDate = formatter.format( date );
+ jsonGenerator.writeString( formattedDate );
+ }
+ }
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/DbDaoUtil.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/DbDaoUtil.java
new file mode 100644
index 0000000..fcd90aa
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/DbDaoUtil.java
@@ -0,0 +1,93 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.utils;
+
+import io.dropwizard.db.DataSourceFactory;
+import io.dropwizard.jdbi.DBIFactory;
+import io.dropwizard.setup.Environment;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import lombok.extern.slf4j.Slf4j;
+import org.glassfish.hk2.api.IterableProvider;
+import org.jvnet.hk2.annotations.Service;
+import org.skife.jdbi.v2.DBI;
+import org.skife.jdbi.v2.Handle;
+
+@Singleton
+@Service
+@Slf4j
+public class DbDaoUtil {
+
+ private static DBI jdbi;
+
+ @Inject
+ private static IterableProvider<Environment> environmentProvider;
+
+ @Inject
+ private static IterableProvider<DataSourceFactory> dataSourceFactoryProvider;
+
+ static {
+ if (jdbi == null) {
+ synchronized (DbDaoUtil.class) {
+ if (jdbi == null) {
+ final DBIFactory factory = new DBIFactory();
+ jdbi = factory
+ .build(environmentProvider.get(), dataSourceFactoryProvider.get(), "mysql");
+ }
+ }
+ }
+ }
+
+ public <K> K getDao(Class<K> clazz) {
+ try {
+ return jdbi.open(clazz);
+ } catch (Exception e) {
+ log.warn("get object instance of Dao error.", e);
+ }
+ return null;
+ }
+
+ public Handle getHandle() {
+ try {
+ return jdbi.open();
+ } catch (Exception e) {
+ log.warn("get object instance of Dao error.", e);
+ }
+ return null;
+ }
+
+ public void close(Object obj) {
+ if (obj != null) {
+ try {
+ jdbi.close(obj);
+ } catch (Exception e) {
+ log.warn("close jdbi connection error.", e);
+ }
+ }
+ }
+
+ public <T> T getJdbiDaoByOnDemand(Class<T> daoClazz) {
+
+ return jdbi.onDemand(daoClazz);
+
+ }
+
+ public <T> T getJdbiDaoByOpen(Class<T> daoClazz) {
+
+ return jdbi.open(daoClazz);
+
+ }
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/JacksonUtil.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/JacksonUtil.java
new file mode 100644
index 0000000..caef0b0
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/JacksonUtil.java
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.utils;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+
+public class JacksonUtil {
+
+ private JacksonUtil() {
+
+ }
+
+ public static String beanToJson(Object obj) throws JsonProcessingException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ return objectMapper.writeValueAsString(obj);
+ }
+
+ public static <T> T jsonToBean(String json, Class<T> cls) throws IOException {
+ ObjectMapper objectMapper = new ObjectMapper();
+ if (json == null) {
+ return objectMapper.readValue("{}", cls);
+ }
+ return objectMapper.readValue(json, cls);
+ }
+
+ public static <T> T jsonToBeanByMatchAttribute(String json, Class<T> cls)
+ throws JsonParseException,
+ JsonMappingException, IOException {
+ if (JudgeNullUtil.isEmpty(json)) {
+ return null;
+ }
+ ObjectMapper objectMapper = new ObjectMapper();
+ objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ return objectMapper.readValue(json, cls);
+ }
+
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/JudgeNullUtil.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/JudgeNullUtil.java
new file mode 100644
index 0000000..beed186
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/JudgeNullUtil.java
@@ -0,0 +1,49 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.utils;
+
+import java.util.List;
+
+public class JudgeNullUtil {
+
+ private JudgeNullUtil() {
+
+ }
+
+ public static boolean isEmpty( short[] shorts ) {
+ return shorts == null || shorts.length == 0;
+ }
+
+ public static boolean isEmpty( int[] ints ) {
+ return ints == null || ints.length == 0;
+ }
+
+ public static boolean isEmpty( long[] longs ) {
+ return longs == null || longs.length == 0;
+ }
+
+ public static boolean isEmpty( Object[] obj ) {
+ return obj == null || obj.length == 0;
+ }
+
+ public static boolean isEmpty( String str ) {
+ return str == null || "".equals( str.trim() );
+ }
+
+ public static boolean isEmpty( List < ? > list ) {
+ return list == null || list.isEmpty();
+ }
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/LanguageUtil.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/LanguageUtil.java
new file mode 100644
index 0000000..484b9a4
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/LanguageUtil.java
@@ -0,0 +1,53 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.utils;
+
+import java.util.Locale;
+import javax.servlet.http.HttpServletRequest;
+import org.openo.holmes.common.constant.AlarmConst;
+
+public class LanguageUtil {
+
+ private LanguageUtil() {
+ }
+
+ public static String getLanguage(HttpServletRequest servletRequest) {
+ String language = (String) servletRequest.getHeader("language-option");
+ if (JudgeNullUtil.isEmpty(language)) {
+ language = AlarmConst.ZH_CN;
+ }
+ if (language.startsWith(AlarmConst.I18N_ZH)) {
+ language = AlarmConst.I18N_ZH;
+ } else if (language.startsWith(AlarmConst.I18N_EN)) {
+ language = AlarmConst.I18N_EN;
+ }
+ return language;
+ }
+
+ public static Locale getLocale(HttpServletRequest servletRequest) {
+ String language = (String) servletRequest.getHeader("language-option");
+ if (JudgeNullUtil.isEmpty(language)) {
+ language = AlarmConst.ZH_CN;
+ }
+ if (language.startsWith(AlarmConst.I18N_ZH)) {
+ language = AlarmConst.I18N_ZH;
+ } else if (language.startsWith(AlarmConst.I18N_EN)) {
+ language = AlarmConst.I18N_EN;
+ }
+ Locale locale = new Locale(language);
+ return locale;
+ }
+}
diff --git a/holmes-actions/src/main/java/org/openo/holmes/common/utils/UserUtil.java b/holmes-actions/src/main/java/org/openo/holmes/common/utils/UserUtil.java
new file mode 100644
index 0000000..723b489
--- /dev/null
+++ b/holmes-actions/src/main/java/org/openo/holmes/common/utils/UserUtil.java
@@ -0,0 +1,35 @@
+/**
+ * Copyright 2017 ZTE Corporation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openo.holmes.common.utils;
+
+import javax.servlet.http.HttpServletRequest;
+import org.openo.holmes.common.constant.AlarmConst;
+
+public class UserUtil {
+
+ private UserUtil() {
+
+ }
+
+ public static String getUserName(HttpServletRequest request) {
+ String userName = AlarmConst.ADMIN;
+ String sessionName = (String) request.getHeader("username");
+ if (sessionName != null) {
+ userName = sessionName.toLowerCase();
+ }
+ return userName;
+ }
+}