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;
22 import java.util.List;
23 import java.util.regex.Matcher;
24 import java.util.regex.Pattern;
25 import javax.xml.bind.annotation.XmlElement;
26 import javax.xml.bind.annotation.XmlRootElement;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
29 import org.slf4j.Logger;
31 @XmlRootElement(name = "ProblemNotification")
32 public class ProblemNotificationXml extends MwtNotificationBase implements GetEventType {
34 private static String EVENTTYPE = "ProblemNotification";
35 private static final Pattern pattern = Pattern.compile(".*\\[layerProtocol=(.*)\\]");
37 * The leading indication for notification or events that are not in the
38 * currentProblem data of the ONF Coremodel
40 private static final String NOCURRENTPROBLEMINDICATION = "#";
42 @XmlElement(name = "problem")
43 private String problem;
45 @XmlElement(name = "severity")
46 private InternalSeverity severity;
48 public ProblemNotificationXml() {
53 * Generic Problem. All the parameters are of type Strings according to YANG
56 * @param nodeName Name of mountpoint
57 * @param uuId Name of Interface Pac
58 * @param problemNameString Name of the problem
59 * @param problemSeverityString Severitycode of the problem
60 * @param counterString Counter from device
61 * @param internaltimeStampString Timestamp according to internal format.
63 public ProblemNotificationXml(String nodeName, String uuId, String problemNameString,
64 InternalSeverity problemSeverityString, String counterString, InternalDateAndTime internaltimeStampString) {
65 super(nodeName, counterString, internaltimeStampString, uuId);
66 this.problem = problemNameString;
67 this.severity = problemSeverityString;
70 public String getProblem() {
74 public InternalSeverity getSeverity() {
78 public boolean isNotManagedAsCurrentProblem() {
79 return problem.startsWith(NOCURRENTPROBLEMINDICATION);
83 * Create a specific ES id for the current log.
85 * @return a string with the generated ES Id
88 public String genSpecificEsId() {
92 Matcher matcher = pattern.matcher(getObjectId());
93 if (matcher.matches() && matcher.groupCount() == 1) {
94 uuId = matcher.group(1);
99 StringBuffer strBuf = new StringBuffer();
100 strBuf.append(getNodeName());
104 strBuf.append(getProblem());
105 return strBuf.toString();
110 public String toString() {
111 return "ProblemNotificationXml [problem=" + problem + ", severity=" + severity + ", toString()="
112 + super.toString() + "]";
116 public String getEventType() {
121 * LOG the newly added problems of the interface pac
126 public static void debugResultList(Logger log, String uuid, List<ProblemNotificationXml> resultList, int idxStart) {
127 if (log.isDebugEnabled()) {
128 StringBuffer sb = new StringBuffer();
130 for (int t = idxStart; t < resultList.size(); t++) {
133 sb.append(resultList.get(t));
136 log.debug("Found problems {} {}", uuid, sb.toString());