diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2018-01-03 20:19:17 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2018-01-03 20:19:17 +0000 |
commit | 989ae85e3a25e059cb963a9bc293526be51273ca (patch) | |
tree | 74f691740612bc83acf31f5366a423505733e9e9 /ONAP-PDP-REST | |
parent | e688c3ab14a546dcc7acc189007ac4d42e349332 (diff) | |
parent | 948367c08eb34ebaac24601cfc2b249b11925255 (diff) |
Merge "Adding PolicyType to getConfig Response"
Diffstat (limited to 'ONAP-PDP-REST')
4 files changed, 44 insertions, 4 deletions
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 9939de966..f91f6e2f2 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()); |