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==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml;
20 import java.util.regex.Matcher;
21 import java.util.regex.Pattern;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Fault;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentEntity;
26 public class FaultEntityManager {
28 private static final Pattern pattern = Pattern.compile(".*\\[layerProtocol=(.*)\\]");
31 * The leading indication for notification or events that are not in the currentProblem data of the ONF Coremodel
33 private static final String NOCURRENTPROBLEMINDICATION = "#";
36 * Specific problems are not moving into current problem list
38 * @param problemName to be verified
39 * @return true if problem is current
41 public static boolean isManagedAsCurrentProblem(String problemName) {
42 return !problemName.startsWith(NOCURRENTPROBLEMINDICATION);
45 public static boolean isManagedAsCurrentProblem(Fault problem) {
46 return isManagedAsCurrentProblem(problem.getProblem());
50 * Specific problems are not moving into current problem list
52 * @param fault to be verified
53 * @return true if cleared indication
55 public static boolean isNoAlarmIndication(Fault fault) {
56 InternalSeverity severity = InternalSeverity.valueOf(fault.getSeverity());
57 return severity.isNoAlarmIndication();
61 * Create a specific ES id for the current log.
63 * @return a string with the generated ES Id
65 public static String genSpecificEsId(String nodeName, String objectId, String problemName) {
69 Matcher matcher = pattern.matcher(objectId);
70 if (matcher.matches() && matcher.groupCount() == 1) {
71 uuId = matcher.group(1);
76 StringBuffer strBuf = new StringBuffer();
77 strBuf.append(nodeName);
81 strBuf.append(problemName);
82 return strBuf.toString();
88 * @param fault used to create uuid for faultcurrent
89 * @return String with Id
91 public static String genSpecificEsId(FaultcurrentEntity fault) {
92 return genSpecificEsId(fault.getNodeId(), fault.getObjectId(), fault.getProblem());