diff options
author | 2018-01-26 17:31:00 +0800 | |
---|---|---|
committer | 2018-01-26 17:31:00 +0800 | |
commit | 2f92be933fc2ef3ccf1f44572a9be99058dd7ec0 (patch) | |
tree | 6348c4ea65e60f3ebefcbf00695ec85b8cc576f2 | |
parent | 3062341deb4383333943f6a0f13b40d368187c25 (diff) |
Fix IQ Findings
Change-Id: I0ab0e2a9f5c3b7e3fa183ddbf7e4ecd2d4ed41ec
Issue-ID: HOLMES-116
Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
-rw-r--r-- | holmes-actions/pom.xml | 4 | ||||
-rw-r--r-- | holmes-actions/src/main/java/org/onap/holmes/common/api/stat/Alarm.java | 89 | ||||
-rw-r--r-- | holmes-actions/src/main/java/org/onap/holmes/common/dcae/DcaeConfigurationQuery.java | 4 | ||||
-rw-r--r-- | pom.xml | 7 |
4 files changed, 6 insertions, 98 deletions
diff --git a/holmes-actions/pom.xml b/holmes-actions/pom.xml index f39f227..86c0433 100644 --- a/holmes-actions/pom.xml +++ b/holmes-actions/pom.xml @@ -81,10 +81,6 @@ <version>3.10.1</version>
</dependency>
<dependency>
- <groupId>org.jdom</groupId>
- <artifactId>jdom</artifactId>
- </dependency>
- <dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
</dependency>
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/api/stat/Alarm.java b/holmes-actions/src/main/java/org/onap/holmes/common/api/stat/Alarm.java index be876e0..9822076 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/api/stat/Alarm.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/api/stat/Alarm.java @@ -16,21 +16,12 @@ package org.onap.holmes.common.api.stat;
-import java.io.Serializable;
-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;
+import net.sf.json.JSONObject;
+
+import java.io.Serializable;
+import java.util.*;
@Getter
@@ -83,47 +74,6 @@ public class Alarm implements AplusData, Cloneable, Serializable { private int linkType = -1;
private int centerType;
- public static Alarm valueOf(String xmlString) {
- Element element;
- 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 ("byte".equals(type)) {
- field.set(alarm, Byte.parseByte(attr.getValue()));
- } else if ("long".equals(type)) {
- field.set(alarm, Long.parseLong(attr.getValue()));
- } else if ("String".equals(type)) {
- 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;
- }
-
public void addLinkIdNodeIdx(int linkId, int index) {
linkIdNodeIdxMap.put(linkId, index);
}
@@ -161,37 +111,8 @@ public class Alarm implements AplusData, Cloneable, Serializable { @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);
+ return JSONObject.fromObject(this).toString();
}
@Override
diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/dcae/DcaeConfigurationQuery.java b/holmes-actions/src/main/java/org/onap/holmes/common/dcae/DcaeConfigurationQuery.java index 597e879..4f8a0a5 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/dcae/DcaeConfigurationQuery.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/dcae/DcaeConfigurationQuery.java @@ -15,10 +15,6 @@ */ package org.onap.holmes.common.dcae; -import javax.ws.rs.client.Client; -import javax.ws.rs.client.ClientBuilder; -import javax.ws.rs.client.WebTarget; -import org.glassfish.jersey.client.ClientConfig; import org.onap.holmes.common.config.MicroServiceConfig; import org.onap.holmes.common.dcae.entity.DcaeConfigurations; import org.onap.holmes.common.dcae.utils.DcaeConfigurationParser; @@ -104,11 +104,6 @@ <version>${quartz.version}</version>
</dependency>
<dependency>
- <groupId>org.jdom</groupId>
- <artifactId>jdom</artifactId>
- <version>1.1.3</version>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
@@ -159,7 +154,7 @@ <dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
- <version>5.10.1</version>
+ <version>5.11.3</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
|