summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java2
-rw-r--r--common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java15
-rw-r--r--common/src/test/resources/demo/config/RuntimeConfig.json22
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java12
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java10
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java2
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java6
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java4
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java4
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java31
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java14
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java15
-rw-r--r--models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java5
-rw-r--r--packages/policy-clamp-docker/pom.xml249
-rw-r--r--packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile47
-rw-r--r--packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile50
-rw-r--r--packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile50
-rw-r--r--packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh62
-rw-r--r--packages/policy-clamp-docker/src/main/docker/dcae-participant.sh64
-rw-r--r--packages/policy-clamp-docker/src/main/docker/policy-participant.sh64
-rw-r--r--packages/policy-clamp-tarball/pom.xml75
-rw-r--r--packages/policy-clamp-tarball/src/main/package/tarball/assembly.xml62
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.json53
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/DcaeParticipantParameters.json70
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.json76
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/logback-default.xml52
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/logback.xml194
-rw-r--r--packages/policy-clamp-tarball/src/main/resources/etc/ssl/policy-truststorebin0 -> 124180 bytes
-rw-r--r--packages/pom.xml61
-rw-r--r--participant/participant-impl/participant-impl-dcae/pom.xml19
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/DcaeParticipantApplication.java6
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java12
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java2
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java3
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java3
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java10
-rw-r--r--participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json22
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/controller/ChartController.java12
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java19
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java18
-rw-r--r--participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java1
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java5
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java19
-rw-r--r--participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java3
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java17
-rw-r--r--participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json22
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java2
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java1
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java111
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java94
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java2
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java13
-rw-r--r--participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json22
-rw-r--r--participant/participant-intermediary/pom.xml1
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java2
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java9
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java58
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java25
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java11
-rw-r--r--pom.xml8
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java3
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java14
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java310
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java56
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java3
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java206
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java1
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java1
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java3
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java31
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java9
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java3
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java83
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java69
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java19
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java8
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java6
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java55
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java1
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java5
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java15
-rw-r--r--runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json22
-rw-r--r--runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json20
-rw-r--r--runtime-controlloop/src/test/resources/parameters/TestParameters.json22
-rw-r--r--runtime-controlloop/src/test/resources/parameters/TestParametersMariaDB.json22
-rw-r--r--runtime-controlloop/src/test/resources/parameters/Unreadable.json22
-rw-r--r--runtime/pom.xml10
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/Application.java19
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java10
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryCache.java2
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/UnknownComponentException.java2
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/Constraint.java70
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ToscaElementProperty.java24
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java192
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaElementParser.java44
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java17
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java41
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/util/ResourceFileUtils.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/dao/model/jsontype/JsonTypeDescriptor.java3
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java49
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java38
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/deploy/DcaeDeployParameters.java13
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java14
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java14
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java17
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/tosca/Dictionary.java4
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java4
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java21
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java1
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java3
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java6
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java4
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java2
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java7
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java10
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java3
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java1
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java1
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java2
-rw-r--r--runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java3
122 files changed, 2306 insertions, 1293 deletions
diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java
index 05b913b22..58b5368a9 100644
--- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java
+++ b/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java
@@ -44,7 +44,7 @@ public class ControlLoopException extends Exception implements ErrorResponseInfo
/**
* Instantiates a new control loop exception.
*
- * @param statusCode the return code for the exception
+ * @param statusCode the status code for the response as a HTTP status code
* @param message the message on the exception
*/
public ControlLoopException(final Response.Status statusCode, final String message) {
diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java
index 3ef3d4cb0..ebc9028f4 100644
--- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java
+++ b/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java
@@ -23,7 +23,6 @@ package org.onap.policy.clamp.controlloop.common.startstop;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.net.URL;
import javax.ws.rs.core.Response;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
@@ -42,6 +41,8 @@ public class CommonCommandLineArguments {
/**
* Construct the options for the policy participant.
+ *
+ * @param options the options for the command line
*/
public CommonCommandLineArguments(final Options options) {
//@formatter:off
@@ -73,6 +74,7 @@ public class CommonCommandLineArguments {
/**
* Validate the command line options.
*
+ * @param configurationFilePath the path to the configuration file
* @throws ControlLoopException on command argument validation errors
*/
public void validate(final String configurationFilePath) throws ControlLoopException {
@@ -92,12 +94,13 @@ public class CommonCommandLineArguments {
* Print help information for policy participant.
*
* @param mainClassName the main class name
+ * @param options the options for the command
* @return the help string
*/
public String help(final String mainClassName, final Options options) {
- final HelpFormatter helpFormatter = new HelpFormatter();
- final StringWriter stringWriter = new StringWriter();
- final PrintWriter printWriter = new PrintWriter(stringWriter);
+ final var helpFormatter = new HelpFormatter();
+ final var stringWriter = new StringWriter();
+ final var printWriter = new PrintWriter(stringWriter);
helpFormatter.printHelp(printWriter, HELP_LINE_LENGTH, mainClassName + " [options...]", "options", options, 0,
0, "");
@@ -119,13 +122,13 @@ public class CommonCommandLineArguments {
}
// The file name refers to a resource on the local file system
- final URL fileUrl = ResourceUtils.getUrl4Resource(fileName);
+ final var fileUrl = ResourceUtils.getUrl4Resource(fileName);
if (fileUrl == null) {
throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist");
}
- final File theFile = new File(fileUrl.getPath());
+ final var theFile = new File(fileUrl.getPath());
if (!theFile.exists()) {
throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist");
diff --git a/common/src/test/resources/demo/config/RuntimeConfig.json b/common/src/test/resources/demo/config/RuntimeConfig.json
index 2c0127b16..529557eab 100644
--- a/common/src/test/resources/demo/config/RuntimeConfig.json
+++ b/common/src/test/resources/demo/config/RuntimeConfig.json
@@ -55,25 +55,5 @@
"topicCommInfrastructure": "dmaap"
}
]
- },
- "healthCheckRestClientParameters": [
- {
- "clientName": "api",
- "hostname": "policy-api",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "policy/api/v1/healthcheck"
- },
- {
- "clientName": "distribution",
- "hostname": "policy-distribution",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "healthcheck"
- }
- ]
+ }
}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java
index cac405abd..2a2cde2ae 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaControlLoop.java
@@ -26,7 +26,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import javax.persistence.AttributeOverride;
-import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
@@ -76,11 +75,8 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
// @formatter:off
@VerifyKey
@NotNull
- @AttributeOverrides({
- @AttributeOverride(name = "name", column = @Column(name = "definition_name")),
- @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
- }
- )
+ @AttributeOverride(name = "name", column = @Column(name = "definition_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
private PfConceptKey definition;
// @formatter:on
@@ -158,7 +154,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
@Override
public ControlLoop toAuthorative() {
- ControlLoop controlLoop = new ControlLoop();
+ var controlLoop = new ControlLoop();
controlLoop.setName(getKey().getName());
controlLoop.setVersion(getKey().getVersion());
@@ -184,7 +180,7 @@ public class JpaControlLoop extends PfConcept implements PfAuthorative<ControlLo
this.elements = new LinkedHashMap<>(controlLoop.getElements().size());
for (Entry<UUID, ControlLoopElement> elementEntry : controlLoop.getElements().entrySet()) {
- JpaControlLoopElement jpaControlLoopElement = new JpaControlLoopElement();
+ var jpaControlLoopElement = new JpaControlLoopElement();
jpaControlLoopElement.setKey(new PfReferenceKey(getKey(), elementEntry.getValue().getId().toString()));
jpaControlLoopElement.fromAuthorative(elementEntry.getValue());
this.elements.put(elementEntry.getKey(), jpaControlLoopElement);
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java
index 69b565266..4d49683bf 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/concepts/JpaParticipant.java
@@ -23,7 +23,6 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.concept
import java.io.Serializable;
import java.util.List;
import javax.persistence.AttributeOverride;
-import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
@@ -66,11 +65,8 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
// @formatter:off
@VerifyKey
@NotNull
- @AttributeOverrides({
- @AttributeOverride(name = "name", column = @Column(name = "definition_name")),
- @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
- }
- )
+ @AttributeOverride(name = "name", column = @Column(name = "definition_name"))
+ @AttributeOverride(name = "version", column = @Column(name = "definition_version"))
private PfConceptKey definition;
// @formatter:on
@@ -142,7 +138,7 @@ public class JpaParticipant extends PfConcept implements PfAuthorative<Participa
@Override
public Participant toAuthorative() {
- Participant participant = new Participant();
+ var participant = new Participant();
participant.setName(key.getName());
participant.setVersion(key.getVersion());
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
index 00eab8f69..f8f1f4145 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProvider.java
@@ -121,10 +121,12 @@ public class ClElementStatisticsProvider extends AbstractModelsProvider {
* Get filtered clElement statistics.
*
* @param name the clElement name for the statistics to get
+ * @param version the clElement version for the statistics to get
* @param startTimeStamp startTimeStamp to filter statistics
* @param endTimeStamp endTimeStamp to filter statistics
* @param sortOrder sortOrder to query database
* @param getRecordNum Total query count from database
+ * @param filterMap the filters to apply to the get operation
* @return the clElement statistics found
* @throws PfModelException on errors getting policies
*/
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
index 5317bb31d..7c34a6654 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java
@@ -162,13 +162,13 @@ public class ControlLoopProvider extends AbstractModelsProvider {
* @param name the name of the control loop to delete
* @param version the version of the control loop to delete
* @return the control loop deleted
- * @throws PfModelException on errors deleting the control loop
+ * @throws PfModelRuntimeException on errors deleting the control loop
*/
public ControlLoop deleteControlLoop(@NonNull final String name, @NonNull final String version) {
var controlLoopKey = new PfConceptKey(name, version);
- JpaControlLoop jpaDeleteControlLoop = getPfDao().get(JpaControlLoop.class, controlLoopKey);
+ var jpaDeleteControlLoop = getPfDao().get(JpaControlLoop.class, controlLoopKey);
if (jpaDeleteControlLoop == null) {
String errorMessage =
@@ -210,6 +210,8 @@ public class ControlLoopProvider extends AbstractModelsProvider {
/**
* Convert JPA control loop list to an authorative control loop list.
*
+ * @param <T> the type of TOSCA entity
+ * @param <J> the type of JPA TOSCA entity
* @param jpaEntityList the list to convert
* @return the authorative list
*/
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java
index c569cadd8..2ccc5d3c1 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProvider.java
@@ -133,7 +133,7 @@ public class ParticipantProvider extends AbstractModelsProvider {
* @param name the name of the participant to delete
* @param version the version of the participant to get
* @return the participant deleted
- * @throws PfModelException on errors deleting participants
+ * @throws PfModelRuntimeException on errors deleting participants
*/
public Participant deleteParticipant(@NonNull final String name, @NonNull final String version) {
@@ -155,7 +155,7 @@ public class ParticipantProvider extends AbstractModelsProvider {
/**
* Convert JPA participant list to an authorative participant list.
*
- * @param foundParticipants the list to convert
+ * @param jpaParticipantList the list to convert
* @return the authorative list
*/
private List<Participant> asParticipantList(List<JpaParticipant> jpaParticipantList) {
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
index 137af3a5e..a7216ed7f 100644
--- a/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProvider.java
@@ -54,6 +54,8 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
* Get Participant statistics.
*
* @param name the name of the participant statistics to get, null to get all stats
+ * @param version the version of the participant statistics to get, null to get all stats for a name
+ * @param timestamp the time stamp for the stats to get
* @return the participant statistics found
* @throws PfModelException on errors getting participant statistics
*/
@@ -77,10 +79,12 @@ public class ParticipantStatisticsProvider extends AbstractModelsProvider {
* Get filtered participant statistics.
*
* @param name the participant name for the statistics to get
+ * @param version the participant version for the statistics to get
* @param startTimeStamp startTimeStamp to filter statistics
* @param endTimeStamp endTimeStamp to filter statistics
* @param sortOrder sortOrder to query database
* @param getRecordNum Total query count from database
+ * @param filterMap the filters to apply to the get operation
* @return the participant statistics found
* @throws PfModelException on errors getting policies
*/
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java
index f5d094f9e..eb6a02898 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ClElementStatisticsProviderTest.java
@@ -41,8 +41,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
public class ClElementStatisticsProviderTest {
private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
private static final Coder CODER = new StandardCoder();
- private static final String CL_ELEMENT_STATS_JSON =
- "src/test/resources/providers/TestClElementStatistics.json";
+ private static final String CL_ELEMENT_STATS_JSON = "src/test/resources/providers/TestClElementStatistics.json";
private static AtomicInteger dbNameCounter = new AtomicInteger();
@@ -53,9 +52,11 @@ public class ClElementStatisticsProviderTest {
/**
* Set up test ClElement statistics provider.
+ *
+ * @throws Exception on errors
*/
@Before
- public void setupDao() throws Exception {
+ public void beforeSetupDao() throws Exception {
parameters = new PolicyModelsProviderParameters();
parameters.setDatabaseDriver("org.h2.Driver");
@@ -82,8 +83,8 @@ public class ClElementStatisticsProviderTest {
}).hasMessageMatching(LIST_IS_NULL);
ClElementStatisticsList createdClElementStats = new ClElementStatisticsList();
- createdClElementStats.setClElementStatistics(clElementStatisticsProvider
- .createClElementStatistics(inputClElementStats.getClElementStatistics()));
+ createdClElementStats.setClElementStatistics(
+ clElementStatisticsProvider.createClElementStatistics(inputClElementStats.getClElementStatistics()));
assertEquals(inputClElementStats.toString().replaceAll("\\s+", ""),
createdClElementStats.toString().replaceAll("\\s+", ""));
@@ -94,22 +95,18 @@ public class ClElementStatisticsProviderTest {
List<ClElementStatistics> getResponse;
- //Return empty list when no data present in db
- getResponse = clElementStatisticsProvider.getClElementStatistics(null, null, null,
- null);
+ // Return empty list when no data present in db
+ getResponse = clElementStatisticsProvider.getClElementStatistics(null, null, null, null);
assertThat(getResponse).isEmpty();
- clElementStatisticsProvider.createClElementStatistics(inputClElementStats
- .getClElementStatistics());
- ToscaConceptIdentifier identifier = inputClElementStats.getClElementStatistics().get(0)
- .getParticipantId();
+ clElementStatisticsProvider.createClElementStatistics(inputClElementStats.getClElementStatistics());
+ ToscaConceptIdentifier identifier = inputClElementStats.getClElementStatistics().get(0).getParticipantId();
Instant instant = inputClElementStats.getClElementStatistics().get(0).getTimeStamp();
String id = inputClElementStats.getClElementStatistics().get(0).getId().toString();
- assertEquals(1, clElementStatisticsProvider.getClElementStatistics(identifier.getName(),
- identifier.getVersion(), id, instant).size());
+ assertEquals(1, clElementStatisticsProvider
+ .getClElementStatistics(identifier.getName(), identifier.getVersion(), id, instant).size());
- assertEquals(1, clElementStatisticsProvider.getFilteredClElementStatistics("name2",
- "1.0.1", null, null, null,
- "DESC", 1).size());
+ assertEquals(1, clElementStatisticsProvider
+ .getFilteredClElementStatistics("name2", "1.0.1", null, null, null, "DESC", 1).size());
}
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java
index 96b63a23d..d362c2718 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProviderTest.java
@@ -56,11 +56,8 @@ public class ControlLoopProviderTest {
private String originalJson = ResourceUtils.getResourceAsString(CONTROL_LOOP_JSON);
private String updateClJson = ResourceUtils.getResourceAsString(UPDATE_CL_JSON);
- /**
- * Set up test control loop provider.
- */
@Before
- public void setupDao() throws Exception {
+ public void beforeSetupDao() throws Exception {
parameters = new PolicyModelsProviderParameters();
parameters.setDatabaseDriver("org.h2.Driver");
@@ -90,7 +87,7 @@ public class ControlLoopProviderTest {
ControlLoops createdControlLoops = new ControlLoops();
createdControlLoops
- .setControlLoopList(controlLoopProvider.createControlLoops(inputControlLoops.getControlLoopList()));
+ .setControlLoopList(controlLoopProvider.createControlLoops(inputControlLoops.getControlLoopList()));
assertEquals(inputControlLoops, createdControlLoops);
}
@@ -120,11 +117,10 @@ public class ControlLoopProviderTest {
}).hasMessageMatching("filter is marked .*ull but is null");
final ToscaTypedEntityFilter<ControlLoop> filter = ToscaTypedEntityFilter.<ControlLoop>builder()
- .type("org.onap.domain.pmsh.PMSHControlLoopDefinition").build();
+ .type("org.onap.domain.pmsh.PMSHControlLoopDefinition").build();
assertEquals(2, controlLoopProvider.getFilteredControlLoops(filter).size());
}
-
@Test
public void testUpdateControlLoops() throws Exception {
assertThatThrownBy(() -> {
@@ -133,7 +129,7 @@ public class ControlLoopProviderTest {
ControlLoops existingControlLoops = new ControlLoops();
existingControlLoops
- .setControlLoopList(controlLoopProvider.createControlLoops(inputControlLoops.getControlLoopList()));
+ .setControlLoopList(controlLoopProvider.createControlLoops(inputControlLoops.getControlLoopList()));
ControlLoop updateResponse = new ControlLoop();
updateResponse = controlLoopProvider.updateControlLoop(updateControlLoops.getControlLoopList().get(0));
@@ -156,5 +152,3 @@ public class ControlLoopProviderTest {
}
}
-
-
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java
index 7a86a49dc..41c106577 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantProviderTest.java
@@ -42,7 +42,7 @@ public class ParticipantProviderTest {
private static final Coder CODER = new StandardCoder();
private static final String PARTICIPANT_JSON =
- "src/test/resources/providers/TestParticipant.json";
+ "src/test/resources/providers/TestParticipant.json";
private static final String LIST_IS_NULL = ".*. is marked .*ull but is null";
private static AtomicInteger dbNameCounter = new AtomicInteger();
@@ -53,11 +53,8 @@ public class ParticipantProviderTest {
private Participant updateParticipants;
private String originalJson = ResourceUtils.getResourceAsString(PARTICIPANT_JSON);
- /**
- * Set up test Participant provider.
- */
@Before
- public void setupDao() throws Exception {
+ public void beforeSetupDao() throws Exception {
parameters = new PolicyModelsProviderParameters();
parameters.setDatabaseDriver("org.h2.Driver");
@@ -86,10 +83,10 @@ public class ParticipantProviderTest {
List<Participant> createdParticipants = new ArrayList<>();
createdParticipants.addAll(participantProvider
- .createParticipants(inputParticipants));
+ .createParticipants(inputParticipants));
assertEquals(createdParticipants.get(0),
- inputParticipants.get(0));
+ inputParticipants.get(0));
}
@@ -108,14 +105,14 @@ public class ParticipantProviderTest {
assertEquals(1, participantProvider.getParticipants(name, version).size());
assertThat(participantProvider.getParticipants("invalid_name",
- "1.0.1")).isEmpty();
+ "1.0.1")).isEmpty();
assertThatThrownBy(() -> {
participantProvider.getFilteredParticipants(null);
}).hasMessageMatching("filter is marked .*ull but is null");
final ToscaTypedEntityFilter<Participant> filter = ToscaTypedEntityFilter.<Participant>builder()
- .type("org.onap.domain.pmsh.PMSHControlLoopDefinition").build();
+ .type("org.onap.domain.pmsh.PMSHControlLoopDefinition").build();
assertEquals(1, participantProvider.getFilteredParticipants(filter).size());
}
diff --git a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java
index d4bc9777a..0fd3693c0 100644
--- a/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ParticipantStatisticsProviderTest.java
@@ -51,11 +51,8 @@ public class ParticipantStatisticsProviderTest {
private ParticipantStatisticsList inputParticipantStatistics;
private String originalJson = ResourceUtils.getResourceAsString(PARTICIPANT_STATS_JSON);
- /**
- * Set up test Participant statistics provider.
- */
@Before
- public void setupDao() throws Exception {
+ public void beforeSetupDao() throws Exception {
parameters = new PolicyModelsProviderParameters();
parameters.setDatabaseDriver("org.h2.Driver");
diff --git a/packages/policy-clamp-docker/pom.xml b/packages/policy-clamp-docker/pom.xml
new file mode 100644
index 000000000..fc6e36085
--- /dev/null
+++ b/packages/policy-clamp-docker/pom.xml
@@ -0,0 +1,249 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2021 Nordix Foundation.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onap.policy.clamp</groupId>
+ <artifactId>clamp-packages</artifactId>
+ <version>6.1.2-SNAPSHOT</version>
+ </parent>
+
+ <packaging>pom</packaging>
+ <artifactId>policy-clamp-docker</artifactId>
+ <name>${project.artifactId}</name>
+ <description>Policy clamp docker image</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ <dist.project.version>${project.version}</dist.project.version>
+ <docker.skip>false</docker.skip>
+ <docker.skip.build>false</docker.skip.build>
+ <docker.skip.push>false</docker.skip.push>
+ <docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry>
+ <docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
+ <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format>
+ </properties>
+
+ <build>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <source>
+ println 'Project version: ' + project.properties['dist.project.version']
+ if (project.properties['dist.project.version'] != null) {
+ def versionArray = project.properties['dist.project.version'].split('-')
+ def minMaxVersionArray = versionArray[0].tokenize('.')
+ if (project.properties['dist.project.version'].endsWith("-SNAPSHOT")) {
+ project.properties['project.docker.latest.minmax.tag.version'] =
+ minMaxVersionArray[0] + "." + minMaxVersionArray[1] + "-SNAPSHOT-latest"
+ } else {
+ project.properties['project.docker.latest.minmax.tag.version'] =
+ minMaxVersionArray[0] + "." + minMaxVersionArray[1] + "-STAGING-latest"
+ }
+ println 'New tag for docker: ' + project.properties['project.docker.latest.minmax.tag.version']
+ }
+ </source>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+
+ <configuration>
+ <verbose>true</verbose>
+ <apiVersion>1.23</apiVersion>
+ <pullRegistry>${docker.pull.registry}</pullRegistry>
+ <pushRegistry>${docker.push.registry}</pushRegistry>
+
+ <images>
+ <image>
+ <name>onap/policy-controlloop-runtime</name>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFile>ClRuntimeDockerfile</dockerFile>
+ <tags>
+ <tag>${project.version}</tag>
+ <tag>${project.version}-${maven.build.timestamp}</tag>
+ <tag>${project.docker.latest.minmax.tag.version}</tag>
+ </tags>
+ <assembly>
+ <inline>
+ <dependencySets>
+ <dependencySet>
+ <includes>
+ <include>org.onap.policy.clamp:policy-clamp-tarball</include>
+ </includes>
+ <outputDirectory>/lib</outputDirectory>
+ <outputFileNameMapping>policy-controlloop-runtime.tar.gz</outputFileNameMapping>
+ </dependencySet>
+ </dependencySets>
+ </inline>
+ </assembly>
+ </build>
+ </image>
+ <image>
+ <name>onap/policy-participant</name>
+ <alias>onap-policy-participant</alias>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFile>PolicyParticipantDockerfile</dockerFile>
+ <tags>
+ <tag>${project.version}</tag>
+ <tag>${project.version}-${maven.build.timestamp}</tag>
+ <tag>${project.docker.latest.minmax.tag.version}</tag>
+ </tags>
+ <assembly>
+ <inline>
+ <dependencySets>
+ <dependencySet>
+ <includes>
+ <include>org.onap.policy.clamp:policy-clamp-tarball</include>
+ </includes>
+ <outputDirectory>/lib</outputDirectory>
+ <outputFileNameMapping>policy-participant.tar.gz</outputFileNameMapping>
+ </dependencySet>
+ <dependencySet>
+ <includes>
+ <include>org.onap.policy.clamp.participant:policy-clamp-participant-impl-policy</include>
+ </includes>
+ <outputFileNameMapping>app.jar</outputFileNameMapping>
+ </dependencySet>
+ </dependencySets>
+ </inline>
+ </assembly>
+ </build>
+ </image>
+ <image>
+ <name>onap/dcae-participant</name>
+ <alias>onap-dcae-participant</alias>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFile>DcaeParticipantDockerfile</dockerFile>
+ <tags>
+ <tag>${project.version}</tag>
+ <tag>${project.version}-${maven.build.timestamp}</tag>
+ <tag>${project.docker.latest.minmax.tag.version}</tag>
+ </tags>
+ <assembly>
+ <inline>
+ <dependencySets>
+ <dependencySet>
+ <includes>
+ <include>org.onap.policy.clamp:policy-clamp-tarball</include>
+ </includes>
+ <outputDirectory>/lib</outputDirectory>
+ <outputFileNameMapping>dcae-participant.tar.gz</outputFileNameMapping>
+ </dependencySet>
+ <dependencySet>
+ <includes>
+ <include>org.onap.policy.clamp.participant:policy-clamp-participant-impl-dcae</include>
+ </includes>
+ <outputFileNameMapping>app.jar</outputFileNameMapping>
+ </dependencySet>
+ </dependencySets>
+ </inline>
+ </assembly>
+ </build>
+ </image>
+ </images>
+ </configuration>
+
+ <executions>
+ <execution>
+ <id>clean-images</id>
+ <phase>pre-clean</phase>
+ <goals>
+ <goal>remove</goal>
+ </goals>
+ <configuration>
+ <removeAll>true</removeAll>
+ </configuration>
+ </execution>
+
+ <execution>
+ <id>generate-images</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+
+ <execution>
+ <id>push-images</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>build</goal>
+ <goal>push</goal>
+ </goals>
+ <configuration>
+ <image>onap/policy-clamp</image>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.clamp</groupId>
+ <artifactId>policy-clamp-tarball</artifactId>
+ <version>${project.version}</version>
+ <classifier>tarball</classifier>
+ <type>tar.gz</type>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.clamp.participant</groupId>
+ <artifactId>policy-clamp-participant-impl-policy</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.clamp.participant</groupId>
+ <artifactId>policy-clamp-participant-impl-dcae</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile b/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile
new file mode 100644
index 000000000..bd5000686
--- /dev/null
+++ b/packages/policy-clamp-docker/src/main/docker/ClRuntimeDockerfile
@@ -0,0 +1,47 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START=======================================================
+# Copyright (C) 2021 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#-------------------------------------------------------------------------------
+
+#
+# Docker file to build an image that runs CLAMP on Java 11 or better in alpine
+#
+FROM onap/policy-jre-alpine:2.2.1
+
+LABEL maintainer="Policy Team"
+
+ARG POLICY_LOGS=/var/log/onap/policy/clamp
+
+ENV POLICY_LOGS=$POLICY_LOGS
+ENV POLICY_HOME=$POLICY_HOME/clamp
+
+RUN mkdir -p $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \
+ chown -R policy:policy $POLICY_HOME $POLICY_LOGS && \
+ mkdir /packages
+COPY /maven/* /packages
+RUN tar xvfz /packages/policy-controlloop-runtime.tar.gz --directory $POLICY_HOME && \
+ rm /packages/policy-controlloop-runtime.tar.gz
+
+WORKDIR $POLICY_HOME
+COPY controlloop-runtime.sh bin/.
+
+RUN chown -R policy:policy * && chmod 755 bin/*.sh
+
+USER policy
+WORKDIR $POLICY_HOME/bin
+ENTRYPOINT [ "./controlloop-runtime.sh" ]
diff --git a/packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile b/packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile
new file mode 100644
index 000000000..368b9348a
--- /dev/null
+++ b/packages/policy-clamp-docker/src/main/docker/DcaeParticipantDockerfile
@@ -0,0 +1,50 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START=======================================================
+# Copyright (C) 2021 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#-------------------------------------------------------------------------------
+
+#
+# Docker file to build an image that runs CLAMP on Java 11 or better in alpine
+#
+FROM onap/policy-jre-alpine:2.2.1
+
+LABEL maintainer="Policy Team"
+
+ARG POLICY_LOGS=/var/log/onap/policy/clamp
+
+ENV POLICY_LOGS=$POLICY_LOGS
+ENV POLICY_HOME=$POLICY_HOME/clamp
+
+RUN mkdir -p $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \
+ chown -R policy:policy $POLICY_HOME $POLICY_LOGS && \
+ mkdir /packages
+COPY /maven/lib/dcae-participant.tar.gz /packages
+RUN tar xvfz /packages/dcae-participant.tar.gz --directory $POLICY_HOME && \
+ rm /packages/dcae-participant.tar.gz && \
+ rm -rf $POLICY_HOME/lib
+
+WORKDIR $POLICY_HOME
+COPY dcae-participant.sh bin/.
+COPY /maven/app.jar /app
+
+RUN chown -R policy:policy * && chmod 755 bin/*.sh && \
+ chown -R policy:policy /app
+
+USER policy
+WORKDIR $POLICY_HOME/bin
+ENTRYPOINT [ "./dcae-participant.sh" ]
diff --git a/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile b/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile
new file mode 100644
index 000000000..3c2082202
--- /dev/null
+++ b/packages/policy-clamp-docker/src/main/docker/PolicyParticipantDockerfile
@@ -0,0 +1,50 @@
+#-------------------------------------------------------------------------------
+# ============LICENSE_START=======================================================
+# Copyright (C) 2021 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#-------------------------------------------------------------------------------
+
+#
+# Docker file to build an image that runs CLAMP on Java 11 or better in alpine
+#
+FROM onap/policy-jre-alpine:2.2.1
+
+LABEL maintainer="Policy Team"
+
+ARG POLICY_LOGS=/var/log/onap/policy/clamp
+
+ENV POLICY_LOGS=$POLICY_LOGS
+ENV POLICY_HOME=$POLICY_HOME/clamp
+
+RUN mkdir -p $POLICY_LOGS $POLICY_HOME $POLICY_HOME/bin && \
+ chown -R policy:policy $POLICY_HOME $POLICY_LOGS && \
+ mkdir /packages
+COPY /maven/lib/policy-participant.tar.gz /packages
+RUN tar xvfz /packages/policy-participant.tar.gz --directory $POLICY_HOME && \
+ rm /packages/policy-participant.tar.gz && \
+ rm -rf $POLICY_HOME/lib
+
+WORKDIR $POLICY_HOME
+COPY policy-participant.sh bin/.
+COPY /maven/app.jar /app
+
+RUN chown -R policy:policy * && chmod 755 bin/*.sh && \
+ chown -R policy:policy /app
+
+USER policy
+WORKDIR $POLICY_HOME/bin
+ENTRYPOINT [ "./policy-participant.sh" ]
diff --git a/packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh b/packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh
new file mode 100644
index 000000000..8d64fa5a4
--- /dev/null
+++ b/packages/policy-clamp-docker/src/main/docker/controlloop-runtime.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/env sh
+#
+# ============LICENSE_START=======================================================
+# Copyright (C) 2021 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#
+
+JAVA_HOME=/usr/lib/jvm/java-11-openjdk/
+KEYSTORE="${KEYSTORE:-$POLICY_HOME/etc/ssl/policy-keystore}"
+TRUSTSTORE="${TRUSTSTORE:-$POLICY_HOME/etc/ssl/policy-truststore}"
+KEYSTORE_PASSWD="${KEYSTORE_PASSWD:-Pol1cy_0nap}"
+TRUSTSTORE_PASSWD="${TRUSTSTORE_PASSWD:-Pol1cy_0nap}"
+
+if [ "$#" -eq 1 ]; then
+ CONFIG_FILE=$1
+else
+ CONFIG_FILE=${CONFIG_FILE}
+fi
+
+if [ -z "$CONFIG_FILE" ]; then
+ CONFIG_FILE="${POLICY_HOME}/etc/ClRuntimeParameters.json"
+fi
+
+echo "Policy clamp config file: $CONFIG_FILE"
+
+if [ -f "${POLICY_HOME}/etc/mounted/policy-truststore" ]; then
+ echo "overriding policy-truststore"
+ cp -f "${POLICY_HOME}"/etc/mounted/policy-truststore "${TRUSTSTORE}"
+fi
+
+if [ -f "${POLICY_HOME}/etc/mounted/policy-keystore" ]; then
+ echo "overriding policy-keystore"
+ cp -f "${POLICY_HOME}"/etc/mounted/policy-keystore "${KEYSTORE}"
+fi
+
+if [ -f "${POLICY_HOME}/etc/mounted/logback.xml" ]; then
+ echo "overriding logback.xml"
+ cp -f "${POLICY_HOME}"/etc/mounted/logback.xml "${POLICY_HOME}"/etc/
+fi
+
+$JAVA_HOME/bin/java -cp "${POLICY_HOME}/etc:${POLICY_HOME}/lib/*" \
+ -Dlogback.configurationFile="${POLICY_HOME}/etc/logback.xml" \
+ -Djavax.net.ssl.keyStore="${KEYSTORE}" \
+ -Djavax.net.ssl.keyStorePassword="${KEYSTORE_PASSWD}" \
+ -Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
+ -Djavax.net.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \
+ org.onap.policy.clamp.controlloop.runtime.main.startstop.Main \
+ -c "${CONFIG_FILE}"
diff --git a/packages/policy-clamp-docker/src/main/docker/dcae-participant.sh b/packages/policy-clamp-docker/src/main/docker/dcae-participant.sh
new file mode 100644
index 000000000..4acb17b39
--- /dev/null
+++ b/packages/policy-clamp-docker/src/main/docker/dcae-participant.sh
@@ -0,0 +1,64 @@
+#!/usr/bin/env sh
+#
+# ============LICENSE_START=======================================================
+# Copyright (C) 2021 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#
+
+JAVA_HOME=/usr/lib/jvm/java-11-openjdk/
+KEYSTORE="${KEYSTORE:-$POLICY_HOME/etc/ssl/policy-keystore}"
+TRUSTSTORE="${TRUSTSTORE:-$POLICY_HOME/etc/ssl/policy-truststore}"
+KEYSTORE_PASSWD="${KEYSTORE_PASSWD:-Pol1cy_0nap}"
+TRUSTSTORE_PASSWD="${TRUSTSTORE_PASSWD:-Pol1cy_0nap}"
+
+if [ "$#" -eq 1 ]; then
+ CONFIG_FILE=$1
+else
+ CONFIG_FILE=${CONFIG_FILE}
+fi
+
+if [ -z "$CONFIG_FILE" ]; then
+ CONFIG_FILE="${POLICY_HOME}/etc/DcaeParticipantParameters.json"
+fi
+
+echo "Policy clamp config file: $CONFIG_FILE"
+
+if [ -f "${POLICY_HOME}/etc/mounted/policy-truststore" ]; then
+ echo "overriding policy-truststore"
+ cp -f "${POLICY_HOME}"/etc/mounted/policy-truststore "${TRUSTSTORE}"
+fi
+
+if [ -f "${POLICY_HOME}/etc/mounted/policy-keystore" ]; then
+ echo "overriding policy-keystore"
+ cp -f "${POLICY_HOME}"/etc/mounted/policy-keystore "${KEYSTORE}"
+fi
+
+if [ -f "${POLICY_HOME}/etc/mounted/logback.xml" ]; then
+ echo "overriding logback xml files"
+ cp -f "${POLICY_HOME}"/etc/mounted/logback*.xml "${POLICY_HOME}"/etc/
+fi
+
+touch /app/app.jar
+mkdir -p "${POLICY_HOME}"/config/
+cp -f "${CONFIG_FILE}" "${POLICY_HOME}"/config/
+
+$JAVA_HOME/bin/java -Djavax.net.ssl.keyStore="${KEYSTORE}" \
+ -Djavax.net.ssl.keyStorePassword="${KEYSTORE_PASSWD}" \
+ -Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
+ -Djavax.net.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \
+ -jar /app/app.jar \
+ --participant.file="${POLICY_HOME}/config/DcaeParticipantParameters.json"
diff --git a/packages/policy-clamp-docker/src/main/docker/policy-participant.sh b/packages/policy-clamp-docker/src/main/docker/policy-participant.sh
new file mode 100644
index 000000000..2e7a7d54b
--- /dev/null
+++ b/packages/policy-clamp-docker/src/main/docker/policy-participant.sh
@@ -0,0 +1,64 @@
+#!/usr/bin/env sh
+#
+# ============LICENSE_START=======================================================
+# Copyright (C) 2021 Nordix Foundation.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#
+
+JAVA_HOME=/usr/lib/jvm/java-11-openjdk/
+KEYSTORE="${KEYSTORE:-$POLICY_HOME/etc/ssl/policy-keystore}"
+TRUSTSTORE="${TRUSTSTORE:-$POLICY_HOME/etc/ssl/policy-truststore}"
+KEYSTORE_PASSWD="${KEYSTORE_PASSWD:-Pol1cy_0nap}"
+TRUSTSTORE_PASSWD="${TRUSTSTORE_PASSWD:-Pol1cy_0nap}"
+
+if [ "$#" -eq 1 ]; then
+ CONFIG_FILE=$1
+else
+ CONFIG_FILE=${CONFIG_FILE}
+fi
+
+if [ -z "$CONFIG_FILE" ]; then
+ CONFIG_FILE="${POLICY_HOME}/etc/PolicyParticipantParameters.json"
+fi
+
+echo "Policy clamp config file: $CONFIG_FILE"
+
+if [ -f "${POLICY_HOME}/etc/mounted/policy-truststore" ]; then
+ echo "overriding policy-truststore"
+ cp -f "${POLICY_HOME}"/etc/mounted/policy-truststore "${TRUSTSTORE}"
+fi
+
+if [ -f "${POLICY_HOME}/etc/mounted/policy-keystore" ]; then
+ echo "overriding policy-keystore"
+ cp -f "${POLICY_HOME}"/etc/mounted/policy-keystore "${KEYSTORE}"
+fi
+
+if [ -f "${POLICY_HOME}/etc/mounted/logback.xml" ]; then
+ echo "overriding logback xml files"
+ cp -f "${POLICY_HOME}"/etc/mounted/logback*.xml "${POLICY_HOME}"/etc/
+fi
+
+touch /app/app.jar
+mkdir -p "${POLICY_HOME}"/config/
+cp -f "${CONFIG_FILE}" "${POLICY_HOME}"/config/
+
+$JAVA_HOME/bin/java -Djavax.net.ssl.keyStore="${KEYSTORE}" \
+ -Djavax.net.ssl.keyStorePassword="${KEYSTORE_PASSWD}" \
+ -Djavax.net.ssl.trustStore="${TRUSTSTORE}" \
+ -Djavax.net.ssl.trustStorePassword="${TRUSTSTORE_PASSWD}" \
+ -jar /app/app.jar \
+ --participant.file="${POLICY_HOME}/config/PolicyParticipantParameters.json"
diff --git a/packages/policy-clamp-tarball/pom.xml b/packages/policy-clamp-tarball/pom.xml
new file mode 100644
index 000000000..559dbaa4d
--- /dev/null
+++ b/packages/policy-clamp-tarball/pom.xml
@@ -0,0 +1,75 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2021 Nordix Foundation.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.clamp</groupId>
+ <artifactId>clamp-packages</artifactId>
+ <version>6.1.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>policy-clamp-tarball</artifactId>
+ <name>${project.artifactId}</name>
+ <description>[${project.parent.artifactId}]</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onap.policy.clamp</groupId>
+ <artifactId>policy-clamp-runtime-controlloop</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.clamp.participant</groupId>
+ <artifactId>policy-clamp-participant-impl-policy</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.policy.clamp.participant</groupId>
+ <artifactId>policy-clamp-participant-impl-dcae</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>generate-complete-tar</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/package/tarball/assembly.xml</descriptor>
+ </descriptors>
+ <finalName>${project.artifactId}-${project.version}</finalName>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/packages/policy-clamp-tarball/src/main/package/tarball/assembly.xml b/packages/policy-clamp-tarball/src/main/package/tarball/assembly.xml
new file mode 100644
index 000000000..6e8cd454a
--- /dev/null
+++ b/packages/policy-clamp-tarball/src/main/package/tarball/assembly.xml
@@ -0,0 +1,62 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2021 Nordix Foundation.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<assembly>
+ <id>tarball</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <dependencySets>
+ <dependencySet>
+ <useProjectArtifact>true</useProjectArtifact>
+ <outputDirectory>${file.separator}lib</outputDirectory>
+ <unpack>false</unpack>
+ <scope>runtime</scope>
+ <includes>
+ <include>*:jar</include>
+ </includes>
+ </dependencySet>
+ </dependencySets>
+ <fileSets>
+ <fileSet>
+ <directory>${project.basedir}/src/main/resources/etc
+ </directory>
+ <includes>
+ <include>*.json</include>
+ <include>*.xml</include>
+ </includes>
+ <outputDirectory>${file.separator}etc</outputDirectory>
+ <lineEnding>unix</lineEnding>
+ <excludes>
+ <exclude>*.formatted</exclude>
+ </excludes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/src/main/resources/etc/ssl
+ </directory>
+ <includes>
+ <include>policy*</include>
+ </includes>
+ <outputDirectory>${file.separator}etc${file.separator}ssl</outputDirectory>
+ <lineEnding>keep</lineEnding>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.json b/packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.json
new file mode 100644
index 000000000..5726fa54d
--- /dev/null
+++ b/packages/policy-clamp-tarball/src/main/resources/etc/ClRuntimeParameters.json
@@ -0,0 +1,53 @@
+{
+ "name": "ControlLoopRuntimeGroup",
+ "restServerParameters": {
+ "host": "0.0.0.0",
+ "port": 6969,
+ "userName": "healthcheck",
+ "password": "zb!XztG34",
+ "https": false,
+ "aaf": false
+ },
+ "participantParameters": {
+ "heartBeatMs": 120000,
+ "updateParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ },
+ "stateChangeParameters": {
+ "maxRetryCount": 1,
+ "maxWaitMs": 30000
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.mariadb.jdbc.Driver",
+ "databaseUrl": "jdbc:mariadb://localhost:3306/controlloop",
+ "databaseUser": "policy",
+ "databasePassword": "P01icY",
+ "persistenceUnit": "CommissioningMariaDb"
+ },
+ "topicParameterGroup": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [ "message-router" ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [ "message-router" ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [ "message-router" ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+}
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/DcaeParticipantParameters.json b/packages/policy-clamp-tarball/src/main/resources/etc/DcaeParticipantParameters.json
new file mode 100644
index 000000000..f3ff62325
--- /dev/null
+++ b/packages/policy-clamp-tarball/src/main/resources/etc/DcaeParticipantParameters.json
@@ -0,0 +1,70 @@
+{
+ "name": "ControlLoopParticipantDcae",
+ "clampClientParameters": {
+ "clientName": "Clamp",
+ "hostname": "0.0.0.0",
+ "port": 8443,
+ "userName": "admin",
+ "password": "password",
+ "useHttps": true,
+ "allowSelfSignedCerts": false
+ },
+ "consulClientParameters": {
+ "clientName": "Consul",
+ "hostname": "consul",
+ "port": 31321,
+ "userName": "admin",
+ "password": "password",
+ "useHttps": false
+ },
+ "intermediaryParameters": {
+ "name": "Participant parameters",
+ "reportingTimeInterval": 120000,
+ "description": "Participant Description",
+ "participantId": {
+ "name": "DCAEParticipant0",
+ "version": "1.0.0"
+ },
+ "participantType": {
+ "name": "org.onap.dcae.controlloop.DCAEMicroserviceControlLoopParticipant",
+ "version": "2.3.4"
+ },
+ "clampControlLoopTopics": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "message-router"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "message-router"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "message-router"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.mariadb.jdbc.Driver",
+ "databaseUrl": "jdbc:mariadb://mariadb:3306/policyadmin",
+ "databaseUser": "policy_user",
+ "databasePassword": "policy_user",
+ "persistenceUnit": "PolicyMariaDb"
+ }
+}
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.json b/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.json
new file mode 100644
index 000000000..e2eb067d9
--- /dev/null
+++ b/packages/policy-clamp-tarball/src/main/resources/etc/PolicyParticipantParameters.json
@@ -0,0 +1,76 @@
+{
+ "name":"ParticipantParameterGroup",
+ "participantStatusParameters":{
+ "timeIntervalMs":10000,
+ "description":"Participant Status",
+ "participantId":{
+ "name": "PolicyParticipant0",
+ "version":"1.0.0"
+ },
+ "participantType":{
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version":"2.3.1"
+ },
+ "participantDefinition":{
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version":"2.3.1"
+ }
+ },
+ "intermediaryParameters": {
+ "name": "Participant parameters",
+ "reportingTimeInterval": 120000,
+ "description": "Participant Description",
+ "participantId": {
+ "name": "PolicyParticipant0",
+ "version": "1.0.0"
+ },
+ "participantType": {
+ "name": "org.onap.policy.controlloop.PolicyControlLoopParticipant",
+ "version": "2.3.1"
+ },
+ "clampControlLoopTopics": {
+ "topicSources": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "message-router"
+ ],
+ "topicCommInfrastructure": "dmaap",
+ "fetchTimeout": 15000
+ }
+ ],
+ "topicSinks": [
+ {
+ "topic": "POLICY-CLRUNTIME-PARTICIPANT",
+ "servers": [
+ "message-router"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "message-router"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ },
+ {
+ "topic": "POLICY-NOTIFICATION",
+ "servers": [
+ "message-router"
+ ],
+ "topicCommInfrastructure": "dmaap"
+ }
+ ]
+ }
+ },
+ "databaseProviderParameters": {
+ "name": "PolicyProviderParameterGroup",
+ "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+ "databaseDriver": "org.mariadb.jdbc.Driver",
+ "databaseUrl": "jdbc:mariadb://mariadb:3306/policyadmin",
+ "databaseUser": "policy_user",
+ "databasePassword": "policy_user",
+ "persistenceUnit": "PolicyMariaDb"
+ }
+}
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/logback-default.xml b/packages/policy-clamp-tarball/src/main/resources/etc/logback-default.xml
new file mode 100644
index 000000000..33446c543
--- /dev/null
+++ b/packages/policy-clamp-tarball/src/main/resources/etc/logback-default.xml
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+
+<configuration scan="true" scanPeriod="30 seconds" debug="false">
+ <statusListener class="ch.qos.logback.core.status.NopStatusListener" />
+
+ <contextName>Clamp</contextName>
+ <property name="VAR_LOG" value="/var/log/onap/policy/clamp/" />
+
+ <!-- USE FOR STD OUT ONLY -->
+ <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+ <encoder>
+ <Pattern>%d %contextName [%t] %level %logger{36} - %msg%n</Pattern>
+ </encoder>
+ </appender>
+
+ <root level="info">
+ <appender-ref ref="STDOUT" />
+ </root>
+
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender">
+ <file>${VAR_LOG}/clamp.log</file>
+ <encoder>
+ <pattern>%d %-5relative [procId=${processId}] [%thread] %-5level
+ %logger{26} - %msg %n %ex{full}</pattern>
+ </encoder>
+ </appender>
+
+ <logger name="org.onap.policy.clamp" level="info" additivity="false">
+ <appender-ref ref="STDOUT" />
+ <appender-ref ref="FILE" />
+ </logger>
+
+</configuration>
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/logback.xml b/packages/policy-clamp-tarball/src/main/resources/etc/logback.xml
new file mode 100644
index 000000000..781861f58
--- /dev/null
+++ b/packages/policy-clamp-tarball/src/main/resources/etc/logback.xml
@@ -0,0 +1,194 @@
+<!--
+ ============LICENSE_START=======================================================
+ policy-clamp
+ ================================================================================
+ Copyright (C) 2021 Nordix Foundation.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ============LICENSE_END=========================================================
+ -->
+
+<configuration scan="true" scanPeriod="30 seconds" debug="false">
+
+ <property name="logDir" value="${POLICY_LOGS}" />
+
+ <property name="errorLog" value="error" />
+ <property name="debugLog" value="debug" />
+ <property name="networkLog" value="network" />
+
+ <property name="metricLog" value="metric" />
+ <property name="transactionLog" value="audit" />
+
+ <property name="debugPattern"
+ value="[%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%level|%logger{0}|%thread] %msg%n" />
+ <property name="errorPattern" value="${debugPattern}" />
+ <property name="networkPattern"
+ value="[%d{yyyy-MM-dd'T'HH:mm:ss.SSS+00:00, UTC}|%t]%m%n" />
+
+ <property
+ name="mpPreamble"
+ value="%X{RequestID}|%X{InvocationID}|%X{ServiceName}|%X{PartnerName}" />
+
+ <property
+ name="mpTime"
+ value="%X{BeginTimestamp}|%X{EndTimestamp}|%X{ElapsedTime}" />
+
+ <property
+ name="mpLine1"
+ value="%X{ServiceInstanceID}|%X{VirtualServerName}|%X{StatusCode}|%X{ResponseCode}|%X{ResponseDescription}" />
+
+ <property
+ name="mpLine2"
+ value="%X{InstanceUUID}|%X{Severity}|%X{TargetEntity}|%X{TargetServiceName}|%X{Server}|%X{ServerIPAddress}" />
+
+ <property
+ name="mpLine3"
+ value="%X{ServerFQDN}|%X{ClientIPAddress}|%X{ProcessKey}|%X{RemoteHost}|%X{AlertSeverity}" />
+
+ <property
+ name="mpLine4"
+ value="%X{TargetVirtualEntity}|%level|%thread| %msg%n" />
+
+
+ <property name="metricPattern"
+ value="{$mpPreamble}|{$mpTime}|{$mpLine1}|{$mpLine2}|{$mpLine3}|$mpLine4" />
+
+ <property name="transactionPattern" value="${metricPattern}" />
+
+ <appender name="ErrorOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${errorLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${errorLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+ <level>WARN</level>
+ </filter>
+ <encoder>
+ <pattern>${errorPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncErrorOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="ErrorOut" />
+ </appender>
+
+ <appender name="DebugOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${debugLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${debugLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${debugPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncDebugOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="DebugOut" />
+ </appender>
+
+ <appender name="NetworkOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${networkLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${networkLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${networkPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncNetworkOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="NetworkOut" />
+ </appender>
+
+ <appender name="MetricOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${metricLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${metricLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${metricPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncMetricOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="MetricOut" />
+ </appender>
+
+ <appender name="TransactionOut"
+ class="ch.qos.logback.core.rolling.RollingFileAppender">
+ <file>${logDir}/${transactionLog}.log</file>
+ <rollingPolicy
+ class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
+ <fileNamePattern>${logDir}/${transactionLog}.%d{yyyy-MM-dd}.%i.log.zip
+ </fileNamePattern>
+ <maxFileSize>50MB</maxFileSize>
+ <maxHistory>30</maxHistory>
+ <totalSizeCap>10GB</totalSizeCap>
+ </rollingPolicy>
+ <encoder>
+ <pattern>${transactionPattern}</pattern>
+ </encoder>
+ </appender>
+
+ <appender name="AsyncTransactionOut"
+ class="ch.qos.logback.classic.AsyncAppender">
+ <appender-ref ref="TransactionOut" />
+ </appender>
+
+ <logger name="network" level="INFO" additivity="false">
+ <appender-ref ref="AsyncNetworkOut" />
+ </logger>
+
+ <logger name="org.eclipse.jetty.server.RequestLog" level="info"
+ additivity="false">
+ <appender-ref ref="AsyncNetworkOut" />
+ </logger>
+
+ <logger name="org.eclipse.jetty" level="ERROR" />
+
+ <root level="INFO">
+ <appender-ref ref="AsyncDebugOut" />
+ <appender-ref ref="AsyncErrorOut" />
+ <appender-ref ref="AsyncMetricOut" />
+ <appender-ref ref="AsyncTransactionOut" />
+ </root>
+
+</configuration>
diff --git a/packages/policy-clamp-tarball/src/main/resources/etc/ssl/policy-truststore b/packages/policy-clamp-tarball/src/main/resources/etc/ssl/policy-truststore
new file mode 100644
index 000000000..8834ac257
--- /dev/null
+++ b/packages/policy-clamp-tarball/src/main/resources/etc/ssl/policy-truststore
Binary files differ
diff --git a/packages/pom.xml b/packages/pom.xml
new file mode 100644
index 000000000..4f5a0849e
--- /dev/null
+++ b/packages/pom.xml
@@ -0,0 +1,61 @@
+<!--
+ ============LICENSE_START=======================================================
+ Copyright (C) 2021 Nordix Foundation.
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+ SPDX-License-Identifier: Apache-2.0
+ ============LICENSE_END=========================================================
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onap.policy.clamp</groupId>
+ <artifactId>policy-clamp</artifactId>
+ <version>6.1.2-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>clamp-packages</artifactId>
+ <packaging>pom</packaging>
+
+ <name>${project.artifactId}</name>
+ <description>[${project.parent.artifactId}] packaging</description>
+
+ <properties>
+ <!-- There is no code in this sub-module, only holds interfaces. So skip sonar. -->
+ <sonar.skip>true</sonar.skip>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>default</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ <modules>
+ <module>policy-clamp-tarball</module>
+ </modules>
+ </profile>
+ <profile>
+ <id>docker</id>
+ <modules>
+ <module>policy-clamp-tarball</module>
+ <module>policy-clamp-docker</module>
+ </modules>
+ <properties>
+ <docker.skip.push>false</docker.skip.push>
+ </properties>
+ </profile>
+ </profiles>
+</project>
+
diff --git a/participant/participant-impl/participant-impl-dcae/pom.xml b/participant/participant-impl/participant-impl-dcae/pom.xml
index 714f1551c..d59bca376 100644
--- a/participant/participant-impl/participant-impl-dcae/pom.xml
+++ b/participant/participant-impl/participant-impl-dcae/pom.xml
@@ -31,44 +31,32 @@
<artifactId>policy-clamp-participant-impl-dcae</artifactId>
<name>${project.artifactId}</name>
<description>DCAE participant, that allows DCAE to partake in control loops</description>
-
- <dependencyManagement>
- <dependencies>
- <!-- Spring Boot BOM -->
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-dependencies</artifactId>
- <version>${version.springboot}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
+ <version>${version.springboot}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
+ <version>${version.springboot}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
+ <version>${version.springboot}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-netty</artifactId>
- <version>${version.mockserver}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mock-server</groupId>
<artifactId>mockserver-client-java</artifactId>
- <version>${version.mockserver}</version>
<scope>test</scope>
</dependency>
</dependencies>
@@ -78,7 +66,6 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
- <version>${version.springboot}</version>
<executions>
<execution>
<goals>
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/DcaeParticipantApplication.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/DcaeParticipantApplication.java
index 25edaf552..9be83bbd3 100644
--- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/DcaeParticipantApplication.java
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/DcaeParticipantApplication.java
@@ -30,8 +30,10 @@ import org.springframework.context.annotation.ComponentScan;
*
*/
@SpringBootApplication
-@ComponentScan({"org.onap.policy.clamp.controlloop.participant.dcae",
- "org.onap.policy.clamp.controlloop.participant.intermediary"})
+@ComponentScan({
+ "org.onap.policy.clamp.controlloop.participant.dcae",
+ "org.onap.policy.clamp.controlloop.participant.intermediary"
+})
@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.dcae.main.parameters")
public class DcaeParticipantApplication {
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java
index e23aaaf23..43326e725 100644
--- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/AbstractHttpClient.java
@@ -24,7 +24,6 @@ import java.io.Closeable;
import java.io.IOException;
import java.util.Collections;
import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.clamp.controlloop.participant.dcae.model.Loop;
@@ -46,6 +45,9 @@ public abstract class AbstractHttpClient implements Closeable {
/**
* Constructor.
+ *
+ * @param restClientParameters the REST client parameters
+ * @throws ControlLoopRuntimeException on errors
*/
protected AbstractHttpClient(BusTopicParams restClientParameters) {
try {
@@ -58,7 +60,7 @@ public abstract class AbstractHttpClient implements Closeable {
protected boolean executePut(String path, String jsonEntity, int statusCode) {
try {
- Response response = httpclient.put(path, Entity.json(jsonEntity), Collections.emptyMap());
+ var response = httpclient.put(path, Entity.json(jsonEntity), Collections.emptyMap());
return response.getStatus() == statusCode;
} catch (Exception e) {
LOGGER.error(MSG_REQUEST_FAILED, httpclient.getName(), e);
@@ -68,7 +70,7 @@ public abstract class AbstractHttpClient implements Closeable {
protected boolean executePut(String path, int statusCode) {
try {
- Response response = httpclient.put(path, Entity.json(""), Collections.emptyMap());
+ var response = httpclient.put(path, Entity.json(""), Collections.emptyMap());
return response.getStatus() == statusCode;
} catch (Exception e) {
LOGGER.error(MSG_REQUEST_FAILED, httpclient.getName(), e);
@@ -78,7 +80,7 @@ public abstract class AbstractHttpClient implements Closeable {
protected Loop executePost(String path, int statusCode) {
try {
- Response response = httpclient.post(path, Entity.json(""), Collections.emptyMap());
+ var response = httpclient.post(path, Entity.json(""), Collections.emptyMap());
if (response.getStatus() != statusCode) {
return null;
}
@@ -91,7 +93,7 @@ public abstract class AbstractHttpClient implements Closeable {
protected Loop executeGet(String path, int statusCode) {
try {
- Response response = httpclient.get(path);
+ var response = httpclient.get(path);
if (response.getStatus() != statusCode) {
return null;
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java
index e928c138f..fd19d9d3a 100644
--- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ClampHttpClient.java
@@ -40,6 +40,8 @@ public class ClampHttpClient extends AbstractHttpClient {
/**
* Constructor.
+ *
+ * @param parameters the DCAE parameters
*/
public ClampHttpClient(ParticipantDcaeParameters parameters) {
super(parameters.getClampClientParameters());
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java
index 4f76e3025..154dd09be 100644
--- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/httpclient/ConsulDcaeHttpClient.java
@@ -31,6 +31,8 @@ public class ConsulDcaeHttpClient extends AbstractHttpClient {
/**
* Constructor.
+ *
+ * @param parameters the DCAE parameters
*/
public ConsulDcaeHttpClient(ParticipantDcaeParameters parameters) {
super(parameters.getConsulClientParameters());
@@ -39,6 +41,7 @@ public class ConsulDcaeHttpClient extends AbstractHttpClient {
/**
* Call consult.
*
+ * @param name the name to deploy
* @param jsonEntity the Entity
* @return true
*/
diff --git a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java
index 76ed1122c..6c5ff1d78 100644
--- a/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java
+++ b/participant/participant-impl/participant-impl-dcae/src/main/java/org/onap/policy/clamp/controlloop/participant/dcae/main/handler/ControlLoopElementHandler.java
@@ -74,6 +74,9 @@ public class ControlLoopElementHandler implements ControlLoopElementListener {
/**
* Constructor.
+ *
+ * @param clampClient the CLAMP client
+ * @param consulClient the Consul client
*/
public ControlLoopElementHandler(ClampHttpClient clampClient, ConsulDcaeHttpClient consulClient) {
this.clampClient = clampClient;
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java
index cb06fcb15..5d8881eb3 100644
--- a/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-dcae/src/test/java/org/onap/policy/clamp/controlloop/participant/dcae/main/parameters/CommonTestData.java
@@ -59,16 +59,19 @@ public class CommonTestData {
/**
* Converts the contents of a map to a parameter class.
*
+ * @param <T> specific type of ParameterGroup class
* @param source property map
* @param clazz class of object to be created from the map
* @return a new object represented by the map
+ * @throws ControlLoopRuntimeException on errors
*/
public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) {
try {
return coder.convert(source, clazz);
} catch (final CoderException e) {
- throw new RuntimeException("cannot create " + clazz.getName() + " from map", e);
+ throw new ControlLoopRuntimeException(Response.Status.INTERNAL_SERVER_ERROR,
+ "cannot create " + clazz.getName() + " from map", e);
}
}
@@ -95,6 +98,7 @@ public class CommonTestData {
*
* @param isEmpty boolean value to represent that object created should be empty or not
* @return a property map suitable for constructing an object
+ * @throws ControlLoopRuntimeException on errors
*/
public Map<String, Object> getClampClientParametersMap(final boolean isEmpty) {
final Map<String, Object> map = new TreeMap<>();
@@ -121,6 +125,7 @@ public class CommonTestData {
*
* @param isEmpty boolean value to represent that object created should be empty or not
* @return a property map suitable for constructing an object
+ * @throws ControlLoopRuntimeException on errors
*/
public Map<String, Object> getConsulClientParametersMap(final boolean isEmpty) {
final Map<String, Object> map = new TreeMap<>();
@@ -228,6 +233,7 @@ public class CommonTestData {
*
* @param port port to be inserted into the parameters
* @return the standard participant parameters
+ * @throws ControlLoopRuntimeException on errors
*/
public ParticipantDcaeParameters getParticipantParameterGroup(int port) {
try {
@@ -244,6 +250,7 @@ public class CommonTestData {
*
* @param port port to be inserted into the parameters
* @return the standard participant parameters
+ * @throws ControlLoopRuntimeException on errors
*/
public static String getParticipantParameterGroupAsString(int port) {
@@ -289,6 +296,7 @@ public class CommonTestData {
*
* @param status the status of Partecipant
* @return the JSON
+ * @throws ControlLoopRuntimeException on errors
*/
public static String createJsonStatus(String status) {
try {
diff --git a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json
index 581ce8f4f..b918defe4 100644
--- a/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json
+++ b/participant/participant-impl/participant-impl-dcae/src/test/resources/parameters/Unreadable.json
@@ -55,27 +55,7 @@
"topicCommInfrastructure": "dmaap"
}
]
- },
- "healthCheckRestClientParameters": [
- {
- "clientName": "api",
- "hostname": "policy-api",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "policy/api/v1/healthcheck"
- },
- {
- "clientName": "distribution",
- "hostname": "policy-distribution",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "healthcheck"
- }
- ]
+ }
}
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/controller/ChartController.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/controller/ChartController.java
index 427b06fc5..5560e47a8 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/controller/ChartController.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/controller/ChartController.java
@@ -74,7 +74,8 @@ public class ChartController {
*
* @param info Info of the chart to be installed
* @return Status of the install operation
- * @throws ServiceException incase of error
+ * @throws ServiceException in case of error
+ * @throws IOException in case of IO error
*/
@PostMapping(path = "/install", consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@@ -97,7 +98,7 @@ public class ChartController {
* @param name name of the chart
* @param version version of the chart
* @return Status of operation
- * @throws ServiceException incase of error.
+ * @throws ServiceException in case of error.
*/
@DeleteMapping(path = "/uninstall/{name}/{version}", produces = MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "Uninstall the Chart")
@@ -118,9 +119,10 @@ public class ChartController {
*
* @param chartFile Multipart file for the helm chart
* @param infoJson AppInfo of the chart
+ * @param overrideFile the file for overriding the chart
* @return Status of onboard operation
- * @throws ServiceException incase of error
- * @throws IOException incase of IO error
+ * @throws ServiceException in case of error
+ * @throws IOException in case of IO error
*/
@PostMapping(path = "/charts", consumes = MediaType.MULTIPART_FORM_DATA_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
@@ -147,7 +149,7 @@ public class ChartController {
* @param name name of the chart
* @param version version of the chart
* @return Status of operation
- * @throws ServiceException incase of error.
+ * @throws ServiceException in case of error.
*/
@DeleteMapping(path = "/charts/{name}/{version}")
@ApiOperation(value = "Delete the chart")
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java
index 1b7599ce9..343a44617 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/helm/HelmClient.java
@@ -46,7 +46,6 @@ public class HelmClient {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
/**
* Install a chart.
*
@@ -70,7 +69,9 @@ public class HelmClient {
* Finds helm chart repository for the chart.
*
* @param chart ChartInfo.
- * @throws ServiceException incase of error
+ * @return the chart repository as a string
+ * @throws ServiceException in case of error
+ * @throws IOException in case of IO errors
*/
public String findChartRepository(ChartInfo chart) throws ServiceException, IOException {
updateHelmRepo();
@@ -127,8 +128,8 @@ public class HelmClient {
return output;
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
- throw new ServiceException(
- "Failed to execute the Command: " + commandStr + ", the command was interrupted", ie);
+ throw new ServiceException("Failed to execute the Command: " + commandStr + ", the command was interrupted",
+ ie);
} catch (Exception exc) {
throw new ServiceException("Failed to execute the Command: " + commandStr, exc);
}
@@ -139,12 +140,12 @@ public class HelmClient {
// @formatter:off
List<String> helmArguments = new ArrayList<>(
Arrays.asList(
- "helm",
- "install", chart.getReleaseName(), chart.getRepository() + "/" + chart.getChartName(),
- "--version", chart.getVersion(),
- "--namespace", chart.getNamespace()
+ "helm",
+ "install", chart.getReleaseName(), chart.getRepository() + "/" + chart.getChartName(),
+ "--version", chart.getVersion(),
+ "--namespace", chart.getNamespace()
)
- );
+ );
// @formatter:on
// Verify if values.yaml available for the chart
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java
index 6accac339..29a49a9ff 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartService.java
@@ -53,7 +53,7 @@ public class ChartService {
* @param name name of the app
* @param version version of the app
* @return chart
- * @throws ServiceException incase of error.
+ * @throws ServiceException in case of error.
*/
public ChartInfo getChart(String name, String version) throws ServiceException {
return chartStore.getChart(name, version);
@@ -63,12 +63,13 @@ public class ChartService {
* Save a helm chart.
* @param chartInfo name and version of the app.
* @param chartFile Helm chart file
+ * @param overrideFile override file
* @return chart details of the helm chart
- * @throws IOException incase of IO error
- * @throws ServiceException incase of error
+ * @throws IOException in case of IO error
+ * @throws ServiceException in case of error
*/
public ChartInfo saveChart(ChartInfo chartInfo, MultipartFile chartFile, MultipartFile overrideFile)
- throws IOException, ServiceException {
+ throws IOException, ServiceException {
return chartStore.saveChart(chartInfo, chartFile, overrideFile);
}
@@ -83,7 +84,8 @@ public class ChartService {
/**
* Install a helm chart.
* @param chart name and version.
- * @throws ServiceException incase of error
+ * @throws ServiceException in case of error
+ * @throws IOException in case of IO errors
*/
public void installChart(ChartInfo chart) throws ServiceException, IOException {
if (chart.getRepository() == null) {
@@ -102,7 +104,9 @@ public class ChartService {
/**
* Finds helm chart repository for a given chart.
* @param chart chartInfo.
- * @throws ServiceException incase of error
+ * @return the chart repo as a string
+ * @throws ServiceException in case of error
+ * @throws IOException in case of IO errors
*/
public String findChartRepo(ChartInfo chart) throws ServiceException, IOException {
logger.info("Fetching helm chart repository for the given chart {} ", chart.getChartName());
@@ -112,7 +116,7 @@ public class ChartService {
/**
* Uninstall a helm chart.
* @param chart name and version
- * @throws ServiceException incase of error.
+ * @throws ServiceException in case of error.
*/
public void uninstallChart(ChartInfo chart) throws ServiceException {
logger.info("Uninstalling helm deployment {}", chart.getReleaseName());
diff --git a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java
index 041c0c810..e7458a4cd 100644
--- a/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java
+++ b/participant/participant-impl/participant-impl-kubernetes/src/main/java/org/onap/policy/clamp/controlloop/participant/kubernetes/service/ChartStore.java
@@ -94,6 +94,7 @@ public class ChartStore {
*
* @param chartInfo chartInfo
* @param chartFile helm chart file.
+ * @param overrideFile override file.
* @return chart
* @throws IOException incase of IO error
* @throws ServiceException incase of error.
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java
index bdc09c8b9..4869b7c2f 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/PolicyParticipantApplication.java
@@ -30,8 +30,9 @@ import org.springframework.context.annotation.ComponentScan;
*
*/
@SpringBootApplication
-@ComponentScan({"org.onap.policy.clamp.controlloop.participant.policy",
- "org.onap.policy.clamp.controlloop.participant.intermediary"})
+@ComponentScan({
+ "org.onap.policy.clamp.controlloop.participant.policy",
+ "org.onap.policy.clamp.controlloop.participant.intermediary"})
@ConfigurationPropertiesScan("org.onap.policy.clamp.controlloop.participant.policy.main.parameters")
public class PolicyParticipantApplication {
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java
index 4b6686156..2579585e5 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/AbstractHttpClient.java
@@ -41,25 +41,26 @@ public abstract class AbstractHttpClient implements Closeable {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractHttpClient.class);
private final HttpClient httpclient;
-
/**
* Constructor.
+ *
+ * @param policyParticipantParameters the parameters for the policy participant
+ * @throws ControlLoopRuntimeException on client start errors
*/
- protected AbstractHttpClient(BusTopicParams policyApiParameters) {
+ protected AbstractHttpClient(BusTopicParams policyParticipantParameters) {
try {
- httpclient = HttpClientFactoryInstance.getClientFactory().build(policyApiParameters);
+ httpclient = HttpClientFactoryInstance.getClientFactory().build(policyParticipantParameters);
} catch (final Exception e) {
throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR, " Client failed to start", e);
}
}
protected Response executePost(String path, final Entity<?> entity) {
- Response response = httpclient.post(path, entity, Map.of(HttpHeaders.ACCEPT,
- MediaType.APPLICATION_JSON, HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON));
+ var response = httpclient.post(path, 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: {}",
+ path, entity, response.getStatus(), response.getStatusInfo());
}
return response;
}
@@ -72,4 +73,4 @@ public abstract class AbstractHttpClient implements Closeable {
public void close() throws IOException {
httpclient.shutdown();
}
-} \ No newline at end of file
+}
diff --git a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java
index 3d1047ce4..38a79f7f6 100644
--- a/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java
+++ b/participant/participant-impl/participant-impl-policy/src/main/java/org/onap/policy/clamp/controlloop/participant/policy/client/PolicyApiHttpClient.java
@@ -35,6 +35,8 @@ public class PolicyApiHttpClient extends AbstractHttpClient {
/**
* Constructor.
+ *
+ * @param parameters the policy participant parameters
*/
public PolicyApiHttpClient(ParticipantPolicyParameters parameters) {
super(parameters.getPolicyApiParameters());
@@ -45,6 +47,7 @@ public class PolicyApiHttpClient extends AbstractHttpClient {
*
* @param toscaServiceTemplate the whole ToscaServiceTemplate
* @return Response
+ * @throws PfModelException on errors creating the policy type
*/
public Response createPolicyType(ToscaServiceTemplate toscaServiceTemplate) throws PfModelException {
return executePost(POLICY_URI + "policytypes", Entity.entity(toscaServiceTemplate, MediaType.APPLICATION_JSON));
diff --git a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java
index e3d7e3aa5..1acc2c838 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-policy/src/test/java/org/onap/policy/clamp/controlloop/participant/policy/main/parameters/CommonTestData.java
@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
import org.onap.policy.common.parameters.ParameterGroup;
@@ -51,15 +52,18 @@ public class CommonTestData {
/**
* Converts the contents of a map to a parameter class.
*
+ * @param <T> the type of ParameterGroup to process
* @param source property map
* @param clazz class of object to be created from the map
* @return a new object represented by the map
+ * @throws ControlLoopRuntimeException on decoding errors
*/
public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) {
try {
return coder.convert(source, clazz);
} catch (final CoderException e) {
- throw new RuntimeException("cannot create " + clazz.getName() + " from map", e);
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE,
+ "cannot create " + clazz.getName() + " from map", e);
}
}
@@ -163,14 +167,15 @@ public class CommonTestData {
*
* @param port port to be inserted into the parameters
* @return the standard participant parameters
+ * @throws ControlLoopRuntimeException on parameter read errors
*/
public ParticipantPolicyParameters getParticipantPolicyParameters(int port) {
try {
return coder.decode(getParticipantPolicyParametersAsString(port), ParticipantPolicyParameters.class);
} catch (CoderException e) {
- throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
- "cannot read participant parameters", e);
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
+ e);
}
}
@@ -179,6 +184,7 @@ public class CommonTestData {
*
* @param port port to be inserted into the parameters
* @return the standard participant parameters
+ * @throws ControlLoopRuntimeException on parameter read errors
*/
public static String getParticipantPolicyParametersAsString(int port) {
@@ -192,8 +198,8 @@ public class CommonTestData {
return json;
} catch (IOException e) {
- throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
- "cannot read participant parameters", e);
+ throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
+ e);
}
}
@@ -211,6 +217,7 @@ public class CommonTestData {
/**
* Nulls out a field within a JSON string.
+ *
* @param json JSON string
* @param field field to be nulled out
* @return a new JSON string with the field nulled out
diff --git a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json
index efbfbe29f..e33409f82 100644
--- a/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json
+++ b/participant/participant-impl/participant-impl-policy/src/test/resources/parameters/Unreadable.json
@@ -47,27 +47,7 @@
"topicCommInfrastructure": "dmaap"
}
]
- },
- "healthCheckRestClientParameters": [
- {
- "clientName": "api",
- "hostname": "policy-api",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "policy/api/v1/healthcheck"
- },
- {
- "clientName": "distribution",
- "hostname": "policy-distribution",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "healthcheck"
- }
- ]
+ }
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java
index b872ec0c6..5a6dbfa81 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/main/rest/AbstractRestController.java
@@ -92,6 +92,8 @@ public abstract class AbstractRestController {
/**
* create a Rest Controller.
+ *
+ * @param simulationProvider the provider for the simulation participant
*/
protected AbstractRestController(SimulationProvider simulationProvider) {
this.simulationProvider = simulationProvider;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java
index 6ee4eac3e..49338c2b0 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/SimulationProvider.java
@@ -41,6 +41,7 @@ public class SimulationProvider {
/**
* Create a participant simulation provider.
+ * @param intermediaryApi the intermediary to use for talking to the CLAMP runtime
*/
public SimulationProvider(ParticipantIntermediaryApi intermediaryApi) {
this.intermediaryApi = intermediaryApi;
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java
index de2a06223..e0569cf0f 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationElementController.java
@@ -68,40 +68,42 @@ public class SimulationElementController extends AbstractRestController {
*/
// @formatter:off
@GetMapping("/elements/{name}/{version}")
- @ApiOperation(value = "Query details of the requested simulated control loop elements",
- notes = "Queries details of the requested simulated control loop elements, "
- + "returning all control loop element details",
- response = ControlLoops.class,
- tags = {
- "Clamp Control Loop Participant Simulator API"
- },
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
+ @ApiOperation(
+ value = "Query details of the requested simulated control loop elements",
+ notes = "Queries details of the requested simulated control loop elements, "
+ + "returning all control loop element details",
+ response = ControlLoops.class,
+ tags = {
+ "Clamp Control Loop Participant Simulator API"
+ },
+ authorizations = @Authorization(value = AUTHORIZATION_TYPE),
+ responseHeaders = {
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
+ }
)
@ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
)
// @formatter:on
public ResponseEntity<Map<UUID, ControlLoopElement>> elements(
@@ -134,31 +136,32 @@ public class SimulationElementController extends AbstractRestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
- },
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
+ },
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
@ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
@ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ }
+ )
}
)
@ApiResponses(
diff --git a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java
index 715ec3410..25ae4ac22 100644
--- a/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java
+++ b/participant/participant-impl/participant-impl-simulator/src/main/java/org/onap/policy/clamp/controlloop/participant/simulator/simulation/rest/SimulationParticipantController.java
@@ -76,39 +76,38 @@ public class SimulationParticipantController extends AbstractRestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
)
}
)
@ApiResponses(
value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
}
)
// @formatter:on
public ResponseEntity<List<Participant>> participants(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Participant name", required = true) @PathVariable("name") String name,
- @ApiParam(value = "Participant version", required = true) @PathVariable("version") String version) {
+ @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Participant name", required = true) @PathVariable("name") String name,
+ @ApiParam(value = "Participant version", required = true) @PathVariable("version") String version) {
return ResponseEntity.ok().body(getSimulationProvider().getParticipants(name, version));
}
@@ -131,31 +130,32 @@ public class SimulationParticipantController extends AbstractRestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
- },
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
+ },
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
@ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
@ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ }
+ )
}
)
@ApiResponses(
@@ -167,10 +167,8 @@ public class SimulationParticipantController extends AbstractRestController {
)
// @formatter:on
public ResponseEntity<TypedSimpleResponse<Participant>> update(
- @RequestHeader(
- name = REQUEST_ID_NAME,
- required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Body of a participant", required = true) @RequestBody Participant body) {
+ @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Body of a participant", required = true) @RequestBody Participant body) {
return ResponseEntity.ok().body(getSimulationProvider().updateParticipant(body));
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java
index 832399660..46495f7c3 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/endtoend/ParticipantSimulatorTest.java
@@ -234,7 +234,7 @@ class ParticipantSimulatorTest {
String.class, uuid);
checkResponseEntity(response, 200, uuid);
- Map returnValue = coder.decode(response.getBody(), Map.class);
+ Map<?, ?> returnValue = coder.decode(response.getBody(), Map.class);
// Verify the result of GET controlloop elements with what is stored
assertThat(returnValue).isEmpty();
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java
index 8ca139bcd..2c9b1ccd2 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java
+++ b/participant/participant-impl/participant-impl-simulator/src/test/java/org/onap/policy/clamp/controlloop/participant/simulator/main/parameters/CommonTestData.java
@@ -29,6 +29,7 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.common.endpoints.parameters.TopicParameters;
import org.onap.policy.common.parameters.ParameterGroup;
@@ -57,15 +58,18 @@ public class CommonTestData {
/**
* Converts the contents of a map to a parameter class.
*
+ * @param <T> the specific parameter group type to convert
* @param source property map
* @param clazz class of object to be created from the map
* @return a new object represented by the map
+ * @throws ControlLoopRuntimeException on parameter parsing errors
*/
public <T extends ParameterGroup> T toObject(final Map<String, Object> source, final Class<T> clazz) {
try {
return coder.convert(source, clazz);
} catch (final CoderException e) {
- throw new RuntimeException("cannot create " + clazz.getName() + " from map", e);
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE,
+ "cannot create " + clazz.getName() + " from map", e);
}
}
@@ -191,14 +195,14 @@ public class CommonTestData {
*
* @param port port to be inserted into the parameters
* @return the standard participant parameters
+ * @throws ControlLoopRuntimeException on parameter read errors
*/
public ParticipantSimulatorParameters getParticipantParameterGroup(int port) {
try {
return coder.decode(getParticipantParameterGroupAsString(port), ParticipantSimulatorParameters.class);
} catch (CoderException e) {
- throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
- e);
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "cannot read participant parameters", e);
}
}
@@ -207,6 +211,7 @@ public class CommonTestData {
*
* @param port port to be inserted into the parameters
* @return the standard participant parameters
+ * @throws ControlLoopRuntimeException on parameter read errors
*/
public static String getParticipantParameterGroupAsString(int port) {
@@ -221,7 +226,7 @@ public class CommonTestData {
} catch (IOException e) {
throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE, "cannot read participant parameters",
- e);
+ e);
}
}
diff --git a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json
index f11bd8c95..fc36b49e4 100644
--- a/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json
+++ b/participant/participant-impl/participant-impl-simulator/src/test/resources/parameters/Unreadable.json
@@ -55,27 +55,7 @@
"topicCommInfrastructure": "dmaap"
}
]
- },
- "healthCheckRestClientParameters": [
- {
- "clientName": "api",
- "hostname": "policy-api",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "policy/api/v1/healthcheck"
- },
- {
- "clientName": "distribution",
- "hostname": "policy-distribution",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "healthcheck"
- }
- ]
+ }
}
diff --git a/participant/participant-intermediary/pom.xml b/participant/participant-intermediary/pom.xml
index df354d46c..aac80a4a2 100644
--- a/participant/participant-intermediary/pom.xml
+++ b/participant/participant-intermediary/pom.xml
@@ -28,7 +28,6 @@
<version>6.1.2-SNAPSHOT</version>
</parent>
- <groupId>org.onap.policy.clamp.participant</groupId>
<artifactId>policy-clamp-participant-intermediary</artifactId>
<name>${project.artifactId}</name>
<description>Common intermediary library for managing DMaaP participant messaging and holding participant and control
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java
index d31ae1082..adc9c2393 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/api/ParticipantIntermediaryApi.java
@@ -24,7 +24,6 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopOrderedState;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopState;
@@ -134,6 +133,7 @@ public interface ParticipantIntermediaryApi {
* if participantHandler is not returned, there is no way to test state change messages
* without dmaap simulator.
*
+ * @return the participant handler
*/
ParticipantHandler getParticipantHandler();
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java
index 3128f1eaa..6926bc30b 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/comm/MessageSender.java
@@ -34,7 +34,6 @@ import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.Parti
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantResponseStatus;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
import org.onap.policy.clamp.controlloop.participant.intermediary.api.ControlLoopElementListener;
-import org.onap.policy.clamp.controlloop.participant.intermediary.comm.ParticipantStatusPublisher;
import org.onap.policy.clamp.controlloop.participant.intermediary.handler.ParticipantHandler;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
@@ -72,7 +71,7 @@ public class MessageSender extends TimerTask implements Closeable {
public void run() {
LOGGER.debug("Sent heartbeat to CLAMP");
- ParticipantResponseDetails response = new ParticipantResponseDetails();
+ var response = new ParticipantResponseDetails();
response.setResponseTo(null);
response.setResponseStatus(ParticipantResponseStatus.PERIODIC);
@@ -100,7 +99,7 @@ public class MessageSender extends TimerTask implements Closeable {
* @param response the details to include in the response message
*/
public void sendResponse(ToscaConceptIdentifier controlLoopId, ParticipantResponseDetails response) {
- ParticipantStatus status = new ParticipantStatus();
+ var status = new ParticipantStatus();
// Participant related fields
status.setParticipantType(participantHandler.getParticipantType());
@@ -109,12 +108,12 @@ public class MessageSender extends TimerTask implements Closeable {
status.setHealthStatus(participantHandler.getHealthStatus());
// Control loop related fields
- ControlLoops controlLoops = participantHandler.getControlLoopHandler().getControlLoops();
+ var controlLoops = participantHandler.getControlLoopHandler().getControlLoops();
status.setControlLoopId(controlLoopId);
status.setControlLoops(controlLoops);
status.setResponse(response);
- ParticipantStatistics participantStatistics = new ParticipantStatistics();
+ var participantStatistics = new ParticipantStatistics();
participantStatistics.setTimeStamp(Instant.now());
participantStatistics.setParticipantId(participantHandler.getParticipantId());
participantStatistics.setHealthStatus(participantHandler.getHealthStatus());
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
index cc2a66b58..18ee29f08 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ControlLoopHandler.java
@@ -27,6 +27,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
@@ -49,6 +50,7 @@ import org.slf4j.LoggerFactory;
/*
* This class is responsible for managing the state of all control loops in the participant.
*/
+@NoArgsConstructor
public class ControlLoopHandler implements Closeable {
private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopHandler.class);
@@ -63,8 +65,6 @@ public class ControlLoopHandler implements Closeable {
@Getter
private List<ControlLoopElementListener> listeners = new ArrayList<>();
- public ControlLoopHandler() {}
-
/**
* Constructor, set the participant ID and messageSender.
*
@@ -85,7 +85,7 @@ public class ControlLoopHandler implements Closeable {
public void registerControlLoopElementListener(ControlLoopElementListener listener) {
listeners.add(listener);
}
-
+
/**
* Handle a control loop element state change message.
*
@@ -95,7 +95,7 @@ public class ControlLoopHandler implements Closeable {
* @return controlLoopElement the updated controlloop element
*/
public ControlLoopElement updateControlLoopElementState(UUID id, ControlLoopOrderedState orderedState,
- ControlLoopState newState) {
+ ControlLoopState newState) {
if (id == null) {
return null;
@@ -106,7 +106,7 @@ public class ControlLoopHandler implements Closeable {
clElement.setOrderedState(orderedState);
clElement.setState(newState);
LOGGER.debug("Control loop element {} state changed to {}", id, newState);
- ParticipantResponseDetails response = new ParticipantResponseDetails();
+ var response = new ParticipantResponseDetails();
response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
response.setResponseMessage("ControlLoopElement state changed to {} " + newState);
messageSender.sendResponse(response);
@@ -141,14 +141,14 @@ public class ControlLoopHandler implements Closeable {
return;
}
- ControlLoop controlLoop = controlLoopMap.get(stateChangeMsg.getControlLoopId());
+ var controlLoop = controlLoopMap.get(stateChangeMsg.getControlLoopId());
if (controlLoop == null) {
LOGGER.debug("Control loop {} does not use this participant", stateChangeMsg.getControlLoopId());
return;
}
- ParticipantResponseDetails response = new ParticipantResponseDetails(stateChangeMsg);
+ var response = new ParticipantResponseDetails(stateChangeMsg);
handleState(controlLoop, response, stateChangeMsg.getOrderedState());
messageSender.sendResponse(response);
}
@@ -161,7 +161,7 @@ public class ControlLoopHandler implements Closeable {
* @param orderedState controlloop ordered state
*/
private void handleState(final ControlLoop controlLoop, final ParticipantResponseDetails response,
- ControlLoopOrderedState orderedState) {
+ ControlLoopOrderedState orderedState) {
switch (orderedState) {
case UNINITIALISED:
handleUninitialisedState(controlLoop, orderedState, response);
@@ -189,16 +189,16 @@ public class ControlLoopHandler implements Closeable {
return;
}
- ControlLoop controlLoop = controlLoopMap.get(updateMsg.getControlLoopId());
+ var controlLoop = controlLoopMap.get(updateMsg.getControlLoopId());
- ParticipantResponseDetails response = new ParticipantResponseDetails(updateMsg);
+ var response = new ParticipantResponseDetails(updateMsg);
// TODO: Updates to existing ControlLoops are not supported yet (Addition/Removal of ControlLoop
// elements to existing ControlLoop has to be supported).
if (controlLoop != null) {
response.setResponseStatus(ParticipantResponseStatus.FAIL);
- response.setResponseMessage("Control loop " + updateMsg.getControlLoopId()
- + " already defined on participant " + participantId);
+ response.setResponseMessage(
+ "Control loop " + updateMsg.getControlLoopId() + " already defined on participant " + participantId);
messageSender.sendResponse(response);
return;
@@ -226,7 +226,7 @@ public class ControlLoopHandler implements Closeable {
response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
response.setResponseMessage(
- "Control loop " + updateMsg.getControlLoopId() + " defined on participant " + participantId);
+ "Control loop " + updateMsg.getControlLoopId() + " defined on participant " + participantId);
messageSender.sendResponse(response);
}
@@ -239,15 +239,14 @@ public class ControlLoopHandler implements Closeable {
* @param response participant response
*/
private void handleUninitialisedState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
- final ParticipantResponseDetails response) {
+ final ParticipantResponseDetails response) {
handleStateChange(controlLoop, orderedState, ControlLoopState.UNINITIALISED, response);
controlLoopMap.remove(controlLoop.getKey().asIdentifier());
for (ControlLoopElementListener clElementListener : listeners) {
try {
for (ControlLoopElement element : controlLoop.getElements().values()) {
- clElementListener.controlLoopElementStateChange(element.getId(), element.getState(),
- orderedState);
+ clElementListener.controlLoopElementStateChange(element.getId(), element.getState(), orderedState);
}
} catch (PfModelException e) {
LOGGER.debug("Control loop element update failed {}", controlLoop.getDefinition());
@@ -263,7 +262,7 @@ public class ControlLoopHandler implements Closeable {
* @param response participant response
*/
private void handlePassiveState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
- final ParticipantResponseDetails response) {
+ final ParticipantResponseDetails response) {
handleStateChange(controlLoop, orderedState, ControlLoopState.PASSIVE, response);
}
@@ -275,19 +274,20 @@ public class ControlLoopHandler implements Closeable {
* @param response participant response
*/
private void handleRunningState(final ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
- final ParticipantResponseDetails response) {
+ final ParticipantResponseDetails response) {
handleStateChange(controlLoop, orderedState, ControlLoopState.RUNNING, response);
}
-
+
/**
* Method to update the state of control loop elements.
*
* @param controlLoop participant status in memory
- * @param orderedState orderedState
- * @param state new state of the control loop elements
+ * @param orderedState orderedState the new ordered state the participant should have
+ * @param newState new state of the control loop elements
+ * @param response the response to the state change request
*/
private void handleStateChange(ControlLoop controlLoop, final ControlLoopOrderedState orderedState,
- ControlLoopState newState, ParticipantResponseDetails response) {
+ ControlLoopState newState, ParticipantResponseDetails response) {
if (orderedState.equals(controlLoop.getOrderedState())) {
response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
@@ -297,26 +297,24 @@ public class ControlLoopHandler implements Closeable {
if (!CollectionUtils.isEmpty(controlLoop.getElements().values())) {
controlLoop.getElements().values().forEach(element -> {
- element.setState(newState);
- element.setOrderedState(orderedState);
- }
- );
+ element.setState(newState);
+ element.setOrderedState(orderedState);
+ });
}
response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
- response.setResponseMessage("ControlLoop state changed from " + controlLoop.getOrderedState()
- + " to " + orderedState);
+ response.setResponseMessage(
+ "ControlLoop state changed from " + controlLoop.getOrderedState() + " to " + orderedState);
controlLoop.setOrderedState(orderedState);
}
-
/**
* Get control loops as a {@link ConrolLoops} class.
*
* @return the control loops
*/
public ControlLoops getControlLoops() {
- ControlLoops controlLoops = new ControlLoops();
+ var controlLoops = new ControlLoops();
controlLoops.setControlLoopList(new ArrayList<>(controlLoopMap.values()));
return controlLoops;
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java
index be2fa1a30..3eae27267 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/IntermediaryActivator.java
@@ -24,7 +24,6 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.core.Response.Status;
import lombok.Getter;
-import lombok.experimental.Delegate;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopStateChange;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantControlLoopUpdate;
@@ -70,21 +69,22 @@ public class IntermediaryActivator extends ServiceManagerContainer {
* Instantiate the activator for participant.
*
* @param parameters the parameters for the participant intermediary
+ * @throws ControlLoopRuntimeException when the activation fails
*/
public IntermediaryActivator(final ParticipantIntermediaryParameters parameters) {
this.parameters = parameters;
topicSinks =
- TopicEndpointManager.getManager().addTopicSinks(parameters.getClampControlLoopTopics().getTopicSinks());
+ TopicEndpointManager.getManager().addTopicSinks(parameters.getClampControlLoopTopics().getTopicSinks());
- topicSources = TopicEndpointManager.getManager()
- .addTopicSources(parameters.getClampControlLoopTopics().getTopicSources());
+ topicSources =
+ TopicEndpointManager.getManager().addTopicSources(parameters.getClampControlLoopTopics().getTopicSources());
try {
this.msgDispatcher = new MessageTypeDispatcher(MSG_TYPE_NAMES);
} catch (final RuntimeException e) {
throw new ControlLoopRuntimeException(Status.INTERNAL_SERVER_ERROR,
- "topic message dispatcher failed to start", e);
+ "topic message dispatcher failed to start", e);
}
// @formatter:off
@@ -131,17 +131,14 @@ public class IntermediaryActivator extends ServiceManagerContainer {
*/
private void registerMsgDispatcher() {
msgDispatcher.register(ParticipantMessageType.PARTICIPANT_STATE_CHANGE.name(),
- (ScoListener<ParticipantStateChange>) new ParticipantStateChangeListener(
- participantHandler.get()));
+ (ScoListener<ParticipantStateChange>) new ParticipantStateChangeListener(participantHandler.get()));
msgDispatcher.register(ParticipantMessageType.PARTICIPANT_HEALTH_CHECK.name(),
- (ScoListener<ParticipantHealthCheck>) new ParticipantHealthCheckListener(
- participantHandler.get()));
+ (ScoListener<ParticipantHealthCheck>) new ParticipantHealthCheckListener(participantHandler.get()));
msgDispatcher.register(ParticipantMessageType.PARTICIPANT_CONTROL_LOOP_STATE_CHANGE.name(),
- (ScoListener<ParticipantControlLoopStateChange>) new ControlLoopStateChangeListener(
- participantHandler.get()));
+ (ScoListener<ParticipantControlLoopStateChange>) new ControlLoopStateChangeListener(
+ participantHandler.get()));
msgDispatcher.register(ParticipantMessageType.PARTICIPANT_CONTROL_LOOP_UPDATE.name(),
- (ScoListener<ParticipantControlLoopUpdate>) new ControlLoopUpdateListener(
- participantHandler.get()));
+ (ScoListener<ParticipantControlLoopUpdate>) new ControlLoopUpdateListener(participantHandler.get()));
for (final TopicSource source : topicSources) {
source.register(msgDispatcher);
}
@@ -158,6 +155,8 @@ public class IntermediaryActivator extends ServiceManagerContainer {
/**
* Return the participant handler.
+ *
+ * @return the participant handler
*/
public ParticipantHandler getParticipantHandler() {
return participantHandler.get();
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
index 980ab6ec1..913c050e3 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/controlloop/participant/intermediary/handler/ParticipantHandler.java
@@ -90,7 +90,7 @@ public class ParticipantHandler implements Closeable {
return;
}
- ParticipantResponseDetails response = new ParticipantResponseDetails(stateChangeMsg);
+ var response = new ParticipantResponseDetails(stateChangeMsg);
switch (stateChangeMsg.getState()) {
case PASSIVE:
@@ -126,7 +126,7 @@ public class ParticipantHandler implements Closeable {
* @param healthCheckMsg participant health check message
*/
public void handleParticipantHealthCheck(final ParticipantHealthCheck healthCheckMsg) {
- ParticipantResponseDetails response = new ParticipantResponseDetails(healthCheckMsg);
+ var response = new ParticipantResponseDetails(healthCheckMsg);
response.setResponseStatus(ParticipantResponseStatus.SUCCESS);
response.setResponseMessage(healthStatus.toString());
@@ -194,6 +194,7 @@ public class ParticipantHandler implements Closeable {
*
* @param definition participant definition
* @param participantState participant state
+ * @return the participant
*/
public Participant updateParticipantState(ToscaConceptIdentifier definition,
ParticipantState participantState) {
@@ -201,7 +202,7 @@ public class ParticipantHandler implements Closeable {
LOGGER.debug("No participant with this ID {}", definition.getName());
return null;
}
- ParticipantResponseDetails response = new ParticipantResponseDetails();
+ var response = new ParticipantResponseDetails();
handleStateChange(participantState, response);
sender.sendResponse(response);
return getParticipant(definition.getName(), definition.getVersion());
@@ -210,11 +211,13 @@ public class ParticipantHandler implements Closeable {
/**
* Get participants as a {@link Participant} class.
*
+ * @param name the participant name to get
+ * @param version the version of the participant to get
* @return the participant
*/
public Participant getParticipant(String name, String version) {
if (participantId.getName().equals(name)) {
- Participant participant = new Participant();
+ var participant = new Participant();
participant.setDefinition(participantId);
participant.setParticipantState(state);
participant.setHealthStatus(healthStatus);
diff --git a/pom.xml b/pom.xml
index d9640b45d..b9d0efd98 100644
--- a/pom.xml
+++ b/pom.xml
@@ -137,5 +137,13 @@
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </dependency>
</dependencies>
</project>
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
index 88e8b1df9..74975e768 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningHandler.java
@@ -21,15 +21,12 @@
package org.onap.policy.clamp.controlloop.runtime.commissioning;
import java.io.IOException;
-import java.util.List;
import java.util.Set;
import javax.ws.rs.core.Response;
import lombok.Getter;
import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
import org.onap.policy.clamp.controlloop.runtime.commissioning.rest.CommissioningController;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.base.PfModelRuntimeException;
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
index 50f6787b9..5bbf6a079 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java
@@ -29,7 +29,6 @@ import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
-import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse;
import org.onap.policy.models.base.PfModelException;
@@ -57,11 +56,10 @@ public class CommissioningProvider implements Closeable {
/**
* Create a commissioning provider.
- *
- * @throws ControlLoopRuntimeException on errors creating the provider
+ * @param databaseProviderParameters parameters for database access
+ * @throws PfModelRuntimeException on errors creating the database provider
*/
- public CommissioningProvider(PolicyModelsProviderParameters databaseProviderParameters)
- throws ControlLoopRuntimeException {
+ public CommissioningProvider(PolicyModelsProviderParameters databaseProviderParameters) {
try {
modelsProvider = new PolicyModelsProviderFactory()
.createPolicyModelsProvider(databaseProviderParameters);
@@ -98,7 +96,7 @@ public class CommissioningProvider implements Closeable {
modelsProvider.createServiceTemplate(serviceTemplate);
}
- CommissioningResponse response = new CommissioningResponse();
+ var response = new CommissioningResponse();
// @formatter:off
response.setAffectedControlLoopDefinitions(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates()
.values()
@@ -123,7 +121,7 @@ public class CommissioningProvider implements Closeable {
modelsProvider.deleteServiceTemplate(name, version);
}
- CommissioningResponse response = new CommissioningResponse();
+ var response = new CommissioningResponse();
response.setAffectedControlLoopDefinitions(
Collections.singletonList(new ToscaConceptIdentifier(name, version)));
@@ -201,7 +199,7 @@ public class CommissioningProvider implements Closeable {
* @throws PfModelException on errors getting control loop definitions
*/
public ToscaServiceTemplate getToscaServiceTemplate(String name, String version) throws PfModelException {
- ToscaServiceTemplates serviceTemplates = new ToscaServiceTemplates();
+ var serviceTemplates = new ToscaServiceTemplates();
serviceTemplates.setServiceTemplates(modelsProvider.getServiceTemplateList(name, version));
return serviceTemplates.getServiceTemplates().get(0);
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java
index 4060ae5be..ebfbbd5ee 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningController.java
@@ -44,8 +44,6 @@ import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProv
import org.onap.policy.clamp.controlloop.runtime.main.rest.RestController;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.base.PfModelRuntimeException;
-import org.onap.policy.models.errors.concepts.ErrorResponse;
-import org.onap.policy.models.errors.concepts.ErrorResponseInfo;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.slf4j.Logger;
@@ -81,58 +79,56 @@ public class CommissioningController extends RestController {
value = "Commissions control loop definitions",
notes = "Commissions control loop definitions, returning the commissioned control loop definition IDs",
response = CommissioningResponse.class,
- tags = {
- "Control Loop Commissioning API"
- },
+ tags = {"Control Loop Commissioning API"},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
)
}
)
@ApiResponses(
value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
}
)
// @formatter:on
- public Response create(
- @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Entity Body of Control Loop", required = true) ToscaServiceTemplate body) {
+ public Response create(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Entity Body of Control Loop", required = true) ToscaServiceTemplate body) {
try {
CommissioningResponse response = provider.createControlLoopDefinitions(body);
- return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId)
- .entity(response).build();
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Commissioning of the control loops failed", e);
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
@@ -153,58 +149,56 @@ public class CommissioningController extends RestController {
@ApiOperation(value = "Delete a commissioned control loop",
notes = "Deletes a Commissioned Control Loop, returning optional error details",
response = CommissioningResponse.class,
- tags = {
- "Clamp Control Loop Commissioning API"
- },
+ tags = {"Clamp Control Loop Commissioning API"},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
name = REQUEST_ID_NAME,
description = REQUEST_ID_HDR_DESCRIPTION,
response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
)
}
)
- @ApiResponses(value = {
+ @ApiResponses(
+ value = {
@ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
@ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
@ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
}
)
// @formatter:on
- public Response delete(
- @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = true) @QueryParam("name") String name,
- @ApiParam(value = "Control Loop definition version", required = true)
- @QueryParam("version") String version) {
+ public Response delete(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Control Loop definition name", required = true) @QueryParam("name") String name,
+ @ApiParam(value = "Control Loop definition version", required = true) @QueryParam("version") String version) {
try {
CommissioningResponse response = provider.deleteControlLoopDefinition(name, version);
- return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId)
- .entity(response).build();
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
+ .build();
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Decommisssioning of control loop failed", e);
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
@@ -226,52 +220,49 @@ public class CommissioningController extends RestController {
notes = "Queries details of the requested commissioned control loop definitions, "
+ "returning all control loop details",
response = ToscaNodeTemplate.class,
- tags = {
- "Clamp Control Loop Commissioning API"
- },
+ tags = {"Clamp Control Loop Commissioning API"},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
+ extensions = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
}
)
@ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
)
// @formatter:on
public Response query(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = true)
- @QueryParam("name") String name,
- @ApiParam(value = "Control Loop definition version", required = true)
- @QueryParam("version") String version) {
+ @ApiParam(value = "Control Loop definition name", required = true) @QueryParam("name") String name,
+ @ApiParam(value = "Control Loop definition version", required = true) @QueryParam("version") String version) {
try {
List<ToscaNodeTemplate> response = provider.getControlLoopDefinitions(name, version);
return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
- .build();
+ .build();
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Get of control loop definitions failed", e);
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
@@ -293,53 +284,50 @@ public class CommissioningController extends RestController {
notes = "Queries details of the requested commissioned tosca service template, "
+ "returning all tosca service template details",
response = ToscaServiceTemplate.class,
- tags = {
- "Clamp Control Loop Commissioning API"
- },
+ tags = {"Clamp Control Loop Commissioning API"},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
)
}
)
@ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
)
// @formatter:on
- public Response queryToscaServiceTemplate(@HeaderParam(REQUEST_ID_NAME)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Tosca service template name", required = true)
- @QueryParam("name") String name,
- @ApiParam(value = "Tosca service template version", required = true)
- @QueryParam("version") String version) {
+ public Response queryToscaServiceTemplate(
+ @HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Tosca service template name", required = true) @QueryParam("name") String name,
+ @ApiParam(value = "Tosca service template version", required = true) @QueryParam("version") String version) {
try {
- ToscaServiceTemplate response = provider.getToscaServiceTemplate(name, version);
+ var response = provider.getToscaServiceTemplate(name, version);
return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
- .build();
+ .build();
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Get of tosca service template failed", e);
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
@@ -361,60 +349,57 @@ public class CommissioningController extends RestController {
notes = "Queries details of the requested commissioned control loop element definitions, "
+ "returning all control loop elements' details",
response = ToscaNodeTemplate.class,
- tags = {
- "Clamp Control Loop Commissioning API"
- },
+ tags = {"Clamp Control Loop Commissioning API"},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
)
}
)
@ApiResponses(
- value = {
- @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
- @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
- @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
- }
+ value = {
+ @ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
+ @ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
+ @ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
+ }
)
// @formatter:on
public Response queryElements(@HeaderParam(REQUEST_ID_NAME) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Control Loop definition name", required = true)
- @QueryParam("name") String name,
- @ApiParam(value = "Control Loop definition version", required = true)
- @QueryParam("version") String version) throws Exception {
+ @ApiParam(value = "Control Loop definition name", required = true) @QueryParam("name") String name,
+ @ApiParam(value = "Control Loop definition version", required = true) @QueryParam("version") String version) {
try {
List<ToscaNodeTemplate> nodeTemplate = provider.getControlLoopDefinitions(name, version);
- //Prevent ambiguous queries with multiple returns
+ // Prevent ambiguous queries with multiple returns
if (nodeTemplate.size() > 1) {
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails("Multiple ControlLoops are not supported");
return returnResponse(Response.Status.NOT_ACCEPTABLE, requestId, resp);
}
List<ToscaNodeTemplate> response = provider.getControlLoopElementDefinitions(nodeTemplate.get(0));
return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
- .build();
+ .build();
} catch (PfModelRuntimeException | PfModelException e) {
LOGGER.warn("Get of control loop element definitions failed", e);
- CommissioningResponse resp = new CommissioningResponse();
+ var resp = new CommissioningResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return returnResponse(e.getErrorResponse().getResponseCode(), requestId, resp);
}
@@ -422,7 +407,6 @@ public class CommissioningController extends RestController {
}
private Response returnResponse(Response.Status status, UUID requestId, CommissioningResponse resp) {
- return addLoggingHeaders(addVersionControlHeaders(Response.status(status)),
- requestId).entity(resp).build();
+ return addLoggingHeaders(addVersionControlHeaders(Response.status(status)), requestId).entity(resp).build();
}
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
index eb72d9219..f458d7c51 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java
@@ -63,6 +63,7 @@ public class ControlLoopInstantiationProvider implements Closeable {
* Create a instantiation provider.
*
* @param databaseProviderParameters the parameters for database access
+ * @throws PfModelRuntimeException on errors creating a provider
*/
public ControlLoopInstantiationProvider(PolicyModelsProviderParameters databaseProviderParameters) {
try {
@@ -89,10 +90,10 @@ public class ControlLoopInstantiationProvider implements Closeable {
synchronized (lockit) {
for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
- ControlLoop checkControlLoop = controlLoopProvider.getControlLoop(controlLoop.getKey().asIdentifier());
+ var checkControlLoop = controlLoopProvider.getControlLoop(controlLoop.getKey().asIdentifier());
if (checkControlLoop != null) {
throw new PfModelException(Response.Status.BAD_REQUEST,
- controlLoop.getKey().asIdentifier() + " already defined");
+ controlLoop.getKey().asIdentifier() + " already defined");
}
}
BeanValidationResult validationResult = validateControlLoops(controlLoops);
@@ -102,9 +103,9 @@ public class ControlLoopInstantiationProvider implements Closeable {
controlLoopProvider.createControlLoops(controlLoops.getControlLoopList());
}
- InstantiationResponse response = new InstantiationResponse();
+ var response = new InstantiationResponse();
response.setAffectedControlLoops(controlLoops.getControlLoopList().stream()
- .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));
+ .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));
return response;
}
@@ -125,9 +126,9 @@ public class ControlLoopInstantiationProvider implements Closeable {
controlLoopProvider.updateControlLoops(controlLoops.getControlLoopList());
}
- InstantiationResponse response = new InstantiationResponse();
+ var response = new InstantiationResponse();
response.setAffectedControlLoops(controlLoops.getControlLoopList().stream()
- .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));
+ .map(cl -> cl.getKey().asIdentifier()).collect(Collectors.toList()));
return response;
}
@@ -136,32 +137,29 @@ public class ControlLoopInstantiationProvider implements Closeable {
* Validate ControlLoops.
*
* @param controlLoops ControlLoops to validate
- * @result the result of validation
+ * @return the result of validation
* @throws PfModelException if controlLoops is not valid
*/
private BeanValidationResult validateControlLoops(ControlLoops controlLoops) throws PfModelException {
- BeanValidationResult result = new BeanValidationResult("ControlLoops", controlLoops);
+ var result = new BeanValidationResult("ControlLoops", controlLoops);
for (ControlLoop controlLoop : controlLoops.getControlLoopList()) {
- BeanValidationResult subResult = new BeanValidationResult(
- "entry " + controlLoop.getDefinition().getName(), controlLoop);
+ var subResult = new BeanValidationResult("entry " + controlLoop.getDefinition().getName(), controlLoop);
List<ToscaNodeTemplate> toscaNodeTemplates = commissioningProvider.getControlLoopDefinitions(
- controlLoop.getDefinition().getName(), controlLoop.getDefinition().getVersion());
+ controlLoop.getDefinition().getName(), controlLoop.getDefinition().getVersion());
if (toscaNodeTemplates.isEmpty()) {
- subResult
- .addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
- ValidationStatus.INVALID, "Commissioned control loop definition not FOUND"));
+ subResult.addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
+ ValidationStatus.INVALID, "Commissioned control loop definition not FOUND"));
} else if (toscaNodeTemplates.size() > 1) {
- subResult
- .addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
- ValidationStatus.INVALID, "Commissioned control loop definition not VALID"));
+ subResult.addResult(new ObjectValidationResult("ControlLoop", controlLoop.getDefinition().getName(),
+ ValidationStatus.INVALID, "Commissioned control loop definition not VALID"));
} else {
List<ToscaNodeTemplate> clElementDefinitions =
- commissioningProvider.getControlLoopElementDefinitions(toscaNodeTemplates.get(0));
+ commissioningProvider.getControlLoopElementDefinitions(toscaNodeTemplates.get(0));
// @formatter:off
Map<String, ToscaConceptIdentifier> definitions = clElementDefinitions
@@ -184,11 +182,11 @@ public class ControlLoopInstantiationProvider implements Closeable {
*
* @param definitions map of all ToscaConceptIdentifiers
* @param definition ToscaConceptIdentifier to validate
- * @result result the validation result
+ * @return the validation result
*/
private ValidationResult validateDefinition(Map<String, ToscaConceptIdentifier> definitions,
- ToscaConceptIdentifier definition) {
- BeanValidationResult result = new BeanValidationResult("entry " + definition.getName(), definition);
+ ToscaConceptIdentifier definition) {
+ var result = new BeanValidationResult("entry " + definition.getName(), definition);
ToscaConceptIdentifier identifier = definitions.get(definition.getName());
if (identifier == null) {
result.setResult(ValidationStatus.INVALID, "Not FOUND");
@@ -207,7 +205,7 @@ public class ControlLoopInstantiationProvider implements Closeable {
* @throws PfModelException on deletion errors
*/
public InstantiationResponse deleteControlLoop(String name, String version) throws PfModelException {
- InstantiationResponse response = new InstantiationResponse();
+ var response = new InstantiationResponse();
synchronized (lockit) {
List<ControlLoop> controlLoops = controlLoopProvider.getControlLoops(name, version);
if (controlLoops.isEmpty()) {
@@ -216,12 +214,12 @@ public class ControlLoopInstantiationProvider implements Closeable {
for (ControlLoop controlLoop : controlLoops) {
if (!ControlLoopState.UNINITIALISED.equals(controlLoop.getState())) {
throw new PfModelException(Response.Status.BAD_REQUEST,
- "Control Loop State is still " + controlLoop.getState());
+ "Control Loop State is still " + controlLoop.getState());
}
}
response.setAffectedControlLoops(Collections
- .singletonList(controlLoopProvider.deleteControlLoop(name, version).getKey().asIdentifier()));
+ .singletonList(controlLoopProvider.deleteControlLoop(name, version).getKey().asIdentifier()));
}
return response;
}
@@ -235,7 +233,7 @@ public class ControlLoopInstantiationProvider implements Closeable {
* @throws PfModelException on errors getting control loops
*/
public ControlLoops getControlLoops(String name, String version) throws PfModelException {
- ControlLoops controlLoops = new ControlLoops();
+ var controlLoops = new ControlLoops();
controlLoops.setControlLoopList(controlLoopProvider.getControlLoops(name, version));
return controlLoops;
@@ -250,7 +248,7 @@ public class ControlLoopInstantiationProvider implements Closeable {
* @throws ControlLoopException on ordered state invalid
*/
public InstantiationResponse issueControlLoopCommand(InstantiationCommand command)
- throws ControlLoopException, PfModelException {
+ throws ControlLoopException, PfModelException {
if (command.getOrderedState() == null) {
throw new ControlLoopException(Status.BAD_REQUEST, "ordered state invalid or not specified on command");
@@ -259,16 +257,16 @@ public class ControlLoopInstantiationProvider implements Closeable {
synchronized (lockit) {
List<ControlLoop> controlLoops = new ArrayList<>(command.getControlLoopIdentifierList().size());
for (ToscaConceptIdentifier id : command.getControlLoopIdentifierList()) {
- ControlLoop controlLoop = controlLoopProvider.getControlLoop(id);
+ var controlLoop = controlLoopProvider.getControlLoop(id);
controlLoop.setCascadedOrderedState(command.getOrderedState());
controlLoops.add(controlLoop);
}
controlLoopProvider.updateControlLoops(controlLoops);
}
- SupervisionHandler supervisionHandler = SupervisionHandler.getInstance();
+ var supervisionHandler = SupervisionHandler.getInstance();
supervisionHandler.triggerControlLoopSupervision(command.getControlLoopIdentifierList());
- InstantiationResponse response = new InstantiationResponse();
+ var response = new InstantiationResponse();
response.setAffectedControlLoops(command.getControlLoopIdentifierList());
return response;
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java
index d81e54ccf..67fd9455e 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationHandler.java
@@ -21,15 +21,12 @@
package org.onap.policy.clamp.controlloop.runtime.instantiation;
import java.io.IOException;
-import java.util.List;
import java.util.Set;
import javax.ws.rs.core.Response;
import lombok.Getter;
import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
import org.onap.policy.clamp.controlloop.runtime.instantiation.rest.InstantiationController;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.base.PfModelRuntimeException;
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java
index 7581aaf74..ea36c71fb 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationController.java
@@ -82,36 +82,35 @@ public class InstantiationController extends RestController {
value = "Commissions control loop definitions",
notes = "Commissions control loop definitions, returning the control loop IDs",
response = InstantiationResponse.class,
- tags = {
- "Control Loop Instantiation API"
- },
+ tags = {"Control Loop Instantiation API"},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
@ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
@ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ }
+ )
}
)
@ApiResponses(
@@ -156,22 +155,23 @@ public class InstantiationController extends RestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
)
}
)
@@ -190,7 +190,7 @@ public class InstantiationController extends RestController {
required = true) @QueryParam("version") String version) {
try {
- ControlLoops response = provider.getControlLoops(name, version);
+ var response = provider.getControlLoops(name, version);
return addLoggingHeaders(addVersionControlHeaders(Response.status(Status.OK)), requestId).entity(response)
.build();
@@ -220,31 +220,32 @@ public class InstantiationController extends RestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)
- },
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)
+ },
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
@ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
@ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ }
+ )
}
)
@ApiResponses(
@@ -289,33 +290,35 @@ public class InstantiationController extends RestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME,
- description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_PATCH_NAME,
- description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = VERSION_LATEST_NAME,
- description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(
- name = REQUEST_ID_NAME,
- description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME,
+ description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_PATCH_NAME,
+ description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = VERSION_LATEST_NAME,
+ description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(
+ name = REQUEST_ID_NAME,
+ description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
}
)
- @ApiResponses(value = {
+ @ApiResponses(
+ value = {
@ApiResponse(code = AUTHENTICATION_ERROR_CODE, message = AUTHENTICATION_ERROR_MESSAGE),
@ApiResponse(code = AUTHORIZATION_ERROR_CODE, message = AUTHORIZATION_ERROR_MESSAGE),
@ApiResponse(code = SERVER_ERROR_CODE, message = SERVER_ERROR_MESSAGE)
@@ -358,21 +361,22 @@ public class InstantiationController extends RestController {
},
authorizations = @Authorization(value = AUTHORIZATION_TYPE),
responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
+ @ResponseHeader(
+ name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
+ response = String.class),
+ @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
+ response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
}
)
}
@@ -407,7 +411,7 @@ public class InstantiationController extends RestController {
* @return the Instantiation Response
*/
private Response createInstantiationErrorResponse(ErrorResponseInfo e, UUID requestId) {
- InstantiationResponse resp = new InstantiationResponse();
+ var resp = new InstantiationResponse();
resp.setErrorDetails(e.getErrorResponse().getErrorMessage());
return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
requestId).entity(resp).build();
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java
index 4c99b8e57..ba25a6dad 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/parameters/ClRuntimeParameterGroup.java
@@ -42,7 +42,6 @@ public class ClRuntimeParameterGroup extends ParameterGroupImpl {
private PolicyModelsProviderParameters databaseProviderParameters;
private ParticipantParameters participantParameters;
private TopicParameterGroup topicParameterGroup;
- private List<BusTopicParams> healthCheckRestClientParameters;
/**
* Create the Control Loop parameter group.
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java
index dd3fa30fc..4955e4a2f 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/RestController.java
@@ -102,6 +102,7 @@ public class RestController {
* Adds logging headers to the response.
*
* @param respBuilder response builder
+ * @param requestId unique ID for this request
* @return the response builder, with version logging
*/
public ResponseBuilder addLoggingHeaders(ResponseBuilder respBuilder, UUID requestId) {
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java
index a4238a9c4..957f53600 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeActivator.java
@@ -64,6 +64,7 @@ public class ClRuntimeActivator extends ServiceManagerContainer {
* Instantiate the activator for the control loop runtime as a complete service.
*
* @param clRuntimeParameterGroup the parameters for the control loop runtime service
+ * @throws ControlLoopRuntimeException if the activator does not start
*/
public ClRuntimeActivator(final ClRuntimeParameterGroup clRuntimeParameterGroup) {
@@ -134,7 +135,7 @@ public class ClRuntimeActivator extends ServiceManagerContainer {
providerClasses.addAll(supervisionHandler.get().getProviderClasses());
providerClasses.addAll(monitoringHandler.get().getProviderClasses());
- RestServer server = new RestServer(clRuntimeParameterGroup.getRestServerParameters(),
+ var server = new RestServer(clRuntimeParameterGroup.getRestServerParameters(),
ControlLoopAafFilter.class,
providerClasses.toArray(new Class<?>[providerClasses.size()]));
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java
index f36bb858b..54167e8a6 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/ClRuntimeCommandLineArguments.java
@@ -20,21 +20,14 @@
package org.onap.policy.clamp.controlloop.runtime.main.startstop;
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.net.URL;
import java.util.Arrays;
import javax.ws.rs.core.Response;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
-import org.apache.commons.lang3.StringUtils;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.clamp.controlloop.common.startstop.CommonCommandLineArguments;
@@ -44,14 +37,11 @@ import org.onap.policy.common.utils.resources.ResourceUtils;
* This class reads and handles command line parameters for the control loop runtime service.
*/
public class ClRuntimeCommandLineArguments {
- private static final String FILE_MESSAGE_PREAMBLE = " file \"";
- private static final int HELP_LINE_LENGTH = 120;
-
private final Options options;
private final CommonCommandLineArguments commonCommandLineArguments;
- @Getter()
- @Setter()
+ @Getter
+ @Setter
private String configurationFilePath = null;
/**
@@ -66,6 +56,7 @@ public class ClRuntimeCommandLineArguments {
* Construct the options for the CLI editor and parse in the given arguments.
*
* @param args The command line arguments
+ * @throws ControlLoopRuntimeException if the arguments are invalid
*/
public ClRuntimeCommandLineArguments(final String[] args) {
// Set up the options with the default constructor
@@ -76,7 +67,7 @@ public class ClRuntimeCommandLineArguments {
parse(args);
} catch (final ControlLoopException e) {
throw new ControlLoopRuntimeException(Response.Status.NOT_ACCEPTABLE,
- "parse error on control loop runtime parameters", e);
+ "parse error on control loop runtime parameters", e);
}
}
@@ -95,7 +86,7 @@ public class ClRuntimeCommandLineArguments {
commandLine = new DefaultParser().parse(options, args);
} catch (final ParseException e) {
throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- "invalid command line arguments specified : " + e.getMessage());
+ "invalid command line arguments specified : " + e.getMessage());
}
// Arguments left over after Commons CLI does its stuff
@@ -103,7 +94,7 @@ public class ClRuntimeCommandLineArguments {
if (remainingArgs.length > 0) {
throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE,
- "too many command line arguments specified : " + Arrays.toString(args));
+ "too many command line arguments specified : " + Arrays.toString(args));
}
if (commandLine.hasOption('h')) {
@@ -138,14 +129,4 @@ public class ClRuntimeCommandLineArguments {
public String getFullConfigurationFilePath() {
return ResourceUtils.getFilePath4Resource(getConfigurationFilePath());
}
-
- /**
- * Sets the configuration file path.
- *
- * @param configurationFilePath the configuration file path
- */
- public void setConfigurationFilePath(final String configurationFilePath) {
- this.configurationFilePath = configurationFilePath;
-
- }
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java
index 8e60d68cf..de1ce6f5d 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/startstop/Main.java
@@ -46,13 +46,14 @@ public class Main {
* Instantiates the control loop runtime service.
*
* @param args the command line arguments
+ * @throws ControlLoopRuntimeException if the CLAMP runtime fails to start
*/
public Main(final String[] args) {
- final String argumentString = Arrays.toString(args);
+ final var argumentString = Arrays.toString(args);
LOGGER.info("Starting the control loop runtime service with arguments - {}", argumentString);
// Check the arguments
- final ClRuntimeCommandLineArguments arguments = new ClRuntimeCommandLineArguments();
+ final var arguments = new ClRuntimeCommandLineArguments();
try {
// The arguments return a string if there is a message to print and we should exit
final String argumentMessage = arguments.parse(args);
@@ -82,12 +83,14 @@ public class Main {
// Add a shutdown hook to shut everything down in an orderly manner
Runtime.getRuntime().addShutdownHook(new ClRuntimeShutdownHookClass());
- String successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_CLAMP);
+ var successMsg = String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_CLAMP);
LOGGER.info(successMsg);
}
/**
* Check if main is running.
+ *
+ * @return true if the CLAMP runtime is running
*/
public boolean isRunning() {
return activator != null && activator.isAlive();
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java
index a7ad9180a..1584766f1 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringHandler.java
@@ -21,15 +21,12 @@
package org.onap.policy.clamp.controlloop.runtime.monitoring;
import java.io.IOException;
-import java.util.List;
import java.util.Set;
import javax.ws.rs.core.Response;
import lombok.Getter;
import org.onap.policy.clamp.controlloop.common.handler.ControlLoopHandler;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
import org.onap.policy.clamp.controlloop.runtime.monitoring.rest.MonitoringQueryController;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.listeners.MessageTypeDispatcher;
import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.models.base.PfModelRuntimeException;
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
index 193f8d557..1bc1312e7 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/MonitoringProvider.java
@@ -30,7 +30,6 @@ import java.util.Map;
import lombok.NonNull;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatistics;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatistics;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList;
@@ -55,6 +54,8 @@ public class MonitoringProvider implements Closeable {
/**
* Create a Monitoring provider.
*
+ * @param parameters parameters for accessing the database for monitoring
+ * @throws PfModelRuntimeException on errors creating the provider
*/
public MonitoringProvider(PolicyModelsProviderParameters parameters) {
@@ -83,9 +84,9 @@ public class MonitoringProvider implements Closeable {
*/
public ParticipantStatisticsList createParticipantStatistics(List<ParticipantStatistics> participantStatistics)
throws PfModelException {
- ParticipantStatisticsList participantStatisticsList = new ParticipantStatisticsList();
- participantStatisticsList.setStatisticsList(participantStatisticsProvider
- .createParticipantStatistics(participantStatistics));
+ var participantStatisticsList = new ParticipantStatisticsList();
+ participantStatisticsList
+ .setStatisticsList(participantStatisticsProvider.createParticipantStatistics(participantStatistics));
return participantStatisticsList;
}
@@ -99,9 +100,9 @@ public class MonitoringProvider implements Closeable {
*/
public ClElementStatisticsList createClElementStatistics(List<ClElementStatistics> clElementStatisticsList)
throws PfModelException {
- ClElementStatisticsList elementStatisticsList = new ClElementStatisticsList();
- elementStatisticsList.setClElementStatistics(clElementStatisticsProvider
- .createClElementStatistics(clElementStatisticsList));
+ var elementStatisticsList = new ClElementStatisticsList();
+ elementStatisticsList
+ .setClElementStatistics(clElementStatisticsProvider.createClElementStatistics(clElementStatisticsList));
return elementStatisticsList;
}
@@ -117,38 +118,36 @@ public class MonitoringProvider implements Closeable {
* @return the participant found
*/
public ParticipantStatisticsList fetchFilteredParticipantStatistics(@NonNull final String name,
- final String version, int recordCount,
- Instant startTime, Instant endTime) {
- ParticipantStatisticsList participantStatisticsList = new ParticipantStatisticsList();
+ final String version, int recordCount, Instant startTime, Instant endTime) {
+ var participantStatisticsList = new ParticipantStatisticsList();
- //Additional parameters can be added in filterMap for filtering data.
+ // Additional parameters can be added in filterMap for filtering data.
Map<String, Object> filterMap = null;
- participantStatisticsList.setStatisticsList(participantStatisticsProvider.getFilteredParticipantStatistics(
- name, version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
+ participantStatisticsList.setStatisticsList(participantStatisticsProvider.getFilteredParticipantStatistics(name,
+ version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
return participantStatisticsList;
}
/**
- * Get all participant statistics records found for a specific control loop. *
+ * Get all participant statistics records found for a specific control loop. *
*
* @param controlLoopName name of the control loop
* @param controlLoopVersion version of the control loop
* @return All the participant statistics found
- * @throws PfModelException on errors getting participant statistics
+ * @throws PfModelRuntimeException on errors getting participant statistics
*/
public ParticipantStatisticsList fetchParticipantStatsPerControlLoop(@NonNull final String controlLoopName,
- @NonNull final String controlLoopVersion)
- throws PfModelException {
- ParticipantStatisticsList statisticsList = new ParticipantStatisticsList();
+ @NonNull final String controlLoopVersion) {
+ var statisticsList = new ParticipantStatisticsList();
List<ParticipantStatistics> participantStatistics = new ArrayList<>();
try {
- //Fetch all participantIds for a specific control loop
- List<ToscaConceptIdentifier> participantIds = getAllParticipantIdsPerControlLoop(controlLoopName,
- controlLoopVersion);
- for (ToscaConceptIdentifier id: participantIds) {
- participantStatistics.addAll(participantStatisticsProvider.getFilteredParticipantStatistics(
- id.getName(), id.getVersion(), null, null, null, DESC_ORDER, 0));
+ // Fetch all participantIds for a specific control loop
+ List<ToscaConceptIdentifier> participantIds =
+ getAllParticipantIdsPerControlLoop(controlLoopName, controlLoopVersion);
+ for (ToscaConceptIdentifier id : participantIds) {
+ participantStatistics.addAll(participantStatisticsProvider
+ .getFilteredParticipantStatistics(id.getName(), id.getVersion(), null, null, null, DESC_ORDER, 0));
}
statisticsList.setStatisticsList(participantStatistics);
} catch (PfModelException e) {
@@ -157,8 +156,6 @@ public class MonitoringProvider implements Closeable {
return statisticsList;
}
-
-
/**
* Get clElement statistics based on specific filters.
*
@@ -172,46 +169,42 @@ public class MonitoringProvider implements Closeable {
* @throws PfModelException on errors getting control loop statistics
*/
public ClElementStatisticsList fetchFilteredClElementStatistics(@NonNull final String name, final String version,
- final String id, Instant startTime, Instant endTime,
- int recordCount) throws PfModelException {
- ClElementStatisticsList clElementStatisticsList = new ClElementStatisticsList();
+ final String id, Instant startTime, Instant endTime, int recordCount) throws PfModelException {
+ var clElementStatisticsList = new ClElementStatisticsList();
Map<String, Object> filterMap = new HashMap<>();
- //Adding UUID in filter if present
+ // Adding UUID in filter if present
if (id != null) {
filterMap.put("localName", id);
}
- clElementStatisticsList.setClElementStatistics(clElementStatisticsProvider.getFilteredClElementStatistics(
- name, version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
+ clElementStatisticsList.setClElementStatistics(clElementStatisticsProvider.getFilteredClElementStatistics(name,
+ version, startTime, endTime, filterMap, DESC_ORDER, recordCount));
return clElementStatisticsList;
}
-
/**
* Get clElement statistics per control loop.
*
* @param name the name of the control loop
* @param version the version of the control loop
* @return the clElement statistics found
- * @throws PfModelException on errors getting control loop statistics
+ * @throws PfModelRuntimeException on errors getting control loop statistics
*/
public ClElementStatisticsList fetchClElementStatsPerControlLoop(@NonNull final String name,
- @NonNull final String version)
- throws PfModelException {
- ClElementStatisticsList clElementStatisticsList = new ClElementStatisticsList();
+ @NonNull final String version) {
+ var clElementStatisticsList = new ClElementStatisticsList();
List<ClElementStatistics> clElementStats = new ArrayList<>();
try {
List<ControlLoopElement> clElements = new ArrayList<>();
- //Fetch all control loop elements for the control loop
- ControlLoop controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name,
- version));
+ // Fetch all control loop elements for the control loop
+ var controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
if (controlLoop != null) {
clElements.addAll(controlLoop.getElements().values());
- //Collect control loop element statistics for each cl element.
+ // Collect control loop element statistics for each cl element.
for (ControlLoopElement clElement : clElements) {
clElementStats.addAll(fetchFilteredClElementStatistics(clElement.getParticipantId().getName(),
- clElement.getParticipantId().getVersion(), clElement.getId().toString(), null,
- null, 0).getClElementStatistics());
+ clElement.getParticipantId().getVersion(), clElement.getId().toString(), null, null, 0)
+ .getClElementStatistics());
}
}
clElementStatisticsList.setClElementStatistics(clElementStats);
@@ -233,7 +226,7 @@ public class MonitoringProvider implements Closeable {
public List<ToscaConceptIdentifier> getAllParticipantIdsPerControlLoop(String name, String version)
throws PfModelException {
List<ToscaConceptIdentifier> participantIds = new ArrayList<>();
- ControlLoop controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
+ var controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
if (controlLoop != null) {
for (ControlLoopElement clElement : controlLoop.getElements().values()) {
participantIds.add(clElement.getParticipantId());
@@ -254,7 +247,7 @@ public class MonitoringProvider implements Closeable {
public Map<String, ToscaConceptIdentifier> getAllClElementsIdPerControlLoop(String name, String version)
throws PfModelException {
Map<String, ToscaConceptIdentifier> clElementId = new HashMap<>();
- ControlLoop controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
+ var controlLoop = controlLoopProvider.getControlLoop(new ToscaConceptIdentifier(name, version));
if (controlLoop != null) {
for (ControlLoopElement clElement : controlLoop.getElements().values()) {
clElementId.put(clElement.getId().toString(), clElement.getParticipantId());
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java
index 2e19ffe3a..7fde5fba3 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryController.java
@@ -67,7 +67,10 @@ public class MonitoringQueryController extends RestController {
*
* @param requestId request ID used in ONAP logging
* @param name the name of the participant to get, null for all participants statistics
+ * @param version the version of the participant to get, null for all participants with the given name
* @param recordCount the record count to be fetched
+ * @param startTime the time from which to get statistics
+ * @param endTime the time to which to get statistics
* @return the participant statistics
*/
// @formatter:off
@@ -91,13 +94,14 @@ public class MonitoringQueryController extends RestController {
@ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
}
)
@ApiResponses(
@@ -174,13 +178,14 @@ public class MonitoringQueryController extends RestController {
@ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
})
@ApiResponses(
value = {
@@ -203,7 +208,7 @@ public class MonitoringQueryController extends RestController {
.entity(response)
.build();
- } catch (PfModelRuntimeException | PfModelException e) {
+ } catch (PfModelRuntimeException e) {
LOGGER.warn("Monitoring of Cl participant statistics failed", e);
return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
requestId).build();
@@ -242,13 +247,14 @@ public class MonitoringQueryController extends RestController {
@ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
})
@ApiResponses(
value = {
@@ -271,7 +277,7 @@ public class MonitoringQueryController extends RestController {
.entity(response)
.build();
- } catch (PfModelRuntimeException | PfModelException e) {
+ } catch (PfModelRuntimeException e) {
LOGGER.warn("Monitoring of Cl Element statistics failed", e);
return addLoggingHeaders(addVersionControlHeaders(Response.status(e.getErrorResponse().getResponseCode())),
requestId).build();
@@ -290,6 +296,8 @@ public class MonitoringQueryController extends RestController {
* @param version version of the control loop
* @param id Id of the control loop element
* @param recordCount the record count to be fetched
+ * @param startTime the time from which to get statistics
+ * @param endTime the time to which to get statistics
* @return the control loop element statistics
*/
// @formatter:off
@@ -313,13 +321,14 @@ public class MonitoringQueryController extends RestController {
@ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
response = UUID.class)},
extensions = {
- @Extension(
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
+ @Extension
+ (
+ name = EXTENSION_NAME,
+ properties = {
+ @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
+ @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
+ }
+ )
})
@ApiResponses(
value = {
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
index 63bff00fc..7c7dc3a69 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java
@@ -20,7 +20,6 @@
package org.onap.policy.clamp.controlloop.runtime.supervision;
-import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.ws.rs.core.Response;
@@ -40,7 +39,6 @@ import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.Parti
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantMessageType;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningHandler;
-import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringHandler;
import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider;
@@ -54,7 +52,6 @@ import org.onap.policy.common.utils.services.Registry;
import org.onap.policy.common.utils.services.ServiceManager;
import org.onap.policy.common.utils.services.ServiceManagerException;
import org.onap.policy.models.base.PfModelException;
-import org.onap.policy.models.base.PfModelRuntimeException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -74,7 +71,6 @@ public class SupervisionHandler extends ControlLoopHandler {
private ControlLoopProvider controlLoopProvider;
private ParticipantProvider participantProvider;
- private CommissioningProvider commissioningProvider;
private MonitoringProvider monitoringProvider;
// Publishers for participant communication
@@ -139,7 +135,7 @@ public class SupervisionHandler extends ControlLoopHandler {
for (ToscaConceptIdentifier controlLoopId : controlLoopIdentifierList) {
try {
- ControlLoop controlLoop = controlLoopProvider.getControlLoop(controlLoopId);
+ var controlLoop = controlLoopProvider.getControlLoop(controlLoopId);
superviseControlLoop(controlLoop);
@@ -223,9 +219,10 @@ public class SupervisionHandler extends ControlLoopHandler {
* Supervise a control loop, performing whatever actions need to be performed on the control loop.
*
* @param controlLoop the control loop to supervises
+ * @throws PfModelException on accessing models in the database
* @throws ControlLoopException on supervision errors
*/
- private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException, PfModelException {
+ private void superviseControlLoop(ControlLoop controlLoop) throws ControlLoopException, PfModelException {
switch (controlLoop.getOrderedState()) {
case UNINITIALISED:
superviseControlLoopUninitialization(controlLoop);
@@ -332,18 +329,18 @@ public class SupervisionHandler extends ControlLoopHandler {
}
private void sendControlLoopUpdate(ControlLoop controlLoop) throws PfModelException {
- ParticipantControlLoopUpdate pclu = new ParticipantControlLoopUpdate();
+ var pclu = new ParticipantControlLoopUpdate();
pclu.setControlLoopId(controlLoop.getKey().asIdentifier());
pclu.setControlLoop(controlLoop);
// TODO: We should look up the correct TOSCA node template here for the control loop
// Tiny hack implemented to return the tosca service template entry from the database and be passed onto dmaap
- commissioningProvider = CommissioningHandler.getInstance().getProvider();
+ var commissioningProvider = CommissioningHandler.getInstance().getProvider();
pclu.setControlLoopDefinition(commissioningProvider.getToscaServiceTemplate(null, null));
controlLoopUpdatePublisher.send(pclu);
}
private void sendControlLoopStateChange(ControlLoop controlLoop) {
- ParticipantControlLoopStateChange clsc = new ParticipantControlLoopStateChange();
+ var clsc = new ParticipantControlLoopStateChange();
clsc.setControlLoopId(controlLoop.getKey().asIdentifier());
clsc.setMessageId(UUID.randomUUID());
clsc.setOrderedState(controlLoop.getOrderedState());
@@ -363,7 +360,7 @@ public class SupervisionHandler extends ControlLoopHandler {
participantStatusMessage.getParticipantId().getVersion());
if (CollectionUtils.isEmpty(participantList)) {
- Participant participant = new Participant();
+ var participant = new Participant();
participant.setName(participantStatusMessage.getParticipantId().getName());
participant.setVersion(participantStatusMessage.getParticipantId().getVersion());
participant.setDefinition(new ToscaConceptIdentifier("unknown", "0.0.0"));
@@ -397,7 +394,7 @@ public class SupervisionHandler extends ControlLoopHandler {
"PARTICIPANT_STATUS message references unknown control loop: " + controlLoop);
}
- ControlLoop dbControlLoop = controlLoopProvider
+ var dbControlLoop = controlLoopProvider
.getControlLoop(new ToscaConceptIdentifier(controlLoop.getName(), controlLoop.getVersion()));
if (dbControlLoop == null) {
exceptionOccured(Response.Status.NOT_FOUND,
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
index 0ccfddff3..4f3faf8af 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionScanner.java
@@ -21,17 +21,9 @@
package org.onap.policy.clamp.controlloop.runtime.supervision;
import java.io.Closeable;
-import java.util.Collection;
-import java.util.List;
-import java.util.TimerTask;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java
index 4dbb3ea02..f7749e164 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/rest/CommissioningControllerTest.java
@@ -127,7 +127,7 @@ public class CommissioningControllerTest extends CommonRestController {
Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT + "?name=noResultWithThisName");
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
- List entityList = rawresp.readEntity(List.class);
+ List<?> entityList = rawresp.readEntity(List.class);
assertThat(entityList).isEmpty();
}
@@ -138,7 +138,7 @@ public class CommissioningControllerTest extends CommonRestController {
Invocation.Builder invocationBuilder = super.sendRequest(COMMISSIONING_ENDPOINT);
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
- List entityList = rawresp.readEntity(List.class);
+ List<?> entityList = rawresp.readEntity(List.class);
assertNotNull(entityList);
assertThat(entityList).hasSize(2);
}
@@ -161,7 +161,7 @@ public class CommissioningControllerTest extends CommonRestController {
+ "?name=org.onap.domain.pmsh.PMSHControlLoopDefinition");
Response rawresp = invocationBuilder.buildGet().invoke();
assertEquals(Response.Status.OK.getStatusCode(), rawresp.getStatus());
- List entityList = rawresp.readEntity(List.class);
+ List<?> entityList = rawresp.readEntity(List.class);
assertNotNull(entityList);
assertThat(entityList).hasSize(4);
}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java
index 44096eecd..78f380405 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/TestMonitoringProvider.java
@@ -47,7 +47,6 @@ import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
public class TestMonitoringProvider {
private static final String CL_PARTICIPANT_STATISTICS_JSON =
@@ -68,8 +67,6 @@ public class TestMonitoringProvider {
private static ClElementStatisticsList inputClElementStatistics;
private static ClElementStatisticsList invalidClElementInput;
-
-
@BeforeClass
public static void beforeSetupStatistics() throws CoderException {
// Reading input json for statistics data
@@ -81,7 +78,6 @@ public class TestMonitoringProvider {
invalidClElementInput = CODER.decode(new File(INVALID_CL_ELEMENT_JSON_INPUT), ClElementStatisticsList.class);
}
-
@Test
public void testCreateParticipantStatistics() throws Exception {
PolicyModelsProviderParameters parameters =
@@ -121,15 +117,14 @@ public class TestMonitoringProvider {
}).hasMessageMatching("name is marked .*null but is null");
// Fetch specific statistics record with name, version and record count
- getResponse = provider.fetchFilteredParticipantStatistics("name2", "1.001", 1,
- null, null);
+ getResponse = provider.fetchFilteredParticipantStatistics("name2", "1.001", 1, null, null);
assertThat(getResponse.getStatisticsList()).hasSize(1);
assertEquals(getResponse.getStatisticsList().get(0).toString().replaceAll("\\s+", ""),
inputParticipantStatistics.getStatisticsList().get(2).toString().replaceAll("\\s+", ""));
// Fetch statistics using timestamp
- getResponse = provider.fetchFilteredParticipantStatistics("name1", "1.001", 0,
- null, Instant.parse("2021-01-10T15:00:00.000Z"));
+ getResponse = provider.fetchFilteredParticipantStatistics("name1", "1.001", 0, null,
+ Instant.parse("2021-01-10T15:00:00.000Z"));
assertThat(getResponse.getStatisticsList()).hasSize(1);
getResponse = provider.fetchFilteredParticipantStatistics("name1", "1.001", 0,
@@ -171,15 +166,12 @@ public class TestMonitoringProvider {
ClElementStatisticsList getResponse;
assertThatThrownBy(() -> {
- provider.fetchFilteredClElementStatistics(null, null, null, null,
- null, 0);
+ provider.fetchFilteredClElementStatistics(null, null, null, null, null, 0);
}).hasMessageMatching("name is marked .*null but is null");
- ClElementStatisticsList lists = provider.createClElementStatistics(inputClElementStatistics
- .getClElementStatistics());
+ var lists = provider.createClElementStatistics(inputClElementStatistics.getClElementStatistics());
- getResponse = provider.fetchFilteredClElementStatistics("name1", null, null, null,
- null, 0);
+ getResponse = provider.fetchFilteredClElementStatistics("name1", null, null, null, null, 0);
assertThat(getResponse.getClElementStatistics()).hasSize(2);
assertEquals(getResponse.getClElementStatistics().get(0).toString().replaceAll("\\s+", ""),
@@ -204,18 +196,17 @@ public class TestMonitoringProvider {
try (MonitoringProvider provider = Mockito.spy(new MonitoringProvider(parameters))) {
provider.createParticipantStatistics(inputParticipantStatistics.getStatisticsList());
- //Mock the response for fetching participant conceptIdentifiers per control loop
+ // Mock the response for fetching participant conceptIdentifiers per control loop
List<ToscaConceptIdentifier> conceptIdentifiers = new ArrayList<>();
conceptIdentifiers.add(new ToscaConceptIdentifier("name1", "1.001"));
- when(provider.getAllParticipantIdsPerControlLoop("testName", "1.001"))
- .thenReturn(conceptIdentifiers);
+ when(provider.getAllParticipantIdsPerControlLoop("testName", "1.001")).thenReturn(conceptIdentifiers);
ParticipantStatisticsList getResponse;
getResponse = provider.fetchParticipantStatsPerControlLoop("testName", "1.001");
assertThat(getResponse.getStatisticsList()).hasSize(2);
assertEquals(getResponse.getStatisticsList().get(0).toString().replaceAll("\\s+", ""),
inputParticipantStatistics.getStatisticsList().get(0).toString().replaceAll("\\s+", ""));
- assertThat(provider.fetchParticipantStatsPerControlLoop("invalidCLName", "1.002")
- .getStatisticsList()).isEmpty();
+ assertThat(provider.fetchParticipantStatsPerControlLoop("invalidCLName", "1.002").getStatisticsList())
+ .isEmpty();
}
}
@@ -224,20 +215,19 @@ public class TestMonitoringProvider {
public void testClElementStatsPerCL() throws Exception {
PolicyModelsProviderParameters parameters =
CommonTestData.geParameterGroup(0, "getelemstatPerCL").getDatabaseProviderParameters();
- //Setup a dummy Control loop data
+ // Setup a dummy Control loop data
ControlLoopElement mockClElement = new ControlLoopElement();
mockClElement.setId(inputClElementStatistics.getClElementStatistics().get(0).getId());
- mockClElement.setParticipantId(new ToscaConceptIdentifier(inputClElementStatistics.getClElementStatistics()
- .get(0).getParticipantId().getName(), inputClElementStatistics.getClElementStatistics().get(0)
- .getParticipantId().getVersion()));
+ mockClElement.setParticipantId(new ToscaConceptIdentifier(
+ inputClElementStatistics.getClElementStatistics().get(0).getParticipantId().getName(),
+ inputClElementStatistics.getClElementStatistics().get(0).getParticipantId().getVersion()));
ControlLoop mockCL = new ControlLoop();
mockCL.setElements(new LinkedHashMap<>());
mockCL.getElements().put(mockClElement.getId(), mockClElement);
- //Mock controlloop data to be returned for the given CL Id
+ // Mock controlloop data to be returned for the given CL Id
ControlLoopProvider mockClProvider = Mockito.mock(ControlLoopProvider.class);
- when(mockClProvider.getControlLoop(new ToscaConceptIdentifier("testCLName", "1.001")))
- .thenReturn(mockCL);
+ when(mockClProvider.getControlLoop(new ToscaConceptIdentifier("testCLName", "1.001"))).thenReturn(mockCL);
try (MonitoringProvider monitoringProvider = new MonitoringProvider(parameters)) {
monitoringProvider.createClElementStatistics(inputClElementStatistics.getClElementStatistics());
@@ -252,13 +242,14 @@ public class TestMonitoringProvider {
assertEquals(getResponse.getClElementStatistics().get(1).toString().replaceAll("\\s+", ""),
inputClElementStatistics.getClElementStatistics().get(1).toString().replaceAll("\\s+", ""));
- assertThat(monitoringProvider.fetchClElementStatsPerControlLoop("invalidCLName", "1.002")
- .getClElementStatistics()).isEmpty();
+ assertThat(
+ monitoringProvider.fetchClElementStatsPerControlLoop("invalidCLName", "1.002").getClElementStatistics())
+ .isEmpty();
- Map<String, ToscaConceptIdentifier> clElementIds = monitoringProvider
- .getAllClElementsIdPerControlLoop("testCLName", "1.001");
- assertThat(clElementIds).containsKey(inputClElementStatistics.getClElementStatistics().get(0).getId()
- .toString());
+ Map<String, ToscaConceptIdentifier> clElementIds =
+ monitoringProvider.getAllClElementsIdPerControlLoop("testCLName", "1.001");
+ assertThat(clElementIds)
+ .containsKey(inputClElementStatistics.getClElementStatistics().get(0).getId().toString());
}
}
}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java
index 118199a2d..a846d9317 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/monitoring/rest/MonitoringQueryControllerTest.java
@@ -30,7 +30,6 @@ import javax.ws.rs.client.Invocation;
import javax.ws.rs.core.Response;
import org.junit.AfterClass;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ClElementStatisticsList;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantStatisticsList;
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java
index 77f802d61..aa17e9c4f 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/CommonTestData.java
@@ -20,6 +20,8 @@
package org.onap.policy.clamp.controlloop.runtime.util;
+import javax.ws.rs.core.Response.Status;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
@@ -39,13 +41,14 @@ public class CommonTestData {
* @param port port to be inserted into the parameters
* @param dbName the database name
* @return the standard Control Loop parameters
+ * @throws ControlLoopRuntimeException on errors reading the control loop parameters
*/
public static ClRuntimeParameterGroup geParameterGroup(final int port, final String dbName) {
try {
return coder.decode(getParameterGroupAsString(port, dbName), ClRuntimeParameterGroup.class);
} catch (CoderException e) {
- throw new RuntimeException("cannot read Control Loop parameters", e);
+ throw new ControlLoopRuntimeException(Status.NOT_ACCEPTABLE, "cannot read Control Loop parameters", e);
}
}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java
index 0d668f139..00b9c6715 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/util/rest/CommonRestController.java
@@ -128,9 +128,8 @@ public class CommonRestController {
/**
* Starts the "Main".
*
- * @throws InterruptedException
- *
- * @throws Exception if an error occurs
+ * @throws InterruptedException if the NetworkUtil method calls are interrupted
+ * @throws IllegalStateException if a controller cannot be started on the requested port
*/
protected static void startMain() throws InterruptedException {
Registry.newRegistry();
@@ -152,11 +151,11 @@ public class CommonRestController {
/**
* Stops the "Main".
*
- * @throws ControlLoopException
- *
- * @throws Exception if an error occurs
+ * @throws ControlLoopException if an error occurs shutting down the controller
+ * @throws InterruptedException if the NetworkUtil method calls are interrupted
+ * @throws IllegalStateException if a controller cannot be started on the requested port
*/
- private static void stopMain() throws Exception {
+ private static void stopMain() throws ControlLoopException, InterruptedException {
if (main != null) {
Main main2 = main;
main = null;
@@ -260,4 +259,4 @@ public class CommonRestController {
Response rawresp = sendNoAuthRequest(endPoint).delete();
assertEquals(Response.Status.UNAUTHORIZED.getStatusCode(), rawresp.getStatus());
}
-} \ No newline at end of file
+}
diff --git a/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json b/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json
index 7682a1812..410c35684 100644
--- a/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json
+++ b/runtime-controlloop/src/test/resources/parameters/InstantiationConfigParametersStd.json
@@ -55,25 +55,5 @@
"topicCommInfrastructure": "dmaap"
}
]
- },
- "healthCheckRestClientParameters": [
- {
- "clientName": "api",
- "hostname": "policy-api",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "policy/api/v1/healthcheck"
- },
- {
- "clientName": "distribution",
- "hostname": "policy-distribution",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "healthcheck"
- }
- ]
+ }
}
diff --git a/runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json b/runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json
index f784dcd16..cce0ab5ee 100644
--- a/runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json
+++ b/runtime-controlloop/src/test/resources/parameters/MinimumParametersH2.json
@@ -37,23 +37,5 @@
"servers" : [ "message-router" ],
"topicCommInfrastructure" : "dmaap"
}]
- },
- "healthCheckRestClientParameters":[{
- "clientName": "api",
- "hostname": "policy-api",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "policy/api/v1/healthcheck"
- },
- {
- "clientName": "distribution",
- "hostname": "policy-distribution",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "healthcheck"
- }]
+ }
}
diff --git a/runtime-controlloop/src/test/resources/parameters/TestParameters.json b/runtime-controlloop/src/test/resources/parameters/TestParameters.json
index c3be762d6..9fbcfb28c 100644
--- a/runtime-controlloop/src/test/resources/parameters/TestParameters.json
+++ b/runtime-controlloop/src/test/resources/parameters/TestParameters.json
@@ -55,25 +55,5 @@
"topicCommInfrastructure": "dmaap"
}
]
- },
- "healthCheckRestClientParameters": [
- {
- "clientName": "api",
- "hostname": "policy-api",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "policy/api/v1/healthcheck"
- },
- {
- "clientName": "distribution",
- "hostname": "policy-distribution",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "healthcheck"
- }
- ]
+ }
}
diff --git a/runtime-controlloop/src/test/resources/parameters/TestParametersMariaDB.json b/runtime-controlloop/src/test/resources/parameters/TestParametersMariaDB.json
index 2c0127b16..529557eab 100644
--- a/runtime-controlloop/src/test/resources/parameters/TestParametersMariaDB.json
+++ b/runtime-controlloop/src/test/resources/parameters/TestParametersMariaDB.json
@@ -55,25 +55,5 @@
"topicCommInfrastructure": "dmaap"
}
]
- },
- "healthCheckRestClientParameters": [
- {
- "clientName": "api",
- "hostname": "policy-api",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "policy/api/v1/healthcheck"
- },
- {
- "clientName": "distribution",
- "hostname": "policy-distribution",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "healthcheck"
- }
- ]
+ }
}
diff --git a/runtime-controlloop/src/test/resources/parameters/Unreadable.json b/runtime-controlloop/src/test/resources/parameters/Unreadable.json
index 3d117f416..1c1e93897 100644
--- a/runtime-controlloop/src/test/resources/parameters/Unreadable.json
+++ b/runtime-controlloop/src/test/resources/parameters/Unreadable.json
@@ -55,24 +55,4 @@
"topicCommInfrastructure": "dmaap"
}
]
- },
- "healthCheckRestClientParameters": [
- {
- "clientName": "api",
- "hostname": "policy-api",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "policy/api/v1/healthcheck"
- },
- {
- "clientName": "distribution",
- "hostname": "policy-distribution",
- "port": 6969,
- "userName": "healthcheck",
- "password": "zb!XztG34",
- "useHttps": true,
- "basePath": "healthcheck"
- }
- ]
+ }
diff --git a/runtime/pom.xml b/runtime/pom.xml
index 1f1a64390..7dda5c6b8 100644
--- a/runtime/pom.xml
+++ b/runtime/pom.xml
@@ -351,16 +351,6 @@
</exclusions>
</dependency>
<dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-core</artifactId>
- <version>1.2.3</version>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <version>1.2.3</version>
- </dependency>
- <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/Application.java b/runtime/src/main/java/org/onap/policy/clamp/clds/Application.java
index ba300ac09..07c174293 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/Application.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/Application.java
@@ -39,7 +39,6 @@ import org.apache.catalina.connector.Connector;
import org.onap.policy.clamp.clds.util.ClampVersioning;
import org.onap.policy.clamp.clds.util.ResourceFileUtils;
import org.onap.policy.clamp.util.PassDecoder;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -54,7 +53,6 @@ import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
-import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
@@ -99,9 +97,6 @@ public class Application extends SpringBootServletInitializer {
@Value("${clamp.config.keyFile:classpath:/clds/aaf/org.onap.clamp.keyfile}")
private String keyFile;
- @Autowired
- private Environment env;
-
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
@@ -124,11 +119,11 @@ public class Application extends SpringBootServletInitializer {
* @throws IOException IO Exception
*/
@Bean
- public ServletRegistrationBean camelServletRegistrationBean() throws IOException {
+ public ServletRegistrationBean<ClampServlet> camelServletRegistrationBean() throws IOException {
eelfLogger.info(ResourceFileUtils.getResourceAsString("boot-message.txt") + "(v"
+ ClampVersioning.getCldsVersionFromProps() + ")" + System.getProperty("line.separator")
+ getSslExpirationDate());
- ServletRegistrationBean registration = new ServletRegistrationBean(new ClampServlet(), "/restservices/clds/*");
+ var registration = new ServletRegistrationBean<ClampServlet>(new ClampServlet(), "/restservices/clds/*");
registration.setName("CamelServlet");
return registration;
}
@@ -140,11 +135,11 @@ public class Application extends SpringBootServletInitializer {
*/
@Bean
public ServletWebServerFactory getEmbeddedServletContainerFactory() {
- TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
+ var tomcat = new TomcatServletWebServerFactory();
if (httpRedirectedPort != null && keystoreFile != null) {
// Automatically redirect to HTTPS
tomcat = new TomcatEmbeddedServletContainerFactoryRedirection();
- Connector newConnector = createRedirectConnector(Integer.parseInt(springServerPort));
+ var newConnector = createRedirectConnector(Integer.parseInt(springServerPort));
if (newConnector != null) {
tomcat.addAdditionalTomcatConnectors(newConnector);
}
@@ -158,7 +153,7 @@ public class Application extends SpringBootServletInitializer {
+ " (Connector disabled)");
return null;
}
- Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
+ var connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setSecure(false);
connector.setPort(Integer.parseInt(httpRedirectedPort));
@@ -167,10 +162,10 @@ public class Application extends SpringBootServletInitializer {
}
private String getSslExpirationDate() throws IOException {
- StringBuilder result = new StringBuilder(" :: SSL Certificates :: ");
+ var result = new StringBuilder(" :: SSL Certificates :: ");
try {
if (keystoreFile != null) {
- KeyStore keystore = KeyStore.getInstance(keyStoreType);
+ var keystore = KeyStore.getInstance(keyStoreType);
keystore.load(ResourceFileUtils.getResourceAsStream(keystoreFile.replace("classpath:", "")),
PassDecoder.decode(keyStorePass, keyFile).toCharArray());
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java
index 9b6338e00..720a3f995 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/AafConfiguration.java
@@ -50,8 +50,8 @@ public class AafConfiguration {
* @return FilterRegistrationBean
*/
@Bean
- public FilterRegistrationBean cadiFilterRegistration() {
- FilterRegistrationBean registration = new FilterRegistrationBean();
+ public FilterRegistrationBean<Filter> cadiFilterRegistration() {
+ var registration = new FilterRegistrationBean<Filter>();
registration.setFilter(cadiFilter());
registration.addUrlPatterns("/restservices/clds/v1/user/*");
registration.addUrlPatterns("/restservices/clds/v2/dictionary/*");
@@ -64,4 +64,4 @@ public class AafConfiguration {
registration.setOrder(0);
return registration;
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java
index 5f10c0afb..0880e9b74 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/CamelConfiguration.java
@@ -117,22 +117,22 @@ public class CamelConfiguration extends RouteBuilder {
private void configureCamelHttpComponent()
throws KeyStoreException, NoSuchAlgorithmException, KeyManagementException, CertificateException,
IOException {
- RequestConfig requestConfig = RequestConfig.custom()
+ var requestConfig = RequestConfig.custom()
.setConnectTimeout(connectTimeout)
.setConnectionRequestTimeout(connectRequestTimeout)
.setSocketTimeout(socketTimeout).build();
if (trustStore != null) {
- KeyStore truststore = KeyStore.getInstance(trustStoreType);
+ var truststore = KeyStore.getInstance(trustStoreType);
truststore.load(
ResourceFileUtils.getResourceAsStream(trustStore),
Objects.requireNonNull(PassDecoder.decode(trustStorePass, keyFile)).toCharArray());
- TrustManagerFactory trustFactory = TrustManagerFactory.getInstance(trustStoreAlgorithm);
+ var trustFactory = TrustManagerFactory.getInstance(trustStoreAlgorithm);
trustFactory.init(truststore);
- SSLContext sslcontext = SSLContext.getInstance("TLS");
+ var sslcontext = SSLContext.getInstance("TLS");
sslcontext.init(null, trustFactory.getTrustManagers(), null);
camelContext.getComponent(HTTPS, HttpComponent.class).setHttpClientConfigurer(builder -> {
- SSLSocketFactory factory = new SSLSocketFactory(sslcontext,
+ var factory = new SSLSocketFactory(sslcontext,
SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
builder.setSSLSocketFactory(factory);
builder.setConnectionManager(new BasicHttpClientConnectionManager(
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryCache.java b/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryCache.java
index a69d1a353..248fdcaea 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryCache.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryCache.java
@@ -53,7 +53,7 @@ public class DcaeInventoryCache {
}
public Set<String> getAllLoopIds() {
- return this.blueprintsMap.keySet();
+ return blueprintsMap.keySet();
}
public Set<DcaeInventoryResponse> getAllBlueprintsPerLoopId(String loopId) {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/UnknownComponentException.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/UnknownComponentException.java
index fb684b57b..d1d45a37d 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/UnknownComponentException.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/UnknownComponentException.java
@@ -24,6 +24,8 @@
package org.onap.policy.clamp.clds.tosca.update;
public class UnknownComponentException extends Exception {
+ private static final long serialVersionUID = 1187337836071750628L;
+
public UnknownComponentException(String nameEntry) {
this.getWrongName(nameEntry);
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/Constraint.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/Constraint.java
index 651456ca6..bdf9af08b 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/Constraint.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/Constraint.java
@@ -31,6 +31,8 @@ import java.util.Map.Entry;
import org.onap.policy.clamp.clds.tosca.update.templates.JsonTemplate;
public class Constraint {
+ private static final String ARRAY = "array";
+ private static final String STRING = "string";
private LinkedHashMap<String, Object> constraints;
private JsonTemplate jsonTemplate;
@@ -43,7 +45,7 @@ public class Constraint {
/**
* Deploy the linkedhashmap which contains the constraints, to extract them one to one.
*
- * @param jsonSchema The json Schema
+ * @param jsonSchema The json Schema
* @param typeProperty The ype property
* @return the json object
*/
@@ -57,14 +59,14 @@ public class Constraint {
/**
* Each case of Tosca constraints below parse specifically the field in the JsonObject.
*
- * @param jsonSchema Json Schema
- * @param nameConstraint Name constraint
+ * @param jsonSchema Json Schema
+ * @param nameConstraint Name constraint
* @param valueConstraint value constraint
- * @param typeProperty Type Property
+ * @param typeProperty Type Property
*/
@SuppressWarnings("unchecked")
public void parseConstraint(JsonObject jsonSchema, String nameConstraint, Object valueConstraint,
- String typeProperty) {
+ String typeProperty) {
switch (nameConstraint) {
case "equal":
checkTemplateField("const", jsonSchema, valueConstraint);
@@ -100,7 +102,7 @@ public class Constraint {
String[] maxtab = nameConstraint.split("_");
this.getLimitValue(jsonSchema, valueConstraint, typeProperty, maxtab[0]);
break;
- default://valid_value
+ default:// valid_value
this.getValueArray(jsonSchema, valueConstraint, typeProperty);
break;
}
@@ -110,17 +112,17 @@ public class Constraint {
/**
* To be done.
*
- * @param jsonSchema json schema
- * @param fieldValue field value
+ * @param jsonSchema json schema
+ * @param fieldValue field value
* @param typeProperty For the complex components, get a specific number of items/properties
*/
public void getSpecificLength(JsonObject jsonSchema, Object fieldValue, String typeProperty) {
switch (typeProperty.toLowerCase()) {
- case "string":
+ case STRING:
checkTemplateField("minLength", jsonSchema, fieldValue);
checkTemplateField("maxLength", jsonSchema, fieldValue);
break;
- case "array":
+ case ARRAY:
if (fieldValue.equals(1) && jsonTemplate.hasFields("uniqueItems")) {
jsonSchema.addProperty("uniqueItems", true);
} else {
@@ -139,48 +141,46 @@ public class Constraint {
/**
* To be done.
*
- * @param jsonSchema json schema
- * @param fieldValue field value
+ * @param jsonSchema json schema
+ * @param fieldValue field value
* @param typeProperty type property
- * @param side Get the limits fieldValue for the properties : depend of the type of the component
+ * @param side Get the limits fieldValue for the properties : depend of the type of the component
*/
public void getLimitValue(JsonObject jsonSchema, Object fieldValue, String typeProperty, String side) {
- switch (typeProperty) {
- case "string":
- if (side.equals("min")) {
- checkTemplateField("minLength", jsonSchema, fieldValue);
- } else {
- checkTemplateField("maxLength", jsonSchema, fieldValue);
- }
- break;
- default:// Array
- if (side.equals("min")) {
- checkTemplateField("minItems", jsonSchema, fieldValue);
- } else {
- checkTemplateField("maxItems", jsonSchema, fieldValue);
- }
- break;
+ if (typeProperty.equals(STRING)) {
+ if (side.equals("min")) {
+ checkTemplateField("minLength", jsonSchema, fieldValue);
+ } else {
+ checkTemplateField("maxLength", jsonSchema, fieldValue);
+ }
+ } else {
+ if (side.equals("min")) {
+ checkTemplateField("minItems", jsonSchema, fieldValue);
+ } else {
+ checkTemplateField("maxItems", jsonSchema, fieldValue);
+ }
}
-
}
/**
* To be done.
*
- * @param jsonSchema Json schema
- * @param fieldValue field value
+ * @param jsonSchema Json schema
+ * @param fieldValue field value
* @param typeProperty Get as Enum the valid values for the property
*/
public void getValueArray(JsonObject jsonSchema, Object fieldValue, String typeProperty) {
if (jsonTemplate.hasFields("enum")) {
- JsonArray enumeration = new JsonArray();
- if (typeProperty.equals("string") || typeProperty.equals("String")) {
+ var enumeration = new JsonArray();
+ if (typeProperty.equals(STRING) || typeProperty.equals("String")) {
+ @SuppressWarnings("unchecked")
ArrayList<String> arrayValues = (ArrayList<String>) fieldValue;
for (String arrayItem : arrayValues) {
enumeration.add(arrayItem);
}
jsonSchema.add("enum", enumeration);
} else {
+ @SuppressWarnings("unchecked")
ArrayList<Number> arrayValues = (ArrayList<Number>) fieldValue;
for (Number arrayItem : arrayValues) {
enumeration.add(arrayItem);
@@ -193,7 +193,7 @@ public class Constraint {
/**
* To be done.
*
- * @param field Field
+ * @param field Field
* @param jsonSchema Json schema
* @param fieldValue Simple way to avoid code duplication
*/
@@ -219,4 +219,4 @@ public class Constraint {
}
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ToscaElementProperty.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ToscaElementProperty.java
index 4db8b0356..77d920860 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ToscaElementProperty.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ToscaElementProperty.java
@@ -27,6 +27,7 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.ArrayList;
import java.util.LinkedHashMap;
+import java.util.List;
import org.onap.policy.clamp.clds.tosca.update.templates.JsonTemplate;
public class ToscaElementProperty {
@@ -40,7 +41,7 @@ public class ToscaElementProperty {
/**
* Constructor.
*
- * @param name the name
+ * @param name the name
* @param items the items
*/
public ToscaElementProperty(String name, LinkedHashMap<String, Object> items) {
@@ -69,9 +70,10 @@ public class ToscaElementProperty {
* For each primitive value, requires to get each field Value and cast it and add it in a Json.
*
* @param fieldsContent field
- * @param fieldName field
- * @param value value
+ * @param fieldName field
+ * @param value value
*/
+ @SuppressWarnings("unchecked")
public void addFieldToJson(JsonObject fieldsContent, String fieldName, Object value) {
if (value != null) {
String typeValue = value.getClass().getSimpleName();
@@ -89,7 +91,7 @@ public class ToscaElementProperty {
fieldsContent.addProperty(fieldName, (Integer) value);
break;
default:
- fieldsContent.add(fieldName, parseArray((ArrayList) value));
+ fieldsContent.add(fieldName, parseArray((ArrayList<Object>) value));
break;
}
}
@@ -101,31 +103,29 @@ public class ToscaElementProperty {
* @param arrayProperties array pro
* @return a json array
*/
- public JsonArray parseArray(ArrayList<Object> arrayProperties) {
- JsonArray arrayContent = new JsonArray();
+ public JsonArray parseArray(List<Object> arrayProperties) {
ArrayList<Object> arrayComponent = new ArrayList<>();
for (Object itemArray : arrayProperties) {
arrayComponent.add(itemArray);
}
- ArrayField af = new ArrayField(arrayComponent);
- arrayContent = af.deploy();
- return arrayContent;
+ var af = new ArrayField(arrayComponent);
+ return af.deploy();
}
/**
* Create an instance of Constraint, to extract the values and add it to the Json (according to the type
- * * of the current property).
+ * * of the current property).
*
* @param json a json
* @param constraints constraints
* @param jsonTemplate template
*/
@SuppressWarnings("unchecked")
- public void addConstraintsAsJson(JsonObject json, ArrayList<Object> constraints, JsonTemplate jsonTemplate) {
+ public void addConstraintsAsJson(JsonObject json, List<Object> constraints, JsonTemplate jsonTemplate) {
for (Object constraint : constraints) {
if (constraint instanceof LinkedHashMap) {
LinkedHashMap<String, Object> valueConstraint = (LinkedHashMap<String, Object>) constraint;
- Constraint constraintParser = new Constraint(valueConstraint, jsonTemplate);
+ var constraintParser = new Constraint(valueConstraint, jsonTemplate);
constraintParser.deployConstraints(json, (String) getItems().get("type"));
}
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
index 74fd8e5fd..1d5ed26e0 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaConverterToJsonSchema.java
@@ -45,6 +45,20 @@ import org.onap.policy.clamp.loop.service.Service;
* @see org.onap.policy.clamp.clds.tosca.update.parser.ToscaConverterToJsonSchema#getJsonSchemaOfToscaElement
*/
public class ToscaConverterToJsonSchema {
+ private static final String ARRAY = "array";
+ private static final String CONSTRAINTS = "constraints";
+ private static final String DESCRIPTION = "description";
+ private static final String ENTRY_SCHEMA = "entry_schema";
+ private static final String FORMAT = "format";
+ private static final String LIST = "list";
+ private static final String MAP = "map";
+ private static final String METADATA = "metadata";
+ private static final String OBJECT = "object";
+ private static final String PROPERTIES = "properties";
+ private static final String REQUIRED = "required";
+ private static final String TITLE = "title";
+ private static final String TYPE = "type";
+
private LinkedHashMap<String, ToscaElement> components;
private LinkedHashMap<String, JsonTemplate> templates;
@@ -55,14 +69,14 @@ public class ToscaConverterToJsonSchema {
/**
* Constructor.
*
- * @param toscaElementsMap All the tosca elements found (policy type + data types + native tosca datatypes)
+ * @param toscaElementsMap All the tosca elements found (policy type + data types + native tosca datatypes)
* @param jsonSchemaTemplates All Json schema templates to use
- * @param metadataParser The metadata parser to use for metadata section
- * @param serviceModel The service model for clamp enrichment
+ * @param metadataParser The metadata parser to use for metadata section
+ * @param serviceModel The service model for clamp enrichment
*/
public ToscaConverterToJsonSchema(LinkedHashMap<String, ToscaElement> toscaElementsMap,
- LinkedHashMap<String, JsonTemplate> jsonSchemaTemplates,
- ToscaMetadataParser metadataParser, Service serviceModel) {
+ LinkedHashMap<String, JsonTemplate> jsonSchemaTemplates, ToscaMetadataParser metadataParser,
+ Service serviceModel) {
this.components = toscaElementsMap;
this.templates = jsonSchemaTemplates;
this.metadataParser = metadataParser;
@@ -87,23 +101,21 @@ public class ToscaConverterToJsonSchema {
*/
public JsonObject getFieldAsObject(ToscaElement toscaElement) {
- JsonObject globalFields = new JsonObject();
- if (templates.get("object").hasFields("title")) {
- globalFields.addProperty("title", toscaElement.getName());
+ var globalFields = new JsonObject();
+ if (templates.get(OBJECT).hasFields(TITLE)) {
+ globalFields.addProperty(TITLE, toscaElement.getName());
}
- if (templates.get("object").hasFields("type")) {
- globalFields.addProperty("type", "object");
+ if (templates.get(OBJECT).hasFields(TYPE)) {
+ globalFields.addProperty(TYPE, OBJECT);
}
- if (templates.get("object").hasFields("description")) {
- if (toscaElement.getDescription() != null) {
- globalFields.addProperty("description", toscaElement.getDescription());
- }
+ if (templates.get(OBJECT).hasFields(DESCRIPTION) && (toscaElement.getDescription() != null)) {
+ globalFields.addProperty(DESCRIPTION, toscaElement.getDescription());
}
- if (templates.get("object").hasFields("required")) {
- globalFields.add("required", this.getRequirements(toscaElement.getName()));
+ if (templates.get(OBJECT).hasFields(REQUIRED)) {
+ globalFields.add(REQUIRED, this.getRequirements(toscaElement.getName()));
}
- if (templates.get("object").hasFields("properties")) {
- globalFields.add("properties", this.deploy(toscaElement.getName()));
+ if (templates.get(OBJECT).hasFields(PROPERTIES)) {
+ globalFields.add(PROPERTIES, this.deploy(toscaElement.getName()));
}
return globalFields;
}
@@ -115,18 +127,18 @@ public class ToscaConverterToJsonSchema {
* @return a json array
*/
public JsonArray getRequirements(String nameComponent) {
- JsonArray requirements = new JsonArray();
+ var requirements = new JsonArray();
ToscaElement toParse = components.get(nameComponent);
- //Check for a father component, and launch the same process
+ // Check for a father component, and launch the same process
if (!"tosca.datatypes.Root".equals(toParse.getDerivedFrom())
&& !"tosca.policies.Root".equals(toParse.getDerivedFrom())) {
requirements.addAll(getRequirements(toParse.getDerivedFrom()));
}
- //Each property is checked, and add to the requirement array if it's required
+ // Each property is checked, and add to the requirement array if it's required
Collection<ToscaElementProperty> properties = toParse.getProperties().values();
for (ToscaElementProperty toscaElementProperty : properties) {
- if (toscaElementProperty.getItems().containsKey("required")
- && toscaElementProperty.getItems().get("required").equals(true)) {
+ if (toscaElementProperty.getItems().containsKey(REQUIRED)
+ && toscaElementProperty.getItems().get(REQUIRED).equals(true)) {
requirements.add(toscaElementProperty.getName());
}
}
@@ -141,19 +153,19 @@ public class ToscaConverterToJsonSchema {
* @return a json object
*/
public JsonObject deploy(String nameComponent) {
- JsonObject jsonSchema = new JsonObject();
+ var jsonSchema = new JsonObject();
ToscaElement toParse = components.get(nameComponent);
- //Check for a father component, and launch the same process
+ // Check for a father component, and launch the same process
if (!toParse.getDerivedFrom().equals("tosca.datatypes.Root")
&& !toParse.getDerivedFrom().equals("tosca.policies.Root")) {
jsonSchema = this.getParent(toParse.getDerivedFrom());
}
- //For each component property, check if its a complex properties (a component) or not. In that case,
- //launch the analyse of the property.
+ // For each component property, check if its a complex properties (a component) or not. In that case,
+ // launch the analyse of the property.
for (Entry<String, ToscaElementProperty> property : toParse.getProperties().entrySet()) {
- if (getToscaElement((String) property.getValue().getItems().get("type")) != null) {
+ if (getToscaElement((String) property.getValue().getItems().get(TYPE)) != null) {
jsonSchema.add(property.getValue().getName(),
- this.getJsonSchemaOfToscaElement((String) property.getValue().getItems().get("type")));
+ this.getJsonSchemaOfToscaElement((String) property.getValue().getItems().get(TYPE)));
} else {
jsonSchema.add(property.getValue().getName(), this.complexParse(property.getValue()));
}
@@ -179,42 +191,42 @@ public class ToscaConverterToJsonSchema {
*/
@SuppressWarnings("unchecked")
public JsonObject complexParse(ToscaElementProperty toscaElementProperty) {
- JsonObject propertiesInJson = new JsonObject();
+ var propertiesInJson = new JsonObject();
JsonTemplate currentPropertyJsonTemplate;
- String typeProperty = (String) toscaElementProperty.getItems().get("type");
- if (typeProperty.toLowerCase().equals("list") || typeProperty.toLowerCase().equals("map")) {
- currentPropertyJsonTemplate = templates.get("object");
+ String typeProperty = (String) toscaElementProperty.getItems().get(TYPE);
+ if (LIST.equalsIgnoreCase(typeProperty) || MAP.equalsIgnoreCase(typeProperty)) {
+ currentPropertyJsonTemplate = templates.get(OBJECT);
} else {
- String propertyType = (String) toscaElementProperty.getItems().get("type");
+ String propertyType = (String) toscaElementProperty.getItems().get(TYPE);
currentPropertyJsonTemplate = templates.get(propertyType.toLowerCase());
}
- //Each "special" field is analysed, and has a specific treatment
+ // Each "special" field is analysed, and has a specific treatment
for (String propertyField : toscaElementProperty.getItems().keySet()) {
switch (propertyField) {
- case "type":
+ case TYPE:
if (currentPropertyJsonTemplate.hasFields(propertyField)) {
String fieldtype = (String) toscaElementProperty.getItems().get(propertyField);
switch (fieldtype.toLowerCase()) {
- case "list":
- propertiesInJson.addProperty("type", "array");
+ case LIST:
+ propertiesInJson.addProperty(TYPE, ARRAY);
break;
- case "map":
- propertiesInJson.addProperty("type", "object");
+ case MAP:
+ propertiesInJson.addProperty(TYPE, OBJECT);
break;
case "scalar-unit.time":
case "scalar-unit.frequency":
case "scalar-unit.size":
- propertiesInJson.addProperty("type", "string");
+ propertiesInJson.addProperty(TYPE, "string");
break;
case "timestamp":
- propertiesInJson.addProperty("type", "string");
- propertiesInJson.addProperty("format", "date-time");
+ propertiesInJson.addProperty(TYPE, "string");
+ propertiesInJson.addProperty(FORMAT, "date-time");
break;
case "float":
- propertiesInJson.addProperty("type", "number");
+ propertiesInJson.addProperty(TYPE, "number");
break;
case "range":
- propertiesInJson.addProperty("type", "integer");
+ propertiesInJson.addProperty(TYPE, "integer");
if (!checkConstraintPresence(toscaElementProperty, "greater_than")
&& currentPropertyJsonTemplate.hasFields("exclusiveMinimum")) {
propertiesInJson.addProperty("exclusiveMinimum", false);
@@ -225,68 +237,58 @@ public class ToscaConverterToJsonSchema {
}
break;
default:
- propertiesInJson.addProperty("type", currentPropertyJsonTemplate.getName());
+ propertiesInJson.addProperty(TYPE, currentPropertyJsonTemplate.getName());
break;
}
}
break;
- case "metadata":
+ case METADATA:
if (metadataParser != null) {
metadataParser.processAllMetadataElement(toscaElementProperty, serviceModel).entrySet()
- .forEach((jsonEntry) -> {
- propertiesInJson.add(jsonEntry.getKey(),
- jsonEntry.getValue());
-
- });
+ .forEach(jsonEntry -> propertiesInJson.add(jsonEntry.getKey(), jsonEntry.getValue()));
}
break;
- case "constraints":
+ case CONSTRAINTS:
toscaElementProperty.addConstraintsAsJson(propertiesInJson,
- (ArrayList<Object>) toscaElementProperty.getItems().get("constraints"),
+ (ArrayList<Object>) toscaElementProperty.getItems().get(CONSTRAINTS),
currentPropertyJsonTemplate);
break;
- case "entry_schema":
- //Here, a way to check if entry is a component (datatype) or a simple string
- if (getToscaElement(this.extractSpecificFieldFromMap(toscaElementProperty, "entry_schema"))
- != null) {
- String nameComponent = this.extractSpecificFieldFromMap(toscaElementProperty, "entry_schema");
- ToscaConverterToJsonSchema child = new ToscaConverterToJsonSchema(components, templates,
- metadataParser, serviceModel);
- JsonObject propertiesContainer = new JsonObject();
+ case ENTRY_SCHEMA:
+ // Here, a way to check if entry is a component (datatype) or a simple string
+ if (getToscaElement(this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA)) != null) {
+ String nameComponent = this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA);
+ var child = new ToscaConverterToJsonSchema(components, templates, metadataParser, serviceModel);
+ var propertiesContainer = new JsonObject();
- switch ((String) toscaElementProperty.getItems().get("type")) {
- case "map": // Get it as an object
- JsonObject componentAsProperty = child.getJsonSchemaOfToscaElement(nameComponent);
- propertiesContainer.add(nameComponent, componentAsProperty);
- if (currentPropertyJsonTemplate.hasFields("properties")) {
- propertiesInJson.add("properties", propertiesContainer);
- }
- break;
- default://list : get it as an Array
- JsonObject componentAsItem = child.getJsonSchemaOfToscaElement(nameComponent);
- if (currentPropertyJsonTemplate.hasFields("properties")) {
- propertiesInJson.add("items", componentAsItem);
- propertiesInJson.addProperty("format", "tabs-top");
- }
- break;
+ if (((String) toscaElementProperty.getItems().get(TYPE)).equals(MAP)) {
+ JsonObject componentAsProperty = child.getJsonSchemaOfToscaElement(nameComponent);
+ propertiesContainer.add(nameComponent, componentAsProperty);
+ if (currentPropertyJsonTemplate.hasFields(PROPERTIES)) {
+ propertiesInJson.add(PROPERTIES, propertiesContainer);
+ }
+ } else {
+ JsonObject componentAsItem = child.getJsonSchemaOfToscaElement(nameComponent);
+ if (currentPropertyJsonTemplate.hasFields(PROPERTIES)) {
+ propertiesInJson.add("items", componentAsItem);
+ propertiesInJson.addProperty(FORMAT, "tabs-top");
+ }
}
-
- } else if (toscaElementProperty.getItems().get("type").equals("list")) {
+ } else if (toscaElementProperty.getItems().get(TYPE).equals(LIST)) {
// Native cases
- JsonObject itemContainer = new JsonObject();
+ var itemContainer = new JsonObject();
String valueInEntrySchema =
- this.extractSpecificFieldFromMap(toscaElementProperty, "entry_schema");
- itemContainer.addProperty("type", valueInEntrySchema);
+ this.extractSpecificFieldFromMap(toscaElementProperty, ENTRY_SCHEMA);
+ itemContainer.addProperty(TYPE, valueInEntrySchema);
propertiesInJson.add("items", itemContainer);
- propertiesInJson.addProperty("format", "tabs-top");
+ propertiesInJson.addProperty(FORMAT, "tabs-top");
}
// MAP Case, for now nothing
break;
default:
- //Each classical field : type, description, default..
- if (currentPropertyJsonTemplate.hasFields(propertyField) && !propertyField.equals("required")) {
+ // Each classical field : type, description, default..
+ if (currentPropertyJsonTemplate.hasFields(propertyField) && !propertyField.equals(REQUIRED)) {
toscaElementProperty.addFieldToJson(propertiesInJson, propertyField,
toscaElementProperty.getItems().get(propertyField));
}
@@ -319,32 +321,32 @@ public class ToscaConverterToJsonSchema {
* Simple method to extract quickly a type field from particular property item.
*
* @param toscaElementProperty the property
- * @param fieldName the fieldname
+ * @param fieldName the fieldname
* @return a string
*/
@SuppressWarnings("unchecked")
public String extractSpecificFieldFromMap(ToscaElementProperty toscaElementProperty, String fieldName) {
LinkedHashMap<String, String> entrySchemaFields =
(LinkedHashMap<String, String>) toscaElementProperty.getItems().get(fieldName);
- return entrySchemaFields.get("type");
+ return entrySchemaFields.get(TYPE);
}
/**
* Check if a constraint, for a specific property, is there.
*
* @param toscaElementProperty property
- * @param nameConstraint name constraint
+ * @param nameConstraint name constraint
* @return a flag boolean
*/
public boolean checkConstraintPresence(ToscaElementProperty toscaElementProperty, String nameConstraint) {
- boolean presentConstraint = false;
- if (toscaElementProperty.getItems().containsKey("constraints")) {
- ArrayList<Object> constraints = (ArrayList) toscaElementProperty.getItems().get("constraints");
+ var presentConstraint = false;
+ if (toscaElementProperty.getItems().containsKey(CONSTRAINTS)) {
+ @SuppressWarnings("unchecked")
+ ArrayList<Object> constraints = (ArrayList<Object>) toscaElementProperty.getItems().get(CONSTRAINTS);
for (Object constraint : constraints) {
- if (constraint instanceof LinkedHashMap) {
- if (((LinkedHashMap) constraint).containsKey(nameConstraint)) {
- presentConstraint = true;
- }
+ if (constraint instanceof LinkedHashMap
+ && ((LinkedHashMap<?, ?>) constraint).containsKey(nameConstraint)) {
+ presentConstraint = true;
}
}
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaElementParser.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaElementParser.java
index a3dd9c3e1..04d577f86 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaElementParser.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/ToscaElementParser.java
@@ -30,6 +30,11 @@ import org.onap.policy.clamp.clds.tosca.update.elements.ToscaElementProperty;
import org.yaml.snakeyaml.Yaml;
public class ToscaElementParser {
+ private static final String DERIVED_FROM = "derived_from";
+ private static final String DESCRIPTION = "description";
+ private static final String PROPERTIES = "properties";
+ private static final String TYPE_VERSION = "type_version";
+
/**
* Constructor.
*/
@@ -37,17 +42,19 @@ public class ToscaElementParser {
}
private static LinkedHashMap<String, Object> searchAllDataTypesAndPolicyTypes(String toscaYaml) {
+ @SuppressWarnings("unchecked")
LinkedHashMap<String, LinkedHashMap<String, Object>> file =
(LinkedHashMap<String, LinkedHashMap<String, Object>>) new Yaml().load(toscaYaml);
LinkedHashMap<String, Object> allDataTypesFound = file.get("data_types");
LinkedHashMap<String, Object> allPolicyTypesFound = file.get("policy_types");
- LinkedHashMap<String, Object> allItemsFound = new LinkedHashMap<>();
+ LinkedHashMap<String, Object> allItemsFound;
// Put the policies and datatypes in the same collection
allItemsFound = (allDataTypesFound == null) ? (new LinkedHashMap<>()) : allDataTypesFound;
allItemsFound.putAll(allPolicyTypesFound == null ? new LinkedHashMap<>() : allPolicyTypesFound);
return allItemsFound;
}
+ @SuppressWarnings("unchecked")
private static LinkedHashMap<String, Object> searchAllNativeToscaDataTypes(String toscaNativeYaml) {
return ((LinkedHashMap<String, LinkedHashMap<String, Object>>) new Yaml().load(toscaNativeYaml))
.get("data_types");
@@ -57,12 +64,11 @@ public class ToscaElementParser {
* Yaml Parse gets raw policies and datatypes, in different sections : necessary to extract
* all entities and put them at the same level.
*
- * @param toscaYaml the tosca model content
+ * @param toscaYaml the tosca model content
* @param nativeToscaYaml the tosca native datatype content
* @return a map of Tosca Element containing all tosca elements found (policy types and datatypes)
*/
- public static LinkedHashMap<String, ToscaElement> searchAllToscaElements(String toscaYaml,
- String nativeToscaYaml) {
+ public static LinkedHashMap<String, ToscaElement> searchAllToscaElements(String toscaYaml, String nativeToscaYaml) {
LinkedHashMap<String, Object> allItemsFound = searchAllDataTypesAndPolicyTypes(toscaYaml);
allItemsFound.putAll(searchAllNativeToscaDataTypes(nativeToscaYaml));
return parseAllItemsFound(allItemsFound);
@@ -73,25 +79,25 @@ public class ToscaElementParser {
*
* @param allMaps maps
*/
+ @SuppressWarnings("unchecked")
private static LinkedHashMap<String, ToscaElement> parseAllItemsFound(LinkedHashMap<String, Object> allMaps) {
- LinkedHashMap<String, ToscaElement> allItemsFound = new LinkedHashMap<String, ToscaElement>();
- //Component creations, from the file maps
+ LinkedHashMap<String, ToscaElement> allItemsFound = new LinkedHashMap<>();
+ // Component creations, from the file maps
for (Entry<String, Object> itemToParse : allMaps.entrySet()) {
LinkedHashMap<String, Object> componentBody = (LinkedHashMap<String, Object>) itemToParse.getValue();
- ToscaElement toscaElement =
- new ToscaElement(itemToParse.getKey(), (String) componentBody.get("derived_from"),
- (String) componentBody.get("description"));
- //If policy, version and type_version :
- if (componentBody.get("type_version") != null) {
- toscaElement.setVersion((String) componentBody.get("type_version"));
- toscaElement.setTypeVersion((String) componentBody.get("type_version"));
+ var toscaElement = new ToscaElement(itemToParse.getKey(), (String) componentBody.get(DERIVED_FROM),
+ (String) componentBody.get(DESCRIPTION));
+ // If policy, version and type_version :
+ if (componentBody.get(TYPE_VERSION) != null) {
+ toscaElement.setVersion((String) componentBody.get(TYPE_VERSION));
+ toscaElement.setTypeVersion((String) componentBody.get(TYPE_VERSION));
}
- //Properties creation, from the map
- if (componentBody.get("properties") != null) {
- LinkedHashMap<String, Object> properties =
- (LinkedHashMap<String, Object>) componentBody.get("properties");
- for (Entry<String, Object> itemToProperty : properties.entrySet()) {
- ToscaElementProperty toscaElementProperty = new ToscaElementProperty(itemToProperty.getKey(),
+ // Properties creation, from the map
+ if (componentBody.get(PROPERTIES) != null) {
+ LinkedHashMap<String, Object> foundProperties =
+ (LinkedHashMap<String, Object>) componentBody.get(PROPERTIES);
+ for (Entry<String, Object> itemToProperty : foundProperties.entrySet()) {
+ var toscaElementProperty = new ToscaElementProperty(itemToProperty.getKey(),
(LinkedHashMap<String, Object>) itemToProperty.getValue());
toscaElement.addProperties(toscaElementProperty);
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java
index 4e55263fb..2a886df3c 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/parser/metadata/ToscaMetadataParserWithDictionarySupport.java
@@ -63,10 +63,11 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa
}
}
+ @SuppressWarnings("unchecked")
private static JsonObject parseMetadataPossibleValues(LinkedHashMap<String, Object> childNodeMap,
DictionaryService dictionaryService, Service serviceModel,
ToscaMetadataExecutor toscaMetadataExecutor) {
- JsonObject childObject = new JsonObject();
+ var childObject = new JsonObject();
if (childNodeMap.containsKey(ToscaSchemaConstants.METADATA)
&& childNodeMap.get(ToscaSchemaConstants.METADATA) != null) {
((LinkedHashMap<String, Object>) childNodeMap.get(ToscaSchemaConstants.METADATA)).forEach((key,
@@ -108,14 +109,14 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa
if (dictionaryKeyArray.length == 2) {
dictionaryElements = new ArrayList<>(dictionaryService.getDictionary(dictionaryKeyArray[0])
.getDictionaryElements());
- JsonArray subDictionaryNames = new JsonArray();
+ var subDictionaryNames = new JsonArray();
new ArrayList<DictionaryElement>(dictionaryService.getDictionary(dictionaryKeyArray[1])
.getDictionaryElements()).forEach(elem -> subDictionaryNames.add(elem.getShortName()));
- JsonArray jsonArray = new JsonArray();
+ var jsonArray = new JsonArray();
Optional.of(dictionaryElements).get().forEach(c -> {
- JsonObject jsonObject = new JsonObject();
+ var jsonObject = new JsonObject();
jsonObject.addProperty(JsonEditorSchemaConstants.TYPE, getJsonType(c.getType()));
if (c.getType() != null
&& c.getType().equalsIgnoreCase(ToscaSchemaConstants.TYPE_STRING)) {
@@ -128,7 +129,7 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa
jsonArray.add(jsonObject);
});
- JsonObject filterObject = new JsonObject();
+ var filterObject = new JsonObject();
filterObject.add(JsonEditorSchemaConstants.FILTERS, jsonArray);
childObject.addProperty(JsonEditorSchemaConstants.TYPE,
@@ -149,8 +150,8 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa
*/
private static void processSimpleDictionaryElements(String[] dictionaryKeyArray, JsonObject childObject,
DictionaryService dictionaryService) {
- JsonArray dictionaryNames = new JsonArray();
- JsonArray dictionaryFullNames = new JsonArray();
+ var dictionaryNames = new JsonArray();
+ var dictionaryFullNames = new JsonArray();
dictionaryService.getDictionary(dictionaryKeyArray[0]).getDictionaryElements().forEach(c -> {
// Json type will be translated before Policy creation
if (c.getType() != null && !c.getType().equalsIgnoreCase("json")) {
@@ -167,7 +168,7 @@ public class ToscaMetadataParserWithDictionarySupport implements ToscaMetadataPa
}
// Add Enum titles for generated translated values during JSON instance
// generation
- JsonObject enumTitles = new JsonObject();
+ var enumTitles = new JsonObject();
enumTitles.add(JsonEditorSchemaConstants.ENUM_TITLES, dictionaryNames);
if (childObject.get(JsonEditorSchemaConstants.OPTIONS) != null) {
childObject.get(JsonEditorSchemaConstants.OPTIONS).getAsJsonArray().add(enumTitles);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java
index 1813d0786..af7f8cc54 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateManager.java
@@ -44,9 +44,9 @@ public class JsonTemplateManager {
/**
* Constructor.
*
- * @param toscaYamlContent Policy Tosca Yaml content as string
+ * @param toscaYamlContent Policy Tosca Yaml content as string
* @param nativeToscaDatatypes The tosca yaml with tosca native datatypes
- * @param jsonSchemaTemplates template properties as string
+ * @param jsonSchemaTemplates template properties as string
*/
public JsonTemplateManager(String toscaYamlContent, String nativeToscaDatatypes, String jsonSchemaTemplates) {
if (toscaYamlContent != null && !toscaYamlContent.isEmpty()) {
@@ -57,7 +57,7 @@ public class JsonTemplateManager {
}
}
- //GETTERS & SETTERS
+ // GETTERS & SETTERS
public LinkedHashMap<String, ToscaElement> getToscaElements() {
return toscaElements;
}
@@ -77,12 +77,12 @@ public class JsonTemplateManager {
/**
* Add a template.
*
- * @param name name
+ * @param name name
* @param jsonTemplateFields fields
*/
public void addTemplate(String name, List<JsonTemplateField> jsonTemplateFields) {
- JsonTemplate jsonTemplate = new JsonTemplate(name, jsonTemplateFields);
- //If it is true, the operation does not have any interest :
+ var jsonTemplate = new JsonTemplate(name, jsonTemplateFields);
+ // If it is true, the operation does not have any interest :
// replace OR put two different object with the same body
if (!jsonSchemaTemplates.containsKey(jsonTemplate.getName()) || !this.hasTemplate(jsonTemplate)) {
this.jsonSchemaTemplates.put(jsonTemplate.getName(), jsonTemplate);
@@ -101,11 +101,11 @@ public class JsonTemplateManager {
/**
* Update Template : adding with true flag, removing with false.
*
- * @param nameTemplate name template
+ * @param nameTemplate name template
* @param jsonTemplateField field name
- * @param operation operation
+ * @param operation operation
*/
- public void updateTemplate(String nameTemplate, JsonTemplateField jsonTemplateField, Boolean operation) {
+ public void updateTemplate(String nameTemplate, JsonTemplateField jsonTemplateField, boolean operation) {
// Operation = true && field is not present => add Field
if (operation
&& !this.jsonSchemaTemplates.get(nameTemplate).getJsonTemplateFields().contains(jsonTemplateField)) {
@@ -124,10 +124,10 @@ public class JsonTemplateManager {
* @return a boolean
*/
public boolean hasTemplate(JsonTemplate jsonTemplate) {
- boolean duplicateTemplate = false;
+ var duplicateTemplate = false;
Collection<String> templatesName = jsonSchemaTemplates.keySet();
if (templatesName.contains(jsonTemplate.getName())) {
- JsonTemplate existingJsonTemplate = jsonSchemaTemplates.get(jsonTemplate.getName());
+ var existingJsonTemplate = jsonSchemaTemplates.get(jsonTemplate.getName());
duplicateTemplate = existingJsonTemplate.checkFields(jsonTemplate);
}
return duplicateTemplate;
@@ -136,17 +136,15 @@ public class JsonTemplateManager {
/**
* For a given policy type, get a corresponding JsonObject from the tosca model.
*
- * @param policyType The policy type in the tosca
+ * @param policyType The policy type in the tosca
* @param toscaMetadataParser The MetadataParser class that must be used if metadata section are encountered,
- * if null they will be skipped
+ * if null they will be skipped
* @return an json object defining the equivalent json schema from the tosca for a given policy type
*/
public JsonObject getJsonSchemaForPolicyType(String policyType, ToscaMetadataParser toscaMetadataParser,
- Service serviceModel)
- throws UnknownComponentException {
- ToscaConverterToJsonSchema
- toscaConverterToJsonSchema = new ToscaConverterToJsonSchema(toscaElements, jsonSchemaTemplates,
- toscaMetadataParser, serviceModel);
+ Service serviceModel) throws UnknownComponentException {
+ var toscaConverterToJsonSchema =
+ new ToscaConverterToJsonSchema(toscaElements, jsonSchemaTemplates, toscaMetadataParser, serviceModel);
if (toscaConverterToJsonSchema.getToscaElement(policyType) == null) {
throw new UnknownComponentException(policyType);
}
@@ -166,7 +164,7 @@ public class JsonTemplateManager {
JsonObject templates = JsonUtils.GSON.fromJson(jsonTemplates, JsonObject.class);
for (Map.Entry<String, JsonElement> templateAsJson : templates.entrySet()) {
- JsonTemplate jsonTemplate = new JsonTemplate(templateAsJson.getKey());
+ var jsonTemplate = new JsonTemplate(templateAsJson.getKey());
JsonObject templateBody = (JsonObject) templateAsJson.getValue();
for (Map.Entry<String, JsonElement> field : templateBody.entrySet()) {
String fieldName = field.getKey();
@@ -174,12 +172,11 @@ public class JsonTemplateManager {
Object fieldValue = bodyFieldAsJson.get("defaultValue").getAsString();
Boolean fieldVisible = bodyFieldAsJson.get("visible").getAsBoolean();
Boolean fieldStatic = bodyFieldAsJson.get("static").getAsBoolean();
- JsonTemplateField
- bodyJsonTemplateField = new JsonTemplateField(fieldName, fieldValue, fieldVisible, fieldStatic);
+ var bodyJsonTemplateField = new JsonTemplateField(fieldName, fieldValue, fieldVisible, fieldStatic);
jsonTemplate.getJsonTemplateFields().add(bodyJsonTemplateField);
}
generatedTemplates.put(jsonTemplate.getName(), jsonTemplate);
}
return generatedTemplates;
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/util/ResourceFileUtils.java b/runtime/src/main/java/org/onap/policy/clamp/clds/util/ResourceFileUtils.java
index d6184c656..ab33984da 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/util/ResourceFileUtils.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/util/ResourceFileUtils.java
@@ -81,9 +81,9 @@ public final class ResourceFileUtils {
}
private static String streamToString(InputStream inputStream) {
- try (Scanner scanner = new Scanner(inputStream)) {
- Scanner delimitedScanner = scanner.useDelimiter("\\A");
+ try (var scanner = new Scanner(inputStream)) {
+ var delimitedScanner = scanner.useDelimiter("\\A");
return delimitedScanner.hasNext() ? delimitedScanner.next() : "";
}
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java b/runtime/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java
index 6479cf767..5cb5e143f 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/configuration/ClampGsonDataFormat.java
@@ -96,7 +96,7 @@ public class ClampGsonDataFormat extends ServiceSupport implements DataFormat, D
@Override
public void marshal(final Exchange exchange, final Object graph, final OutputStream stream) throws Exception {
- try (final OutputStreamWriter osw = new OutputStreamWriter(stream, StandardCharsets.UTF_8);
+ try (final var osw = new OutputStreamWriter(stream, StandardCharsets.UTF_8);
final BufferedWriter writer = IOHelper.buffered(osw)) {
gson.toJson(graph, writer);
}
@@ -112,7 +112,7 @@ public class ClampGsonDataFormat extends ServiceSupport implements DataFormat, D
@Override
public Object unmarshal(final Exchange exchange, final InputStream stream) throws Exception {
- try (final InputStreamReader isr = new InputStreamReader(stream, StandardCharsets.UTF_8);
+ try (final var isr = new InputStreamReader(stream, StandardCharsets.UTF_8);
final BufferedReader reader = IOHelper.buffered(isr)) {
if (unmarshalType.equals(String.class)) {
return IOUtils.toString(reader);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/dao/model/jsontype/JsonTypeDescriptor.java b/runtime/src/main/java/org/onap/policy/clamp/dao/model/jsontype/JsonTypeDescriptor.java
index ed8464b14..ddc39599c 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/dao/model/jsontype/JsonTypeDescriptor.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/dao/model/jsontype/JsonTypeDescriptor.java
@@ -73,6 +73,7 @@ public class JsonTypeDescriptor extends AbstractTypeDescriptor<JsonObject> {
return JsonUtils.GSON_JPA_MODEL.fromJson(string, JsonObject.class);
}
+ @SuppressWarnings("unchecked")
@Override
public <X> X unwrap(JsonObject value, Class<X> type, WrapperOptions options) {
if (value == null) {
@@ -95,7 +96,7 @@ public class JsonTypeDescriptor extends AbstractTypeDescriptor<JsonObject> {
return null;
}
- if (String.class.isInstance(value)) {
+ if (value instanceof String) {
return JsonUtils.GSON_JPA_MODEL.fromJson((String) value, JsonObject.class);
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java b/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java
index f46f4227b..2da1c0553 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/CsarInstaller.java
@@ -45,7 +45,6 @@ import org.onap.policy.clamp.loop.service.Service;
import org.onap.policy.clamp.loop.template.LoopElementModel;
import org.onap.policy.clamp.loop.template.LoopTemplate;
import org.onap.policy.clamp.loop.template.LoopTemplatesRepository;
-import org.onap.policy.clamp.loop.template.PolicyModel;
import org.onap.policy.clamp.loop.template.PolicyModelsRepository;
import org.onap.policy.clamp.policy.PolicyEngineServices;
import org.springframework.beans.factory.annotation.Autowired;
@@ -95,11 +94,11 @@ public class CsarInstaller {
boolean alreadyInstalled = csarServiceInstaller.isServiceAlreadyDeployed(csar);
for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
- alreadyInstalled = alreadyInstalled
- && loopTemplatesRepository.existsById(LoopTemplate.generateLoopTemplateName(
- csar.getSdcNotification().getServiceName(), csar.getSdcNotification().getServiceVersion(),
- blueprint.getValue().getResourceAttached().getResourceInstanceName(),
- blueprint.getValue().getBlueprintArtifactName()));
+ alreadyInstalled =
+ alreadyInstalled && loopTemplatesRepository.existsById(LoopTemplate.generateLoopTemplateName(
+ csar.getSdcNotification().getServiceName(), csar.getSdcNotification().getServiceVersion(),
+ blueprint.getValue().getResourceAttached().getResourceInstanceName(),
+ blueprint.getValue().getBlueprintArtifactName()));
}
return alreadyInstalled;
}
@@ -109,14 +108,14 @@ public class CsarInstaller {
*
* @param csar The Csar Handler
* @throws SdcArtifactInstallerException The SdcArtifactInstallerException
- * @throws InterruptedException The InterruptedException
- * @throws BlueprintParserException In case of issues with the blueprint
- * parsing
+ * @throws InterruptedException The InterruptedException
+ * @throws BlueprintParserException In case of issues with the blueprint
+ * parsing
*/
public void installTheCsar(CsarHandler csar)
throws SdcArtifactInstallerException, InterruptedException, BlueprintParserException {
logger.info("Installing the CSAR " + csar.getFilePath());
- Service associatedService = csarServiceInstaller.installTheService(csar);
+ var associatedService = csarServiceInstaller.installTheService(csar);
cdsDataInstaller.installCdsServiceProperties(csar, associatedService);
installTheLoopTemplates(csar, associatedService);
@@ -126,12 +125,12 @@ public class CsarInstaller {
/**
* Install the loop templates from the csar.
*
- * @param csar The Csar Handler
+ * @param csar The Csar Handler
* @param service The service object that is related to the loop
* @throws SdcArtifactInstallerException The SdcArtifactInstallerException
- * @throws InterruptedException The InterruptedException
- * @throws BlueprintParserException In case of issues with the blueprint
- * parsing
+ * @throws InterruptedException The InterruptedException
+ * @throws BlueprintParserException In case of issues with the blueprint
+ * parsing
*/
public void installTheLoopTemplates(CsarHandler csar, Service service)
throws SdcArtifactInstallerException, InterruptedException, BlueprintParserException {
@@ -150,10 +149,9 @@ public class CsarInstaller {
}
private LoopTemplate createLoopTemplateFromBlueprint(CsarHandler csar, BlueprintArtifact blueprintArtifact,
- Service service)
- throws IOException, ParseException, InterruptedException, BlueprintParserException,
+ Service service) throws IOException, ParseException, InterruptedException, BlueprintParserException,
SdcArtifactInstallerException {
- LoopTemplate newLoopTemplate = new LoopTemplate();
+ var newLoopTemplate = new LoopTemplate();
newLoopTemplate.setBlueprint(blueprintArtifact.getDcaeBlueprint());
newLoopTemplate.setName(LoopTemplate.generateLoopTemplateName(csar.getSdcNotification().getServiceName(),
csar.getSdcNotification().getServiceVersion(),
@@ -173,22 +171,19 @@ public class CsarInstaller {
}
private HashSet<LoopElementModel> createMicroServiceModels(BlueprintArtifact blueprintArtifact,
- List<BlueprintMicroService> microServicesChain)
- throws SdcArtifactInstallerException {
+ List<BlueprintMicroService> microServicesChain) throws SdcArtifactInstallerException {
HashSet<LoopElementModel> newSet = new HashSet<>();
for (BlueprintMicroService microService : microServicesChain) {
- LoopElementModel loopElementModel =
- new LoopElementModel(microService.getModelType(), LoopElementModel.MICRO_SERVICE_TYPE,
- null);
+ var loopElementModel =
+ new LoopElementModel(microService.getModelType(), LoopElementModel.MICRO_SERVICE_TYPE, null);
newSet.add(loopElementModel);
- PolicyModel newPolicyModel = policyEngineServices.createPolicyModelFromPolicyEngine(microService);
+ var newPolicyModel = policyEngineServices.createPolicyModelFromPolicyEngine(microService);
if (newPolicyModel != null) {
loopElementModel.addPolicyModel(newPolicyModel);
} else {
- throw new SdcArtifactInstallerException(
- "Unable to find the policy specified in the blueprint " + blueprintArtifact
- .getBlueprintArtifactName() + ") on the Policy Engine:"
- + microService.getModelType() + "/" + microService.getModelVersion());
+ throw new SdcArtifactInstallerException("Unable to find the policy specified in the blueprint "
+ + blueprintArtifact.getBlueprintArtifactName() + ") on the Policy Engine:"
+ + microService.getModelType() + "/" + microService.getModelVersion());
}
}
return newSet;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java b/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java
index 6a935d011..e6c05ddd9 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/DcaeComponent.java
@@ -43,6 +43,10 @@ import org.onap.policy.clamp.loop.Loop;
import org.onap.policy.clamp.policy.microservice.MicroServicePolicy;
public class DcaeComponent extends ExternalComponent {
+ private static final String INSTALL = "install";
+ private static final String PROCESSING = "processing";
+ private static final String SUCCEEDED = "succeeded";
+ private static final String UNINSTALL = "uninstall";
@Transient
private static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeComponent.class);
@@ -136,12 +140,12 @@ public class DcaeComponent extends ExternalComponent {
*/
public static String getDeployPayload(Loop loop) {
JsonObject globalProp = loop.getGlobalPropertiesJson();
- JsonObject deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(
+ var deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(
UNIQUE_BLUEPRINT_PARAMETERS);
String serviceTypeId = loop.getLoopTemplate().getDcaeBlueprintId();
- JsonObject rootObject = new JsonObject();
+ var rootObject = new JsonObject();
rootObject.addProperty(DCAE_SERVICETYPE_ID, serviceTypeId);
if (deploymentProp != null) {
rootObject.add(DCAE_INPUTS, deploymentProp);
@@ -159,12 +163,12 @@ public class DcaeComponent extends ExternalComponent {
*/
public static String getDeployPayload(Loop loop, MicroServicePolicy microServicePolicy) {
JsonObject globalProp = loop.getGlobalPropertiesJson();
- JsonObject deploymentProp =
+ var deploymentProp =
globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(microServicePolicy.getName());
String serviceTypeId = microServicePolicy.getDcaeBlueprintId();
- JsonObject rootObject = new JsonObject();
+ var rootObject = new JsonObject();
rootObject.addProperty(DCAE_SERVICETYPE_ID, serviceTypeId);
if (deploymentProp != null) {
rootObject.add(DCAE_INPUTS, deploymentProp);
@@ -180,7 +184,7 @@ public class DcaeComponent extends ExternalComponent {
* @return The payload in string (json)
*/
public static String getUndeployPayload(Loop loop) {
- JsonObject rootObject = new JsonObject();
+ var rootObject = new JsonObject();
rootObject.addProperty(DCAE_SERVICETYPE_ID, loop.getLoopTemplate().getDcaeBlueprintId());
logger.info("DCAE Undeploy payload for unique blueprint: " + rootObject.toString());
return rootObject.toString();
@@ -193,7 +197,7 @@ public class DcaeComponent extends ExternalComponent {
* @return The payload in string (json)
*/
public static String getUndeployPayload(MicroServicePolicy policy) {
- JsonObject rootObject = new JsonObject();
+ var rootObject = new JsonObject();
rootObject.addProperty(DCAE_SERVICETYPE_ID, policy.getDcaeBlueprintId());
logger.info("DCAE Undeploy payload for multiple blueprints: " + rootObject.toString());
return rootObject.toString();
@@ -208,26 +212,26 @@ public class DcaeComponent extends ExternalComponent {
if (dcaeResponse == null) {
setState(BLUEPRINT_DEPLOYED);
} else {
- if (dcaeResponse.getOperationType().equals("install") && dcaeResponse.getStatus().equals("succeeded")) {
+ if (dcaeResponse.getOperationType().equals(INSTALL) && dcaeResponse.getStatus().equals(SUCCEEDED)) {
setState(MICROSERVICE_INSTALLED_SUCCESSFULLY);
} else {
- if (dcaeResponse.getOperationType().equals("install") && dcaeResponse.getStatus()
- .equals("processing")) {
+ if (dcaeResponse.getOperationType().equals(INSTALL) && dcaeResponse.getStatus()
+ .equals(PROCESSING)) {
setState(PROCESSING_MICROSERVICE_INSTALLATION);
} else {
- if (dcaeResponse.getOperationType().equals("install") && dcaeResponse.getStatus()
+ if (dcaeResponse.getOperationType().equals(INSTALL) && dcaeResponse.getStatus()
.equals("failed")) {
setState(MICROSERVICE_INSTALLATION_FAILED);
} else {
- if (dcaeResponse.getOperationType().equals("uninstall")
- && dcaeResponse.getStatus().equals("succeeded")) {
+ if (dcaeResponse.getOperationType().equals(UNINSTALL)
+ && dcaeResponse.getStatus().equals(SUCCEEDED)) {
setState(MICROSERVICE_UNINSTALLED_SUCCESSFULLY);
} else {
- if (dcaeResponse.getOperationType().equals("uninstall")
- && dcaeResponse.getStatus().equals("processing")) {
+ if (dcaeResponse.getOperationType().equals(UNINSTALL)
+ && dcaeResponse.getStatus().equals(PROCESSING)) {
setState(PROCESSING_MICROSERVICE_UNINSTALLATION);
} else {
- if (dcaeResponse.getOperationType().equals("uninstall") && dcaeResponse.getStatus()
+ if (dcaeResponse.getOperationType().equals(UNINSTALL) && dcaeResponse.getStatus()
.equals("failed")) {
setState(MICROSERVICE_UNINSTALLATION_FAILED);
} else {
@@ -251,10 +255,10 @@ public class DcaeComponent extends ExternalComponent {
*/
public static List<DcaeInventoryResponse> convertToDcaeInventoryResponse(String responseBody)
throws ParseException {
- JSONParser parser = new JSONParser();
+ var parser = new JSONParser();
JSONObject jsonObj = (JSONObject) parser.parse(responseBody);
JSONArray itemsArray = (JSONArray) jsonObj.get("items");
- Iterator it = itemsArray.iterator();
+ Iterator<?> it = itemsArray.iterator();
List<DcaeInventoryResponse> inventoryResponseList = new LinkedList<>();
while (it.hasNext()) {
JSONObject item = (JSONObject) it.next();
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/deploy/DcaeDeployParameters.java b/runtime/src/main/java/org/onap/policy/clamp/loop/deploy/DcaeDeployParameters.java
index 1a1414611..d4b80e509 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/deploy/DcaeDeployParameters.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/deploy/DcaeDeployParameters.java
@@ -27,6 +27,8 @@ import com.google.gson.JsonObject;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.onap.policy.clamp.clds.util.JsonUtils;
import org.onap.policy.clamp.loop.Loop;
import org.onap.policy.clamp.loop.components.external.DcaeComponent;
@@ -36,8 +38,8 @@ import org.yaml.snakeyaml.Yaml;
/**
* To decode the bluprint input parameters.
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class DcaeDeployParameters {
-
private static LinkedHashMap<String, JsonObject> init(Loop loop) {
LinkedHashMap<String, JsonObject> deploymentParamMap = new LinkedHashMap<>();
Set<MicroServicePolicy> microServiceList = loop.getMicroServicePolicies();
@@ -54,9 +56,10 @@ public class DcaeDeployParameters {
microService.getName());
}
+ @SuppressWarnings("unchecked")
private static JsonObject generateDcaeDeployParameter(String blueprint, String policyId) {
- JsonObject deployJsonBody = new JsonObject();
- Yaml yaml = new Yaml();
+ var deployJsonBody = new JsonObject();
+ var yaml = new Yaml();
Map<String, Object> inputsNodes = ((Map<String, Object>) ((Map<String, Object>) yaml
.load(blueprint)).get("inputs"));
inputsNodes.entrySet().stream().filter(e -> !e.getKey().contains("policy_id")).forEach(elem -> {
@@ -91,8 +94,8 @@ public class DcaeDeployParameters {
* @return The deploymentParameters in Json
*/
public static JsonObject getDcaeDeploymentParametersInJson(Loop loop) {
- JsonObject globalProperties = new JsonObject();
- JsonObject deployParamJson = new JsonObject();
+ var globalProperties = new JsonObject();
+ var deployParamJson = new JsonObject();
if (loop.getLoopTemplate().getUniqueBlueprint()) {
// Normally the unique blueprint could contain multiple microservices but then we can't guess
// the policy id params that will be used, so here we expect only one by default.
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java b/runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java
index f8bdab6c2..11587ce57 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java
@@ -27,34 +27,26 @@ package org.onap.policy.clamp.policy;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
import java.io.UnsupportedEncodingException;
-import java.util.Map;
import javax.persistence.Column;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
-import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
-import org.hibernate.annotations.TypeDefs;
-import org.json.JSONObject;
import org.onap.policy.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport;
import org.onap.policy.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.policy.clamp.loop.common.AuditEntity;
import org.onap.policy.clamp.loop.service.Service;
import org.onap.policy.clamp.loop.template.LoopElementModel;
import org.onap.policy.clamp.loop.template.PolicyModel;
-import org.yaml.snakeyaml.Yaml;
@MappedSuperclass
-@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)})
+@TypeDef(name = "json", typeClass = StringJsonUserType.class)
public abstract class Policy extends AuditEntity {
@Transient
@@ -89,8 +81,8 @@ public abstract class Policy extends AuditEntity {
@Expose
@ManyToOne(fetch = FetchType.EAGER)
- @JoinColumns({@JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type"),
- @JoinColumn(name = "policy_model_version", referencedColumnName = "version")})
+ @JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type")
+ @JoinColumn(name = "policy_model_version", referencedColumnName = "version")
private PolicyModel policyModel;
/**
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java b/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java
index 4142841e2..d56480053 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.util.LinkedHashMap;
import org.apache.camel.CamelContext;
import org.apache.camel.Exchange;
-import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.ExchangeBuilder;
import org.onap.policy.clamp.clds.config.ClampProperties;
import org.onap.policy.clamp.clds.sdc.controller.installer.BlueprintMicroService;
@@ -95,7 +94,7 @@ public class PolicyEngineServices {
* @return A PolicyModel created from policyEngine data or null if nothing is found on policyEngine
*/
public PolicyModel createPolicyModelFromPolicyEngine(String policyType, String policyVersion) {
- PolicyModel policyModelFound = policyModelsService.getPolicyModel(policyType, policyVersion);
+ var policyModelFound = policyModelsService.getPolicyModel(policyType, policyVersion);
if (policyModelFound == null) {
String policyTosca = this.downloadOnePolicyToscaModel(policyType, policyVersion);
if (policyTosca != null && !policyTosca.isEmpty()) {
@@ -127,6 +126,7 @@ public class PolicyEngineServices {
* This method synchronize the clamp database and the policy engine.
* So it creates the required PolicyModel.
*/
+ @SuppressWarnings("unchecked")
public void synchronizeAllPolicies() {
LinkedHashMap<String, Object> loadedYaml;
loadedYaml = new Yaml().load(downloadAllPolicyModels());
@@ -162,12 +162,12 @@ public class PolicyEngineServices {
*/
public String downloadOnePolicyToscaModel(String policyType, String policyVersion) {
logger.info("Downloading the policy tosca model " + policyType + "/" + policyVersion);
- DumperOptions options = new DumperOptions();
+ var options = new DumperOptions();
options.setDefaultScalarStyle(DumperOptions.ScalarStyle.PLAIN);
options.setIndent(4);
options.setPrettyFlow(true);
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- Yaml yamlParser = new Yaml(options);
+ var yamlParser = new Yaml(options);
String responseBody = callCamelRoute(
ExchangeBuilder.anExchange(camelContext).withProperty("policyModelType", policyType)
.withProperty("policyModelVersion", policyVersion).withProperty(RAISE_EXCEPTION_FLAG, false)
@@ -200,9 +200,9 @@ public class PolicyEngineServices {
}
private String callCamelRoute(Exchange exchange, String camelFlow, String logMsg) {
- for (int i = 0; i < retryLimit; i++) {
- try (ProducerTemplate producerTemplate = camelContext.createProducerTemplate()) {
- Exchange exchangeResponse = producerTemplate.send(camelFlow, exchange);
+ for (var i = 0; i < retryLimit; i++) {
+ try (var producerTemplate = camelContext.createProducerTemplate()) {
+ var exchangeResponse = producerTemplate.send(camelFlow, exchange);
if (HttpStatus.valueOf((Integer) exchangeResponse.getIn().getHeader(Exchange.HTTP_RESPONSE_CODE))
.is2xxSuccessful()) {
return (String) exchangeResponse.getIn().getBody();
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java
index 6098d0f63..38425fe93 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupsAnalyzer.java
@@ -26,7 +26,6 @@ package org.onap.policy.clamp.policy.pdpgroup;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@@ -82,7 +81,7 @@ public class PdpGroupsAnalyzer {
// Copy the subgroup but empty the policies & types
pdpGroupsDeploymentPerToscaIdentifier.computeIfAbsent(toscaId, toscaKey -> new ConcurrentHashMap<>())
.computeIfAbsent(pdpGroupSource.getName(), pdpGroupName -> {
- PdpGroup pdpGroupCopy = new PdpGroup(pdpGroupSource);
+ var pdpGroupCopy = new PdpGroup(pdpGroupSource);
pdpGroupCopy.setPdpSubgroups(new ArrayList<>());
return pdpGroupCopy;
}).getPdpSubgroups().add(new PdpSubGroup(pdpSubGroupSource));
@@ -107,8 +106,8 @@ public class PdpGroupsAnalyzer {
Map<String, PdpGroup> mapOfGroups =
this.pdpGroupsDeploymentPerPolicy.get(new ToscaConceptIdentifier(policyName, version));
if (mapOfGroups != null) {
- JsonObject policyPdpGroups = new JsonObject();
- JsonArray pdpGroupsArray = new JsonArray();
+ var policyPdpGroups = new JsonObject();
+ var pdpGroupsArray = new JsonArray();
policyPdpGroups.add(ASSIGNED_PDP_GROUPS_INFO, pdpGroupsArray);
pdpGroupsArray.add(JsonUtils.GSON
.toJsonTree(mapOfGroups));
@@ -133,8 +132,8 @@ public class PdpGroupsAnalyzer {
if (PdpState.TERMINATED.equals(pdpGroup.getPdpGroupState())) {
return null;
}
- JsonObject supportedPdpGroup = new JsonObject();
- JsonArray supportedSubgroups = new JsonArray();
+ var supportedPdpGroup = new JsonObject();
+ var supportedSubgroups = new JsonArray();
supportedPdpGroup.add(pdpGroup.getName(), supportedSubgroups);
pdpGroup.getPdpSubgroups().stream().forEach(pdpSubGroup -> {
if (pdpSubGroup.getSupportedPolicyTypes().stream().anyMatch(policyTypeIdentifier ->
@@ -155,8 +154,8 @@ public class PdpGroupsAnalyzer {
* @return It returns a JsonObject containing each pdpGroup and subgroups associated
*/
public static JsonObject getSupportedPdpGroupsForModelType(PdpGroups pdpGroups, String policyType, String version) {
- JsonObject supportedPdpGroups = new JsonObject();
- JsonArray pdpGroupsArray = new JsonArray();
+ var supportedPdpGroups = new JsonObject();
+ var pdpGroupsArray = new JsonArray();
supportedPdpGroups.add(SUPPORTED_PDP_GROUPS_INFO, pdpGroupsArray);
pdpGroups.getGroups().stream().map(pdpGroup -> PdpGroupsAnalyzer.getSupportedPdpSubgroupsForModelType(pdpGroup,
@@ -177,4 +176,4 @@ public class PdpGroupsAnalyzer {
.setPolicyPdpGroup(getSupportedPdpGroupsForModelType(pdpGroups, policyModel.getPolicyModelType(),
policyModel.getVersion())));
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/tosca/Dictionary.java b/runtime/src/main/java/org/onap/policy/clamp/tosca/Dictionary.java
index 4b01d6902..4f748d5dd 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/tosca/Dictionary.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/tosca/Dictionary.java
@@ -188,8 +188,8 @@ public class Dictionary extends AuditEntity implements Serializable {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java
index 557a2e96c..45d4d64b1 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/AuthorizationControllerItCase.java
@@ -70,6 +70,8 @@ public class AuthorizationControllerItCase {
public static void setupBefore() {
sc.setAuthentication(new Authentication() {
+ private static final long serialVersionUID = -6282526745791629050L;
+
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return Arrays.asList(new SimpleGrantedAuthority(
@@ -121,7 +123,7 @@ public class AuthorizationControllerItCase {
@Test
public void testIsUserPermitted() {
- assertEquals(AuthorizationController.getPrincipalName(sc), "admin");
+ assertEquals("admin", AuthorizationController.getPrincipalName(sc));
assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl", "dev", "read")));
assertTrue(auth.isUserPermitted(new SecureServicePermission("permission-type-cl-manage", "dev", "DEPLOY")));
assertTrue(auth.isUserPermitted(
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java b/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java
index 017881ba7..ad7efed36 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/it/RobotItCase.java
@@ -67,11 +67,13 @@ public class RobotItCase {
public void robotTests() throws Exception {
File robotFolder = new File(getClass().getClassLoader().getResource("robotframework").getFile());
Volume testsVolume = new Volume("/opt/robotframework/tests");
- DockerClient client = DockerClientBuilder
- .getInstance()
- .withDockerCmdExecFactory(new NettyDockerCmdExecFactory())
- .build();
-
+ // @formatter:off
+ DockerClient client =
+ DockerClientBuilder
+ .getInstance()
+ .withDockerCmdExecFactory(new NettyDockerCmdExecFactory())
+ .build();
+ // @formatter:on
BuildImageResultCallback callback = new BuildImageResultCallback() {
@Override
@@ -82,14 +84,17 @@ public class RobotItCase {
};
String imageId = client.buildImageCmd(robotFolder).exec(callback).awaitImageId();
- CreateContainerResponse createContainerResponse = client.createContainerCmd(imageId)
+ // @formatter:off
+ CreateContainerResponse createContainerResponse =
+ client
+ .createContainerCmd(imageId)
.withVolumes(testsVolume)
- .withBinds(
- new Bind(robotFolder.getAbsolutePath() + "/tests/", testsVolume, AccessMode.rw))
+ .withBinds(new Bind(robotFolder.getAbsolutePath() + "/tests/", testsVolume, AccessMode.rw))
.withEnv("CLAMP_PORT=" + httpPort)
.withStopTimeout(TIMEOUT_S)
.withNetworkMode("host")
.exec();
+ // @formatter:on
String id = createContainerResponse.getId();
client.startContainerCmd(id).exec();
InspectContainerResponse exec;
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
index 08e425abf..423876ede 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandlerTest.java
@@ -55,7 +55,6 @@ public class CsarHandlerTest {
private static final String SERVICE_UUID = "serviceUUID";
private static final String RESOURCE1_UUID = "resource1UUID";
private static final String RESOURCE1_INSTANCE_NAME = "sim-1802 0";
- private static final String RESOURCE1_INSTANCE_NAME_IN_CSAR = "sim18020";
private static final String BLUEPRINT1_NAME = "FOI.Simfoimap223S0112.event_proc_bp.yaml";
private static final String BLUEPRINT2_NAME = "FOI.Simfoimap223S0112.event_proc_bp2.yaml";
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java
index 6f6f5c104..9cf7cee6b 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ArrayFieldTest.java
@@ -47,9 +47,10 @@ public class ArrayFieldTest extends TestCase {
ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json"));
ToscaElement toscaElement = jsonTemplateManager.getToscaElements().get("onap.datatype.controlloop.Actor");
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("actor");
+ @SuppressWarnings("unchecked")
ArrayField arrayParser = new ArrayField((ArrayList<Object>) toscaElementProperty.getItems().get("default"));
JsonArray toTest = arrayParser.deploy();
String reference = "[1,\"String\",5.5,true]";
assertEquals(reference, String.valueOf(toTest));
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java
index 493ee992c..06a8bdac8 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ConstraintTest.java
@@ -48,6 +48,7 @@ public class ConstraintTest extends TestCase {
/**
* Test get value array.
*/
+ @SuppressWarnings("unchecked")
public void testGetValuesArray() {
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("timeout");
JsonTemplate jsonTemplate = jsonTemplateManager.getJsonSchemaTemplates().get("integer");
@@ -70,6 +71,7 @@ public class ConstraintTest extends TestCase {
/**
* Test get Specific length.
*/
+ @SuppressWarnings("unchecked")
public void testGetSpecificLength() {
//Test for string type, same process for array
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("id");
@@ -88,6 +90,7 @@ public class ConstraintTest extends TestCase {
/**
* Test get limit value.
*/
+ @SuppressWarnings("unchecked")
public void testGetLimitValue() {
//Test for array type, same process for string
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("description");
@@ -102,5 +105,4 @@ public class ConstraintTest extends TestCase {
toTest = resultProcess.get("maxItems").getAsInt();
assertEquals(7, toTest);
}
-
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java
index 5652fa9cd..c43b84a66 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/tosca/update/ToscaElementPropertyTest.java
@@ -50,6 +50,7 @@ public class ToscaElementPropertyTest extends TestCase {
ResourceFileUtils.getResourceAsString("clds/tosca-converter/templates.json"));
ToscaElement toscaElement = jsonTemplateManager.getToscaElements().get("onap.datatype.controlloop.Actor");
ToscaElementProperty toscaElementProperty = toscaElement.getProperties().get("actor");
+ @SuppressWarnings("unchecked")
JsonArray toTest =
toscaElementProperty.parseArray((ArrayList<Object>) toscaElementProperty.getItems().get("default"));
assertNotNull(toTest);
@@ -60,6 +61,7 @@ public class ToscaElementPropertyTest extends TestCase {
*
* @throws IOException In case of failure
*/
+ @SuppressWarnings("unchecked")
public void testAddConstraintsAsJson() throws IOException {
JsonTemplateManager jsonTemplateManager = new JsonTemplateManager(
ResourceFileUtils.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"),
@@ -76,4 +78,4 @@ public class ToscaElementPropertyTest extends TestCase {
String test = "{\"enum\":[\"error\",\"timeout\",\"retries\",\"guard\",\"exception\"]}";
assertEquals(test, String.valueOf(toTest));
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java b/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java
index ab6a41bca..4b93ed7be 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/clds/util/LoggingUtilsTest.java
@@ -132,7 +132,7 @@ public class LoggingUtilsTest {
assertEquals(targetServiceName, mdc.get(OnapLogConstants.Mdcs.TARGET_SERVICE_NAME));
}
- private boolean checkMapKeys(Map map, String[] keys) {
+ private boolean checkMapKeys(Map<String, String> map, String[] keys) {
return Arrays.stream(keys).allMatch(key -> map.get(key) != null);
}
}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java b/runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java
index 622fd5999..1cc7e9032 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/flow/FlowLogOperationTest.java
@@ -24,7 +24,6 @@
package org.onap.policy.clamp.flow;
-import static junit.framework.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -74,8 +73,8 @@ public class FlowLogOperationTest {
// then
String entity = mdcAdapter.get(OnapLogConstants.Mdcs.TARGET_ENTITY);
String serviceName = mdcAdapter.get(OnapLogConstants.Mdcs.TARGET_SERVICE_NAME);
- assertEquals(entity, mockEntity);
- assertEquals(serviceName, mockServiceName);
+ assertThat(entity).isEqualTo(mockEntity);
+ assertThat(serviceName).isEqualTo(mockServiceName);
}
@Test
@@ -99,4 +98,4 @@ public class FlowLogOperationTest {
// then
assertThat(mdcAdapter.get(OnapLogConstants.Mdcs.ENTRY_TIMESTAMP)).isNull();
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java
index 6728d292c..54ecaa639 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopControllerTestItCase.java
@@ -104,8 +104,7 @@ public class LoopControllerTestItCase {
+ "\"success\":\"\",\"failure\":\"\",\"failure_timeout\":\"\",\"failure_retries\":\"\","
+ "\"failure_exception\":\"\",\"failure_guard\":\"\",\"target\":{\"type\":\"VNF\","
+ "\"resourceID\":\"vFW_PG_T1\"}}]}}}]";
- JsonParser parser = new JsonParser();
- JsonElement ele = parser.parse(policy);
+ JsonElement ele = JsonParser.parseString(policy);
JsonArray arr = ele.getAsJsonArray();
Loop loop = loopController.updateOperationalPolicies(EXAMPLE_LOOP_NAME, arr);
assertThat(loop.getOperationalPolicies()).hasSize(1);
@@ -126,8 +125,7 @@ public class LoopControllerTestItCase {
+ "\"cbs_host\":\"config-binding-service\",\"cbs_port\":\"10000\",\"external_port\":\"32012\","
+ "\"policy_model_id\":\"onap.policies.monitoring.cdap.tca.hi.lo.app\","
+ "\"policy_id\":\"tca_k8s_CLTCA_v1_0_vFW_PG_T10_k8s-tca-clamp-policy-05162019\"}}";
- JsonParser parser = new JsonParser();
- JsonElement ele = parser.parse(policy);
+ JsonElement ele = JsonParser.parseString(policy);
JsonObject obj = ele.getAsJsonObject();
loopController.updateGlobalPropertiesJson(EXAMPLE_LOOP_NAME, obj);
Loop loop = loopController.getLoop(EXAMPLE_LOOP_NAME);
@@ -170,6 +168,6 @@ public class LoopControllerTestItCase {
loopController.removeOperationalPolicy(EXAMPLE_LOOP_NAME, "testPolicyModel", "1.0.0");
Loop newLoop2 = loopController.getLoop(EXAMPLE_LOOP_NAME);
- assertThat(newLoop2.getOperationalPolicies().size()).isEqualTo(0);
+ assertThat(newLoop2.getOperationalPolicies().size()).isZero();
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java
index 7b0ab8614..ab256eafb 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/loop/LoopLogServiceTestItCase.java
@@ -47,7 +47,6 @@ public class LoopLogServiceTestItCase {
private static final String EXAMPLE_JSON = "{\"testName\":\"testValue\"}";
private static final String CLAMP_COMPONENT = "CLAMP";
private static final String SAMPLE_LOG_MESSAGE = "Sample log";
- private static final String BLUEPRINT = "blueprint";
@Autowired
LoopService loopService;
@@ -93,4 +92,4 @@ public class LoopLogServiceTestItCase {
assertThat(log.getId()).isEqualTo(id);
Assertions.assertThat(log.getLoop()).isEqualTo(testLoop);
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java
index 30d4ebe28..03cd89aeb 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupAnalyzerTest.java
@@ -26,7 +26,6 @@ package org.onap.policy.clamp.policy.pdpgroup;
import static org.assertj.core.api.Assertions.assertThat;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import org.junit.BeforeClass;
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java
index f3c3fc6cd..ce695ec6f 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadExceptionTest.java
@@ -21,7 +21,6 @@
package org.onap.policy.clamp.policy.pdpgroup;
import org.junit.Test;
-import org.onap.policy.clamp.policy.pdpgroup.PdpGroupPayloadException;
import org.onap.policy.common.utils.test.ExceptionsTester;
public class PdpGroupPayloadExceptionTest extends ExceptionsTester {
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java
index 34674e3ec..b07d3869c 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayloadTest.java
@@ -70,6 +70,6 @@ public class PdpGroupPayloadTest {
JsonObject listOfOperations = new JsonObject();
listOfOperations.add(PdpGroupPayload.PDP_ACTIONS, operations);
- PdpGroupPayload pdpGroupPayload = new PdpGroupPayload(listOfOperations);
+ new PdpGroupPayload(listOfOperations);
}
}
diff --git a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java
index be7a9d674..733e3734e 100644
--- a/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java
+++ b/runtime/src/test/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMergerTest.java
@@ -23,9 +23,6 @@
package org.onap.policy.clamp.policy.pdpgroup;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import com.google.gson.JsonObject;
import java.io.IOException;
import java.util.Arrays;
import org.junit.BeforeClass;