summaryrefslogtreecommitdiffstats
path: root/ECOMP-PDP-REST/src
diff options
context:
space:
mode:
authorRavindra Bakkamanthala <rb7147@att.com>2017-05-23 14:56:12 -0400
committerRavindra Bakkamanthala <rb7147@att.com>2017-05-23 16:49:56 -0400
commit87c95be02a8a4d77e165dede90777e811b59dcae (patch)
tree4712199fc3520b530dda0c4d3b074c327df547f2 /ECOMP-PDP-REST/src
parent7e547eaa55920dfbc9691eab33bb728395b50cf2 (diff)
Commit includes ControlLoopPolicy API and bugfixes
Change-Id: I3e18bb8b4c31a0d908bb0cff4c85e2a3fb450a63 Signed-off-by: Ravindra Bakkamanthala <rb7147@att.com>
Diffstat (limited to 'ECOMP-PDP-REST/src')
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdateConfigPolicyService.java2
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetDecisionService.java2
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetMetricsService.java7
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PAPServices.java330
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PDPServices.java25
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/SendEventService.java2
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/config/PDPApiAuth.java4
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/impl/XACMLPdpPolicyFinderFactory.java2
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/ManualNotificationUpdateThread.java4
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java8
-rw-r--r--ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java4
-rw-r--r--ECOMP-PDP-REST/src/main/resources/logback.xml4
-rw-r--r--ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/XACMLPdpServletTest.java4
13 files changed, 69 insertions, 329 deletions
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdateConfigPolicyService.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdateConfigPolicyService.java
index e26fae18a..850115f22 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdateConfigPolicyService.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/CreateUpdateConfigPolicyService.java
@@ -72,7 +72,7 @@ public class CreateUpdateConfigPolicyService {
policyParameters.setPolicyDescription(configPolicyAPIRequest.getPolicyDescription());
policyParameters.setEcompName(configPolicyAPIRequest.getEcompName());
policyParameters.setConfigName(configPolicyAPIRequest.getConfigName());
- Map<AttributeType, Map<String, String>> attributes = new HashMap<AttributeType, Map<String, String>>();
+ Map<AttributeType, Map<String, String>> attributes = new HashMap<>();
attributes.put(AttributeType.MATCHING, configPolicyAPIRequest.getConfigAttributes());
policyParameters.setAttributes(attributes);
policyParameters.setConfigBodyType(PolicyType.valueOf(configPolicyAPIRequest.getConfigType()));
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetDecisionService.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetDecisionService.java
index 33f2d07d7..f70c3fb97 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetDecisionService.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetDecisionService.java
@@ -161,7 +161,7 @@ public class GetDecisionService {
message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No eCOMPComponentName given : " + eCOMPComponentName;
return false;
}
- if (decisionAttributes == null && decisionAttributes.isEmpty()) {
+ if (decisionAttributes == null || decisionAttributes.isEmpty()) {
message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Decision Attributes Given. ";
return false;
}
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetMetricsService.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetMetricsService.java
index 14812edfb..d390df864 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetMetricsService.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/GetMetricsService.java
@@ -81,11 +81,6 @@ public class GetMetricsService {
}
private void run() throws PolicyException {
- // Check Validation.
- /*
- * if(!getValidation()){ LOGGER.error(message); throw new
- * PolicyException(message); }
- */
// Get Result.
try {
status = HttpStatus.OK;
@@ -124,7 +119,7 @@ public class GetMetricsService {
} catch (JsonException | IllegalStateException e) {
message = XACMLErrorConstants.ERROR_DATA_ISSUE
- + " improper JSON object : " + json.toString();
+ + " improper JSON object : " + json != null ? json.toString() : "JSON is null";
LOGGER.error(message);
metricsResponse.setResponseMessage(message);
metricsResponse.setResponseCode(400);
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PAPServices.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PAPServices.java
index 5aa3360ca..fe8c79409 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PAPServices.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PAPServices.java
@@ -25,7 +25,6 @@ import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
-import java.net.URI;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
@@ -193,22 +192,26 @@ public class PAPServices {
// Read the Response
LOGGER.debug("connected to the PAP : " + getPAP());
LOGGER.debug("--- Response: ---");
- Map<String, List<String>> headers = connection.getHeaderFields();
- for (String key : headers.keySet()) {
- LOGGER.debug("Header :" + key + " Value: " + headers.get(key));
- }
-
- try {
- response = checkResponse(connection, requestID);
- } catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
- response = XACMLErrorConstants.ERROR_SYSTEM_ERROR + e;
- throw new PolicyException(
- XACMLErrorConstants.ERROR_SYSTEM_ERROR
- + "Decoding the result ", e);
- }
- if (junit) {
- response = SUCCESS;
+ if(connection != null){
+ Map<String, List<String>> headers = connection.getHeaderFields();
+ for (String key : headers.keySet()) {
+ LOGGER.debug("Header :" + key + " Value: " + headers.get(key));
+ }
+
+ try {
+ response = checkResponse(connection, requestID);
+ } catch (IOException e) {
+ LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+ response = XACMLErrorConstants.ERROR_SYSTEM_ERROR + e;
+ throw new PolicyException(
+ XACMLErrorConstants.ERROR_SYSTEM_ERROR
+ + "Decoding the result ", e);
+ }
+ if (junit) {
+ response = SUCCESS;
+ }
+ }else{
+ response = XACMLErrorConstants.ERROR_SYSTEM_ERROR + "connection is null";
}
return response;
} else {
@@ -266,11 +269,8 @@ public class PAPServices {
connection.setInstanceFollowRedirects(false);
connection.setDoOutput(true);
connection.setDoInput(true);
- // mb1915 - begin
- // mb1915 - set requestID in header properties to be used to send to PAP on the GET request so PAP won't generate another
connection.setRequestProperty("X-ECOMP-RequestID", requestID.toString());
- // mb1915 - end
-
+
//DO the connect
connection.connect();
@@ -335,266 +335,6 @@ public class PAPServices {
return version;
}
- public StdPDPPolicy getGitPath(String policyScope, String filePrefix, String policyName, String activeVersion, String clientScope, UUID requestID, String id) throws PolicyException{
- String gitPath = null;
- Boolean isValid = false;
- String policyId= null;
- String description = null;
- String pushVersion = null;
- HttpURLConnection connection = null;
- String [] parameters = {"apiflag=gitPath", "policyScope="+policyScope, "filePrefix="+filePrefix,
- "policyName="+policyName, "activeVersion="+activeVersion};
- if (paps == null || paps.isEmpty()) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "PAPs List is Empty.");
- try {
- throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"PAPs List is empty.");
- } catch (Exception e) {
- LOGGER.error(e.getMessage());
- }
- }else {
- int papsCount = 0;
- boolean connected = false;
- while (papsCount < paps.size()) {
- try {
- String fullURL = getPAP();
- if (parameters != null && parameters.length > 0) {
- String queryString = "";
- for (String p : parameters) {
- queryString += "&" + p;
- }
- fullURL += "?" + queryString.substring(1);
- }
-
- URL url = new URL (fullURL);
-
- //Open the connection
- connection = (HttpURLConnection)url.openConnection();
-
- // Setting Content-Type
- connection.setRequestProperty("Content-Type",
- "application/json");
-
- // Adding Authorization
- connection.setRequestProperty("Authorization", "Basic "
- +getPAPEncoding());
-
- connection.setRequestProperty("Environment", environment);
- connection.setRequestProperty("ClientScope", clientScope);
-
- //set the method and headers
- connection.setRequestMethod("GET");
- connection.setUseCaches(false);
- connection.setInstanceFollowRedirects(false);
- connection.setDoOutput(true);
- connection.setDoInput(true);
- // mb1915 - begin
- // mb1915 - set requestID in header properties to be used to send to PAP on the GET request so PAP won't generate another
- connection.setRequestProperty("X-ECOMP-RequestID", requestID.toString());
- // mb1915 - end
-
- //DO the connect
- connection.connect();
-
- // If Connected to PAP then break from the loop and continue with the Request
- if (connection.getResponseCode() > 0) {
- connected = true;
- break;
-
- } else {
- LOGGER.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP connection Error");
- }
- } catch (Exception e) {
- // This means that the PAP is not working
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP connection Error : " + e);
- rotatePAPList();
- }
- papsCount++;
- }
-
- if (connected) {
- //Read the Response
- LOGGER.debug("connected to the PAP : " + getPAP());
- LOGGER.debug("--- Response: ---");
- Map<String, List<String>> headers = connection.getHeaderFields();
- for (String key : headers.keySet()) {
- LOGGER.debug("Header :" + key + " Value: " + headers.get(key));
- }
- try {
- if (connection.getResponseCode() == 200) {
- // Check for successful creation of policy
- gitPath = connection.getHeaderField("gitPath");
- policyId = connection.getHeaderField("policyId");
- description = connection.getHeaderField("description");
- pushVersion = connection.getHeaderField("version");
- isValid = Boolean.parseBoolean(connection.getHeaderField("isValid"));
-
- LOGGER.debug("GitPath from Header: " + gitPath);
- LOGGER.debug("policyId from Header: " + policyId);
- LOGGER.debug("description from Header: " + description);
- LOGGER.debug("version from Header: " + pushVersion);
- LOGGER.debug("isValid from Header: " + isValid);
-
- /*if (gitPath != null && !gitPath.equalsIgnoreCase("")) {
- return gitPath;
- }*/ if (gitPath == null || gitPath.trim().isEmpty()) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "could not retrieve the gitPath from the PAP");
- }
- } else if (connection.getResponseCode() == 404) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "response code of the URL is "
- + connection.getResponseCode() + ". This indicates a problem with getting the gitPath from the PAP");
- } else {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "BAD REQUEST: Error occured while getting the gitPath from the PAP. The request may be incorrect.");
- }
- } catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
- try {
- throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ", e);
- } catch (Exception e1) {
- LOGGER.error(e1.getMessage());
- }
- }
-
- } else {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get valid response from PAP(s) " + paps);
- try {
- throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ");
- } catch (Exception e) {
- LOGGER.error(e.getMessage());
- }
- }
- }
- LOGGER.debug("Full gitPath policy xml file: " + gitPath);
- URI selectedURI = getSelectedURI(gitPath, clientScope, requestID);
- LOGGER.debug("The selectedURI is : " + selectedURI.toString());
- String name = filePrefix+policyName;
-
- StdPDPPolicy selectedPolicy;
- try {
- selectedPolicy = new StdPDPPolicy(id, true, name, selectedURI, isValid, policyId, description, pushVersion);
- } catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+e.getMessage());
- throw new PolicyException(e);
- }
- return selectedPolicy;
- }
-
- private URI getSelectedURI(String gitPath, String clientScope, UUID requestID){
- URI selectedURI = null;
- HttpURLConnection connection = null;
- String [] parameters = {"apiflag=uri", "gitPath="+gitPath};
- if (paps == null || paps.isEmpty()) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "PAPs List is Empty.");
- try {
- throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"PAPs List is empty.");
- } catch (Exception e) {
- LOGGER.error(e.getMessage());
- }
- }else {
- int papsCount = 0;
- boolean connected = false;
- while (papsCount < paps.size()) {
- try {
- String fullURL = getPAP();
- if (parameters != null && parameters.length > 0) {
- String queryString = "";
- for (String p : parameters) {
- queryString += "&" + p;
- }
- fullURL += "?" + queryString.substring(1);
- }
-
- URL url = new URL (fullURL);
-
- //Open the connection
- connection = (HttpURLConnection)url.openConnection();
-
- // Setting Content-Type
- connection.setRequestProperty("Content-Type",
- "application/json");
-
- // Adding Authorization
- connection.setRequestProperty("Authorization", "Basic "
- + getPAPEncoding());
-
- connection.setRequestProperty("Environment", environment);
- connection.setRequestProperty("ClientScope", clientScope);
-
- //set the method and headers
- connection.setRequestMethod("GET");
- connection.setUseCaches(false);
- connection.setInstanceFollowRedirects(false);
- connection.setDoOutput(true);
- connection.setDoInput(true);
- // mb1915 - begin
- // mb1915 - set requestID in header properties to be used to send to PAP on the GET request so PAP won't generate another
- connection.setRequestProperty("X-ECOMP-RequestID", requestID.toString());
- // mb1915 - end
-
- //DO the connect
- connection.connect();
- responseCode = connection.getResponseCode();
- // If Connected to PAP then break from the loop and continue with the Request
- if (connection.getResponseCode() > 0) {
- connected = true;
- break;
-
- } else {
- LOGGER.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP connection Error");
- }
- } catch (Exception e) {
- // This means that the PAP is not working
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PAP connection Error : " + e);
- rotatePAPList();
- }
- papsCount++;
- }
-
- if (connected) {
- //Read the Response
- LOGGER.debug("connected to the PAP : " + getPAP());
- LOGGER.debug("--- Response: ---");
- Map<String, List<String>> headers = connection.getHeaderFields();
- for (String key : headers.keySet()) {
- LOGGER.debug("Header :" + key + " Value: " + headers.get(key));
- }
- try {
- if (connection.getResponseCode() == 200) {
- // Check for successful creation of policy
- String uri = connection.getHeaderField("selectedURI");
- LOGGER.debug("URI from Header: " + uri);
- if (uri != null && !uri.equalsIgnoreCase("")) {
- selectedURI = URI.create(uri);
- return selectedURI;
- } else {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "could not retrieve the gitPath from the PAP");
- }
- } else if (connection.getResponseCode() == 404) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "response code of the URL is "
- + connection.getResponseCode() + ". This indicates a problem with getting the gitPath from the PAP");
- } else {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "BAD REQUEST: Error occured while getting the gitPath from the PAP. The request may be incorrect.");
- }
- } catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
- try {
- throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ", e);
- } catch (Exception e1) {
- LOGGER.error(e1.getMessage());
- }
- }
-
- } else {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Unable to get valid response from PAP(s) " + paps);
- try {
- throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE +"ERROR in connecting to the PAP ");
- } catch (Exception e) {
- LOGGER.error(e.getMessage());
- }
- }
- }
- return selectedURI;
- }
-
private String checkResponse(HttpURLConnection connection, UUID requestID) throws IOException {
String response = null;
if (responseCode == 200 || junit) {
@@ -879,20 +619,22 @@ public class PAPServices {
// Read the Response
LOGGER.debug("connected to the PAP : " + getPAP());
LOGGER.debug("--- Response: ---");
- Map<String, List<String>> headers = connection.getHeaderFields();
- for (String key : headers.keySet()) {
- LOGGER.debug("Header :" + key + " Value: " + headers.get(key));
- }
- try {
- if(responseCode==202){
- StdPDPPolicy policy = (StdPDPPolicy) new ObjectInputStream(connection.getInputStream()).readObject();
- return policy;
+ if(connection != null){
+ Map<String, List<String>> headers = connection.getHeaderFields();
+ for (String key : headers.keySet()) {
+ LOGGER.debug("Header :" + key + " Value: " + headers.get(key));
}
- } catch (IOException | ClassNotFoundException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
- throw new PolicyException(
- XACMLErrorConstants.ERROR_SYSTEM_ERROR
- + "Decoding the result ", e);
+ try {
+ if(responseCode==202){
+ StdPDPPolicy policy = (StdPDPPolicy) new ObjectInputStream(connection.getInputStream()).readObject();
+ return policy;
+ }
+ } catch (IOException | ClassNotFoundException e) {
+ LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+ throw new PolicyException(
+ XACMLErrorConstants.ERROR_SYSTEM_ERROR
+ + "Decoding the result ", e);
+ }
}
return null;
} else {
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PDPServices.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PDPServices.java
index 4476b388b..a25c322a0 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PDPServices.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/PDPServices.java
@@ -114,9 +114,9 @@ public class PDPServices {
private Collection<PDPResponse> checkResponse(Response response) throws PolicyException{
String pdpConfigLocation = null;
- Collection<PDPResponse> combinedResult = new HashSet<PDPResponse>();
+ Collection<PDPResponse> combinedResult = new HashSet<>();
int priority = DEFAULT_PRIORITY;
- Map<Integer, PDPResponse> uniqueResult = new HashMap<Integer, PDPResponse>();
+ Map<Integer, PDPResponse> uniqueResult = new HashMap<>();
for (Result result : response.getResults()) {
if (!result.getDecision().equals(Decision.PERMIT)) {
LOGGER.debug("Decision not a Permit. " + result.getDecision().toString());
@@ -153,12 +153,12 @@ public class PDPServices {
String policyName = null;
String policyVersion = null;
match = new Matches();
- Map<String, String> matchingConditions = new HashMap<String, String>();
- Map<String, String> configAttributes = new HashMap<String, String>();
- Map<String, String> responseAttributes = new HashMap<String,String>();
- Map<String, String> actionTaken = new HashMap<String, String>();
+ Map<String, String> matchingConditions = new HashMap<>();
+ Map<String, String> configAttributes = new HashMap<>();
+ Map<String, String> responseAttributes = new HashMap<>();
+ Map<String, String> actionTaken = new HashMap<>();
PDPResponse pdpResponse = new PDPResponse();
- Map<String, String> adviseAttributes = new HashMap<String, String>();
+ Map<String, String> adviseAttributes = new HashMap<>();
for (AttributeAssignment attribute : advice.getAttributeAssignments()) {
adviseAttributes.put(attribute.getAttributeId().stringValue(), attribute.getAttributeValue().getValue().toString());
if (attribute.getAttributeValue().getValue().toString().equalsIgnoreCase("CONFIGURATION")) {
@@ -267,7 +267,7 @@ public class PDPServices {
// Obligation actions
// Action advised should be in obligations.
for (Obligation obligation : result.getObligations()) {
- Map<String, String> actionAdvised = new HashMap<String, String>();
+ Map<String, String> actionAdvised = new HashMap<>();
PDPResponse pdpResponse = new PDPResponse();
for (AttributeAssignment attribute : obligation.getAttributeAssignments()) {
actionAdvised.put(attribute.getAttributeId().stringValue(),
@@ -302,8 +302,9 @@ public class PDPServices {
if(pdpConfigLocation.contains("/")){
pdpConfigLocation = pdpConfigLocation.replace("/", File.separator);
}
+ InputStream inputStream = null;
try {
- InputStream inputStream = new FileInputStream(new File(pdpConfigLocation));
+ inputStream = new FileInputStream(new File(pdpConfigLocation));
try {
if (pdpConfigLocation.endsWith("json")) {
pdpResponse.setType(PolicyType.JSON);
@@ -335,7 +336,7 @@ public class PDPServices {
pdpResponse.setType(PolicyType.PROPERTIES);
Properties configProp = new Properties();
configProp.load(inputStream);
- Map<String, String> propVal = new HashMap<String, String>();
+ Map<String, String> propVal = new HashMap<>();
for(String name: configProp.stringPropertyNames()) {
propVal.put(name, configProp.getProperty(name));
}
@@ -365,6 +366,10 @@ public class PDPServices {
} catch (MalformedURLException e) {
LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
throw new Exception(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error in ConfigURL", e);
+ }finally{
+ if(inputStream != null){
+ inputStream.close();
+ }
}
}
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/SendEventService.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/SendEventService.java
index 4659ead5c..412adfa86 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/SendEventService.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/api/services/SendEventService.java
@@ -102,7 +102,7 @@ public class SendEventService {
private Collection<PolicyResponse> eventResult(
Collection<PDPResponse> generateRequest) {
- Collection<PolicyResponse> result = new HashSet<PolicyResponse>();
+ Collection<PolicyResponse> result = new HashSet<>();
if (generateRequest == null) {
return null;
}
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/config/PDPApiAuth.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/config/PDPApiAuth.java
index ed98e5420..e6122d324 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/config/PDPApiAuth.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/config/PDPApiAuth.java
@@ -160,7 +160,7 @@ public class PDPApiAuth {
throw new PolicyEngineException(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"Cannot Load the Properties file", e);
}
// Read the Properties and Load the Clients and their scopes.
- clientMap = new HashMap<String, ArrayList<String>>();
+ clientMap = new HashMap<>();
//
for (Object propKey : clientProp.keySet()) {
String clientID = (String)propKey;
@@ -174,7 +174,7 @@ public class PDPApiAuth {
}
}
}
- if (clientMap == null || clientMap.isEmpty()) {
+ if (clientMap.isEmpty()) {
PolicyLogger.debug(XACMLErrorConstants.ERROR_PERMISSIONS + "No Clients ID , Client Key and Scopes are available. Cannot serve any Clients !!");
throw new PolicyEngineException("Empty Client file");
}
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/impl/XACMLPdpPolicyFinderFactory.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/impl/XACMLPdpPolicyFinderFactory.java
index 0e06b3b8b..0d6d12a63 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/impl/XACMLPdpPolicyFinderFactory.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/impl/XACMLPdpPolicyFinderFactory.java
@@ -167,7 +167,7 @@ public class XACMLPdpPolicyFinderFactory extends PolicyFinderFactory {
return null;
}
- List<PolicyDef> listPolicyDefs = new ArrayList<PolicyDef>();
+ List<PolicyDef> listPolicyDefs = new ArrayList<>();
for (String policyId : policyIdArray) {
PolicyDef policyDef = this.loadPolicyDef(policyId);
if (policyDef != null) {
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/ManualNotificationUpdateThread.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/ManualNotificationUpdateThread.java
index 1acc18eb0..27d6b6f76 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/ManualNotificationUpdateThread.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/ManualNotificationUpdateThread.java
@@ -97,7 +97,7 @@ public class ManualNotificationUpdateThread implements Runnable {
String consumerTopic = aURL.getHost() + aURL.getPort() + "UpdateRequest";
SendMessage(consumerTopic, "Starting-Topic");
- final LinkedList<String> urlList = new LinkedList<String> ();
+ final LinkedList<String> urlList = new LinkedList<> ();
for ( String u : clusterList.split ( "," ) ){
urlList.add ( u );
}
@@ -151,7 +151,7 @@ public class ManualNotificationUpdateThread implements Runnable {
String consumerTopic = XACMLProperties.getProperty(XACMLRestProperties.PROP_NOTIFICATION_TOPIC).trim();
SendMessage(consumerTopic, "Starting-Topic");
- dmaapList = new ArrayList<String>();
+ dmaapList = new ArrayList<>();
for ( String u : dmaapServers.split ( "," ) ){
dmaapList.add ( u );
}
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java
index 4c933776c..ed2fbd1f4 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationController.java
@@ -85,8 +85,8 @@ public class NotificationController {
boolean updated = false;
boolean removed = false;
Notification notification = new Notification();
- HashSet<Removed> removedPolicies = new HashSet<Removed>();
- HashSet<Updated> updatedPolicies = new HashSet<Updated>();
+ HashSet<Removed> removedPolicies = new HashSet<>();
+ HashSet<Updated> updatedPolicies = new HashSet<>();
if (oldStatus == null) {
oldStatus = newStatus;
@@ -229,7 +229,7 @@ public class NotificationController {
while (allOfs.hasNext()) {
AllOf allOf = allOfs.next();
Iterator<Match> matches = allOf.getMatches();
- HashMap<String, String> matchValues = new HashMap<String, String>();
+ HashMap<String, String> matchValues = new HashMap<>();
while (matches.hasNext()) {
Match match = matches.next();
LOGGER.info("Attribute Value is: "+ match.getAttributeValue().getValue().toString());
@@ -339,7 +339,7 @@ public class NotificationController {
if(updated && removed){
notification.setNotificationType(NotificationType.BOTH);
if(notification.getLoadedPolicies()!=null){
- HashSet<Updated> updatedPolicies = new HashSet<Updated>();
+ HashSet<Updated> updatedPolicies = new HashSet<>();
for(Updated oldUpdatedPolicy: notification.getLoadedPolicies()){
Updated updatePolicy = oldUpdatedPolicy;
if(notification.getRemovedPolicies()!=null){
diff --git a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java
index cb1cf9f03..136f22268 100644
--- a/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java
+++ b/ECOMP-PDP-REST/src/main/java/org/openecomp/policy/pdp/rest/notifications/NotificationServer.java
@@ -140,10 +140,8 @@ public class NotificationServer {
} catch (MalformedURLException e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error creating the UEB publisher" + e1.getMessage());
- e1.printStackTrace();
} catch (GeneralSecurityException e1) {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error creating the UEB publisher" + e1.getMessage());
- e1.printStackTrace();
}
try {
@@ -189,7 +187,7 @@ public class NotificationServer {
if(dmaapServers.contains(",")) {
dmaapList = new ArrayList<String>(Arrays.asList(dmaapServers.split("\\s*,\\s*")));
} else {
- dmaapList = new ArrayList<String>();
+ dmaapList = new ArrayList<>();
dmaapList.add(dmaapServers);
}
diff --git a/ECOMP-PDP-REST/src/main/resources/logback.xml b/ECOMP-PDP-REST/src/main/resources/logback.xml
index 9c0e2ebce..df4d33f32 100644
--- a/ECOMP-PDP-REST/src/main/resources/logback.xml
+++ b/ECOMP-PDP-REST/src/main/resources/logback.xml
@@ -29,7 +29,7 @@
<!-- specify the component name
<ECOMP-component-name>::= "MSO" | "DCAE" | "ASDC " | "AAI" |"Policy" | "SDNC" | "AC" -->
<property name="componentName" value="Policy"></property>
- <property name="subComponentName" value="XACML-PDP-REST"></property>
+ <property name="subComponentName" value="ECOMP-PDP-REST"></property>
<!-- log file names -->
<property name="errorLogName" value="error" />
@@ -205,7 +205,7 @@
<maxIndex>9</maxIndex>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
- <level>INFO</level>
+ <level>DEBUG</level>
</filter>
<triggeringPolicy
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
diff --git a/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/XACMLPdpServletTest.java b/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/XACMLPdpServletTest.java
index 7f302ffa8..581abbe08 100644
--- a/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/XACMLPdpServletTest.java
+++ b/ECOMP-PDP-REST/src/test/java/org/openecomp/policy/pdp/rest/XACMLPdpServletTest.java
@@ -56,7 +56,7 @@ import junit.framework.TestCase;
public class XACMLPdpServletTest extends TestCase{
private static Logger LOGGER = FlexLogger.getLogger(XACMLPdpServletTest.class);
- private List<String> headers = new ArrayList<String>();
+ private List<String> headers = new ArrayList<>();
private HttpServletRequest httpServletRequest;
private HttpServletResponse httpServletResponse;
@@ -110,7 +110,7 @@ public class XACMLPdpServletTest extends TestCase{
// when IntegrityMonitor.getInstance is called, return the mock object
PowerMockito.when(IntegrityMonitor.getInstance(Mockito.anyString(), Mockito.any(Properties.class))).thenReturn(im);
} catch (Exception e1) {
- e1.printStackTrace();
+ LOGGER.error("Exception Occured"+e1);
}
try {