summaryrefslogtreecommitdiffstats
path: root/PolicyEngineClient/src/main/java/org
diff options
context:
space:
mode:
authorITSERVICES\rb7147 <rb7147@att.com>2017-04-25 11:46:00 -0400
committerITSERVICES\rb7147 <rb7147@att.com>2017-05-03 09:58:17 -0400
commite0addf5b588a1244f9679becd90999dfcb4c3a94 (patch)
tree1212772d6366730266ff0e093c874b07aa716c29 /PolicyEngineClient/src/main/java/org
parent39fb0f30472777e4b60d6a7ac8aa4eb9773961ff (diff)
Policy 1707 commit to LF
Change-Id: Ibe6f01d92f9a434c040abb05d5386e89d675ae65 Signed-off-by: ITSERVICES\rb7147 <rb7147@att.com>
Diffstat (limited to 'PolicyEngineClient/src/main/java/org')
-rw-r--r--PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java6
-rw-r--r--PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsRawPolicyClient.java13
-rw-r--r--PolicyEngineClient/src/main/java/org/openecomp/policyEngine/DecisionPolicyClient.java2
-rw-r--r--PolicyEngineClient/src/main/java/org/openecomp/policyEngine/Handler.java2
-rw-r--r--PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ImportBRMSTemplate.java30
-rw-r--r--PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ImportMicroServiceClient.java5
-rw-r--r--PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ListConfigPoliciesClient.java11
-rw-r--r--PolicyEngineClient/src/main/java/org/openecomp/policyEngine/MainClient.java44
-rw-r--r--PolicyEngineClient/src/main/java/org/openecomp/policyEngine/PolicyEngineTestClient.java3
9 files changed, 37 insertions, 79 deletions
diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java
index 4ecc488c5..37d25f2b9 100644
--- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java
+++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ActionPolicyClient.java
@@ -21,7 +21,6 @@
package org.openecomp.policyEngine;
import java.util.Arrays;
-import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
@@ -31,10 +30,8 @@ import java.util.UUID;
import org.openecomp.policy.api.AttributeType;
import org.openecomp.policy.api.PolicyChangeResponse;
import org.openecomp.policy.api.PolicyClass;
-import org.openecomp.policy.api.PolicyConfigType;
import org.openecomp.policy.api.PolicyEngine;
import org.openecomp.policy.api.PolicyParameters;
-import org.openecomp.policy.api.PolicyType;
public class ActionPolicyClient {
static Boolean isEdit = true;
@@ -59,9 +56,6 @@ public class ActionPolicyClient {
attributes.put(AttributeType.MATCHING, configAttributes);
policyParameters.setAttributes(attributes);
- //Set the Rule Algorithm
- // Map<String, Map<String, Map<String, String>>> translated to Map<Dynamic Label, Map<Field1,Map<Combo Operator, Field2>>>
- Map<String, Map<String,Map<String,String>>> ruleAlgorithm = new HashMap<String, Map<String,Map<String,String>>>();
List<String> dynamicRuleAlgorithmLabels = new LinkedList<String>();
List<String> dynamicRuleAlgorithmFunctions = new LinkedList<String>();
diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsRawPolicyClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsRawPolicyClient.java
index a8601c1cb..478b7e96a 100644
--- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsRawPolicyClient.java
+++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/BrmsRawPolicyClient.java
@@ -22,31 +22,18 @@ package org.openecomp.policyEngine;
import java.io.BufferedReader;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
-import javax.json.Json;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-
import org.openecomp.policy.api.AttributeType;
import org.openecomp.policy.api.PolicyChangeResponse;
-import org.openecomp.policy.api.PolicyClass;
import org.openecomp.policy.api.PolicyConfigType;
import org.openecomp.policy.api.PolicyEngine;
import org.openecomp.policy.api.PolicyParameters;
diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/DecisionPolicyClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/DecisionPolicyClient.java
index 1c446fdca..6b0b02eee 100644
--- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/DecisionPolicyClient.java
+++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/DecisionPolicyClient.java
@@ -63,8 +63,6 @@ public class DecisionPolicyClient {
attributes.put(AttributeType.SETTINGS, settingsMap);
policyParameters.setAttributes(attributes);
- //Set the Rule Algorithm... These are Optional
- Map<String, Map<String,Map<String,String>>> ruleAlgorithm = new HashMap<String, Map<String,Map<String,String>>>();
List<String> dynamicRuleAlgorithmLabels = new LinkedList<String>();
List<String> dynamicRuleAlgorithmFunctions = new LinkedList<String>();
diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/Handler.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/Handler.java
index 448b54270..cc54e7758 100644
--- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/Handler.java
+++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/Handler.java
@@ -56,6 +56,7 @@ public class Handler implements NotificationHandler{
// Checking the Name is correct or not.
try {
PolicyEngine policyEngine = new PolicyEngine("config.properties");
+ @SuppressWarnings("deprecation")
Collection<PolicyConfig> policyConfigs = policyEngine.getConfigByPolicyName(updatedPolicy.getPolicyName());
for(PolicyConfig policyConfig: policyConfigs){
if(policyConfig.getPolicyConfigStatus().equals(PolicyConfigStatus.CONFIG_RETRIEVED)){
@@ -93,6 +94,7 @@ public class Handler implements NotificationHandler{
// Checking the Name is correct or not.
try {
PolicyEngine policyEngine = new PolicyEngine("config.properties");
+ @SuppressWarnings("deprecation")
Collection<PolicyConfig> policyConfigs = policyEngine.getConfigByPolicyName(updatedPolicy.getPolicyName());
for(PolicyConfig policyConfig: policyConfigs){
if(policyConfig.getPolicyConfigStatus().equals(PolicyConfigStatus.CONFIG_RETRIEVED)){
diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ImportBRMSTemplate.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ImportBRMSTemplate.java
new file mode 100644
index 000000000..bb34c4985
--- /dev/null
+++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ImportBRMSTemplate.java
@@ -0,0 +1,30 @@
+package org.openecomp.policyEngine;
+
+import java.io.File;
+import java.util.UUID;
+
+import org.openecomp.policy.api.ImportParameters;
+import org.openecomp.policy.api.PolicyChangeResponse;
+import org.openecomp.policy.api.PolicyEngine;
+import org.openecomp.policy.api.ImportParameters.IMPORT_TYPE;
+
+public class ImportBRMSTemplate {
+ public static void main(String[] args) {
+ try{
+ PolicyEngine policyEngine = new PolicyEngine("config.properties");
+ ImportParameters importParameters = new ImportParameters();
+ importParameters.setFilePath("testResources"+File.separator+"test.drl");
+ importParameters.setServiceName("testTemplate");
+ importParameters.setRequestID(UUID.randomUUID());
+ importParameters.setServiceType(IMPORT_TYPE.BRMSPARAM);
+
+ // API method to create Policy or update policy
+ PolicyChangeResponse response = null;
+ response = policyEngine.policyEngineImport(importParameters);
+ System.out.println(response.getResponseMessage());
+
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ }
+ }
+}
diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ImportMicroServiceClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ImportMicroServiceClient.java
index ffb49d5ed..70e79805e 100644
--- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ImportMicroServiceClient.java
+++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ImportMicroServiceClient.java
@@ -20,14 +20,12 @@
package org.openecomp.policyEngine;
-import java.util.ArrayList;
-import java.util.List;
import java.util.UUID;
import org.openecomp.policy.api.ImportParameters;
+import org.openecomp.policy.api.ImportParameters.IMPORT_TYPE;
import org.openecomp.policy.api.PolicyChangeResponse;
import org.openecomp.policy.api.PolicyEngine;
-import org.openecomp.policy.api.ImportParameters.IMPORT_TYPE;
public class ImportMicroServiceClient {
static Boolean isEdit = false;
@@ -35,7 +33,6 @@ public class ImportMicroServiceClient {
try{
PolicyEngine policyEngine = new PolicyEngine("config.properties");
ImportParameters importParameters = new ImportParameters();
- List<String> filepath = new ArrayList<String>();
importParameters.setFilePath("C:\\Workspaces\\models\\TestingModel\\ControllerServiceSampleSdnlServiceInstance-v0.1.0-SNAPSHOT.zip");
importParameters.setServiceName("ControllerServiceSampleSdnlServiceInstance");
diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ListConfigPoliciesClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ListConfigPoliciesClient.java
index fa013bb69..11f4b0331 100644
--- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ListConfigPoliciesClient.java
+++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/ListConfigPoliciesClient.java
@@ -20,26 +20,15 @@
package org.openecomp.policyEngine;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
import org.openecomp.policy.api.ConfigRequestParameters;
import org.openecomp.policy.api.PolicyConfigException;
import org.openecomp.policy.api.PolicyEngine;
import org.openecomp.policy.api.PolicyEngineException;
-import org.w3c.dom.Document;
public class ListConfigPoliciesClient {
public static void main(String[] args) {
diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/MainClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/MainClient.java
index e7a2f8195..eb3c3b9de 100644
--- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/MainClient.java
+++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/MainClient.java
@@ -38,10 +38,8 @@ import org.openecomp.policy.api.LoadedPolicy;
import org.openecomp.policy.api.NotificationScheme;
import org.openecomp.policy.api.PolicyConfig;
import org.openecomp.policy.api.PolicyConfigException;
-import org.openecomp.policy.api.PolicyConfigStatus;
import org.openecomp.policy.api.PolicyEngine;
import org.openecomp.policy.api.PolicyEngineException;
-import org.openecomp.policy.api.PolicyType;
import org.openecomp.policy.api.RemovedPolicy;
import org.w3c.dom.Document;
@@ -50,8 +48,6 @@ public class MainClient {
PolicyEngine policyEngine;
try {
policyEngine = new PolicyEngine("config.properties");
- String eCOMPComponentName = ".*" ;
- String configName = ".*" ;
Map<String, String> configAttributes = new HashMap<String,String>();
configAttributes.put("java", "java");
configAttributes.put("peach", "Tar");
@@ -65,6 +61,7 @@ public class MainClient {
// Config Example
try {
+ @SuppressWarnings("deprecation")
Collection<PolicyConfig> policyConfigs = policyEngine.getConfigByPolicyName(".*");//(eCOMPComponentName, configName, configAttributes);
if(policyConfigs!=null && !policyConfigs.isEmpty()){
for(PolicyConfig policyConfig: policyConfigs){
@@ -72,50 +69,11 @@ public class MainClient {
System.out.println("Config Status: " + policyConfig.getPolicyConfigStatus());
System.out.println("Policy Name: "+ policyConfig.getPolicyName());
System.out.println("policy Version: " + policyConfig.getPolicyVersion());
- /*System.out.println("policy Type: " + policyConfig.getType().toString());
- System.out.println("Matching Conditions: " + policyConfig.getMatchingConditions());
- System.out.println("Body is : ");
- if(policyConfig.getPolicyConfigStatus().equals(PolicyConfigStatus.CONFIG_RETRIEVED)){
- if(policyConfig.getType().equals(PolicyType.OTHER)){
- System.out.println(policyConfig.toOther());
- }else if(policyConfig.getType().equals(PolicyType.JSON)){
- System.out.println(policyConfig.toJSON().toString());
- }else if(policyConfig.getType().equals(PolicyType.PROPERTIES)){
- System.out.println(policyConfig.toProperties().toString());
- }else if(policyConfig.getType().equals(PolicyType.XML)){
- try {
- printDocument(policyConfig.toXML(), System.out);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }*/
}
}
} catch (PolicyConfigException e) {
e.printStackTrace();
}
- // Action example
- /*try{
- Collection<PolicyResponse> policyResponses = org.openecomp.policyEngine.sendEvent(eventAttributes);
- if(policyResponses!=null && !policyResponses.isEmpty()){
- for(PolicyResponse policyResponse: policyResponses){
- System.out.println(policyResponse.getPolicyResponseMessage() + " : " + policyResponse.getPolicyResponseStatus());
- System.out.println(policyResponse.getActionAdvised());
- System.out.println(policyResponse.getActionTaken());
- System.out.println(policyResponse.getRequestAttributes());
- }
- }
- }catch (PolicyEventException e){
- e.printStackTrace();
- }*/
- /*// Decision example
- try{
- PolicyDecision policyDecision = org.openecomp.policyEngine.getDecision(eCOMPComponentName, decisionAttributes);
- System.out.println(policyDecision.toString());
- } catch(PolicyDecisionException e){
- e.printStackTrace();
- }*/
// Manual Notifications..
policyEngine.setScheme(NotificationScheme.MANUAL_ALL_NOTIFICATIONS);
diff --git a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/PolicyEngineTestClient.java b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/PolicyEngineTestClient.java
index f2606a971..16468e0ec 100644
--- a/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/PolicyEngineTestClient.java
+++ b/PolicyEngineClient/src/main/java/org/openecomp/policyEngine/PolicyEngineTestClient.java
@@ -67,6 +67,7 @@ public class PolicyEngineTestClient {
* @return
*/
+ @SuppressWarnings("deprecation")
public static ArrayList<String> getConfig(PolicyEngine policyEngine,
String eCOMPComponentName, String configName,
Map<String, String> configAttributes) {
@@ -117,6 +118,7 @@ public class PolicyEngineTestClient {
// Decision example
try {
UUID requestID = UUID.randomUUID();
+ @SuppressWarnings("deprecation")
DecisionResponse policyDecision = policyEngine.getDecision(
eCOMPComponentName, decisionAttributes, requestID);
resultReceived.add(policyDecision.getDecision().toString());
@@ -140,6 +142,7 @@ public class PolicyEngineTestClient {
ArrayList<String> resultReceived = new ArrayList<String>();
try {
UUID requestID = UUID.randomUUID();
+ @SuppressWarnings("deprecation")
Collection<PolicyResponse> policyResponses = policyEngine
.sendEvent(eventAttributes, requestID);
if (policyResponses != null && !policyResponses.isEmpty()) {