From 7c2f57f8efc971f1d93a544256c084f52f7c3ed2 Mon Sep 17 00:00:00 2001 From: "Singal, Kapil (ks220y)" Date: Mon, 17 Feb 2020 17:46:59 -0500 Subject: Refactoring deprecated lang3.StringEscapeUtils Replace deprecated org.apache.commons.lang3.StringEscapeUtils with org.apache.commons.text.StringEscapeUtils Change-Id: Ib0303919d883a577effbb6fa15ddeb289cb936fc Issue-ID: CCSDK-2104 Signed-off-by: Singal, Kapil (ks220y) --- sli/common/pom.xml | 6 +- .../org/onap/ccsdk/sli/core/sli/SvcLogicNode.java | 108 ++++++++++----------- .../sli/core/slipluginutils/SliStringUtils.java | 6 +- 3 files changed, 62 insertions(+), 58 deletions(-) diff --git a/sli/common/pom.xml b/sli/common/pom.xml index 7ba72192..8290a42b 100755 --- a/sli/common/pom.xml +++ b/sli/common/pom.xml @@ -42,6 +42,10 @@ org.apache.commons commons-lang3 + + org.apache.commons + commons-text + org.onap.ccsdk.sli.core dblib-provider @@ -56,7 +60,7 @@ org.onap.logging-analytics logging-slf4j - + junit diff --git a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java index 72cfea50..b0d4fc05 100644 --- a/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java +++ b/sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java @@ -10,9 +10,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,7 +22,7 @@ */ /** - * + * */ package org.onap.ccsdk.sli.core.sli; @@ -36,17 +36,17 @@ import java.util.Set; import java.util.HashSet; import java.util.TreeMap; -import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.text.StringEscapeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class SvcLogicNode implements Serializable { - + private static final Logger LOG = LoggerFactory .getLogger(SvcLogicExprListener.class); - + private static final long serialVersionUID = 2L; - + private String nodeName; private int nodeId; private String nodeType; @@ -57,7 +57,7 @@ public class SvcLogicNode implements Serializable { private HashMap attributes; private HashMap outcomes; private HashMap parameters; - + public SvcLogicNode(int nodeId, String nodeType, SvcLogicGraph graph) { this.nodeId = nodeId; @@ -67,9 +67,9 @@ public class SvcLogicNode implements Serializable { attributes = new HashMap<> (); parameters = new HashMap<> (); outcomes = null; - + } - + public SvcLogicNode(int nodeId, String nodeType, String nodeName, SvcLogicGraph graph) throws DuplicateValueException { this.nodeId = nodeId; @@ -81,28 +81,28 @@ public class SvcLogicNode implements Serializable { outcomes = null; graph.setNamedNode(nodeName, this); } - - + + public int getNodeId() { return nodeId; } - + public String getNodeName() { return nodeName; } - + public String getNodeType() { return nodeType; } - + public SvcLogicGraph getGraph() { return graph; } - + public int getNumOutcomes() { if (outcomes == null) @@ -114,7 +114,7 @@ public class SvcLogicNode implements Serializable { return outcomes.size(); } } - + public SvcLogicExpression getAttribute(String name) { if (attributes.containsKey(name)) @@ -125,28 +125,28 @@ public class SvcLogicNode implements Serializable { { return null; } - + } - + public void setAttribute(String name, String value) throws SvcLogicException { setAttribute(name, new SvcLogicAtom("STRING", value)); } - + public void setAttribute(String name, SvcLogicExpression value) throws SvcLogicException { if (attributes.containsKey(name)) { throw new DuplicateValueException("Duplicate attribute "+name); } - + attributes.put(name, value); } - + public void mapParameter(String name, String value) throws SvcLogicException { - + if (parameters.containsKey(name)) { throw new DuplicateValueException("Duplicate parameter "+name); @@ -163,7 +163,7 @@ public class SvcLogicNode implements Serializable { int lastParen = value.lastIndexOf("`"); String evalExpr = value.trim().substring(1, lastParen); parmValue = SvcLogicExpressionFactory.parse(evalExpr); - + } else { @@ -185,7 +185,7 @@ public class SvcLogicNode implements Serializable { throw new SvcLogicException(e.getMessage()); } } - + public SvcLogicExpression getParameter(String name) { if (parameters.containsKey(name)) @@ -197,23 +197,23 @@ public class SvcLogicNode implements Serializable { return null; } } - + public boolean isVisited() { return visited; } public void setVisited(boolean visited, boolean recursive) { this.visited = visited; - + if (recursive) { Set> outcomeSet = getOutcomeSet(); - + if (outcomeSet == null) { return; } - + for (Iterator> iter = outcomeSet.iterator(); iter.hasNext();) { Map.Entry curOutcome = iter.next(); @@ -222,14 +222,14 @@ public class SvcLogicNode implements Serializable { } } } - + public void addOutcome(String outcomeValue, SvcLogicNode node) throws SvcLogicException { if (outcomes == null) { outcomes = new HashMap<>(); } - + if (outcomeValue.length() == 0) { outcomeValue = "\"\""; } @@ -237,35 +237,35 @@ public class SvcLogicNode implements Serializable { { throw new DuplicateValueException("Duplicate outcome value "+outcomeValue); } - + outcomes.put(outcomeValue, node); } - + public Set> getOutcomeSet() { if (outcomes == null) { return new HashSet<>(); } - + return outcomes.entrySet(); - + } - + public Set> getParameterSet() { if (parameters == null) { return new HashSet<>(); } - + return parameters.entrySet(); - + } - + public void printAsGv(PrintStream pstr) { - + if (visited) { return; @@ -274,9 +274,9 @@ public class SvcLogicNode implements Serializable { { visited = true; } - + StringBuffer sbuff = new StringBuffer(); - + sbuff.append("node"); sbuff.append(nodeId); sbuff.append(" [ shape=none, margin=0, label=<"); @@ -292,7 +292,7 @@ public class SvcLogicNode implements Serializable { sbuff.append(nodeName); sbuff.append(""); } - + Set> attrSet = attributes.entrySet(); for (Iterator> iter = attrSet.iterator() ; iter.hasNext();) { @@ -304,15 +304,15 @@ public class SvcLogicNode implements Serializable { sbuff.append(""); } sbuff.append("
>];"); - + pstr.println(sbuff.toString()); - - + + if (outcomes != null) { TreeMap sortedOutcomes = new TreeMap<>(outcomes); Set> outcomeSet = sortedOutcomes.entrySet(); - + for (Iterator> iter = outcomeSet.iterator(); iter.hasNext();) { Map.Entry curOutcome = iter.next(); @@ -323,7 +323,7 @@ public class SvcLogicNode implements Serializable { } } } - + public void printAsXml(PrintStream pstr, int indentLvl) { if (visited) @@ -337,7 +337,7 @@ public class SvcLogicNode implements Serializable { } pstr.print("<"); pstr.print(this.getNodeType()); - + Set> attrSet = attributes.entrySet(); for (Iterator> iter = attrSet.iterator() ; iter.hasNext();) { @@ -348,7 +348,7 @@ public class SvcLogicNode implements Serializable { pstr.print(curAttr.getValue()); pstr.print("'`"); } - + if ((parameters == null || parameters.isEmpty()) && (outcomes == null || outcomes.isEmpty())) { @@ -360,7 +360,7 @@ public class SvcLogicNode implements Serializable { { pstr.print(">\n"); } - + // Print parameters (if any) if (parameters != null) { @@ -405,7 +405,7 @@ public class SvcLogicNode implements Serializable { pstr.print("\n"); } } - + // Print node end tag for (int i = 0 ; i < indentLvl ; i++) { @@ -415,7 +415,7 @@ public class SvcLogicNode implements Serializable { pstr.print(this.getNodeType()); pstr.print(">\n"); pstr.flush(); - + } @@ -429,7 +429,7 @@ public class SvcLogicNode implements Serializable { { return null; } - + if (outcomes.containsKey(value)) { return outcomes.get(value); diff --git a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java index d343ce25..fdc057b2 100644 --- a/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java +++ b/sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java @@ -27,7 +27,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.Map; -import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.text.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.onap.ccsdk.sli.core.sli.SvcLogicContext; import org.onap.ccsdk.sli.core.sli.SvcLogicException; @@ -334,7 +334,7 @@ public class SliStringUtils implements SvcLogicJavaPlugin { ctx.setAttribute(parameters.get("outputPath"), parameters.get(INPUT_PARAM_SOURCE) .replaceAll(parameters.get(INPUT_PARAM_TARGET), parameters.get("replacement"))); } - + /** * Provides substring functionality to Directed Graphs. *

@@ -456,7 +456,7 @@ public class SliStringUtils implements SvcLogicJavaPlugin { public static void xmlEscapeText(Map inParams, SvcLogicContext ctx) { String source = inParams.get(INPUT_PARAM_SOURCE); String target = inParams.get(INPUT_PARAM_TARGET); - source = StringEscapeUtils.escapeXml(source); + source = StringEscapeUtils.escapeXml10(source); ctx.setAttribute(target, source); } -- cgit 1.2.3-korg