1 /*******************************************************************************
2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
17 ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml;
20 import com.fasterxml.jackson.annotation.JsonIgnore;
21 import java.util.List;
22 import javax.xml.bind.annotation.XmlElement;
23 import javax.xml.bind.annotation.XmlRootElement;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.FaultEntityManager;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
27 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultcurrent;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentBuilder;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultlog;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogBuilder;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogEntity;
33 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
34 import org.slf4j.Logger;
36 @XmlRootElement(name = "ProblemNotification")
37 public class ProblemNotificationXml extends MwtNotificationBase implements GetEventType {
39 private static String EVENTTYPE = "ProblemNotification";
41 @XmlElement(name = "problem")
42 private String problem;
44 @XmlElement(name = "severity")
45 private InternalSeverity severity;
47 public ProblemNotificationXml() {
52 * Generic Problem. All the parameters are of type Strings according to YANG
55 * @param nodeName Name of mountpoint
56 * @param uuId Name of Interface Pac
57 * @param problemNameString Name of the problem
58 * @param problemSeverityString Severitycode of the problem
59 * @param counter Counter from device
60 * @param internaltimeStampString Timestamp according to internal format.
62 public ProblemNotificationXml(String nodeName, String uuId, String problemNameString,
63 InternalSeverity problemSeverityString, Integer counter, InternalDateAndTime internaltimeStampString) {
64 super(nodeName, counter, internaltimeStampString, uuId);
65 this.problem = problemNameString;
66 this.severity = problemSeverityString;
69 public ProblemNotificationXml(FaultlogEntity input) {
70 this(input.getNodeId(), input.getObjectId(), input.getProblem(), InternalSeverity.valueOf(input.getSeverity()),
71 input.getCounter(), InternalDateAndTime.valueOf(input.getTimestamp()));
74 public String getProblem() {
78 public InternalSeverity getSeverity() {
82 public boolean isNotManagedAsCurrentProblem() {
83 return ! FaultEntityManager.isManagedAsCurrentProblem(getProblem());
86 public boolean isNoAlarmIndication() {
87 return severity.isNoAlarmIndication();
91 * Create a specific ES id for the current log.
92 * @return a string with the generated ES Id
95 public String genSpecificEsId() {
96 return FaultEntityManager.genSpecificEsId(getNodeName(), getObjectId(), getProblem());
100 public Faultlog getFaultlog(SourceType sourceType) {
101 return new FaultlogBuilder().setNodeId(getNodeName()).setCounter(Integer.parseInt(getCounter()))
102 .setObjectId(getObjectId()).setProblem(getProblem()).setSourceType(sourceType)
103 .setSeverity(getSeverity().toDataProviderSeverityType()).setTimestamp(new DateAndTime(getTimeStamp()))
108 public Faultcurrent getFaultcurrent() {
109 return new FaultcurrentBuilder().setNodeId(getNodeName()).setCounter(Integer.parseInt(getCounter()))
110 .setObjectId(genSpecificEsId()).setProblem(getProblem())
111 .setSeverity(getSeverity().toDataProviderSeverityType()).setTimestamp(new DateAndTime(getTimeStamp()))
116 public String toString() {
117 return "ProblemNotificationXml [problem=" + problem + ", severity=" + severity + ", toString()="
118 + super.toString() + "]";
122 public String getEventType() {
127 * LOG the newly added problems of the interface pac
128 * @param log of logger
129 * @param uuid as log info
130 * @param resultList with all problems
131 * @param idxStart start of listing till end
133 public static void debugResultList(Logger log, String uuid, List<ProblemNotificationXml> resultList, int idxStart) {
134 if (log.isDebugEnabled()) {
135 StringBuffer sb = new StringBuffer();
137 for (int t = idxStart; t < resultList.size(); t++) {
140 sb.append(resultList.get(t));
143 log.debug("Found problems {} {}", uuid, sb.toString());