X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcomponents%2FPolicy.java;fp=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcomponents%2FPolicy.java;h=169e6e14ea43f90ae3789b92df3b513e3fd1fa46;hp=130b2e55aaeb01840d19bb8badf933b75a2b70db;hb=24c6b1682bb59691f8d5e631b1074355b7d82a54;hpb=461b2b7eeca1586423349bc0c4c65f80f027292d diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java index 130b2e55a..169e6e14e 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java @@ -45,6 +45,7 @@ import org.onap.policy.rest.XACMLRestProperties; import org.onap.policy.rest.adapter.PolicyRestAdapter; import org.onap.policy.xacml.util.XACMLPolicyWriter; +import com.att.research.xacml.api.pap.PAPException; import com.att.research.xacml.std.IdentifierImpl; import com.att.research.xacml.util.XACMLProperties; import com.att.research.xacmlatt.pdp.policy.PolicyDef; @@ -144,11 +145,11 @@ public abstract class Policy { * @return Either the PolicyAdapter.getData() or PolicyAdapter.getPolicyData() */ public abstract Object getCorrectPolicyDataObject(); - public abstract Map savePolicies() throws Exception; + public abstract Map savePolicies() throws PAPException; //This is the method for preparing the policy for saving. We have broken it out //separately because the fully configured policy is used for multiple things - public abstract boolean prepareToSave() throws Exception; + public abstract boolean prepareToSave() throws PAPException; // create match for onap and config name @@ -213,7 +214,7 @@ public abstract class Policy { protected static boolean isJSONValid(String data) { JsonReader jsonReader = null; try { - JSONObject j = new JSONObject(data); + new JSONObject(data); InputStream stream = new ByteArrayInputStream(data.getBytes(StandardCharsets.UTF_8)); jsonReader = Json.createReader(stream); LOGGER.info("Json Value is: " + jsonReader.read().toString() ); @@ -350,13 +351,13 @@ public abstract class Policy { return actionHome; } - private static void loadWebapps() throws Exception{ + private static void loadWebapps() throws PAPException{ if(actionHome == null || configHome == null){ Path webappsPath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS)); //Sanity Check if (webappsPath == null) { PolicyLogger.error("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS); - throw new Exception("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS); + throw new PAPException("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS); } Path webappsPathConfig; Path webappsPathAction; @@ -367,14 +368,14 @@ public abstract class Policy { webappsPathConfig = Paths.get(webappsPath.toString()+"/Config"); webappsPathAction = Paths.get(webappsPath.toString()+"/Action"); } - if(Files.notExists(webappsPathConfig)){ + if(!webappsPathConfig.toFile().exists()){ try { Files.createDirectories(webappsPathConfig); } catch (IOException e) { PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Policy", "Failed to create config directory"); } } - if(Files.notExists(webappsPathAction)){ + if(!webappsPathAction.toFile().exists()){ try { Files.createDirectories(webappsPathAction); } catch (IOException e) {