X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=ONAP-PDP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpdp%2Frest%2Fapi%2Fservices%2FPDPServices.java;h=efaa5c1673caab127d552192777a068c00734645;hp=e495c99503b615c443231b514b6e3933cd089e30;hb=80f072f60509ef3a35369a60857fe05f6c2a993a;hpb=c53fa990ea27ec074859eb94bcb7ec6deaa2157b diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java index e495c9950..efaa5c167 100644 --- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java +++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java @@ -21,10 +21,10 @@ package org.onap.policy.pdp.rest.api.services; import java.io.File; import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; -import java.net.MalformedURLException; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; @@ -37,6 +37,7 @@ import javax.json.JsonReader; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; @@ -65,6 +66,7 @@ import com.att.research.xacml.api.Request; import com.att.research.xacml.api.Response; import com.att.research.xacml.api.Result; import com.att.research.xacml.api.pdp.PDPEngine; +import com.att.research.xacml.api.pdp.PDPException; import com.att.research.xacml.std.json.JSONRequest; import com.att.research.xacml.std.json.JSONResponse; import com.att.research.xacml.util.XACMLProperties; @@ -333,7 +335,7 @@ public class PDPServices { return treatment; } - private PDPResponse configCall(String pdpConfigLocation) throws Exception{ + private PDPResponse configCall(String pdpConfigLocation) throws PDPException, IOException{ PDPResponse pdpResponse = new PDPResponse(); if(pdpConfigLocation.contains("/")){ pdpConfigLocation = pdpConfigLocation.replace("/", File.separator); @@ -366,7 +368,7 @@ public class PDPServices { pdpResponse.setConfig(writer.toString()); } catch (Exception e) { LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ e); - throw new Exception(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ "Unable to parse the XML config", e); + throw new PDPException(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ "Unable to parse the XML config", e); } } else if (pdpConfigLocation.endsWith("properties")) { pdpResponse.setType(PolicyType.PROPERTIES); @@ -394,14 +396,14 @@ public class PDPServices { PolicyResponseStatus.NO_ACTION_REQUIRED, PolicyConfigStatus.CONFIG_RETRIEVED); return pdpResponse; - } catch (IOException e) { + } catch (IOException | ParserConfigurationException e) { LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e); - throw new Exception(XACMLErrorConstants.ERROR_PROCESS_FLOW + + throw new PDPException(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Cannot open a connection to the configURL", e); } - } catch (MalformedURLException e) { + } catch (FileNotFoundException e) { LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e); - throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error in ConfigURL", e); + throw new PDPException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error in ConfigURL", e); }finally{ if(inputStream != null){ inputStream.close(); @@ -409,8 +411,7 @@ public class PDPServices { } } - private Response callPDP(Request request, - UUID requestID) throws Exception{ + private Response callPDP(Request request, UUID requestID){ Response response = null; // Get the PDPEngine if (requestID == null) {