aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java2
-rw-r--r--ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java1
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/models/PolicyConfig.java8
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java2
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetConfigService.java36
-rw-r--r--ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PushPolicyService.java2
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java7
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java8
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java14
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java1
-rw-r--r--PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java10
12 files changed, 83 insertions, 10 deletions
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java
index 85d79f74a..4f65e26a0 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/XACMLPapServlet.java
@@ -40,7 +40,6 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Scanner;
@@ -88,7 +87,6 @@ import org.onap.policy.xacml.api.pap.ONAPPapEngineFactory;
import org.onap.policy.xacml.api.pap.OnapPDP;
import org.onap.policy.xacml.api.pap.OnapPDPGroup;
import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
-import org.onap.policy.xacml.std.pap.StdPAPPolicy;
import org.onap.policy.xacml.std.pap.StdPDP;
import org.onap.policy.xacml.std.pap.StdPDPGroup;
import org.onap.policy.xacml.std.pap.StdPDPItemSetChangeNotifier.StdItemSetChangeListener;
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
index cf183114c..70745b9b3 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
@@ -69,7 +69,6 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
-import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.onap.policy.common.logging.eelf.MessageCodes;
@@ -93,7 +92,6 @@ import org.onap.policy.xacml.api.pap.OnapPDPGroup;
import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
import org.onap.policy.xacml.std.pap.StdPDPGroup;
import org.onap.policy.xacml.std.pap.StdPDPPolicy;
-import org.onap.policy.xacml.util.XACMLPolicyScanner;
import org.onap.policy.xacml.util.XACMLPolicyWriter;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java
index c7148213d..c8b8c6a05 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/daoimpl/CommonClassDaoImpl.java
@@ -45,7 +45,6 @@ import org.onap.policy.rest.jpa.PolicyRoles;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
-import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
@Service("CommonClassDao")
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/models/PolicyConfig.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/models/PolicyConfig.java
index 391ef6c8a..3614bac08 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/models/PolicyConfig.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/models/PolicyConfig.java
@@ -24,6 +24,7 @@ import io.swagger.annotations.ApiModel;
import java.util.Map;
import org.onap.policy.api.PolicyConfigStatus;
+import org.onap.policy.api.PolicyConfigType;
import org.onap.policy.api.PolicyType;
import org.onap.policy.models.APIConfigResponse;
@@ -34,6 +35,7 @@ public class PolicyConfig implements APIConfigResponse{
private PolicyType type;
private String config;
private String policyName;
+ private PolicyConfigType policyType;
private String policyVersion;
private Map<String, String> matchingConditions;
private Map<String, String> responseAttributes;
@@ -92,4 +94,10 @@ public class PolicyConfig implements APIConfigResponse{
public Map<String,String> getResponseAttributes(){
return responseAttributes;
}
+ public PolicyConfigType getPolicyType() {
+ return policyType;
+ }
+ public void setPolicyType(PolicyConfigType policyType) {
+ this.policyType = policyType;
+ }
}
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java
index 483e13c23..b5797d131 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/CreateUpdatePolicyServiceImpl.java
@@ -23,7 +23,6 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
-import org.glassfish.jersey.spi.Contract;
import org.onap.policy.api.PolicyException;
import org.onap.policy.api.PolicyParameters;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
@@ -34,7 +33,6 @@ import org.onap.policy.rest.util.PolicyValidation;
import org.onap.policy.rest.util.PolicyValidationRequestWrapper;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Controller;
import com.google.common.base.Strings;
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetConfigService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetConfigService.java
index 58d5c8f31..6e6badf6a 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetConfigService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/GetConfigService.java
@@ -36,6 +36,7 @@ import javax.json.JsonObjectBuilder;
import org.onap.policy.api.ConfigRequestParameters;
import org.onap.policy.api.PolicyConfigException;
import org.onap.policy.api.PolicyConfigStatus;
+import org.onap.policy.api.PolicyConfigType;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.pdp.rest.api.models.PDPResponse;
@@ -143,11 +144,46 @@ public class GetConfigService {
policyConfig.setProperty(stdStatus.getProperty());
policyConfig.setResponseAttributes(stdStatus.getResponseAttributes());
policyConfig.setType(stdStatus.getType());
+ policyConfig.setPolicyType(getPolicyType(stdStatus.getPolicyName()));
result.add(policyConfig);
}
}
return result;
}
+
+ // Returns PolicyConfigType based on policyName.
+ private PolicyConfigType getPolicyType(String policyName) {
+ if(policyName != null) {
+ String name = policyName;
+ if(name.endsWith(".xml")){
+ name = name.substring(0, name.substring(0, name.lastIndexOf('.')).lastIndexOf('.'));
+ }
+ name = name.substring(name.lastIndexOf('.')+1);
+ PolicyConfigType extType = extendedServices(name);
+ if(extType != null) return extType;
+ if (name.startsWith("Config_BRMS_Param_")) {
+ return PolicyConfigType.BRMS_PARAM;
+ } else if(name.startsWith("Config_BRMS_Raw_")) {
+ return PolicyConfigType.BRMS_RAW;
+ } else if(name.startsWith("Config_Fault_")) {
+ return PolicyConfigType.ClosedLoop_Fault;
+ } else if(name.startsWith("Config_FW_")) {
+ return PolicyConfigType.Firewall;
+ } else if(name.startsWith("Config_PM_")) {
+ return PolicyConfigType.ClosedLoop_PM;
+ } else if(name.startsWith("Config_MS_")) {
+ return PolicyConfigType.MicroService;
+ } else if(name.startsWith("Config_")) {
+ return PolicyConfigType.Base;
+ }
+ }
+ return null;
+ }
+
+ public PolicyConfigType extendedServices(String policyName) {
+ // For extended services policyName will be required.
+ return null;
+ }
// Filter logic required for results comparing with requests.
private Collection<PolicyConfig> filterResults(
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PushPolicyService.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PushPolicyService.java
index 773f0d86a..a3d18b3e6 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PushPolicyService.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PushPolicyService.java
@@ -26,12 +26,10 @@ import org.onap.policy.api.PushPolicyParameters;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.xacml.api.XACMLErrorConstants;
-import org.onap.policy.xacml.std.pap.StdPAPPolicy;
import org.onap.policy.xacml.std.pap.StdPDPPolicy;
import org.springframework.http.HttpStatus;
import com.att.research.xacml.api.pap.PAPException;
-import com.att.research.xacml.api.pap.PDPPolicy;
public class PushPolicyService {
private static final Logger LOGGER = FlexLogger.getLogger(PushPolicyService.class.getName());
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java
index 652fd4da3..aa5ee1304 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/api/PolicyConfig.java
@@ -111,6 +111,13 @@ public interface PolicyConfig {
* @return <code>Map</code> of <code>String, String</code> which consists of the Response Attributes of the Policy retrieved.
*/
public Map<String,String> getResponseAttributes();
+
+ /**
+ * Gets the {@link PolicyConfigType} of the policy that has been retrieved.
+ *
+ * @return the <code>PolicyConfigType</code> of the policy that has been retrieved.
+ */
+ public PolicyConfigType getPolicyType();
/**
* Returns the <code>String</code> version of the <code>PolicyConfig</code> object.
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java b/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java
index 7efee00b8..be363c24f 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/models/APIPolicyConfigResponse.java
@@ -22,12 +22,14 @@ package org.onap.policy.models;
import java.util.Map;
import org.onap.policy.api.PolicyConfigStatus;
+import org.onap.policy.api.PolicyConfigType;
import org.onap.policy.api.PolicyType;
public class APIPolicyConfigResponse implements APIConfigResponse {
private String policyConfigMessage;
private PolicyConfigStatus policyConfigStatus;
private PolicyType type;
+ private PolicyConfigType policyType;
private String config;
private String policyName;
private String policyVersion;
@@ -88,4 +90,10 @@ public class APIPolicyConfigResponse implements APIConfigResponse {
public Map<String,String> getResponseAttributes(){
return responseAttributes;
}
+ public PolicyConfigType getPolicyType() {
+ return policyType;
+ }
+ public void setPolicyType(PolicyConfigType policyType) {
+ this.policyType = policyType;
+ }
}
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java
index 8a9b0a0b4..62db64491 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyConfig.java
@@ -28,6 +28,7 @@ import javax.json.JsonObject;
import org.onap.policy.api.PolicyConfig;
import org.onap.policy.api.PolicyConfigStatus;
+import org.onap.policy.api.PolicyConfigType;
import org.onap.policy.api.PolicyType;
import org.w3c.dom.Document;
@@ -48,6 +49,7 @@ public class StdPolicyConfig implements PolicyConfig{
private String configStatus;
private String policyName;
private String policyVersion;
+ private PolicyConfigType type;
private Map<String,String> matchingConditions;
private Map<String,String> responseAttributes;
@@ -89,7 +91,7 @@ public class StdPolicyConfig implements PolicyConfig{
@Override
public String getPolicyName() {
if(policyName!=null && policyName.contains(".xml")){
- return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf(".")).lastIndexOf(".")));
+ return (policyName.substring(0, policyName.substring(0, policyName.lastIndexOf('.')).lastIndexOf('.')));
}
return policyName;
}
@@ -158,7 +160,17 @@ public class StdPolicyConfig implements PolicyConfig{
this.responseAttributes = responseAttributes;
}
+
+ public void setPolicyType(PolicyConfigType policyType) {
+ this.type = policyType;
+ }
+
@Override
+ public PolicyConfigType getPolicyType(){
+ return this.type;
+ }
+
+ @Override
public String toString() {
return "PolicyConfig [ policyConfigStatus=" + policyConfigStatus + ", policyConfigMessage=" + configStatus + ", policyName=" + policyName +
""
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
index bef964174..6c74dde89 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
@@ -625,6 +625,7 @@ public class StdPolicyEngine {
policyConfig.setPolicyName(policyConfigResponse.getPolicyName());
policyConfig.setPolicyType(policyConfigResponse.getType());
policyConfig.setPolicyVersion(policyConfigResponse.getPolicyVersion());
+ policyConfig.setPolicyType(policyConfigResponse.getPolicyType());
policyConfig.setResponseAttributes(policyConfigResponse.getResponseAttributes());
setMatches(policyConfig.getMatchingConditions());
if (policyConfigResponse.getType() != null) {
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java
index 798cbde37..fc854b077 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdStatus.java
@@ -29,6 +29,7 @@ import javax.json.JsonObject;
import org.onap.policy.api.DecisionResponse;
import org.onap.policy.api.PolicyConfig;
import org.onap.policy.api.PolicyConfigStatus;
+import org.onap.policy.api.PolicyConfigType;
import org.onap.policy.api.PolicyDecision;
import org.onap.policy.api.PolicyResponse;
import org.onap.policy.api.PolicyResponseStatus;
@@ -39,6 +40,7 @@ public class StdStatus extends StdPolicyResponse implements PolicyConfig, Policy
private PolicyType policyType;
private Properties properties;
private JsonObject jsonObject;
+ private PolicyConfigType type;
private Document document;
private String other;
private PolicyConfigStatus policyConfigStatus;
@@ -232,4 +234,12 @@ public class StdStatus extends StdPolicyResponse implements PolicyConfig, Policy
public String getDetails(){
return details;
}
+
+ public PolicyConfigType getPolicyType() {
+ return type;
+ }
+
+ public void setPolicyType(PolicyConfigType policyType) {
+ this.type = policyType;
+ }
}