summaryrefslogtreecommitdiffstats
path: root/plugins/forwarding-plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/forwarding-plugins')
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java5
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarder.java37
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderParameters.java1
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java12
4 files changed, 26 insertions, 29 deletions
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java
index b50d6ff3..fde1a6fa 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/file/FilePolicyForwarder.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2019 Intel Crop. All rights reserved.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -90,9 +91,9 @@ public class FilePolicyForwarder implements PolicyForwarder {
writer.write("policyName: " + name);
if (fileForwarderParameters.isVerbose()) {
writer.newLine();
- writer.write("policy: " + pol.toString());
+ writer.write("policy: " + pol);
}
- LOGGER.debug("Sucessfully forwarded the policy to store into file {}.", path);
+ LOGGER.debug("Successfully forwarded the policy to store into file {}.", path);
} catch (final InvalidPathException | IOException exp) {
final String message = "Error sending policy to file under path:" + fileForwarderParameters.getPath();
throw new PolicyForwardingException(message, exp);
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarder.java
index 99615f50..c9ca5003 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarder.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarder.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Nordix Foundation.
- * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +28,6 @@ import java.util.Map;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
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;
@@ -52,7 +50,6 @@ public class LifecycleApiAutomationCompositionForwarder implements PolicyForward
private static final String COMMISSION_AUTOMATION_COMPOSITION_URI = "/onap/acm/v2/commission";
private static final Logger LOGGER = LoggerFactory.getLogger(LifecycleApiAutomationCompositionForwarder.class);
- private LifecycleApiAutomationCompositionForwarderParameters forwarderParameters;
private HttpClient automationCompositionClient;
/**
@@ -60,10 +57,11 @@ public class LifecycleApiAutomationCompositionForwarder implements PolicyForward
*/
@Override
public void configure(final String parameterGroupName) throws HttpClientConfigException {
- forwarderParameters = ParameterService.get(parameterGroupName);
+ LifecycleApiAutomationCompositionForwarderParameters forwarderParameters =
+ ParameterService.get(parameterGroupName);
automationCompositionClient = HttpClientFactoryInstance.getClientFactory().build(
- forwarderParameters.getAutomationCompositionRuntimeParameters());
+ forwarderParameters.getAutomationCompositionRuntimeParameters());
}
/**
@@ -77,7 +75,7 @@ public class LifecycleApiAutomationCompositionForwarder implements PolicyForward
}
if (!failedEntities.isEmpty()) {
throw new PolicyForwardingException(
- "Failed forwarding the following entities: " + Arrays.toString(failedEntities.toArray()));
+ "Failed forwarding the following entities: " + Arrays.toString(failedEntities.toArray()));
}
}
@@ -86,8 +84,8 @@ public class LifecycleApiAutomationCompositionForwarder implements PolicyForward
if (entity instanceof ToscaServiceTemplate) {
final var toscaServiceTemplate = (ToscaServiceTemplate) entity;
if (null != toscaServiceTemplate.getToscaTopologyTemplate()
- && null != toscaServiceTemplate.getNodeTypes()
- && null != toscaServiceTemplate.getDataTypes()) {
+ && null != toscaServiceTemplate.getNodeTypes()
+ && null != toscaServiceTemplate.getDataTypes()) {
commissionAutomationComposition(toscaServiceTemplate);
}
} else {
@@ -99,23 +97,22 @@ public class LifecycleApiAutomationCompositionForwarder implements PolicyForward
}
}
- private Response commissionAutomationComposition(final ToscaServiceTemplate toscaServiceTemplate)
- throws PolicyForwardingException {
- return invokeHttpClient(Entity.entity(toscaServiceTemplate, MediaType.APPLICATION_JSON),
- COMMISSION_AUTOMATION_COMPOSITION_URI);
+ private void commissionAutomationComposition(final ToscaServiceTemplate toscaServiceTemplate)
+ throws PolicyForwardingException {
+ invokeHttpClient(Entity.entity(toscaServiceTemplate, MediaType.APPLICATION_JSON));
}
- private Response invokeHttpClient(final Entity<?> entity, final String path)
- throws PolicyForwardingException {
- var response = automationCompositionClient.post(path, entity, Map.of(HttpHeaders.ACCEPT,
- MediaType.APPLICATION_JSON, HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON));
+ private void invokeHttpClient(final Entity<?> entity) throws PolicyForwardingException {
+ var response = automationCompositionClient.post(
+ LifecycleApiAutomationCompositionForwarder.COMMISSION_AUTOMATION_COMPOSITION_URI, entity,
+ Map.of(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON, HttpHeaders.CONTENT_TYPE,
+ MediaType.APPLICATION_JSON));
if (response.getStatus() / 100 != 2) {
- LOGGER.error(
- "Invocation of path {} failed for entity {}. Response status: {}, Response status info: {}",
- path, entity, response.getStatus(), response.getStatusInfo());
+ LOGGER.error("Invocation of path {} failed for entity {}. Response status: {}, Response status info: {}",
+ LifecycleApiAutomationCompositionForwarder.COMMISSION_AUTOMATION_COMPOSITION_URI,
+ entity, response.getStatus(), response.getStatusInfo());
throw new PolicyForwardingException("Failed creating the entity - " + entity);
}
- return response;
}
}
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderParameters.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderParameters.java
index be7c5263..2b7efbd5 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderParameters.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiAutomationCompositionForwarderParameters.java
@@ -1,7 +1,6 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2022 Nordix Foundation.
- * Modifications Copyright (C) 2022 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java
index 3a380843..9be6a0b2 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiPolicyForwarder.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019,2022 Nordix Foundation.
+ * Copyright (C) 2019, 2022 Nordix Foundation.
* Modifications Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada.
* ================================================================================
@@ -114,10 +114,10 @@ public class LifecycleApiPolicyForwarder implements PolicyForwarder {
}
}
- private Response createPolicyType(final ToscaServiceTemplate toscaServiceTemplate)
+ private void createPolicyType(final ToscaServiceTemplate toscaServiceTemplate)
throws PolicyForwardingException {
- return invokeHttpClient(Entity.entity(toscaServiceTemplate, MediaType.APPLICATION_JSON), CREATE_POLICY_TYPE_URI,
- true);
+ invokeHttpClient(Entity.entity(toscaServiceTemplate, MediaType.APPLICATION_JSON), CREATE_POLICY_TYPE_URI,
+ true);
}
private Response createPolicy(final ToscaServiceTemplate toscaServiceTemplate) throws PolicyForwardingException {
@@ -125,7 +125,7 @@ public class LifecycleApiPolicyForwarder implements PolicyForwarder {
CREATE_POLICY_URI, true);
}
- private Response deployPolicy(final ToscaServiceTemplate toscaServiceTemplate) throws PolicyForwardingException {
+ private void deployPolicy(final ToscaServiceTemplate toscaServiceTemplate) throws PolicyForwardingException {
final var pdpPolicies = new PdpDeployPolicies();
final List<ToscaConceptIdentifierOptVersion> policyIdentifierList = new ArrayList<>();
for (final Map<String, ToscaPolicy> policyMap : toscaServiceTemplate.getToscaTopologyTemplate().getPolicies()) {
@@ -139,7 +139,7 @@ public class LifecycleApiPolicyForwarder implements PolicyForwarder {
policyIdentifierList.add(toscaPolicyIdentifier);
}
pdpPolicies.setPolicies(policyIdentifierList);
- return invokeHttpClient(Entity.entity(pdpPolicies, MediaType.APPLICATION_JSON), DEPLOY_POLICY_URI, false);
+ invokeHttpClient(Entity.entity(pdpPolicies, MediaType.APPLICATION_JSON), DEPLOY_POLICY_URI, false);
}
private Response invokeHttpClient(final Entity<?> entity, final String path, final boolean wantApi)