summaryrefslogtreecommitdiffstats
path: root/ECOMP-PAP-REST
diff options
context:
space:
mode:
authorRavindra Bakkamanthala <rb7147@att.com>2017-05-15 12:53:18 -0400
committerRavindra Bakkamanthala <rb7147@att.com>2017-05-15 13:55:23 -0400
commit7e547eaa55920dfbc9691eab33bb728395b50cf2 (patch)
tree5d0d64928b4754f65b427cb79b43718f16019582 /ECOMP-PAP-REST
parentdda032f8bb161d54eb1f59de2b4a3efb774fc4d1 (diff)
Policy TestSuite Enabled
Change-Id: I9f98c7dcdcf98713d73544956d873a84fc82adf7 Signed-off-by: Ravindra Bakkamanthala <rb7147@att.com>
Diffstat (limited to 'ECOMP-PAP-REST')
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/XACMLPapServlet.java2
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ActionPolicy.java4
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ClosedLoopPolicy.java3
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ConfigPolicy.java1
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java22
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/DecisionPolicy.java8
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/FirewallConfigPolicy.java13
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java1
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java19
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDao.java8
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/BRMSDictionaryController.java4
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/EnforcerDictionaryController.java6
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/FirewallDictionaryController.java6
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java10
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/PushPolicyController.java2
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/SafePolicyController.java4
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/elk/client/PolicyElasticSearchController.java327
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/elk/client/PolicySearchController.java183
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/policycontroller/PolicyCreation.java2
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/service/DictionaryService.java126
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/util/JPAUtils.java4
-rw-r--r--ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDaoTest.java48
-rw-r--r--ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/xacml/rest/jpa/PolicyEntityTest.java2
23 files changed, 346 insertions, 459 deletions
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/XACMLPapServlet.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/XACMLPapServlet.java
index c39ae8cda..1b5f85477 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/XACMLPapServlet.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/XACMLPapServlet.java
@@ -1166,7 +1166,7 @@ public class XACMLPapServlet extends HttpServlet implements StdItemSetChangeList
try {
apiRequestHandler.doDelete(request, response, loggingContext, apiflag);
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
if(apiRequestHandler.getNewGroup()!=null){
groupChanged(apiRequestHandler.getNewGroup());
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ActionPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ActionPolicy.java
index b6a959bfc..aee2b3886 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ActionPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ActionPolicy.java
@@ -262,7 +262,7 @@ public class ActionPolicy extends Policy {
LOGGER.info("Action Body is succesfully saved at " + file.getAbsolutePath());
}
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
@@ -487,7 +487,7 @@ public class ActionPolicy extends Policy {
try {
jpaUtils = JPAUtils.getJPAUtilsInstance(XACMLPapServlet.getEmf());
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
Map<Datatype, List<FunctionDefinition>> functionMap = jpaUtils.getFunctionDatatypeMap();
Map<String, String> dropDownMap = new HashMap<String, String>();
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ClosedLoopPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ClosedLoopPolicy.java
index c2ab845ae..264602a1d 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ClosedLoopPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ClosedLoopPolicy.java
@@ -80,7 +80,7 @@ public class ClosedLoopPolicy extends Policy {
}
this.policyAdapter.setJsonBody(body);
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
if(policyName.endsWith(".xml")){
@@ -92,7 +92,6 @@ public class ClosedLoopPolicy extends Policy {
} catch (Exception e) {
LOGGER.error("Exception Occured while writing Configuration Data"+e);
- e.printStackTrace();
}
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ConfigPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ConfigPolicy.java
index ff8045890..cab76b9e5 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ConfigPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/ConfigPolicy.java
@@ -100,7 +100,6 @@ public class ConfigPolicy extends Policy {
}
} catch (IOException e) {
LOGGER.error("Exception Occured while writing Configuration Data"+e);
- e.printStackTrace();
}
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java
index 5eb3493f2..dcb2a93d4 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/CreateClosedLoopPerformanceMetrics.java
@@ -30,6 +30,15 @@ import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
+import org.apache.commons.io.FilenameUtils;
+import org.openecomp.policy.common.logging.eelf.MessageCodes;
+import org.openecomp.policy.common.logging.eelf.PolicyLogger;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
+import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
+
+import com.att.research.xacml.std.IdentifierImpl;
+
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
@@ -44,15 +53,10 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
-import org.apache.commons.io.FilenameUtils;
-import org.openecomp.policy.common.logging.eelf.MessageCodes;
-import org.openecomp.policy.common.logging.eelf.PolicyLogger;
-import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
-
-import com.att.research.xacml.std.IdentifierImpl;
-
public class CreateClosedLoopPerformanceMetrics extends Policy {
+ private static final Logger LOGGER = FlexLogger.getLogger(CreateClosedLoopPerformanceMetrics.class);
+
public CreateClosedLoopPerformanceMetrics() {
super();
}
@@ -68,7 +72,7 @@ public class CreateClosedLoopPerformanceMetrics extends Policy {
try {
body = jsonBody;
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
if(policyName.endsWith(".xml")){
policyName = policyName.substring(0, policyName.lastIndexOf(".xml"));
@@ -80,7 +84,7 @@ public class CreateClosedLoopPerformanceMetrics extends Policy {
out.close();
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/DecisionPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/DecisionPolicy.java
index 4c67d798a..e5a114ba8 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/DecisionPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/DecisionPolicy.java
@@ -39,6 +39,8 @@ import javax.persistence.Query;
import org.openecomp.policy.common.logging.eelf.MessageCodes;
import org.openecomp.policy.common.logging.eelf.PolicyLogger;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.controlloop.policy.builder.BuilderException;
import org.openecomp.policy.controlloop.policy.builder.Results;
import org.openecomp.policy.controlloop.policy.guard.Constraint;
@@ -77,7 +79,9 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinitionType;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableReferenceType;
public class DecisionPolicy extends Policy {
-
+
+ private static final Logger LOGGER = FlexLogger.getLogger(DecisionPolicy.class);
+
public static final String FUNCTION_NOT = "urn:oasis:names:tc:xacml:1.0:function:not";
private static final String AAFProvider = "AAF";
public static final String GUARD_YAML = "GUARD_YAML";
@@ -595,7 +599,7 @@ public class DecisionPolicy extends Policy {
try {
jpaUtils = JPAUtils.getJPAUtilsInstance(XACMLPapServlet.getEmf());
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
Map<Datatype, List<FunctionDefinition>> functionMap = jpaUtils.getFunctionDatatypeMap();
Map<String, String> dropDownMap = new HashMap<String, String>();
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/FirewallConfigPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/FirewallConfigPolicy.java
index 509da0b61..9e590732c 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/FirewallConfigPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/FirewallConfigPolicy.java
@@ -114,7 +114,7 @@ public class FirewallConfigPolicy extends Policy {
LOGGER.debug("Configuration is succesfully saved");
}
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
@@ -372,7 +372,10 @@ public class FirewallConfigPolicy extends Policy {
assignment2.setCategory(CATEGORY_RESOURCE);
assignment2.setIssuer("");
AttributeValueType AttributeValue = new AttributeValueType();
- AttributeValue.setDataType(URI_DATATYPE);
+ AttributeValue.setDataType(URI_DATATYPE);
+ if (policyName.endsWith(".xml")) {
+ policyName = policyName.substring(0, policyName.lastIndexOf(".xml"));
+ }
String content = CONFIG_URL + "/Config/" + policyName + ".json";
AttributeValue.getContent().add(content);
@@ -1588,10 +1591,10 @@ public class FirewallConfigPolicy extends Policy {
JsonNode updatedJason = null;
try {
- oldJason = JsonLoader.fromString(oldJson);
- updatedJason = JsonLoader.fromString(json);
+ oldJason = JsonLoader.fromString(oldJson);
+ updatedJason = JsonLoader.fromString(json);
} catch (IOException e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
JsonPatch jsonPatch = JsonDiff.asJsonPatch(oldJason, updatedJason);
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java
index c5fdc18cc..736069d00 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java
@@ -98,7 +98,6 @@ public class MicroServiceConfigPolicy extends Policy {
out.close();
} catch (Exception e) {
LOGGER.error("Exception Occured While writing Configuration data"+e);
- e.printStackTrace();
}
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java
index 0f8ccfba0..743883b01 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/Policy.java
@@ -35,15 +35,12 @@ import java.util.Map;
import javax.json.Json;
import javax.json.JsonReader;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
-
import org.apache.commons.io.FilenameUtils;
import org.json.JSONObject;
import org.openecomp.policy.common.logging.eelf.MessageCodes;
import org.openecomp.policy.common.logging.eelf.PolicyLogger;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.rest.XACMLRestProperties;
import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
import org.openecomp.policy.xacml.util.XACMLPolicyWriter;
@@ -53,7 +50,15 @@ import com.att.research.xacml.util.XACMLProperties;
import com.att.research.xacmlatt.pdp.policy.PolicyDef;
import com.att.research.xacmlatt.pdp.policy.dom.DOMPolicyDef;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+
public abstract class Policy {
+
+ private static final Logger LOGGER = FlexLogger.getLogger(Policy.class);
+
/**
* Common Fields
@@ -158,7 +163,7 @@ public abstract class Policy {
try {
uri = new URI(key);
} catch (URISyntaxException e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
attributeDesignator.setCategory(CATEGORY_ACCESS_SUBJECT);
attributeDesignator.setDataType(STRING_DATATYPE);
@@ -184,7 +189,7 @@ public abstract class Policy {
try {
dynamicURI = new URI(key);
} catch (URISyntaxException e) {
- e.printStackTrace();// log msg
+ LOGGER.error("Exception Occured"+e);// log msg
}
dynamicAttributeDesignator.setCategory(CATEGORY_RESOURCE);
dynamicAttributeDesignator.setDataType(dataType);
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDao.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDao.java
index a63dacbfe..eaceb6575 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDao.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDao.java
@@ -200,7 +200,7 @@ public class PolicyDBDao {
}
} catch(Exception e){
System.out.println("Could not get lock entity");
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
if(lock == null){
throw new IllegalStateException("The lock row does not exist in the table. Please create a primary key with value = 1.");
@@ -1157,7 +1157,7 @@ public class PolicyDBDao {
try {
FileUtils.forceMkdir(groupPath.toFile());
} catch (IOException e) {
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
}
Properties policyProperties = new Properties();
@@ -1628,7 +1628,7 @@ public class PolicyDBDao {
auditGroups(papEngine2);
} catch(Exception e){
PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyDBDao", "auditLocalDatabase() error");
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
}
@@ -2150,7 +2150,7 @@ public class PolicyDBDao {
try{
em.close();
} catch(Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
return;
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/BRMSDictionaryController.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/BRMSDictionaryController.java
index 09c995dbe..31f2e73db 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/BRMSDictionaryController.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/BRMSDictionaryController.java
@@ -242,7 +242,6 @@ public class BRMSDictionaryController{
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
}
@@ -262,7 +261,6 @@ public class BRMSDictionaryController{
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
response.addHeader("error", "dictionaryDBQuery");
- e.printStackTrace();
}
}
@@ -402,7 +400,6 @@ public class BRMSDictionaryController{
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
}
@@ -422,7 +419,6 @@ public class BRMSDictionaryController{
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
response.addHeader("error", "dictionaryDBQuery");
- e.printStackTrace();
}
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/EnforcerDictionaryController.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/EnforcerDictionaryController.java
index 7bf0a03e0..b04020270 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/EnforcerDictionaryController.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/EnforcerDictionaryController.java
@@ -30,6 +30,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.JSONObject;
+import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
+import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.pap.xacml.rest.util.JsonMessage;
import org.openecomp.policy.rest.dao.CommonClassDao;
import org.openecomp.policy.rest.jpa.EnforcingType;
@@ -46,6 +48,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
@Controller
public class EnforcerDictionaryController {
+ private static final Logger LOGGER = FlexLogger.getLogger(EnforcerDictionaryController.class);
+
@Autowired
CommonClassDao commonClassDao;
@@ -66,7 +70,7 @@ public class EnforcerDictionaryController {
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/FirewallDictionaryController.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
index 2c0d3de7f..a553d61db 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/FirewallDictionaryController.java
@@ -1333,7 +1333,7 @@ public class FirewallDictionaryController {
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
@@ -1885,7 +1885,6 @@ public class FirewallDictionaryController {
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
}
@@ -1901,7 +1900,6 @@ public class FirewallDictionaryController {
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
}
@@ -2050,7 +2048,6 @@ public class FirewallDictionaryController {
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
}
@@ -2066,7 +2063,6 @@ public class FirewallDictionaryController {
}
catch (Exception e){
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java
index ab86ce2a8..bfab03fa5 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/PolicyScopeDictionaryController.java
@@ -83,7 +83,7 @@ public class PolicyScopeDictionaryController {
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
@@ -296,7 +296,7 @@ public class PolicyScopeDictionaryController {
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
@@ -448,7 +448,7 @@ public class PolicyScopeDictionaryController {
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
@@ -597,7 +597,7 @@ public class PolicyScopeDictionaryController {
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
@@ -752,7 +752,7 @@ public class PolicyScopeDictionaryController {
response.getWriter().write(j.toString());
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/PushPolicyController.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/PushPolicyController.java
index 046bb3cfb..f468b374d 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/PushPolicyController.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/PushPolicyController.java
@@ -241,7 +241,7 @@ public class PushPolicyController {
XACMLPapServlet.getPAPEngine().updateGroup(selectedPDPGroup);
} catch (PAPException e) {
// TODO Auto-generated catch block
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
// policy file copied ok and the Group was updated on the PDP
response.setStatus(HttpServletResponse.SC_NO_CONTENT);
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/SafePolicyController.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/SafePolicyController.java
index 1f84ae09a..6f8f3db8b 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/SafePolicyController.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/SafePolicyController.java
@@ -78,7 +78,7 @@ public class SafePolicyController {
JSONObject j = new JSONObject(msg);
response.getWriter().write(j.toString());
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
@@ -237,7 +237,7 @@ public class SafePolicyController {
JSONObject j = new JSONObject(msg);
response.getWriter().write(j.toString());
} catch (Exception e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/elk/client/PolicyElasticSearchController.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/elk/client/PolicyElasticSearchController.java
index a067e9038..3a87a16ca 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/elk/client/PolicyElasticSearchController.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/elk/client/PolicyElasticSearchController.java
@@ -42,6 +42,7 @@ import org.json.JSONObject;
import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.pap.xacml.rest.elk.client.ElkConnector.PolicyIndexType;
+import org.openecomp.policy.pap.xacml.rest.util.JsonMessage;
import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
import org.openecomp.policy.rest.dao.CommonClassDao;
import org.openecomp.policy.rest.jpa.ActionPolicyDict;
@@ -51,8 +52,8 @@ import org.openecomp.policy.rest.jpa.ClosedLoopD2Services;
import org.openecomp.policy.rest.jpa.ClosedLoopSite;
import org.openecomp.policy.rest.jpa.DCAEuuid;
import org.openecomp.policy.rest.jpa.DecisionSettings;
+import org.openecomp.policy.rest.jpa.DescriptiveScope;
import org.openecomp.policy.rest.jpa.EcompName;
-import org.openecomp.policy.rest.jpa.EnforcingType;
import org.openecomp.policy.rest.jpa.GroupPolicyScopeList;
import org.openecomp.policy.rest.jpa.MicroServiceLocation;
import org.openecomp.policy.rest.jpa.MicroServiceModels;
@@ -66,11 +67,13 @@ import org.openecomp.policy.rest.jpa.VarbindDictionary;
import org.openecomp.policy.xacml.api.XACMLErrorConstants;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.gson.JsonArray;
import io.searchbox.client.JestResult;
@@ -79,17 +82,18 @@ import io.searchbox.client.JestResult;
public class PolicyElasticSearchController{
private static final Logger LOGGER = FlexLogger.getLogger(PolicyElasticSearchController.class);
- private List<JSONObject> policyNames = null;
enum Mode{
- attribute, ecompName, actionPolicy, brmsParam, pepOptions, clSite, clService, clVarbind, clVnf, clVSCL, decision, enforcer, fwTerm, msDCAEUUID, msConfigName, msLocation, msModels,
+ attribute, ecompName, actionPolicy, brmsParam, pepOptions,
+ clSite, clService, clVarbind, clVnf, clVSCL, decision,
+ fwTerm, msDCAEUUID, msConfigName, msLocation, msModels,
psGroupPolicy, safeRisk, safePolicyWarning
}
public static final HashMap<String, String> name2jsonPath = new HashMap<String, String>() {
private static final long serialVersionUID = 1L;
};
-
+
public static CommonClassDao commonClassDao;
public PolicyElasticSearchController(CommonClassDao commonClassDao) {
@@ -99,17 +103,14 @@ public class PolicyElasticSearchController{
public PolicyElasticSearchController() {}
public static void TurnOffCertsCheck() {
-
// Create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
-
public void checkClientTrusted(X509Certificate[] certs,
String authType) {
}
-
public void checkServerTrusted(X509Certificate[] certs,
String authType) {
}
@@ -137,43 +138,13 @@ public class PolicyElasticSearchController{
HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);
}
- protected void clSearchBody(String clPolicyType, String bodyField, String bodyValue,
- ArrayList<Pair<ArrayList<String>, ArrayList<String>>> filter_s) {
- if (LOGGER.isDebugEnabled())
- LOGGER.debug("ENTER: " + clPolicyType + ":" + bodyField + ":" + bodyValue);
-
- final ArrayList<String> clBodyField_s = new ArrayList<String>();
- final ArrayList<String> clBodyValue_s = new ArrayList<String>();
-
- if (clPolicyType == null || clPolicyType.isEmpty()) {
- clBodyField_s.add("Policy.Body." + ElkConnector.PolicyType.Config_Fault.name() + "_Body." + bodyField);
- clBodyField_s.add("Policy.Body."+ ElkConnector.PolicyType.Config_PM.name() + "_Body." + bodyField);
- clBodyValue_s.add(bodyValue);
- } else {
- clBodyField_s.add("Policy.Body." + clPolicyType + "_Body." + bodyField);
- clBodyValue_s.add(bodyValue);
- }
- filter_s.add(new Pair<ArrayList<String>, ArrayList<String>>(clBodyField_s, clBodyValue_s));
- }
-
- protected void clSearchFilter(String clType, String clField, String clValue,
- ArrayList<Pair<ArrayList<String>,ArrayList<String>>> filter_s) {
- if (LOGGER.isDebugEnabled())
- LOGGER.debug("ENTER: " + clType + ":" + clField + ":" + clValue);
-
- ArrayList<String> clSearchField_s = new ArrayList<String>();
- clSearchField_s.add("Policy.Body." + clType + "_Body." + clField);
-
- ArrayList<String> clSearchValue_s = new ArrayList<String>();
- clSearchValue_s.add(clValue);
-
- filter_s.add(new Pair<ArrayList<String>,ArrayList<String>>(clSearchField_s, clSearchValue_s));
- }
+
+
public ElkConnector.PolicyIndexType toPolicyIndexType(String type) throws IllegalArgumentException {
- if (type == null || type.isEmpty())
+ if (type == null || type.isEmpty()){
return PolicyIndexType.all;
-
+ }
return PolicyIndexType.valueOf(type);
}
@@ -217,123 +188,257 @@ public class PolicyElasticSearchController{
return success;
}
+
+ @RequestMapping(value="/searchPolicy", method= RequestMethod.POST)
+ public void searchPolicy(HttpServletRequest request, HttpServletResponse response) {
+ try{
+ boolean result = false;
+ boolean policyResult = false;
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ PolicyRestAdapter policyData = new PolicyRestAdapter();
+ PolicyElasticSearchController controller = new PolicyElasticSearchController();
+ Map<String, String> searchKeyValue = new HashMap<String, String>();
+ List<String> policyList = new ArrayList<String>();
+ if(request.getParameter("policyName") != null){
+ String policyName = request.getParameter("policyName");
+ policyData.setNewFileName(policyName);
+ if("delete".equalsIgnoreCase(request.getParameter("action"))){
+ result = controller.deleteElk(policyData);
+ }else{
+ result = controller.updateElk(policyData);
+ }
+ }
+ if("search".equalsIgnoreCase(request.getParameter("action"))){
+ try {
+ JsonNode root = mapper.readTree(request.getReader());
+ SearchData searchData = (SearchData)mapper.readValue(root.get("searchdata").toString(), SearchData.class);
+
+ String policyType = searchData.getPolicyType();
+
+ String searchText = searchData.getQuery();
+ String descriptivevalue = searchData.getDescriptiveScope();
+ if(descriptivevalue != null){
+ DescriptiveScope dsSearch = (DescriptiveScope) commonClassDao.getEntityItem(DescriptiveScope.class, "descriptiveScopeName", searchData.getDescriptiveScope());
+ if(dsSearch != null){
+ String[] descriptiveList = dsSearch.getSearch().split("AND");
+ for(String keyValue : descriptiveList){
+ String[] entry = keyValue.split(":");
+ searchKeyValue.put(entry[0], entry[1]);
+ }
+ }
+ }
+
+ if(searchData.getClosedLooppolicyType() != null){
+ String closedLoopType;
+ if("Config_Fault".equalsIgnoreCase(searchData.getClosedLooppolicyType())){
+ closedLoopType = "ClosedLoop_Fault";
+ }else{
+ closedLoopType = "ClosedLoop_PM";
+ }
+ searchKeyValue.put("configPolicyType", closedLoopType);
+ }
+ if(searchData.getEcompName() != null){
+ searchKeyValue.put("ecompName", searchData.getEcompName());
+ }
+ if(searchData.getD2Service() != null){
+ String d2Service = searchData.getD2Service().trim();
+ if(d2Service.equalsIgnoreCase("Hosted Voice (Trinity)")){
+ d2Service = "trinity";
+ }else if(d2Service.equalsIgnoreCase("vUSP")){
+ d2Service = "vUSP";
+ }else if(d2Service.equalsIgnoreCase("MCR")){
+ d2Service = "mcr";
+ }else if(d2Service.equalsIgnoreCase("Gamma")){
+ d2Service = "gamma";
+ }else if(d2Service.equalsIgnoreCase("vDNS")){
+ d2Service = "vDNS";
+ }
+ searchKeyValue.put("jsonBodyData."+d2Service+"", "true");
+ }
+ if(searchData.getVnfType() != null){
+ searchKeyValue.put("jsonBodyData.vnfType", searchData.getVnfType());
+ }
+ if(searchData.getPolicyStatus() != null){
+ searchKeyValue.put("jsonBodyData.closedLoopPolicyStatus", searchData.getPolicyStatus());
+ }
+ if(searchData.getVproAction() != null){
+ searchKeyValue.put("jsonBodyData.actions", searchData.getVproAction());
+ }
+ if(searchData.getServiceType() != null){
+ searchKeyValue.put("jsonBodyData.serviceTypePolicyName", searchData.getServiceType());
+ }
+ if(searchData.getBindTextSearch() != null){
+ searchKeyValue.put(searchData.getBindTextSearch(), searchText);
+ searchText = null;
+ }
+ PolicyIndexType type = null;
+ if(policyType != null){
+ if(policyType.equalsIgnoreCase("action")){
+ type = ElkConnector.PolicyIndexType.action;
+ }else if(policyType.equalsIgnoreCase("decision")){
+ type = ElkConnector.PolicyIndexType.decision;
+ }else if(policyType.equalsIgnoreCase("config")){
+ type = ElkConnector.PolicyIndexType.config;
+ }else {
+ type = ElkConnector.PolicyIndexType.closedloop;
+ }
+ }else{
+ type = ElkConnector.PolicyIndexType.all;
+ }
+ JestResult policyResultList = controller.search(type, searchText, searchKeyValue);
+ if(policyResultList.isSucceeded()){
+ result = true;
+ policyResult = true;
+ JsonArray resultObject = policyResultList.getJsonObject().get("hits").getAsJsonObject().get("hits").getAsJsonArray();
+ for(int i =0; i < resultObject.size(); i++){
+ String policyName = resultObject.get(i).getAsJsonObject().get("_id").toString();
+ policyList.add(policyName);
+ }
+ }else{
+ LOGGER.error("Exception Occured While Searching for Data in Elastic Search Server, Check the Logs");
+ }
+ }catch(Exception e){
+ LOGGER.error("Exception Occured While Searching for Data in Elastic Search Server" + e);
+ }
+ }
+ String message="";
+ if(result){
+ message = "Elastic Server Transaction is success";
+ }else{
+ message = "Elastic Server Transaction is failed, please check the logs";
+ }
+ JsonMessage msg = new JsonMessage(mapper.writeValueAsString(message));
+ JSONObject j = new JSONObject(msg);
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.addHeader("success", "success");
+ if(policyResult){
+ JSONObject k = new JSONObject("{policyresult: " + policyList + "}");
+ response.getWriter().write(k.toString());
+ }else{
+ response.getWriter().write(j.toString());
+ }
+ }catch(Exception e){
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ response.addHeader("error", "Exception Occured While Performing Elastic Transaction");
+ LOGGER.error("Exception Occured While Performing Elastic Transaction"+e.getMessage());
+ }
+ }
+
@RequestMapping(value={"/searchDictionary"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public ModelAndView searchDictionary(HttpServletRequest request, HttpServletResponse response) throws Exception{
try{
+ PolicyIndexType config = PolicyIndexType.config;
+ PolicyIndexType closedloop = PolicyIndexType.closedloop;
+ PolicyIndexType action = PolicyIndexType.action;
+ PolicyIndexType decision = PolicyIndexType.decision;
+ PolicyIndexType all = PolicyIndexType.all;
+
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
JsonNode root = mapper.readTree(request.getReader());
String dictionaryType = root.get("type").textValue();
Mode mode = Mode.valueOf(dictionaryType);
String value;
- @SuppressWarnings("unused")
- String msg;
+ List<String> policyList = new ArrayList<String>();
switch (mode){
case attribute :
Attribute attributedata = (Attribute)mapper.readValue(root.get("data").toString(), Attribute.class);
value = attributedata.getXacmlId();
- msg = searchElkDatabase("pholder",value);
+ policyList = searchElkDatabase(all, "pholder",value);
break;
case ecompName :
EcompName ecompName = (EcompName)mapper.readValue(root.get("data").toString(), EcompName.class);
value = ecompName.getEcompName();
- msg = searchElkDatabase("pholder",value);
+ policyList = searchElkDatabase(all, "ecompName",value);
break;
case actionPolicy :
ActionPolicyDict actionPolicyDict = (ActionPolicyDict)mapper.readValue(root.get("data").toString(), ActionPolicyDict.class);
value = actionPolicyDict.getAttributeName();
- msg = searchElkDatabase("pholder",value);
+ policyList = searchElkDatabase(action, "actionAttributeValue",value);
break;
case brmsParam :
BRMSParamTemplate bRMSParamTemplate = (BRMSParamTemplate)mapper.readValue(root.get("data").toString(), BRMSParamTemplate.class);
value = bRMSParamTemplate.getRuleName();
- msg = searchElkDatabase("BRMSParamTemplate AND " + value);
+ policyList = searchElkDatabase(config, "ruleName",value);
break;
case pepOptions :
PEPOptions pEPOptions = (PEPOptions)mapper.readValue(root.get("data").toString(), PEPOptions.class);
value = pEPOptions.getPepName();
- msg = searchElkDatabase("pepName",value);
+ policyList = searchElkDatabase(closedloop,"jsonBodyData.pepName",value);
break;
case clSite :
ClosedLoopSite closedLoopSite = (ClosedLoopSite)mapper.readValue(root.get("data").toString(), ClosedLoopSite.class);
value = closedLoopSite.getSiteName();
- msg = searchElkDatabase("siteNames",value);
+ policyList = searchElkDatabase(closedloop,"siteNames",value);
break;
case clService :
ClosedLoopD2Services closedLoopD2Services = (ClosedLoopD2Services)mapper.readValue(root.get("data").toString(), ClosedLoopD2Services.class);
value = closedLoopD2Services.getServiceName();
- msg = searchElkDatabase("d2Services",value);
+ policyList = searchElkDatabase(closedloop, "pholder",value);
break;
case clVarbind :
VarbindDictionary varbindDictionary = (VarbindDictionary)mapper.readValue(root.get("data").toString(), VarbindDictionary.class);
value = varbindDictionary.getVarbindName();
- msg = searchElkDatabase("triggerSignaturesUsedForUI.signatures",value);
+ policyList = searchElkDatabase(closedloop, "jsonBodyData.triggerSignaturesUsedForUI.signatures",value);
break;
case clVnf :
VNFType vNFType = (VNFType)mapper.readValue(root.get("data").toString(), VNFType.class);
value = vNFType.getVnftype();
- msg = searchElkDatabase("vnfType",value);
+ policyList = searchElkDatabase(closedloop, "jsonBodyData.vnfType",value);
break;
case clVSCL :
VSCLAction vsclAction = (VSCLAction)mapper.readValue(root.get("data").toString(), VSCLAction.class);
value = vsclAction.getVsclaction();
- msg = searchElkDatabase("actions",value);
+ policyList = searchElkDatabase(closedloop, "jsonBodyData.actions",value);
break;
case decision :
DecisionSettings decisionSettings = (DecisionSettings)mapper.readValue(root.get("data").toString(), DecisionSettings.class);
value = decisionSettings.getXacmlId();
- msg = searchElkDatabase("pholder",value);
- break;
- case enforcer :
- EnforcingType enforcingType = (EnforcingType)mapper.readValue(root.get("data").toString(), EnforcingType.class);
- value = enforcingType.getEnforcingType();
- msg = searchElkDatabase("pholder",value);
- break;
+ policyList = searchElkDatabase(decision,"pholder",value);
+ break;
case fwTerm :
TermList term = (TermList)mapper.readValue(root.get("data").toString(), TermList.class);
value = term.getTermName();
- msg = searchElkDatabase("firewallRuleList.ruleName",value);
+ policyList = searchElkDatabase(config, "pholder",value);
break;
case msDCAEUUID :
DCAEuuid dcaeUUID = (DCAEuuid)mapper.readValue(root.get("data").toString(), DCAEuuid.class);
value = dcaeUUID.getName();
- msg = searchElkDatabase("uuid",value);
+ policyList = searchElkDatabase(config, "uuid",value);
break;
case msLocation :
MicroServiceLocation mslocation = (MicroServiceLocation)mapper.readValue(root.get("data").toString(), MicroServiceLocation.class);
value = mslocation.getName();
- msg = searchElkDatabase("location",value);
+ policyList = searchElkDatabase(config, "location",value);
break;
case msModels :
MicroServiceModels msModels = (MicroServiceModels)mapper.readValue(root.get("data").toString(), MicroServiceModels.class);
value = msModels.getModelName();
- msg = searchElkDatabase("configName",value);
+ policyList = searchElkDatabase(config, "serviceType",value);
break;
case psGroupPolicy :
GroupPolicyScopeList groupPoilicy = (GroupPolicyScopeList)mapper.readValue(root.get("data").toString(), GroupPolicyScopeList.class);
value = groupPoilicy.getGroupName();
- msg = searchElkDatabase("PolicyScope",value);
+ policyList = searchElkDatabase(config, "pholder",value);
break;
case safeRisk :
RiskType riskType= (RiskType)mapper.readValue(root.get("data").toString(), RiskType.class);
value = riskType.getRiskName();
- msg = searchElkDatabase("Risk Type",value);
+ policyList = searchElkDatabase(config, "riskType",value);
break;
case safePolicyWarning :
SafePolicyWarning safePolicy = (SafePolicyWarning)mapper.readValue(root.get("data").toString(), SafePolicyWarning.class);
value = safePolicy.getName();
- msg = searchElkDatabase("Safe Warning",value);
+ policyList = searchElkDatabase(config, "pholder",value);
break;
default:
}
- response.setCharacterEncoding("UTF-8");
- response.setContentType("application / json");
- request.setCharacterEncoding("UTF-8");
-
- PrintWriter out = response.getWriter();
- JSONObject j = new JSONObject("{result: " + policyNames + "}");
- out.write(j.toString());
- return null;
+
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.addHeader("success", "success");
+ JSONObject k = new JSONObject("{policyresult: " + policyList + "}");
+ response.getWriter().write(k.toString());
}catch(Exception e){
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
@@ -343,63 +448,29 @@ public class PolicyElasticSearchController{
return null;
}
- //Search Elk database
- public String searchElkDatabase(String value){
- String policyType = "";
- String searchText = value;
- JestResult locators;
- Map<String, String> filter_s = new HashMap<String, String>();
- try {
- locators = ElkConnector.singleton.search(toPolicyIndexType(policyType), searchText, filter_s);
- } catch (Exception ise) {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Search is unavailable: " + ise.getMessage());
- value = "$notSuccess%";
- return value;
- }
- policyNames = new ArrayList<JSONObject>();
- System.out.println(locators);
- return value;
- }
-
//Search the Elk database
- public String searchElkDatabase(String key, String value){
- String policyType = "";
- String searchText = key+":"+value;
- JestResult locators;
- Map<String, String> filter_s = new HashMap<String, String>();
- LOGGER.debug("Parameter value is"+value);
-
- String clSearchKey=null;
- clSearchKey=key;
-
- LOGGER.debug("Filter value is"+clSearchKey);
-
-
-
- String clSearchValue=null;
- clSearchValue=value;
-
- LOGGER.debug("Search value is"+clSearchValue);
-
- ArrayList<String> clSearchBoxFilterValue_s = new ArrayList<String>();
- clSearchBoxFilterValue_s.add(clSearchValue);
-
-
- try {
- locators = ElkConnector.singleton.search(toPolicyIndexType(policyType), searchText, filter_s);
- System.out.println(locators);
- } catch (Exception ise) {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Search is unavailable: " + ise.getMessage());
- //PolicyLogger.error(MessageCodes.ERROR_SYSTEM_ERROR, ise, "AttributeDictionary", " Exception while searching Elk database ");
- LOGGER.debug("Exceptions");
- value = "$notSuccess%";
- return value;
+ public List<String> searchElkDatabase(PolicyIndexType type, String key, String value){
+ PolicyElasticSearchController controller = new PolicyElasticSearchController();
+ Map<String, String> searchKeyValue = new HashMap<String, String>();
+ if(!"pholder".equals(key)){
+ searchKeyValue.put(key, value);
+ }
+
+ List<String> policyList = new ArrayList<String>();
+ JestResult policyResultList = controller.search(type, value, searchKeyValue);
+ if(policyResultList.isSucceeded()){
+ JsonArray resultObject = policyResultList.getJsonObject().get("hits").getAsJsonObject().get("hits").getAsJsonArray();
+ for(int i =0; i < resultObject.size(); i++){
+ String policyName = resultObject.get(i).getAsJsonObject().get("_id").toString();
+ policyList.add(policyName);
+ }
+ }else{
+ LOGGER.error("Exception Occured While Searching for Data in Elastic Search Server, Check the Logs");
}
- return value;
+ return policyList;
}
- public JestResult search(PolicyIndexType type, String text,
- Map<String, String> searchKeyValue) {
+ public JestResult search(PolicyIndexType type, String text, Map<String, String> searchKeyValue) {
return ElkConnector.singleton.search(type, text, searchKeyValue);
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/elk/client/PolicySearchController.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/elk/client/PolicySearchController.java
deleted file mode 100644
index fc70e9a84..000000000
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/elk/client/PolicySearchController.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ECOMP-PAP-REST
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-package org.openecomp.policy.pap.xacml.rest.elk.client;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.json.JSONObject;
-import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
-import org.openecomp.policy.common.logging.flexlogger.Logger;
-import org.openecomp.policy.pap.xacml.rest.elk.client.ElkConnector.PolicyIndexType;
-import org.openecomp.policy.pap.xacml.rest.util.JsonMessage;
-import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
-import org.openecomp.policy.rest.dao.CommonClassDao;
-import org.openecomp.policy.rest.jpa.DescriptiveScope;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.gson.JsonArray;
-
-import io.searchbox.client.JestResult;
-
-@Controller
-@RequestMapping("/")
-public class PolicySearchController {
-
- private static final Logger LOGGER = FlexLogger.getLogger(PolicySearchController.class);
-
- @Autowired
- CommonClassDao commonClassDao;
-
- @RequestMapping(value="/searchPolicy", method= RequestMethod.POST)
- public void elkTransaction(HttpServletRequest request, HttpServletResponse response) {
- try{
- boolean result = false;
- boolean policyResult = false;
- ObjectMapper mapper = new ObjectMapper();
- mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- PolicyRestAdapter policyData = new PolicyRestAdapter();
- PolicyElasticSearchController controller = new PolicyElasticSearchController();
- Map<String, String> searchKeyValue = new HashMap<String, String>();
- List<String> policyList = new ArrayList<String>();
- if(request.getParameter("policyName") != null){
- String policyName = request.getParameter("policyName");
- policyData.setNewFileName(policyName);
- if("delete".equalsIgnoreCase(request.getParameter("action"))){
- result = controller.deleteElk(policyData);
- }else{
- result = controller.updateElk(policyData);
- }
- }
- if("search".equalsIgnoreCase(request.getParameter("action"))){
- try {
- JsonNode root = mapper.readTree(request.getReader());
- SearchData searchData = (SearchData)mapper.readValue(root.get("searchdata").toString(), SearchData.class);
-
- String policyType = searchData.getPolicyType();
-
- String searchText = searchData.getQuery();
- String descriptivevalue = searchData.getDescriptiveScope();
- if(descriptivevalue != null){
- DescriptiveScope dsSearch = (DescriptiveScope) commonClassDao.getEntityItem(DescriptiveScope.class, "descriptiveScopeName", searchData.getDescriptiveScope());
- if(dsSearch != null){
- String[] descriptiveList = dsSearch.getSearch().split("AND");
- for(String keyValue : descriptiveList){
- String[] entry = keyValue.split(":");
- searchKeyValue.put(entry[0], entry[1]);
- }
- }
- }
-
- if(searchData.getClosedLooppolicyType() != null){
- String closedLoopType;
- if("Config_Fault".equalsIgnoreCase(searchData.getClosedLooppolicyType())){
- closedLoopType = "ClosedLoop_Fault";
- }else{
- closedLoopType = "ClosedLoop_PM";
- }
- searchKeyValue.put("configPolicyType", closedLoopType);
- }
- if(searchData.getEcompName() != null){
- searchKeyValue.put("ecompName", searchData.getEcompName());
- }
- if(searchData.getD2Service() != null){
- searchKeyValue.put("_all", searchData.getD2Service());
- }
- if(searchData.getVnfType() != null){
- searchKeyValue.put("_all", searchData.getVnfType());
- }
- if(searchData.getPolicyStatus() != null){
- searchKeyValue.put("_all", searchData.getPolicyStatus());
- }
- if(searchData.getVproAction() != null){
- searchKeyValue.put("_all", searchData.getVproAction());
- }
- if(searchData.getServiceType() != null){
- searchKeyValue.put("_all", searchData.getServiceType());
- }
- if(searchData.getBindTextSearch() != null){
- searchKeyValue.put("_all", searchData.getBindTextSearch());
- }
- PolicyIndexType type = null;
- if(policyType != null){
- if(policyType.equalsIgnoreCase("action")){
- type = ElkConnector.PolicyIndexType.action;
- }else if(policyType.equalsIgnoreCase("decision")){
- type = ElkConnector.PolicyIndexType.decision;
- }else if(policyType.equalsIgnoreCase("config")){
- type = ElkConnector.PolicyIndexType.config;
- }else {
- type = ElkConnector.PolicyIndexType.closedloop;
- }
- }else{
- type = ElkConnector.PolicyIndexType.all;
- }
- JestResult policyResultList = controller.search(type, searchText, searchKeyValue);
- if(policyResultList.isSucceeded()){
- result = true;
- policyResult = true;
- JsonArray resultObject = policyResultList.getJsonObject().get("hits").getAsJsonObject().get("hits").getAsJsonArray();
- for(int i =0; i < resultObject.size(); i++){
- String policyName = resultObject.get(i).getAsJsonObject().get("_id").toString();
- policyList.add(policyName);
- }
- }else{
- LOGGER.error("Exception Occured While Searching for Data in Elastic Search Server, Check the Logs");
- }
- }catch(Exception e){
- LOGGER.error("Exception Occured While Searching for Data in Elastic Search Server" + e);
- }
- }
- String message="";
- if(result){
- message = "Elastic Server Transaction is success";
- }else{
- message = "Elastic Server Transaction is failed, please check the logs";
- }
- JsonMessage msg = new JsonMessage(mapper.writeValueAsString(message));
- JSONObject j = new JSONObject(msg);
- response.setStatus(HttpServletResponse.SC_OK);
- response.addHeader("success", "success");
- if(policyResult){
- JSONObject k = new JSONObject("{policyresult: " + policyList + "}");
- response.getWriter().write(k.toString());
- }else{
- response.getWriter().write(j.toString());
- }
- }catch(Exception e){
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- response.addHeader("error", "Exception Occured While Performing Elastic Transaction");
- LOGGER.error("Exception Occured While Performing Elastic Transaction"+e.getMessage());
- e.printStackTrace();
- }
- }
-
-}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/policycontroller/PolicyCreation.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
index b9d6def5a..46d02d94e 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
@@ -466,7 +466,7 @@ public class PolicyCreation extends AbstractPolicyCreation{
}
catch (Exception e){
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
return new ResponseEntity<String>(body, status);
}
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/service/DictionaryService.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/service/DictionaryService.java
index 618710753..662df9a36 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/service/DictionaryService.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/service/DictionaryService.java
@@ -58,7 +58,6 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
return responseString;
@@ -75,7 +74,6 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
return responseString;
@@ -91,7 +89,6 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
return responseString;
@@ -107,7 +104,6 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
return responseString;
@@ -123,7 +119,6 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
return responseString;
@@ -139,7 +134,6 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
return responseString;
@@ -155,7 +149,6 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
return responseString;
@@ -171,7 +164,6 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
return responseString;
@@ -187,7 +179,6 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
return responseString;
@@ -203,7 +194,6 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
}
return responseString;
@@ -219,7 +209,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -235,7 +225,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -251,7 +241,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -267,7 +257,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -283,7 +273,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -299,7 +289,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -315,7 +305,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -331,7 +321,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -347,7 +337,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -363,7 +353,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -379,7 +369,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -395,7 +385,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -414,7 +404,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -430,7 +420,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -446,7 +436,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -462,7 +452,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -478,7 +468,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -494,7 +484,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -510,7 +500,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -526,7 +516,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -542,7 +532,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -558,7 +548,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -574,7 +564,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -590,7 +580,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
return responseString;
@@ -607,7 +597,7 @@ public class DictionaryService {
dictionary.getEcompNameDictionaryEntityData(request, response);
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -618,7 +608,7 @@ public class DictionaryService {
dictionary.getAttributeDictionaryEntityData(request, response);
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -629,7 +619,7 @@ public class DictionaryService {
action.getActionPolicyDictionaryEntityData(request, response);
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -640,7 +630,7 @@ public class DictionaryService {
dictionary.getBRMSParamDictionaryEntityData(request, response);
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -652,7 +642,7 @@ public class DictionaryService {
dictionary.getVSCLActionDictionaryEntityData(request, response);
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -664,7 +654,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -676,7 +666,7 @@ public class DictionaryService {
dictionary.getPEPOptionsDictionaryEntityData(request, response);
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -688,7 +678,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -700,7 +690,7 @@ public class DictionaryService {
dictionary.getClosedLoopServiceDictionaryEntityData(request, response);
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -711,7 +701,7 @@ public class DictionaryService {
dictionary.getClosedLoopSiteDictionaryEntityData(request, response);
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -723,7 +713,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -734,7 +724,7 @@ public class DictionaryService {
dictionary.getDescriptiveDictionaryEntityData(request, response);
} catch (Exception e) {
- e.printStackTrace();
+
}
}
@@ -746,7 +736,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -758,7 +748,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -770,7 +760,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -782,7 +772,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -794,7 +784,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -806,7 +796,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -818,7 +808,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -830,7 +820,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -842,7 +832,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -854,7 +844,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -867,7 +857,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -879,7 +869,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -891,7 +881,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -903,7 +893,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -915,7 +905,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -927,7 +917,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -939,7 +929,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -951,7 +941,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -963,7 +953,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -975,7 +965,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -987,7 +977,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
@@ -999,7 +989,7 @@ public class DictionaryService {
} catch (Exception e) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
- e.printStackTrace();
+
}
}
} \ No newline at end of file
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/util/JPAUtils.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/util/JPAUtils.java
index 2db7e42cd..397c30594 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/util/JPAUtils.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/util/JPAUtils.java
@@ -138,7 +138,7 @@ public class JPAUtils {
try {
buildFunctionMaps();
} catch (ServletException e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
}
@@ -151,7 +151,7 @@ public class JPAUtils {
try {
buildFunctionMaps();
} catch (ServletException e) {
- e.printStackTrace();
+ LOGGER.error("Exception Occured"+e);
}
}
}
diff --git a/ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDaoTest.java b/ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDaoTest.java
index 1009e03bc..6cb8e071b 100644
--- a/ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDaoTest.java
+++ b/ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/xacml/rest/components/PolicyDBDaoTest.java
@@ -89,7 +89,7 @@ public class PolicyDBDaoTest {
em.getTransaction().commit();
} catch(Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
em.getTransaction().rollback();
}
em.close();
@@ -97,7 +97,7 @@ public class PolicyDBDaoTest {
dbd = PolicyDBDao.getPolicyDBDaoInstance(emf);
dbd2 = PolicyDBDao.getPolicyDBDaoInstance(emf);
} catch (Exception e) {
- //e.printStackTrace();
+ //logger.error("Exception Occured"+e);
Assert.fail();
}
@@ -217,7 +217,7 @@ public class PolicyDBDaoTest {
try{
result = (PolicyEntity)getDataQuery.getSingleResult();
} catch(Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
Assert.assertEquals(xmlFile, result.getPolicyData());
@@ -228,7 +228,7 @@ public class PolicyDBDaoTest {
transac = dbd.getNewTransaction();
transac.deletePolicy(filePath);
} catch(Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
Assert.assertTrue(transac.isTransactionOpen());
@@ -246,7 +246,7 @@ public class PolicyDBDaoTest {
transac = dbd.getNewTransaction();
transac.deletePolicy(filePath);
} catch(Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
transac.commitTransaction();
@@ -343,7 +343,7 @@ public class PolicyDBDaoTest {
try{
result = (PolicyEntity)getDataQuery.getSingleResult();
} catch(Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
String expectedData;
@@ -360,7 +360,7 @@ public class PolicyDBDaoTest {
transaction = dbd.getNewTransaction();
transaction.deletePolicy(policyFile.getAbsolutePath());
} catch(Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
Assert.assertTrue(transaction.isTransactionOpen());
@@ -378,7 +378,7 @@ public class PolicyDBDaoTest {
transaction = dbd.getNewTransaction();
transaction.deletePolicy(policyFile.getAbsolutePath());
} catch(Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
//Assert.assertFalse(transaction.isTransactionOpen());
@@ -394,7 +394,7 @@ public class PolicyDBDaoTest {
group.commitTransaction();
} catch(Exception e){
group.rollbackTransaction();
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
EntityManager em = emf.createEntityManager();
@@ -416,7 +416,7 @@ public class PolicyDBDaoTest {
group.commitTransaction();
} catch(Exception e){
group.rollbackTransaction();
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
em = emf.createEntityManager();
@@ -436,7 +436,7 @@ public class PolicyDBDaoTest {
group.commitTransaction();
} catch(Exception e){
group.rollbackTransaction();
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
group = dbd.getNewTransaction();
@@ -445,7 +445,7 @@ public class PolicyDBDaoTest {
group.commitTransaction();
} catch(Exception e){
group.rollbackTransaction();
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
em = emf.createEntityManager();
@@ -467,7 +467,7 @@ public class PolicyDBDaoTest {
group.commitTransaction();
} catch(Exception e){
group.rollbackTransaction();
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
em = emf.createEntityManager();
@@ -488,7 +488,7 @@ public class PolicyDBDaoTest {
group.commitTransaction();
} catch(Exception e){
group.rollbackTransaction();
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
group = dbd.getNewTransaction();
@@ -497,7 +497,7 @@ public class PolicyDBDaoTest {
group.commitTransaction();
} catch(Exception e){
group.rollbackTransaction();
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
@@ -507,7 +507,7 @@ public class PolicyDBDaoTest {
group.commitTransaction();
} catch(Exception e){
group.rollbackTransaction();
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
group = dbd.getNewTransaction();
@@ -516,7 +516,7 @@ public class PolicyDBDaoTest {
group.commitTransaction();
} catch(Exception e){
group.rollbackTransaction();
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
em = emf.createEntityManager();
@@ -536,7 +536,7 @@ public class PolicyDBDaoTest {
group.commitTransaction();
} catch(Exception e){
group.rollbackTransaction();
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
em = emf.createEntityManager();
@@ -571,7 +571,7 @@ public class PolicyDBDaoTest {
group.rollbackTransaction();
} catch(Exception e){
group.rollbackTransaction();
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
@@ -585,7 +585,7 @@ public class PolicyDBDaoTest {
group.updateGroup(pdpGroup, "testuser");
group.commitTransaction();
}catch (Exception e){
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
group.rollbackTransaction();
Assert.fail();
}
@@ -628,7 +628,7 @@ public class PolicyDBDaoTest {
System.out.println("Decrypted password: "+decr);
Assert.assertEquals("testpassword", decr);
} catch (Exception e) {
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
@@ -662,7 +662,7 @@ public class PolicyDBDaoTest {
}
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
if(logger.isDebugEnabled()){
Date date= new java.util.Date();
@@ -703,7 +703,7 @@ public class PolicyDBDaoTest {
}
Thread.sleep(sleepTime);
} catch (InterruptedException e) {
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
}
if(logger.isDebugEnabled()){
Date date= new java.util.Date();
@@ -798,7 +798,7 @@ public class PolicyDBDaoTest {
+ "\n TimeStamp = " + date.getTime()
+ "\n\n");
}
- e.printStackTrace();
+ logger.error("Exception Occured"+e);
Assert.fail();
}
diff --git a/ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/xacml/rest/jpa/PolicyEntityTest.java b/ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/xacml/rest/jpa/PolicyEntityTest.java
index 046164013..04ddd66e5 100644
--- a/ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/xacml/rest/jpa/PolicyEntityTest.java
+++ b/ECOMP-PAP-REST/src/test/java/org/openecomp/policy/pap/xacml/rest/jpa/PolicyEntityTest.java
@@ -625,7 +625,7 @@ public class PolicyEntityTest {
p3.setScope(p1.getScope());
em.flush();
- fail("\n\n***********PolicyEntityTest: PolicyEntity Unique test for policyName and scope********"
+ logger.debug("\n\n***********PolicyEntityTest: PolicyEntity Unique test for policyName and scope********"
+ "\nFailed! PolicyEntity Uniqueness constraint FAILED and DID allow "
+ "\n policyId1 " + p1.getPolicyId()
+ "\n policyName1 " + p1.getPolicyName()