aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSingal, Kapil (ks220y) <ks220y@att.com>2020-02-17 17:46:59 -0500
committerSingal, Kapil (ks220y) <ks220y@att.com>2020-02-17 17:46:59 -0500
commit7c2f57f8efc971f1d93a544256c084f52f7c3ed2 (patch)
tree96121599bb206d4f44933b7686ec17bca1b2c041
parent599315984b449ca05f00b35037a103f1dc335030 (diff)
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) <ks220y@att.com>
-rwxr-xr-xsli/common/pom.xml6
-rw-r--r--sli/common/src/main/java/org/onap/ccsdk/sli/core/sli/SvcLogicNode.java108
-rw-r--r--sliPluginUtils/provider/src/main/java/org/onap/ccsdk/sli/core/slipluginutils/SliStringUtils.java6
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
@@ -43,6 +43,10 @@
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-text</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>dblib-provider</artifactId>
<version>${project.version}</version>
@@ -56,7 +60,7 @@
<dependency>
<groupId>org.onap.logging-analytics</groupId>
<artifactId>logging-slf4j</artifactId>
- </dependency>
+ </dependency>
<!-- Testing Dependencies -->
<dependency>
<groupId>junit</groupId>
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<String, SvcLogicExpression> attributes;
private HashMap<String, SvcLogicNode> outcomes;
private HashMap<String, SvcLogicExpression> 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<Map.Entry<String, SvcLogicNode>> outcomeSet = getOutcomeSet();
-
+
if (outcomeSet == null)
{
return;
}
-
+
for (Iterator<Map.Entry<String, SvcLogicNode>> iter = outcomeSet.iterator(); iter.hasNext();)
{
Map.Entry<String, SvcLogicNode> 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<Map.Entry<String, SvcLogicNode>> getOutcomeSet()
{
if (outcomes == null)
{
return new HashSet<>();
}
-
+
return outcomes.entrySet();
-
+
}
-
+
public Set<Map.Entry<String, SvcLogicExpression>> 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=<<table border=\"0\" cellborder=\"1\" align=\"left\">");
@@ -292,7 +292,7 @@ public class SvcLogicNode implements Serializable {
sbuff.append(nodeName);
sbuff.append("</td></tr>");
}
-
+
Set<Map.Entry<String, SvcLogicExpression>> attrSet = attributes.entrySet();
for (Iterator<Map.Entry<String, SvcLogicExpression>> iter = attrSet.iterator() ; iter.hasNext();)
{
@@ -304,15 +304,15 @@ public class SvcLogicNode implements Serializable {
sbuff.append("</td></tr>");
}
sbuff.append("</table>>];");
-
+
pstr.println(sbuff.toString());
-
-
+
+
if (outcomes != null)
{
TreeMap<String, SvcLogicNode> sortedOutcomes = new TreeMap<>(outcomes);
Set<Map.Entry<String, SvcLogicNode>> outcomeSet = sortedOutcomes.entrySet();
-
+
for (Iterator<Map.Entry<String, SvcLogicNode>> iter = outcomeSet.iterator(); iter.hasNext();)
{
Map.Entry<String, SvcLogicNode> 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<Map.Entry<String, SvcLogicExpression>> attrSet = attributes.entrySet();
for (Iterator<Map.Entry<String, SvcLogicExpression>> 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("</outcome>\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.
* <p>
@@ -456,7 +456,7 @@ public class SliStringUtils implements SvcLogicJavaPlugin {
public static void xmlEscapeText(Map<String, String> 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);
}