From 87c95be02a8a4d77e165dede90777e811b59dcae Mon Sep 17 00:00:00 2001 From: Ravindra Bakkamanthala Date: Tue, 23 May 2017 14:56:12 -0400 Subject: Commit includes ControlLoopPolicy API and bugfixes Change-Id: I3e18bb8b4c31a0d908bb0cff4c85e2a3fb450a63 Signed-off-by: Ravindra Bakkamanthala --- .../services/CreateUpdateConfigPolicyService.java | 2 +- .../pdp/rest/api/services/GetDecisionService.java | 2 +- .../pdp/rest/api/services/GetMetricsService.java | 7 +- .../policy/pdp/rest/api/services/PAPServices.java | 330 +++------------------ .../policy/pdp/rest/api/services/PDPServices.java | 25 +- .../pdp/rest/api/services/SendEventService.java | 2 +- .../policy/pdp/rest/config/PDPApiAuth.java | 4 +- .../pdp/rest/impl/XACMLPdpPolicyFinderFactory.java | 2 +- .../ManualNotificationUpdateThread.java | 4 +- .../rest/notifications/NotificationController.java | 8 +- .../pdp/rest/notifications/NotificationServer.java | 4 +- ECOMP-PDP-REST/src/main/resources/logback.xml | 4 +- 12 files changed, 67 insertions(+), 327 deletions(-) (limited to 'ECOMP-PDP-REST/src/main') 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> attributes = new HashMap>(); + Map> 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> 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> 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> 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> 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> 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> 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 checkResponse(Response response) throws PolicyException{ String pdpConfigLocation = null; - Collection combinedResult = new HashSet(); + Collection combinedResult = new HashSet<>(); int priority = DEFAULT_PRIORITY; - Map uniqueResult = new HashMap(); + Map 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 matchingConditions = new HashMap(); - Map configAttributes = new HashMap(); - Map responseAttributes = new HashMap(); - Map actionTaken = new HashMap(); + Map matchingConditions = new HashMap<>(); + Map configAttributes = new HashMap<>(); + Map responseAttributes = new HashMap<>(); + Map actionTaken = new HashMap<>(); PDPResponse pdpResponse = new PDPResponse(); - Map adviseAttributes = new HashMap(); + Map 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 actionAdvised = new HashMap(); + Map 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 propVal = new HashMap(); + Map 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 eventResult( Collection generateRequest) { - Collection result = new HashSet(); + Collection 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>(); + 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 listPolicyDefs = new ArrayList(); + List 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 urlList = new LinkedList (); + final LinkedList 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(); + 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 removedPolicies = new HashSet(); - HashSet updatedPolicies = new HashSet(); + HashSet removedPolicies = new HashSet<>(); + HashSet updatedPolicies = new HashSet<>(); if (oldStatus == null) { oldStatus = newStatus; @@ -229,7 +229,7 @@ public class NotificationController { while (allOfs.hasNext()) { AllOf allOf = allOfs.next(); Iterator matches = allOf.getMatches(); - HashMap matchValues = new HashMap(); + HashMap 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 updatedPolicies = new HashSet(); + HashSet 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(Arrays.asList(dmaapServers.split("\\s*,\\s*"))); } else { - dmaapList = new ArrayList(); + 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 @@ - + @@ -205,7 +205,7 @@ 9 - INFO + DEBUG -- cgit 1.2.3-korg