diff options
Diffstat (limited to 'applications/common/src/main/java/org')
4 files changed, 13 insertions, 28 deletions
diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java index 52ecd84b..0f0f7ea2 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/PolicyApiCaller.java @@ -23,10 +23,7 @@ package org.onap.policy.pdp.xacml.application.common; import java.net.HttpURLConnection; import javax.ws.rs.core.Response; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; import org.onap.policy.common.endpoints.http.client.HttpClient; -import org.onap.policy.common.endpoints.http.client.HttpClientConfigException; -import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; import org.slf4j.Logger; @@ -46,16 +43,10 @@ public class PolicyApiCaller { /** * Constructs the object. * - * @param params target specification - * @throws PolicyApiException if an error occurs + * @param httpClient API REST client */ - public PolicyApiCaller(BusTopicParams params) throws PolicyApiException { - try { - params.setClientName("policy-api"); - httpClient = makeClient(params); - } catch (HttpClientConfigException e) { - throw new PolicyApiException("connection to host: " + params.getHostname(), e); - } + public PolicyApiCaller(HttpClient httpClient) { + this.httpClient = httpClient; } /** @@ -87,10 +78,4 @@ public class PolicyApiCaller { throw new PolicyApiException(type.toString(), e); } } - - // these methods may be overridden by junit tests - - protected HttpClient makeClient(BusTopicParams busParams) throws HttpClientConfigException { - return HttpClientFactoryInstance.getClientFactory().build(busParams); - } } diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java index 7512fb76..8d1bf617 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/XacmlApplicationServiceProvider.java @@ -27,7 +27,7 @@ import java.nio.file.Path; import java.util.List; import java.util.Map; import org.apache.commons.lang3.tuple.Pair; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -64,9 +64,9 @@ public interface XacmlApplicationServiceProvider { * Also gives api rest parameters if needed. * * @param pathForData Local Path - * @param policyApiParameters API rest parameters + * @param policyApiClient API rest client */ - void initialize(Path pathForData, BusTopicParams policyApiParameters) + void initialize(Path pathForData, HttpClient policyApiClient) throws XacmlApplicationException; /** diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java index cca2d218..e473de88 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdMatchableTranslator.java @@ -52,7 +52,7 @@ import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType; import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType; import org.apache.commons.lang3.tuple.Pair; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; import org.onap.policy.common.utils.coder.StandardYamlCoder; @@ -94,7 +94,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha private final Map<ToscaConceptIdentifier, MatchablePolicyType> matchableCache = new HashMap<>(); @Setter - private BusTopicParams apiRestParameters; + private HttpClient apiClient; @Setter private Path pathForData; @@ -572,7 +572,7 @@ public class StdMatchableTranslator extends StdBaseTranslator implements Matcha // ToscaServiceTemplate policyTemplate = null; try { - var api = new PolicyApiCaller(this.apiRestParameters); + var api = new PolicyApiCaller(this.apiClient); policyTemplate = api.getPolicyType(policyTypeId); } catch (PolicyApiException e) { diff --git a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java index 40968758..466aae12 100644 --- a/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java +++ b/applications/common/src/main/java/org/onap/policy/pdp/xacml/application/common/std/StdXacmlApplicationServiceProvider.java @@ -43,7 +43,7 @@ import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; import org.apache.commons.lang3.tuple.Pair; -import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams; +import org.onap.policy.common.endpoints.http.client.HttpClient; import org.onap.policy.models.decisions.concepts.DecisionRequest; import org.onap.policy.models.decisions.concepts.DecisionResponse; import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier; @@ -67,7 +67,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica private Path pathForData = null; @Getter - private BusTopicParams policyApiParameters; + private HttpClient policyApiClient; private Properties pdpProperties = null; private PDPEngine pdpEngine = null; private Map<ToscaPolicy, Path> mapLoadedPolicies = new HashMap<>(); @@ -83,7 +83,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica } @Override - public void initialize(Path pathForData, BusTopicParams policyApiParameters) + public void initialize(Path pathForData, HttpClient policyApiClient) throws XacmlApplicationException { // // Save our path @@ -93,7 +93,7 @@ public abstract class StdXacmlApplicationServiceProvider implements XacmlApplica // // Save our params // - this.policyApiParameters = policyApiParameters; + this.policyApiClient = policyApiClient; // // Look for and load the properties object // |