From d80880b097d08f9ab9dda54355216890a4b345dc Mon Sep 17 00:00:00 2001 From: rb7147 Date: Wed, 26 Jul 2017 10:11:15 -0400 Subject: [POLICY-117] Resolve the Policy Critical issues Change-Id: Ice72d7fa40151bff5db42f5dd632f04a3853b094 Signed-off-by: rb7147 --- .../openecomp/policy/xacml/action/FindAction.java | 25 ++++++---------------- .../custom/EcompFunctionDefinitionFactory.java | 5 ++++- .../FunctionDefinitionCustomRegexpMatch.java | 10 ++++++--- 3 files changed, 18 insertions(+), 22 deletions(-) (limited to 'ECOMP-PDP') diff --git a/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/action/FindAction.java b/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/action/FindAction.java index 2bcb903e8..5419b8946 100644 --- a/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/action/FindAction.java +++ b/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/action/FindAction.java @@ -20,7 +20,6 @@ package org.openecomp.policy.xacml.action; import java.io.BufferedReader; -import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; @@ -35,7 +34,6 @@ import javax.json.Json; import javax.json.JsonReader; import org.apache.http.HttpResponse; -import org.apache.http.client.ClientProtocolException; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; @@ -272,11 +270,8 @@ public class FindAction { output = output + out; } response = output; - } catch (ClientProtocolException e) { - LOGGER.error(e.getMessage()); - response = e.getMessage(); - } catch (IOException e) { - LOGGER.error(e.getMessage()); + } catch (Exception e) { + LOGGER.error(e.getMessage()+e); response = e.getMessage(); } finally { httpClient.getConnectionManager().shutdown(); @@ -313,11 +308,8 @@ public class FindAction { output = output + out; } response = output; - } catch (ClientProtocolException e) { - LOGGER.error(e.getMessage()); - response = e.getMessage(); - } catch (IOException e) { - LOGGER.error(e.getMessage()); + }catch (Exception e) { + LOGGER.error(e.getMessage() +e); response = e.getMessage(); } finally { httpClient.getConnectionManager().shutdown(); @@ -353,13 +345,10 @@ public class FindAction { output = output + out; } response = output; - } catch (ClientProtocolException e) { - LOGGER.error(e.getMessage()); + } catch (Exception e) { + LOGGER.error(e.getMessage() +e); response = e.getMessage(); - } catch (IOException e) { - LOGGER.error(e.getMessage()); - response = e.getMessage(); - } finally { + }finally { httpClient.getConnectionManager().shutdown(); } } diff --git a/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/custom/EcompFunctionDefinitionFactory.java b/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/custom/EcompFunctionDefinitionFactory.java index 202468feb..2cb8e67ae 100644 --- a/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/custom/EcompFunctionDefinitionFactory.java +++ b/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/custom/EcompFunctionDefinitionFactory.java @@ -24,6 +24,8 @@ import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.Map; +import org.openecomp.policy.common.logging.flexlogger.FlexLogger; +import org.openecomp.policy.common.logging.flexlogger.Logger; import org.openecomp.policy.xacml.pdp.std.functions.FunctionDefinitionCustomRegexpMatch; import com.att.research.xacml.api.Identifier; @@ -34,6 +36,7 @@ import com.att.research.xacmlatt.pdp.policy.FunctionDefinitionFactory; import com.att.research.xacmlatt.pdp.std.StdFunctions; public class EcompFunctionDefinitionFactory extends FunctionDefinitionFactory { + private static Logger logger = FlexLogger.getLogger(EcompFunctionDefinitionFactory.class); private static Map mapFunctionDefinitions = new HashMap<>(); private static boolean needMapInit = true; @@ -60,7 +63,7 @@ public class EcompFunctionDefinitionFactory extends FunctionDefinitionFactory { try { register((FunctionDefinition)(field.get(null))); } catch (IllegalAccessException ex) { - + logger.error(ex.getMessage() +ex); } } } diff --git a/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/pdp/std/functions/FunctionDefinitionCustomRegexpMatch.java b/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/pdp/std/functions/FunctionDefinitionCustomRegexpMatch.java index 5b84ab0f6..5c11f8c43 100644 --- a/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/pdp/std/functions/FunctionDefinitionCustomRegexpMatch.java +++ b/ECOMP-PDP/src/main/java/org/openecomp/policy/xacml/pdp/std/functions/FunctionDefinitionCustomRegexpMatch.java @@ -22,6 +22,9 @@ package org.openecomp.policy.xacml.pdp.std.functions; import java.util.List; +import org.openecomp.policy.common.logging.flexlogger.FlexLogger; +import org.openecomp.policy.common.logging.flexlogger.Logger; + import com.att.research.xacml.api.DataType; import com.att.research.xacml.api.DataTypeException; import com.att.research.xacml.api.Identifier; @@ -46,7 +49,7 @@ import com.att.research.xacmlatt.pdp.std.functions.FunctionDefinitionBase; * @param the java class for the data type of the function Input arguments */ public class FunctionDefinitionCustomRegexpMatch extends FunctionDefinitionBase { - + private static Logger logger = FlexLogger.getLogger(FunctionDefinitionCustomRegexpMatch.class); /** * Constructor - need dataTypeArgs input because of java Generic type-erasure during compilation. @@ -70,7 +73,7 @@ public class FunctionDefinitionCustomRegexpMatch extends FunctionDefinitionBa // get the regular expression FunctionArgument regexpArgument = arguments.get(0); - ConvertedArgument convertedArgument = new ConvertedArgument(regexpArgument, DataTypes.DT_STRING, false); + ConvertedArgument convertedArgument = new ConvertedArgument<>(regexpArgument, DataTypes.DT_STRING, false); if ( ! convertedArgument.isOk()) { return ExpressionResult.newError(getFunctionStatus(convertedArgument.getStatus())); } @@ -82,7 +85,7 @@ public class FunctionDefinitionCustomRegexpMatch extends FunctionDefinitionBa // now get the element to match FunctionArgument elementArgument = arguments.get(1); - ConvertedArgument convertedElement = new ConvertedArgument(elementArgument, this.getDataTypeArgs(), false); + ConvertedArgument convertedElement = new ConvertedArgument<>(elementArgument, this.getDataTypeArgs(), false); if ( ! convertedElement.isOk()) { return ExpressionResult.newError(getFunctionStatus(convertedElement.getStatus())); } @@ -93,6 +96,7 @@ public class FunctionDefinitionCustomRegexpMatch extends FunctionDefinitionBa try { elementValueString = this.getDataTypeArgs().toStringValue(elementValueObject); } catch (DataTypeException e) { + logger.error(e.getMessage() +e); String message = e.getMessage(); if (e.getCause() != null) { message = e.getCause().getMessage(); -- cgit 1.2.3-korg