diff options
author | Tej, Tarun <tt3868@att.com> | 2017-12-12 15:04:43 -0500 |
---|---|---|
committer | Tej, Tarun <tt3868@att.com> | 2017-12-13 17:07:58 -0500 |
commit | 948367c08eb34ebaac24601cfc2b249b11925255 (patch) | |
tree | 662ec1834c897b3d77447905a3f9db397a2bd2bd /ONAP-PDP-REST/src/main | |
parent | aa9e865ccf191e814b50b8b4b51d516fc359d948 (diff) |
Adding PolicyType to getConfig Response
Adding a new parameter PolicyType so that getConfig Response can be known
based on type of policy. Fixes for project warnings and unused imports.
Issue-ID: POLICY-434
Change-Id: I0874abb7e986a8bb42ae18561064a8d7534eade6
Signed-off-by: Tej, Tarun <tt3868@att.com>
Diffstat (limited to 'ONAP-PDP-REST/src/main')
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 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()); |