X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=applications%2Fcommon%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpdp%2Fxacml%2Fapplication%2Fcommon%2FOnapPolicyFinderFactory.java;h=7da455c0db0a962c5135b79548b4fc939dc8aa9e;hb=59c38b6b3dfbd43c876f85ffb1e4b484951ced44;hp=1e47c5b529fa88c2924c2fa94d939f0c230e7039;hpb=934c39bcdb5ff9a095331f60ef1b279ec91875a9;p=policy%2Fxacml-pdp.git diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapPolicyFinderFactory.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapPolicyFinderFactory.java index 1e47c5b5..7da455c0 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapPolicyFinderFactory.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/OnapPolicyFinderFactory.java @@ -18,7 +18,6 @@ * ============LICENSE_END========================================================= */ - package org.onap.policy.pdp.xacml.application.common; import com.att.research.xacml.std.StdStatusCode; @@ -64,18 +63,16 @@ public class OnapPolicyFinderFactory extends PolicyFinderFactory { private List referencedPolicies; private boolean needsInit = true; - private Properties properties = null; + private Properties properties; /** - * Empty constructor. + * Empty private constructor. We do not want to create + * an instance of this without giving Properties object. + * + * @throws OnapPolicyFinderFactoryException Exception will be thrown */ - public OnapPolicyFinderFactory() { - logger.debug("Constructed without properties"); - // - // Here we differ from the StdPolicyFinderFactory in that we initialize right away. - // We do not wait for a policy request to happen to look for and load policies. - // - this.init(); + public OnapPolicyFinderFactory() throws OnapPolicyFinderFactoryException { + throw new OnapPolicyFinderFactoryException("Please use the constructor with Properties object."); } /** @@ -106,12 +103,7 @@ public class OnapPolicyFinderFactory extends PolicyFinderFactory { * @return a PolicyDef loaded from the given identifier */ protected PolicyDef loadPolicyDef(String policyId) { - String propLocation = null; - if (this.properties == null) { - propLocation = XACMLProperties.getProperty(policyId + PROP_FILE); - } else { - propLocation = this.properties.getProperty(policyId + PROP_FILE); - } + String propLocation = this.properties.getProperty(policyId + PROP_FILE); if (propLocation != null) { // // Try to load it from the file @@ -121,11 +113,8 @@ public class OnapPolicyFinderFactory extends PolicyFinderFactory { return policy; } } - if (this.properties == null) { - propLocation = XACMLProperties.getProperty(policyId + PROP_URL); - } else { - propLocation = this.properties.getProperty(policyId + PROP_URL); - } + + propLocation = this.properties.getProperty(policyId + PROP_URL); if (propLocation != null) { PolicyDef policy = this.loadPolicyUrlDef(propLocation); if (policy != null) { @@ -200,12 +189,7 @@ public class OnapPolicyFinderFactory extends PolicyFinderFactory { * @return a List of PolicyDefs loaded from the given property name */ protected List getPolicyDefs(String propertyName) { - String policyIds; - if (this.properties != null) { - policyIds = this.properties.getProperty(propertyName); - } else { - policyIds = XACMLProperties.getProperty(propertyName); - } + String policyIds = this.properties.getProperty(propertyName); if (Strings.isNullOrEmpty(policyIds)) { return Collections.emptyList(); }