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.regex.Matcher;
22 import java.util.regex.Pattern;
23 import javax.xml.bind.annotation.XmlElement;
24 import javax.xml.bind.annotation.XmlRootElement;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalDateAndTime;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.internalTypes.InternalSeverity;
28 @XmlRootElement(name = "ProblemNotification")
29 public class ProblemNotificationXml extends MwtNotificationBase implements GetEventType {
31 private static String EVENTTYPE = "ProblemNotification";
32 private static final Pattern pattern = Pattern.compile(".*\\[layerProtocol=(.*)\\]");
34 * The leading indication for notification or events that are not in the
35 * currentProblem data of the ONF Coremodel
37 private static final String NOCURRENTPROBLEMINDICATION = "#";
39 @XmlElement(name = "problem")
40 private String problem;
42 @XmlElement(name = "severity")
43 private InternalSeverity severity;
45 public ProblemNotificationXml() {
50 * Generic Problem. All the parameters are of type Strings according to YANG
53 * @param nodeName Name of mountpoint
54 * @param uuId Name of Interface Pac
55 * @param problemNameString Name of the problem
56 * @param problemSeverityString Severitycode of the problem
57 * @param counterString Counter from device
58 * @param internaltimeStampString Timestamp according to internal format.
60 public ProblemNotificationXml(String nodeName, String uuId, String problemNameString,
61 InternalSeverity problemSeverityString, String counterString, InternalDateAndTime internaltimeStampString) {
62 super(nodeName, counterString, internaltimeStampString, uuId);
63 this.problem = problemNameString;
64 this.severity = problemSeverityString;
67 public String getProblem() {
71 public InternalSeverity getSeverity() {
75 public boolean isNotManagedAsCurrentProblem() {
76 return problem.startsWith(NOCURRENTPROBLEMINDICATION);
80 * Create a specific ES id for the current log.
82 * @return a string with the generated ES Id
85 public String genSpecificEsId() {
89 Matcher matcher = pattern.matcher(getObjectId());
90 if (matcher.matches() && matcher.groupCount() == 1) {
91 uuId = matcher.group(1);
96 StringBuffer strBuf = new StringBuffer();
97 strBuf.append(getNodeName());
101 strBuf.append(getProblem());
102 return strBuf.toString();
106 public String toString() {
107 return "ProblemNotificationXml [problem=" + problem + ", severity=" + severity + ", toString()="
108 + super.toString() + "]";
112 public String getEventType() {