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 --- .../org/openecomp/policy/api/PolicyEngine.java | 4 ++-- .../org/openecomp/policy/std/AutoClientUEB.java | 9 +++------ .../openecomp/policy/std/ManualClientEndDMAAP.java | 4 +++- .../openecomp/policy/std/ManualClientEndUEB.java | 15 +++++---------- .../java/org/openecomp/policy/std/MatchStore.java | 6 +++--- .../policy/std/NotificationUnMarshal.java | 2 +- .../org/openecomp/policy/std/StdPolicyEngine.java | 22 +++++++++++----------- PolicyEngineAPI/src/main/resources/logback.xml | 2 +- 8 files changed, 29 insertions(+), 35 deletions(-) (limited to 'PolicyEngineAPI/src/main') diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngine.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngine.java index 4fad508f6..4e2c092c1 100644 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngine.java +++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/api/PolicyEngine.java @@ -326,8 +326,8 @@ public class PolicyEngine{ /** * Retrieves the count of policies on the PAP, PDP, and Policy Engine as a whole * - * @param parameters {@link com.att.labs.ecomp.policy.api.MetricsRequestParameters} which represents the Parameters required to get the Policy Metrics - * @return {@link com.att.labs.ecomp.policy.api.MetricsResponse} which consists of the response related to getMetrics Request. + * @param parameters {@link org.openecomp.policy.api.MetricsRequestParameters} which represents the Parameters required to get the Policy Metrics + * @return {@link org.openecomp.policy.api.MetricsResponse} which consists of the response related to getMetrics Request. * @throws PolicyException PolicyException related to the operation * * */ diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java index 91d81d043..782187720 100644 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java +++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/AutoClientUEB.java @@ -22,7 +22,6 @@ package org.openecomp.policy.std; import java.net.MalformedURLException; import java.net.URL; -import java.security.GeneralSecurityException; import java.util.List; import java.util.UUID; @@ -127,11 +126,9 @@ public class AutoClientUEB implements Runnable { CConsumer = builder.build(); - } catch (MalformedURLException e1) { - e1.printStackTrace(); - } catch (GeneralSecurityException e1) { - e1.printStackTrace(); - } + } catch (Exception e1) { + logger.error("Exception Occured" + e1); + } while (this.isRunning() ) { try { diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndDMAAP.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndDMAAP.java index 0e30ada39..f4a218d66 100644 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndDMAAP.java +++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndDMAAP.java @@ -60,7 +60,9 @@ public class ManualClientEndDMAAP { } catch (Exception e) { logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Publisher: ", e); } - pub.close (); + if(pub != null){ + pub.close (); + } } //NOTE: should be able to remove this for DMAAP since we will not be creating topics dynamically diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java index f2a6a96d8..287e5c851 100644 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java +++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/ManualClientEndUEB.java @@ -23,7 +23,6 @@ package org.openecomp.policy.std; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; -import java.security.GeneralSecurityException; import java.util.List; import org.json.JSONObject; @@ -90,10 +89,8 @@ public class ManualClientEndUEB { CambriaPublisher pub = null; try { pub = CambriaClientFactory.createSimplePublisher(null, UEBlist, pubTopic); - } catch (MalformedURLException e1) { - e1.printStackTrace(); - } catch (GeneralSecurityException e1) { - e1.printStackTrace(); + } catch (Exception e1) { + logger.error("Exception Occured"+e1); } final JSONObject msg1 = new JSONObject (); @@ -135,11 +132,9 @@ public class ManualClientEndUEB { String id = "0"; try { CConsumer = CambriaClientFactory.createConsumer ( null, uebURLList, topic + uniquID, "clientGroup", id, 15*1000, 1000 ); - } catch (MalformedURLException e1) { - e1.printStackTrace(); - } catch (GeneralSecurityException e1) { - e1.printStackTrace(); - } + } catch (Exception e1) { + logger.error("Exception Occured"+e1); + } int count = 1; while (count < 4) { publishMessage(topic + "UpdateRequest", uniquID, uebURLList); diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java index ac3c9e968..1459dd9d9 100644 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java +++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/MatchStore.java @@ -34,7 +34,7 @@ import org.openecomp.policy.std.StdRemovedPolicy; import org.openecomp.policy.common.logging.flexlogger.*; public class MatchStore { - private static HashSet matchStore = new HashSet(); + private static HashSet matchStore = new HashSet<>(); private static Logger logger = FlexLogger.getLogger(MatchStore.class.getName()); public static HashSet getMatchStore() { @@ -115,7 +115,7 @@ public class MatchStore { } if(oldNotification.getRemovedPolicies()!=null && !oldNotification.getRemovedPolicies().isEmpty()){ // send all removed policies to client. - Collection removedPolicies = new HashSet(); + Collection removedPolicies = new HashSet<>(); StdRemovedPolicy newRemovedPolicy; for(RemovedPolicy removedPolicy: oldNotification.getRemovedPolicies()){ newRemovedPolicy = new StdRemovedPolicy(); @@ -127,7 +127,7 @@ public class MatchStore { removed = true; } if(oldNotification.getLoadedPolicies()!=null && !oldNotification.getLoadedPolicies().isEmpty()){ - Collection updatedPolicies = new HashSet(); + Collection updatedPolicies = new HashSet<>(); StdLoadedPolicy newUpdatedPolicy; for(LoadedPolicy updatedPolicy: oldNotification.getLoadedPolicies()){ // if it is config policies check their matches.. diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java index a09391baf..196f89b3d 100644 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java +++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/NotificationUnMarshal.java @@ -39,7 +39,7 @@ public class NotificationUnMarshal { notification = mapper.readValue(json, StdPDPNotification.class); if(notification!=null){ if(notification.getLoadedPolicies()!=null){ - Collection stdLoadedPolicies = new ArrayList(); + Collection stdLoadedPolicies = new ArrayList<>(); for(LoadedPolicy loadedPolicy: notification.getLoadedPolicies()){ StdLoadedPolicy stdLoadedPolicy = (StdLoadedPolicy) loadedPolicy; if(notification.getRemovedPolicies()!=null){ diff --git a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java index abe5ee767..5b10f3066 100644 --- a/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java +++ b/PolicyEngineAPI/src/main/java/org/openecomp/policy/std/StdPolicyEngine.java @@ -97,9 +97,9 @@ import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.RestTemplate; import org.xml.sax.InputSource; -import com.att.aft.dme2.internal.gson.Gson; -import com.att.aft.dme2.internal.gson.GsonBuilder; import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; /** * PolicyEngine Implementation class @@ -565,7 +565,7 @@ public class StdPolicyEngine { public Collection getConfigImpl(ConfigRequestParameters configRequestParameters) throws PolicyConfigException{ String resource= "getConfig"; - ArrayList response = new ArrayList(); + ArrayList response = new ArrayList<>(); String body = new String(); // Create Request. try { @@ -598,7 +598,7 @@ public class StdPolicyEngine { } private ArrayList configResult(APIPolicyConfigResponse[] response) throws PolicyConfigException { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); if(response!=null && response.length>0){ for(APIPolicyConfigResponse policyConfigResponse: response){ StdPolicyConfig policyConfig = new StdPolicyConfig(); @@ -647,7 +647,7 @@ public class StdPolicyEngine { private void setMatches(Map matchingConditions) { Matches match = new Matches(); - HashMap configAttributes = new HashMap(); + HashMap configAttributes = new HashMap<>(); try{ for(String key: matchingConditions.keySet()){ if(key.equalsIgnoreCase("ECOMPName")){ @@ -741,7 +741,7 @@ public class StdPolicyEngine { } public Collection listConfigImpl(ConfigRequestParameters listRequestParameters) throws PolicyConfigException{ - Collection policyList = new ArrayList(); + Collection policyList = new ArrayList<>(); if (junit){ policyList.add("Policy Name: listConfigTest"); return policyList; @@ -796,7 +796,7 @@ public class StdPolicyEngine { } private ArrayList eventResult(StdPolicyResponse[] response) throws PolicyEventException{ - ArrayList eventResult = new ArrayList(); + ArrayList eventResult = new ArrayList<>(); if(response!=null && response.length>0){ for(StdPolicyResponse policyConfigResponse: response){ eventResult.add(policyConfigResponse); @@ -860,7 +860,7 @@ public class StdPolicyEngine { typeDefault = new ArrayList(Arrays.asList(prop.getProperty("NOTIFICATION_TYPE").split(","))); notificationType = typeDefault; } else { - notificationType = new ArrayList(); + notificationType = new ArrayList<>(); notificationType.add(check_type); } } @@ -873,7 +873,7 @@ public class StdPolicyEngine { if(serverList.contains(",")) { notificationURLList = new ArrayList(Arrays.asList(serverList.split(","))); } else { - notificationURLList = new ArrayList(); + notificationURLList = new ArrayList<>(); notificationURLList.add(serverList); } } @@ -911,8 +911,8 @@ public class StdPolicyEngine { environment = Environment.DEVL.toString(); } // Initializing the values. - pdps = new ArrayList(); - encoding = new ArrayList(); + pdps = new ArrayList<>(); + encoding = new ArrayList<>(); // Check the Keys for PDP_URLs Collection unsorted = prop.keySet(); @SuppressWarnings({ "rawtypes", "unchecked" }) diff --git a/PolicyEngineAPI/src/main/resources/logback.xml b/PolicyEngineAPI/src/main/resources/logback.xml index 9e990ccd3..098db5a54 100644 --- a/PolicyEngineAPI/src/main/resources/logback.xml +++ b/PolicyEngineAPI/src/main/resources/logback.xml @@ -205,7 +205,7 @@ 9 - INFO + DEBUG -- cgit 1.2.3-korg