summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/controlloop/persistence/provider/ControlLoopProvider.java25
-rw-r--r--models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java37
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProvider.java82
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProvider.java84
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java5
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java66
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/SupervisionHandler.java28
-rw-r--r--runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java25
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java34
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java72
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java25
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java65
-rw-r--r--runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java14
-rw-r--r--runtime-controlloop/src/test/resources/META-INF/persistence.xml1
-rwxr-xr-x[-rw-r--r--]runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh0
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java14
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/Application.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java38
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java16
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java10
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultDictionaryElements.java34
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultUserConfiguration.java5
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/SslConfig.java11
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java2
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/CldsConfiguration.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/SdcControllerConfiguration.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/SdcSingleController.java12
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/BlueprintParser.java26
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/ChainGenerator.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java31
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/service/CldsHealthcheckService.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/JsonEditorSchemaConstants.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/ToscaSchemaConstants.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ArrayField.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java9
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java46
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateField.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/util/ClampVersioning.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/clds/util/OnapLogConstants.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java20
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/cds/CdsDataInstaller.java9
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/common/AuditEntity.java9
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/components/external/ExternalComponentState.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/components/external/PolicyComponent.java2
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/log/LoopLog.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java13
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java1
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplate.java11
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplateLoopElementModel.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModelsService.java2
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/Policy.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/PolicyEngineServices.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/PolicyPayload.java19
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java8
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java28
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java60
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java7
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java4
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java9
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryElement.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryService.java6
-rw-r--r--runtime/src/main/java/org/onap/policy/clamp/util/SemanticVersioning.java8
-rw-r--r--runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml45
-rw-r--r--runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml25
72 files changed, 895 insertions, 368 deletions
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 4e502c64c..71407916d 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
@@ -22,12 +22,15 @@ package org.onap.policy.clamp.controlloop.models.controlloop.persistence.provide
import java.util.ArrayList;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
import javax.ws.rs.core.Response;
import lombok.NonNull;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
import org.onap.policy.models.base.PfAuthorative;
import org.onap.policy.models.base.PfConceptKey;
import org.onap.policy.models.base.PfKey;
@@ -38,6 +41,7 @@ import org.onap.policy.models.provider.impl.AbstractModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaEntity;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
import org.onap.policy.models.tosca.simple.concepts.JpaToscaNodeTemplate;
import org.springframework.stereotype.Component;
@@ -184,6 +188,26 @@ public class ControlLoopProvider extends AbstractModelsProvider {
}
/**
+ * Saves Instance Properties to the database.
+ * @param serviceTemplate the service template
+ * @return a Map of tosca node templates
+ */
+ public Map<String, ToscaNodeTemplate> saveInstanceProperties(ToscaServiceTemplate serviceTemplate) {
+
+ Map<String, ToscaNodeTemplate> savedNodeTemplates = new HashMap<>();
+
+ serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach((key, template) -> {
+ JpaToscaNodeTemplate jpaToscaNodeTemplate = new JpaToscaNodeTemplate(template);
+
+ getPfDao().create(jpaToscaNodeTemplate);
+
+ savedNodeTemplates.put(key, template);
+ });
+
+ return savedNodeTemplates;
+ }
+
+ /**
* Get Node Templates.
*
* @param name the name of the node template to get, null to get all node templates
@@ -220,4 +244,5 @@ public class ControlLoopProvider extends AbstractModelsProvider {
private <T extends ToscaEntity, J extends PfAuthorative<T>> List<T> asEntityList(List<J> jpaEntityList) {
return jpaEntityList.stream().map(J::toAuthorative).collect(Collectors.toList());
}
+
}
diff --git a/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java
new file mode 100644
index 000000000..eed339447
--- /dev/null
+++ b/models/src/main/java/org/onap/policy/clamp/controlloop/models/messages/rest/instantiation/InstancePropertiesResponse.java
@@ -0,0 +1,37 @@
+/*
+ * ============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=========================================================
+ */
+
+package org.onap.policy.clamp.controlloop.models.messages.rest.instantiation;
+
+import java.util.List;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.onap.policy.clamp.controlloop.models.messages.rest.SimpleResponse;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+
+/**
+ * Response to Instance Properties requests that affect a change.
+ */
+@Getter
+@Setter
+@ToString(callSuper = true)
+public class InstancePropertiesResponse extends SimpleResponse {
+ private List<ToscaConceptIdentifier> affectedInstanceProperties;
+}
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 e676cbe0e..74b5394f4 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
@@ -33,8 +33,13 @@ import java.util.stream.Collectors;
import javax.ws.rs.core.Response.Status;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
+import org.onap.policy.clamp.controlloop.models.controlloop.concepts.Participant;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse;
+import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaCapabilityType;
@@ -62,6 +67,8 @@ public class CommissioningProvider {
private final PolicyModelsProvider modelsProvider;
private final ControlLoopProvider clProvider;
private final ObjectMapper mapper = new ObjectMapper();
+ private final ParticipantProvider participantProvider;
+ private final SupervisionHandler supervisionHandler;
private static final Object lockit = new Object();
@@ -71,9 +78,14 @@ public class CommissioningProvider {
* @param modelsProvider the PolicyModelsProvider
* @param clProvider the ControlLoopProvider
*/
- public CommissioningProvider(PolicyModelsProvider modelsProvider, ControlLoopProvider clProvider) {
+ public CommissioningProvider(PolicyModelsProvider modelsProvider,
+ ControlLoopProvider clProvider,
+ SupervisionHandler supervisionHandler,
+ ParticipantProvider participantProvider) {
this.modelsProvider = modelsProvider;
this.clProvider = clProvider;
+ this.supervisionHandler = supervisionHandler;
+ this.participantProvider = participantProvider;
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
}
@@ -85,9 +97,33 @@ public class CommissioningProvider {
* @throws PfModelException on creation errors
*/
public CommissioningResponse createControlLoopDefinitions(ToscaServiceTemplate serviceTemplate)
- throws PfModelException {
+ throws PfModelException, ControlLoopException {
+
+ if (verifyIfInstancePropertiesExists()) {
+ throw new ControlLoopException(Status.BAD_REQUEST,
+ "Delete instances, to commission control loop definitions");
+ }
+
synchronized (lockit) {
modelsProvider.createServiceTemplate(serviceTemplate);
+ List<Participant> participantList =
+ participantProvider.getParticipants(null,
+ null);
+
+ if (participantList != null) {
+ for (Participant participant: participantList) {
+ var participantType = new ToscaConceptIdentifier();
+ participantType.setName(participant.getType());
+ participantType.setVersion(participant.getTypeVersion());
+
+ var participantUpdate = new ParticipantUpdate();
+ participantUpdate.setParticipantId(participant.getDefinition());
+ participantUpdate.setParticipantType(participantType);
+
+ this.supervisionHandler.handleSendCommissionMessage(participantUpdate);
+ }
+ }
+
}
var response = new CommissioningResponse();
@@ -110,8 +146,33 @@ public class CommissioningProvider {
* @return the result of the deletion
* @throws PfModelException on deletion errors
*/
- public CommissioningResponse deleteControlLoopDefinition(String name, String version) throws PfModelException {
+ public CommissioningResponse deleteControlLoopDefinition(String name, String version)
+ throws PfModelException, ControlLoopException {
+
+ if (verifyIfInstancePropertiesExists()) {
+ throw new ControlLoopException(Status.BAD_REQUEST,
+ "Delete instances, to commission control loop definitions");
+ }
+
synchronized (lockit) {
+ List<Participant> participantList =
+ participantProvider.getParticipants(null,
+ null);
+
+ if (participantList != null) {
+ for (Participant participant : participantList) {
+ var participantType = new ToscaConceptIdentifier();
+ participantType.setName(participant.getType());
+ participantType.setVersion(participant.getTypeVersion());
+
+ var participantUpdate = new ParticipantUpdate();
+ participantUpdate.setParticipantId(participant.getDefinition());
+ participantUpdate.setParticipantType(participantType);
+
+ this.supervisionHandler.handleSendDeCommissionMessage(participantUpdate);
+ }
+ }
+
modelsProvider.deleteServiceTemplate(name, version);
}
@@ -365,7 +426,9 @@ public class CommissioningProvider {
* @return the tosca service template
* @throws PfModelException on errors getting tosca service template
*/
- public String getToscaServiceTemplateReduced(String name, String version) throws PfModelException {
+ public String getToscaServiceTemplateReduced(String name, String version)
+ throws PfModelException {
+
var serviceTemplates = new ToscaServiceTemplates();
serviceTemplates.setServiceTemplates(modelsProvider.getServiceTemplateList(name, version));
@@ -431,4 +494,15 @@ public class CommissioningProvider {
throw new PfModelException(Status.BAD_REQUEST, "Converion to Json Schema failed", e);
}
}
+
+ /**
+ * Validates to see if there is any instance properties saved.
+ *
+ * @return true if exists instance properties
+ */
+ private Boolean verifyIfInstancePropertiesExists() {
+ return clProvider.getNodeTemplates(null, null).stream()
+ .anyMatch(nodeTemplate -> nodeTemplate.getKey().getName().contains("_Instance"));
+
+ }
}
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 cb22132b4..da85b0a83 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
@@ -37,6 +37,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
import org.onap.policy.clamp.controlloop.models.messages.rest.GenericNameVersion;
import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopOrderStateResponse;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstancePropertiesResponse;
import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand;
import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
@@ -48,6 +49,7 @@ import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.stereotype.Component;
/**
@@ -62,6 +64,44 @@ public class ControlLoopInstantiationProvider {
private static final Object lockit = new Object();
+ private static final String CL_ELEMENT_NAME = "name";
+
+ /**
+ * Create Instance Properties.
+ *
+ * @param serviceTemplate the service template
+ * @return the result of the instantiation operation
+ * @throws PfModelException on creation errors
+ */
+ public InstancePropertiesResponse saveInstanceProperties(ToscaServiceTemplate serviceTemplate) {
+
+ String instanceName = generateSequentialInstanceName();
+
+ Map<String, ToscaNodeTemplate> nodeTemplates = serviceTemplate.getToscaTopologyTemplate().getNodeTemplates();
+
+ nodeTemplates.forEach((key, template) -> {
+ String name = key + instanceName;
+ String description = template.getDescription() + instanceName;
+ template.setName(name);
+ template.setDescription(description);
+
+ changeInstanceElementsName(template, instanceName);
+
+ });
+
+ Map<String, ToscaNodeTemplate> toscaSavedNodeTemplate = controlLoopProvider
+ .saveInstanceProperties(serviceTemplate);
+
+ var response = new InstancePropertiesResponse();
+
+ // @formatter:off
+ response.setAffectedInstanceProperties(toscaSavedNodeTemplate.values().stream().map(template ->
+ template.getKey().asIdentifier()).collect(Collectors.toList()));
+ // @formatter:on
+
+ return response;
+ }
+
/**
* Create control loops.
*
@@ -267,10 +307,10 @@ public class ControlLoopInstantiationProvider {
List<ControlLoop> controlLoops = controlLoopProvider.getControlLoops(name, version);
- ControlLoopOrderStateResponse response = new ControlLoopOrderStateResponse();
+ var response = new ControlLoopOrderStateResponse();
controlLoops.forEach(controlLoop -> {
- GenericNameVersion genericNameVersion = new GenericNameVersion();
+ var genericNameVersion = new GenericNameVersion();
genericNameVersion.setName(controlLoop.getName());
genericNameVersion.setVersion(controlLoop.getVersion());
response.getControlLoopIdentifierList().add(genericNameVersion);
@@ -278,4 +318,44 @@ public class ControlLoopInstantiationProvider {
return response;
}
+
+ /**
+ * Creates instance element name.
+ *
+ * @param serviceTemplate the service serviceTemplate
+ * @param instanceName to amend to the element name
+ */
+ private void changeInstanceElementsName(ToscaNodeTemplate serviceTemplate, String instanceName) {
+
+ @SuppressWarnings("unchecked")
+ List<Map<String, String>> controlLoopElements = (List<Map<String, String>>) serviceTemplate.getProperties()
+ .get("elements");
+
+ if (controlLoopElements != null) {
+ controlLoopElements.forEach(clElement -> {
+ String name = clElement.get(CL_ELEMENT_NAME) + instanceName;
+ clElement.replace(CL_ELEMENT_NAME, name);
+ });
+ }
+ }
+
+
+ /**
+ * Generates Instance Name in sequential order and return it to append to the Node Template Name.
+ *
+ * @return instanceName
+ */
+ private String generateSequentialInstanceName() {
+ List<ToscaNodeTemplate> nodeTemplates = controlLoopProvider.getNodeTemplates(null, null);
+
+ int instanceNumber =
+ nodeTemplates.stream().map(ToscaNodeTemplate::getName)
+ .filter(name -> name.contains("_Instance")).map(n -> {
+ String[] defNameArr = n.split("_Instance");
+
+ return Integer.parseInt(defNameArr[1]);
+ }).reduce(0, Math::max);
+
+ return "_Instance" + (instanceNumber + 1);
+ }
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
index ec7f14d8b..2c3a41e26 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/CommissioningController.java
@@ -33,6 +33,7 @@ import java.util.Map;
import java.util.UUID;
import javax.ws.rs.core.Response.Status;
import lombok.RequiredArgsConstructor;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
import org.onap.policy.clamp.controlloop.models.messages.rest.commissioning.CommissioningResponse;
import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
import org.onap.policy.clamp.controlloop.runtime.main.web.AbstractRestController;
@@ -120,7 +121,7 @@ public class CommissioningController extends AbstractRestController {
name = REQUEST_ID_NAME,
required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
@ApiParam(value = "Entity Body of Control Loop", required = true) @RequestBody ToscaServiceTemplate body)
- throws PfModelException {
+ throws PfModelException, ControlLoopException {
return ResponseEntity.ok().body(provider.createControlLoopDefinitions(body));
}
@@ -187,7 +188,7 @@ public class CommissioningController extends AbstractRestController {
@ApiParam(
value = "Control Loop definition version",
required = true) @RequestParam("version") String version)
- throws PfModelException {
+ throws PfModelException, ControlLoopException {
return ResponseEntity.ok().body(provider.deleteControlLoopDefinition(name, version));
}
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java
index 6f0c859da..d2a85c46d 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/main/rest/InstantiationController.java
@@ -33,11 +33,13 @@ import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.ControlLoopOrderStateResponse;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstancePropertiesResponse;
import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand;
import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
import org.onap.policy.clamp.controlloop.runtime.instantiation.ControlLoopInstantiationProvider;
import org.onap.policy.clamp.controlloop.runtime.main.web.AbstractRestController;
import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
@@ -127,6 +129,70 @@ public class InstantiationController extends AbstractRestController {
}
/**
+ * Saves instance properties.
+ *
+ * @param requestId request ID used in ONAP logging
+ * @param body the body of control loop following TOSCA definition
+ * @return a response
+ */
+ // @formatter:off
+ @PostMapping(value = "/instanceProperties",
+ consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
+ produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
+ @ApiOperation(
+ value = "Saves instance properties",
+ notes = "Saves instance properties, returning the saved instances properties and it's version",
+ response = InstancePropertiesResponse.class,
+ tags = {TAGS},
+ 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)
+ }
+ )
+ // @formatter:on
+ public ResponseEntity<InstancePropertiesResponse> createInstanceProperties(
+ @RequestHeader(
+ name = REQUEST_ID_NAME,
+ required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
+ @ApiParam(value = "Body of instance properties", required = true) @RequestBody ToscaServiceTemplate body)
+ throws PfModelException {
+
+ return ResponseEntity.ok().body(provider.saveInstanceProperties(body));
+ }
+
+ /**
* Queries details of all control loops.
*
* @param requestId request ID used in ONAP logging
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 0e2ff5ca9..7cc5d7fee 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
@@ -21,7 +21,6 @@
package org.onap.policy.clamp.controlloop.runtime.supervision;
import java.util.List;
-import java.util.Map;
import javax.ws.rs.core.Response;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
@@ -35,6 +34,7 @@ import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantDeregister;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantRegister;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantStatus;
+import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider;
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ControlLoopStateChangePublisher;
@@ -141,7 +141,7 @@ public class SupervisionHandler {
participantRegisterAckPublisher.send(participantRegisterMessage.getMessageId());
participantUpdatePublisher.send(participantRegisterMessage.getParticipantId(),
- participantRegisterMessage.getParticipantType());
+ participantRegisterMessage.getParticipantType(), true);
}
/**
@@ -166,6 +166,30 @@ public class SupervisionHandler {
}
/**
+ * Send commissioning update message to dmaap.
+ *
+ * @param participantUpdateMessage the ParticipantUpdate message to send
+ */
+ public void handleSendCommissionMessage(ParticipantUpdate participantUpdateMessage) {
+ LOGGER.debug("Participant update message being sent {}", participantUpdateMessage);
+
+ participantUpdatePublisher.send(participantUpdateMessage.getParticipantId(),
+ participantUpdateMessage.getParticipantType(), true);
+ }
+
+ /**
+ * Send decommissioning update message to dmaap.
+ *
+ * @param participantUpdateMessage the ParticipantUpdate message to send
+ */
+ public void handleSendDeCommissionMessage(ParticipantUpdate participantUpdateMessage) {
+ LOGGER.debug("Participant update message being sent {}", participantUpdateMessage);
+
+ participantUpdatePublisher.send(participantUpdateMessage.getParticipantId(),
+ participantUpdateMessage.getParticipantType(), false);
+ }
+
+ /**
* Supervise a control loop, performing whatever actions need to be performed on the control loop.
*
* @param controlLoop the control loop to supervises
diff --git a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
index 5edf528b8..d5dc4a6d0 100644
--- a/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
+++ b/runtime-controlloop/src/main/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/ParticipantUpdatePublisher.java
@@ -22,22 +22,21 @@ package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
import java.time.Instant;
import java.util.ArrayList;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import lombok.AllArgsConstructor;
-import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
-import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
import org.onap.policy.models.base.PfModelException;
+import org.onap.policy.models.provider.PolicyModelsProvider;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplates;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -51,7 +50,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
private static final Logger LOGGER = LoggerFactory.getLogger(ParticipantUpdatePublisher.class);
private static final String CONTROL_LOOP_ELEMENT = "ControlLoopElement";
- private final CommissioningProvider commissioningProvider;
+ private final PolicyModelsProvider modelsProvider;
private static final Coder CODER = new StandardCoder();
/**
@@ -60,7 +59,8 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
* @param participantId the participant Id
* @param participantType the participant Type
*/
- public void send(ToscaConceptIdentifier participantId, ToscaConceptIdentifier participantType) {
+ public void send(ToscaConceptIdentifier participantId, ToscaConceptIdentifier participantType,
+ boolean commissionFlag) {
var message = new ParticipantUpdate();
message.setParticipantId(participantId);
message.setParticipantType(participantType);
@@ -68,7 +68,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
ToscaServiceTemplate toscaServiceTemplate;
try {
- toscaServiceTemplate = commissioningProvider.getToscaServiceTemplate(null, null);
+ toscaServiceTemplate = modelsProvider.getServiceTemplateList(null, null).get(0);
} catch (PfModelException pfme) {
LOGGER.warn("Get of tosca service template failed, cannot send participantupdate", pfme);
return;
@@ -91,8 +91,15 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
}
}
- message.setParticipantDefinitionUpdates(participantDefinitionUpdates);
- message.setToscaServiceTemplate(toscaServiceTemplate);
+ if (commissionFlag) {
+ // Commission the controlloop but sending participantdefinitions to participants
+ message.setParticipantDefinitionUpdates(participantDefinitionUpdates);
+ message.setToscaServiceTemplate(toscaServiceTemplate);
+ } else {
+ // DeCommission the controlloop but deleting participantdefinitions on participants
+ message.setParticipantDefinitionUpdates(null);
+ message.setToscaServiceTemplate(null);
+ }
LOGGER.debug("Participant Update sent {}", message);
super.send(message);
}
@@ -127,7 +134,7 @@ public class ParticipantUpdatePublisher extends AbstractParticipantPublisher<Par
private ParticipantDefinition getParticipantDefinition(ControlLoopElementDefinition clDefinition,
ToscaConceptIdentifier clParticipantId,
List<ControlLoopElementDefinition> controlLoopElementDefinitionList) {
- ParticipantDefinition participantDefinition = new ParticipantDefinition();
+ var participantDefinition = new ParticipantDefinition();
participantDefinition.setParticipantId(clParticipantId);
controlLoopElementDefinitionList.add(clDefinition);
participantDefinition.setControlLoopElementDefinitionList(controlLoopElementDefinitionList);
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java
index 232d6d83c..5c49b8523 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/commissioning/CommissioningProviderTest.java
@@ -33,6 +33,7 @@ import java.util.Map;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ControlLoopProvider;
+import org.onap.policy.clamp.controlloop.models.controlloop.persistence.provider.ParticipantProvider;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData;
import org.onap.policy.common.utils.coder.Coder;
@@ -62,7 +63,7 @@ class CommissioningProviderTest {
private ControlLoopProvider clProvider = null;
private static final Coder CODER = new StandardCoder();
private final ObjectMapper mapper = new ObjectMapper();
-
+ private ParticipantProvider participantProvider;
@AfterEach
void close() throws Exception {
@@ -72,6 +73,9 @@ class CommissioningProviderTest {
if (clProvider != null) {
clProvider.close();
}
+ if (participantProvider != null) {
+ participantProvider.close();
+ }
}
/**
@@ -85,8 +89,10 @@ class CommissioningProviderTest {
modelsProvider =
CommonTestData.getPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
+ participantProvider = new ParticipantProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
- CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider);
+ CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider,
+ null, participantProvider);
ToscaServiceTemplate serviceTemplate = yamlTranslator
.fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML), ToscaServiceTemplate.class);
@@ -122,8 +128,10 @@ class CommissioningProviderTest {
modelsProvider =
CommonTestData.getPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
+ participantProvider = new ParticipantProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
- CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider);
+ CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider,
+ null, participantProvider);
// Test Service template is null
assertThatThrownBy(() -> provider.createControlLoopDefinitions(null)).hasMessageMatching(TEMPLATE_IS_NULL);
List<ToscaNodeTemplate> listOfTemplates = provider.getControlLoopDefinitions(null, null);
@@ -151,8 +159,10 @@ class CommissioningProviderTest {
modelsProvider =
CommonTestData.getPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
+ participantProvider = new ParticipantProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
- CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider);
+ CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider,
+ null, participantProvider);
ToscaServiceTemplate serviceTemplate = yamlTranslator
.fromYaml(ResourceUtils
.getResourceAsString(COMMON_TOSCA_SERVICE_TEMPLATE_YAML), ToscaServiceTemplate.class);
@@ -179,8 +189,10 @@ class CommissioningProviderTest {
modelsProvider =
CommonTestData.getPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
+ participantProvider = new ParticipantProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
- CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider);
+ CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider,
+ null, participantProvider);
ToscaServiceTemplate serviceTemplate = yamlTranslator
.fromYaml(ResourceUtils
.getResourceAsString(COMMON_TOSCA_SERVICE_TEMPLATE_YAML), ToscaServiceTemplate.class);
@@ -207,8 +219,10 @@ class CommissioningProviderTest {
modelsProvider =
CommonTestData.getPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
+ participantProvider = new ParticipantProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
- CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider);
+ CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider,
+ null, participantProvider);
ToscaServiceTemplate serviceTemplate = yamlTranslator
.fromYaml(ResourceUtils
.getResourceAsString(COMMON_TOSCA_SERVICE_TEMPLATE_YAML), ToscaServiceTemplate.class);
@@ -258,8 +272,10 @@ class CommissioningProviderTest {
modelsProvider =
CommonTestData.getPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
+ participantProvider = new ParticipantProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
- CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider);
+ CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider,
+ null, participantProvider);
ToscaServiceTemplate serviceTemplate = yamlTranslator
.fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML), ToscaServiceTemplate.class);
@@ -286,8 +302,10 @@ class CommissioningProviderTest {
modelsProvider =
CommonTestData.getPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
+ participantProvider = new ParticipantProvider(clRuntimeParameterGroup.getDatabaseProviderParameters());
- CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider);
+ CommissioningProvider provider = new CommissioningProvider(modelsProvider, clProvider,
+ null, participantProvider);
ToscaServiceTemplate serviceTemplate = yamlTranslator
.fromYaml(ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML), ToscaServiceTemplate.class);
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
index c414ffa02..d1aaddc5a 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/ControlLoopInstantiationProviderTest.java
@@ -26,7 +26,9 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.io.IOException;
import java.util.ArrayList;
import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException;
@@ -49,9 +51,14 @@ import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantDer
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantRegisterAckPublisher;
import org.onap.policy.clamp.controlloop.runtime.supervision.comm.ParticipantUpdatePublisher;
import org.onap.policy.clamp.controlloop.runtime.util.CommonTestData;
+import org.onap.policy.common.utils.coder.YamlJsonTranslator;
+import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.provider.PolicyModelsProviderFactory;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
+import org.springframework.beans.factory.annotation.Autowired;
/**
* Class to perform unit test of {@link ControlLoopInstantiationProvider}}.
@@ -88,10 +95,21 @@ class ControlLoopInstantiationProviderTest {
+ " item \"ControlLoop\" value \"org.onap.domain.PMSHControlLoopDefinition\" INVALID,"
+ " Commissioned control loop definition not FOUND\n";
+ private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate();
+
+ private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
+
private static SupervisionHandler supervisionHandler;
private static CommissioningProvider commissioningProvider;
private static ControlLoopProvider clProvider;
private static PolicyModelsProvider modelsProvider;
+ private static ParticipantProvider participantProvider;
+
+ @BeforeAll
+ public static void setUpBeforeClass() throws Exception {
+ serviceTemplate = yamlTranslator.fromYaml(ResourceUtils.getResourceAsString(TOSCA_TEMPLATE_YAML),
+ ToscaServiceTemplate.class);
+ }
/**
* setup Db Provider Parameters.
@@ -105,11 +123,13 @@ class ControlLoopInstantiationProviderTest {
modelsProvider =
CommonTestData.getPolicyModelsProvider(controlLoopParameters.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(controlLoopParameters.getDatabaseProviderParameters());
+ participantProvider = new ParticipantProvider(controlLoopParameters.getDatabaseProviderParameters());
+
var participantStatisticsProvider =
new ParticipantStatisticsProvider(controlLoopParameters.getDatabaseProviderParameters());
var clElementStatisticsProvider =
new ClElementStatisticsProvider(controlLoopParameters.getDatabaseProviderParameters());
- commissioningProvider = new CommissioningProvider(modelsProvider, clProvider);
+ commissioningProvider = new CommissioningProvider(modelsProvider, clProvider, null, participantProvider);
var monitoringProvider =
new MonitoringProvider(participantStatisticsProvider, clElementStatisticsProvider, clProvider);
var participantProvider = new ParticipantProvider(controlLoopParameters.getDatabaseProviderParameters());
@@ -123,24 +143,31 @@ class ControlLoopInstantiationProviderTest {
participantRegisterAckPublisher, participantDeregisterAckPublisher, participantUpdatePublisher);
}
+ @BeforeEach
+ public void populateDb() throws Exception {
+ createEntryInDB();
+ }
+
@AfterAll
public static void closeDbProvider() throws PfModelException {
clProvider.close();
modelsProvider.close();
}
+ @AfterEach
+ public void cleanDatabase() throws Exception {
+ deleteEntryInDB(serviceTemplate.getName(), serviceTemplate.getVersion());
+ }
+
@Test
void testInstantiationCrud() throws Exception {
+
ControlLoops controlLoopsCreate =
InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Crud");
ControlLoops controlLoopsDb = getControlLoopsFromDb(controlLoopsCreate);
assertThat(controlLoopsDb.getControlLoopList()).isEmpty();
var instantiationProvider =
new ControlLoopInstantiationProvider(clProvider, commissioningProvider, supervisionHandler);
-
- // to validate control Loop, it needs to define ToscaServiceTemplate
- InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, commissioningProvider);
-
InstantiationResponse instantiationResponse = instantiationProvider.createControlLoops(controlLoopsCreate);
InstantiationUtils.assertInstantiationResponse(instantiationResponse, controlLoopsCreate);
@@ -192,11 +219,12 @@ class ControlLoopInstantiationProviderTest {
}
private ControlLoops getControlLoopsFromDb(ControlLoops controlLoopsSource) throws Exception {
+
ControlLoops controlLoopsDb = new ControlLoops();
controlLoopsDb.setControlLoopList(new ArrayList<>());
- var instantiationProvider =
- new ControlLoopInstantiationProvider(clProvider, commissioningProvider, supervisionHandler);
+ var instantiationProvider = new ControlLoopInstantiationProvider(clProvider,
+ commissioningProvider, supervisionHandler);
for (ControlLoop controlLoop : controlLoopsSource.getControlLoopList()) {
ControlLoops controlLoopsFromDb =
@@ -208,6 +236,7 @@ class ControlLoopInstantiationProviderTest {
@Test
void testInstantiationDelete() throws Exception {
+
ControlLoops controlLoops =
InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Delete");
assertThat(getControlLoopsFromDb(controlLoops).getControlLoopList()).isEmpty();
@@ -217,9 +246,6 @@ class ControlLoopInstantiationProviderTest {
var instantiationProvider =
new ControlLoopInstantiationProvider(clProvider, commissioningProvider, supervisionHandler);
- // to validate control Loop, it needs to define ToscaServiceTemplate
- InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, commissioningProvider);
-
assertThatThrownBy(
() -> instantiationProvider.deleteControlLoop(controlLoop0.getName(), controlLoop0.getVersion()))
.hasMessageMatching(CONTROL_LOOP_NOT_FOUND);
@@ -263,6 +289,7 @@ class ControlLoopInstantiationProviderTest {
@Test
void testCreateControlLoops_NoDuplicates() throws Exception {
+
ControlLoops controlLoopsCreate =
InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "NoDuplicates");
@@ -272,9 +299,6 @@ class ControlLoopInstantiationProviderTest {
var instantiationProvider =
new ControlLoopInstantiationProvider(clProvider, commissioningProvider, supervisionHandler);
- // to validate control Loop, it needs to define ToscaServiceTemplate
- InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, commissioningProvider);
-
InstantiationResponse instantiationResponse = instantiationProvider.createControlLoops(controlLoopsCreate);
InstantiationUtils.assertInstantiationResponse(instantiationResponse, controlLoopsCreate);
@@ -288,13 +312,14 @@ class ControlLoopInstantiationProviderTest {
@Test
void testCreateControlLoops_CommissionedClElementNotFound() throws Exception {
+
ControlLoops controlLoops = InstantiationUtils
.getControlLoopsFromResource(CL_INSTANTIATION_DEFINITION_NAME_NOT_FOUND_JSON, "ClElementNotFound");
var provider = new ControlLoopInstantiationProvider(clProvider, commissioningProvider, supervisionHandler);
// to validate control Loop, it needs to define ToscaServiceTemplate
- InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, commissioningProvider);
+ // InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, commissioningProvider);
assertThat(getControlLoopsFromDb(controlLoops).getControlLoopList()).isEmpty();
@@ -324,7 +349,6 @@ class ControlLoopInstantiationProviderTest {
@Test
void testInstantiationVersions() throws Exception {
-
// create controlLoops V1
ControlLoops controlLoopsV1 =
InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "V1");
@@ -333,9 +357,6 @@ class ControlLoopInstantiationProviderTest {
var instantiationProvider =
new ControlLoopInstantiationProvider(clProvider, commissioningProvider, supervisionHandler);
- // to validate control Loop, it needs to define ToscaServiceTemplate
- InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, commissioningProvider);
-
InstantiationUtils.assertInstantiationResponse(instantiationProvider.createControlLoops(controlLoopsV1),
controlLoopsV1);
@@ -386,4 +407,19 @@ class ControlLoopInstantiationProviderTest {
assertThat(controlLoopsGet.getControlLoopList()).isEmpty();
}
}
+
+ private synchronized void deleteEntryInDB(String name, String version) throws Exception {
+ if (!modelsProvider.getServiceTemplateList(null, null).isEmpty()) {
+ modelsProvider.deleteServiceTemplate(name, version);
+ }
+ }
+
+ private synchronized void createEntryInDB() throws Exception {
+ try {
+ deleteEntryInDB(serviceTemplate.getName(), serviceTemplate.getVersion());
+ modelsProvider.createServiceTemplate(serviceTemplate);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java
index 9a9fc1680..8529c0c9b 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/InstantiationUtils.java
@@ -25,8 +25,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
+import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop;
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
+import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstancePropertiesResponse;
import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand;
import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
@@ -133,11 +135,32 @@ public class InstantiationUtils {
* @throws PfModelException if an error occurs
*/
public static void storeToscaServiceTemplate(String path, CommissioningProvider commissioningProvider)
- throws PfModelException {
+ throws PfModelException, ControlLoopException {
ToscaServiceTemplate template =
yamlTranslator.fromYaml(ResourceUtils.getResourceAsString(path), ToscaServiceTemplate.class);
+ commissioningProvider.deleteControlLoopDefinition(null, null);
+
commissioningProvider.createControlLoopDefinitions(template);
}
+
+ /**
+ * Assert that instance properties has been properly saved.
+ *
+ * @param response InstancePropertiesResponse
+ * @throws PfModelException if an error occurs
+ */
+ public static void assertInstancePropertiesResponse(InstancePropertiesResponse response) throws PfModelException {
+
+ assertThat(response).isNotNull();
+ assertThat(response.getErrorDetails()).isNull();
+ assertThat(response.getAffectedInstanceProperties()).hasSize(8);
+
+ boolean containsInstance = response.getAffectedInstanceProperties().stream()
+ .anyMatch(identifier -> identifier.getName().contains("_Instance"));
+
+ assertThat(containsInstance).isTrue();
+
+ }
}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java
index 6c9674dec..41c55dd2d 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/instantiation/rest/InstantiationControllerTest.java
@@ -28,6 +28,9 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.core.Response;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@@ -35,12 +38,17 @@ import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoop
import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoops;
import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationCommand;
import org.onap.policy.clamp.controlloop.models.messages.rest.instantiation.InstantiationResponse;
-import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
import org.onap.policy.clamp.controlloop.runtime.instantiation.ControlLoopInstantiationProvider;
import org.onap.policy.clamp.controlloop.runtime.instantiation.InstantiationUtils;
+import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
import org.onap.policy.clamp.controlloop.runtime.main.rest.InstantiationController;
import org.onap.policy.clamp.controlloop.runtime.util.rest.CommonRestController;
+import org.onap.policy.common.utils.coder.YamlJsonTranslator;
+import org.onap.policy.common.utils.resources.ResourceUtils;
+import org.onap.policy.models.provider.PolicyModelsProvider;
+import org.onap.policy.models.provider.PolicyModelsProviderFactory;
import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@@ -72,24 +80,29 @@ class InstantiationControllerTest extends CommonRestController {
private static final String INSTANTIATION_COMMAND_ENDPOINT = "instantiation/command";
+ private static ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate();
+
+ private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
+
+
@Autowired
- private ControlLoopInstantiationProvider instantiationProvider;
+ private ClRuntimeParameterGroup clRuntimeParameterGroup;
@Autowired
- private CommissioningProvider commissioningProvider;
+ private ControlLoopInstantiationProvider instantiationProvider;
@LocalServerPort
private int randomServerPort;
- /**
- * starts Main and inserts a commissioning template.
- *
- * @throws Exception if an error occurs
- */
+ @BeforeAll
+ public static void setUpBeforeClass() throws Exception {
+ serviceTemplate = yamlTranslator.fromYaml(ResourceUtils.getResourceAsString(TOSCA_TEMPLATE_YAML),
+ ToscaServiceTemplate.class);
+ }
+
@BeforeEach
- public void setUpBeforeClass() throws Exception {
- // to validate control Loop, it needs to define ToscaServiceTemplate
- InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, commissioningProvider);
+ public void populateDb() throws Exception {
+ createEntryInDB();
}
@BeforeEach
@@ -97,6 +110,11 @@ class InstantiationControllerTest extends CommonRestController {
super.setHttpPrefix(randomServerPort);
}
+ @AfterEach
+ public void cleanDatabase() throws Exception {
+ deleteEntryInDB(serviceTemplate.getName(), serviceTemplate.getVersion());
+ }
+
@Test
void testSwagger() throws Exception {
super.testSwagger(INSTANTIATION_ENDPOINT);
@@ -138,6 +156,7 @@ class InstantiationControllerTest extends CommonRestController {
@Test
void testCreate() throws Exception {
+
ControlLoops controlLoopsFromRsc =
InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Create");
@@ -159,6 +178,7 @@ class InstantiationControllerTest extends CommonRestController {
@Test
void testCreateBadRequest() throws Exception {
+
ControlLoops controlLoopsFromRsc =
InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "CreateBadRequest");
@@ -185,7 +205,7 @@ class InstantiationControllerTest extends CommonRestController {
@Test
void testQuery() throws Exception {
- // inserts a ControlLoops to DB
+
var controlLoops = InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Query");
instantiationProvider.createControlLoops(controlLoops);
@@ -203,6 +223,7 @@ class InstantiationControllerTest extends CommonRestController {
@Test
void testUpdate() throws Exception {
+
ControlLoops controlLoopsCreate =
InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Update");
@@ -238,6 +259,7 @@ class InstantiationControllerTest extends CommonRestController {
@Test
void testDelete() throws Exception {
+
ControlLoops controlLoopsFromRsc =
InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Delete");
@@ -259,6 +281,7 @@ class InstantiationControllerTest extends CommonRestController {
@Test
void testDeleteBadRequest() throws Exception {
+
ControlLoops controlLoopsFromRsc =
InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "DelBadRequest");
@@ -293,6 +316,7 @@ class InstantiationControllerTest extends CommonRestController {
@Test
void testCommand() throws Exception {
+
var controlLoops = InstantiationUtils.getControlLoopsFromResource(CL_INSTANTIATION_CREATE_JSON, "Command");
instantiationProvider.createControlLoops(controlLoops);
@@ -313,4 +337,21 @@ class InstantiationControllerTest extends CommonRestController {
assertEquals(command.getOrderedState(), controlLoopsGet.getControlLoopList().get(0).getOrderedState());
}
}
+
+ private synchronized void deleteEntryInDB(String name, String version) throws Exception {
+ try (PolicyModelsProvider modelsProvider = new PolicyModelsProviderFactory()
+ .createPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters())) {
+ if (!modelsProvider.getServiceTemplateList(null, null).isEmpty()) {
+ modelsProvider.deleteServiceTemplate(name, version);
+ }
+ }
+ }
+
+ private synchronized void createEntryInDB() throws Exception {
+ try (PolicyModelsProvider modelsProvider = new PolicyModelsProviderFactory()
+ .createPolicyModelsProvider(clRuntimeParameterGroup.getDatabaseProviderParameters())) {
+ deleteEntryInDB(serviceTemplate.getName(), serviceTemplate.getVersion());
+ modelsProvider.createServiceTemplate(serviceTemplate);
+ }
+ }
}
diff --git a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java
index 10116a240..73ec4e482 100644
--- a/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java
+++ b/runtime-controlloop/src/test/java/org/onap/policy/clamp/controlloop/runtime/supervision/comm/SupervisionMessagesTest.java
@@ -23,7 +23,6 @@ package org.onap.policy.clamp.controlloop.runtime.supervision.comm;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -44,7 +43,6 @@ import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.Parti
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdate;
import org.onap.policy.clamp.controlloop.models.messages.dmaap.participant.ParticipantUpdateAck;
import org.onap.policy.clamp.controlloop.runtime.commissioning.CommissioningProvider;
-import org.onap.policy.clamp.controlloop.runtime.instantiation.InstantiationUtils;
import org.onap.policy.clamp.controlloop.runtime.main.parameters.ClRuntimeParameterGroup;
import org.onap.policy.clamp.controlloop.runtime.monitoring.MonitoringProvider;
import org.onap.policy.clamp.controlloop.runtime.supervision.SupervisionHandler;
@@ -70,10 +68,12 @@ class SupervisionMessagesTest extends CommonRestController {
private static final Object lockit = new Object();
private static final CommInfrastructure INFRA = CommInfrastructure.NOOP;
private static final String TOPIC = "my-topic";
+ private static final long interval = 1000;
private static SupervisionHandler supervisionHandler;
private static CommissioningProvider commissioningProvider;
private static ControlLoopProvider clProvider;
private static PolicyModelsProvider modelsProvider;
+ private static ParticipantProvider participantProvider;
private static final YamlJsonTranslator yamlTranslator = new YamlJsonTranslator();
private static final String TOSCA_TEMPLATE_YAML =
"src/test/resources/rest/servicetemplates/pmsh_multiple_cl_tosca.yaml";
@@ -91,11 +91,13 @@ class SupervisionMessagesTest extends CommonRestController {
modelsProvider = CommonTestData.getPolicyModelsProvider(controlLoopParameters.getDatabaseProviderParameters());
clProvider = new ControlLoopProvider(controlLoopParameters.getDatabaseProviderParameters());
+ participantProvider = new ParticipantProvider(controlLoopParameters.getDatabaseProviderParameters());
+
var participantStatisticsProvider =
new ParticipantStatisticsProvider(controlLoopParameters.getDatabaseProviderParameters());
var clElementStatisticsProvider =
new ClElementStatisticsProvider(controlLoopParameters.getDatabaseProviderParameters());
- commissioningProvider = new CommissioningProvider(modelsProvider, clProvider);
+ commissioningProvider = new CommissioningProvider(modelsProvider, clProvider, null, participantProvider);
var monitoringProvider =
new MonitoringProvider(participantStatisticsProvider, clElementStatisticsProvider, clProvider);
var participantProvider = new ParticipantProvider(controlLoopParameters.getDatabaseProviderParameters());
@@ -128,6 +130,7 @@ class SupervisionMessagesTest extends CommonRestController {
ToscaServiceTemplate serviceTemplate = yamlTranslator.fromYaml(
ResourceUtils.getResourceAsString(TOSCA_SERVICE_TEMPLATE_YAML), ToscaServiceTemplate.class);
+ // List<ToscaNodeTemplate> listOfTemplates = commissioningProvider.getControlLoopDefinitions(null, null);
commissioningProvider.createControlLoopDefinitions(serviceTemplate);
participantRegisterListener.onTopicEvent(INFRA, TOPIC, null, participantRegisterMsg);
}
@@ -177,9 +180,6 @@ class SupervisionMessagesTest extends CommonRestController {
@Test
void testSendParticipantUpdate() throws Exception {
- InstantiationUtils.storeToscaServiceTemplate(TOSCA_TEMPLATE_YAML, commissioningProvider);
- commissioningProvider.getToscaServiceTemplate(null, null);
-
final ParticipantUpdate participantUpdateMsg = new ParticipantUpdate();
participantUpdateMsg.setParticipantId(getParticipantId());
participantUpdateMsg.setTimestamp(Instant.now());
@@ -209,7 +209,7 @@ class SupervisionMessagesTest extends CommonRestController {
participantUpdateMsg.setToscaServiceTemplate(toscaServiceTemplate);
synchronized (lockit) {
ParticipantUpdatePublisher participantUpdatePublisher =
- new ParticipantUpdatePublisher(commissioningProvider);
+ new ParticipantUpdatePublisher(modelsProvider);
participantUpdatePublisher.active(Collections.singletonList(Mockito.mock(TopicSink.class)));
participantUpdatePublisher.send(participantUpdateMsg);
}
diff --git a/runtime-controlloop/src/test/resources/META-INF/persistence.xml b/runtime-controlloop/src/test/resources/META-INF/persistence.xml
index 6e31cca47..c4e2e8d55 100644
--- a/runtime-controlloop/src/test/resources/META-INF/persistence.xml
+++ b/runtime-controlloop/src/test/resources/META-INF/persistence.xml
@@ -104,6 +104,7 @@
<class>org.onap.policy.models.tosca.simple.concepts.JpaToscaTopologyTemplate</class>
<class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoop</class>
<class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaControlLoopElement</class>
+ <class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipant</class>
<class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaParticipantStatistics</class>
<class>org.onap.policy.clamp.controlloop.models.controlloop.persistence.concepts.JpaClElementStatistics</class>
diff --git a/runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh b/runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh
index 5e661777b..5e661777b 100644..100755
--- a/runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh
+++ b/runtime-controlloop/src/test/resources/testscripts/listenOnTopic.sh
diff --git a/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java b/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java
index 5fefc6d79..62614e729 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/authorization/AuthorizationController.java
@@ -89,8 +89,8 @@ public class AuthorizationController {
*/
public void authorize(Exchange camelExchange, String typeVar, String instanceVar,
String action) {
- String type = refProp.getStringValue(PERM_PREFIX + typeVar);
- String instance = refProp.getStringValue(PERM_INSTANCE);
+ var type = refProp.getStringValue(PERM_PREFIX + typeVar);
+ var instance = refProp.getStringValue(PERM_INSTANCE);
if (null == type || type.isEmpty()) {
// authorization is turned off, since the permission is not defined
@@ -100,8 +100,8 @@ public class AuthorizationController {
instance = instanceVar;
}
String principalName = AuthorizationController.getPrincipalName(SecurityContextHolder.getContext());
- SecureServicePermission perm = SecureServicePermission.create(type, instance, action);
- Date startTime = new Date();
+ var perm = SecureServicePermission.create(type, instance, action);
+ var startTime = new Date();
LoggingUtils.setTargetContext("Clamp", "authorize");
LoggingUtils.setTimeContext(startTime, new Date());
logger.debug(LoggerUtils.SECURITY_LOG_MARKER, "checking if {} has permission: {}", principalName, perm);
@@ -148,7 +148,7 @@ public class AuthorizationController {
}
protected boolean hasRole(String role) {
- Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ var authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return false;
}
@@ -168,8 +168,8 @@ public class AuthorizationController {
* @return the clds info
*/
public ClampInformation getClampInformation() {
- ClampInformation clampInfo = new ClampInformation();
- Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
+ var clampInfo = new ClampInformation();
+ var authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return new ClampInformation();
}
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 8b0056c0a..229d664be 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
@@ -71,7 +71,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@EnableJpaAuditing
public class Application extends SpringBootServletInitializer {
- protected static final Logger logger = LoggerFactory.getLogger(Application.class);
+ protected static final Logger appLogger = LoggerFactory.getLogger(Application.class);
// This settings is an additional one to Spring config,
// only if we want to have an additional port automatically redirected to
// HTTPS
@@ -120,7 +120,7 @@ public class Application extends SpringBootServletInitializer {
*/
@Bean
public ServletRegistrationBean<ClampServlet> camelServletRegistrationBean() throws IOException {
- logger.info("{} (v {} ), {}, {}", ResourceFileUtils.getResourceAsString("boot-message.txt"),
+ appLogger.info("{} (v {} ), {}, {}", ResourceFileUtils.getResourceAsString("boot-message.txt"),
ClampVersioning.getCldsVersionFromProps(), System.getProperty("line.separator"),
getSslExpirationDate());
var registration = new ServletRegistrationBean<ClampServlet>(new ClampServlet(), "/restservices/clds/*");
@@ -149,7 +149,7 @@ public class Application extends SpringBootServletInitializer {
private Connector createRedirectConnector(int redirectSecuredPort) {
if (redirectSecuredPort <= 0) {
- logger.warn(
+ appLogger.warn(
"HTTP port redirection to HTTPS is disabled because the HTTPS"
+ " port is 0 (random port) or -1 (Connector disabled)");
return null;
@@ -183,7 +183,7 @@ public class Application extends SpringBootServletInitializer {
result.append("* NONE HAS been configured");
}
} catch (CertificateException | NoSuchAlgorithmException | KeyStoreException e) {
- logger.warn("SSL certificate access error", e);
+ appLogger.warn("SSL certificate access error", e);
}
return result.toString();
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java b/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java
index 428f02a93..0e520dec1 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/ClampServlet.java
@@ -73,7 +73,7 @@ public class ClampServlet extends CamelHttpTransportServlet {
private static List<SecureServicePermission> permissionList;
private synchronized List<String> loadDynamicAuthenticationClasses() {
- WebApplicationContext webAppContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
+ var webAppContext = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
if (webAppContext != null) {
String authClassProperty = webAppContext.getEnvironment().getProperty(AUTHENTICATION_CLASS);
if (!StringUtils.isBlank(authClassProperty)) {
@@ -130,14 +130,14 @@ public class ClampServlet extends CamelHttpTransportServlet {
*/
@Override
protected void doService(HttpServletRequest request, HttpServletResponse response) {
- Principal principal = request.getUserPrincipal();
+ var principal = request.getUserPrincipal();
if (principal != null && loadDynamicAuthenticationClasses().stream()
.anyMatch(className -> className.equals(principal.getClass().getName()))) {
// When AAF is enabled, there is a need to provision the permissions to Spring
// system
List<GrantedAuthority> grantedAuths = new ArrayList<>();
for (SecureServicePermission perm : getPermissionList()) {
- String permString = perm.toString();
+ var permString = perm.toString();
if (request.isUserInRole(permString)) {
grantedAuths.add(new SimpleGrantedAuthority(permString));
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java b/runtime/src/main/java/org/onap/policy/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java
index f66a09c41..1f71fc843 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/TomcatEmbeddedServletContainerFactoryRedirection.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -43,9 +43,9 @@ public class TomcatEmbeddedServletContainerFactoryRedirection extends TomcatServ
*/
@Override
protected void postProcessContext(Context context) {
- SecurityConstraint securityConstraint = new SecurityConstraint();
+ var securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
- SecurityCollection collection = new SecurityCollection();
+ var collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java b/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java
index cc15f0f9e..27f706d77 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/client/CdsServices.java
@@ -4,7 +4,7 @@
* ================================================================================
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* ================================================================================
- * Modifications Copyright (C) 2021 AT&T.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -71,8 +71,8 @@ public class CdsServices {
public CdsBpWorkFlowListResponse getBlueprintWorkflowList(String blueprintName, String blueprintVersion) {
LoggingUtils.setTargetContext("CDS", "getBlueprintWorkflowList");
- try (ProducerTemplate producerTemplate = camelContext.createProducerTemplate()) {
- Exchange exchangeResponse =
+ try (var producerTemplate = camelContext.createProducerTemplate()) {
+ var exchangeResponse =
producerTemplate.send("direct:get-blueprint-workflow-list", ExchangeBuilder.anExchange(camelContext)
.withProperty("blueprintName", blueprintName)
.withProperty("blueprintVersion", blueprintVersion)
@@ -83,7 +83,7 @@ public class CdsServices {
String cdsResponse = (String) exchangeResponse.getIn().getBody();
logger.info("getBlueprintWorkflowList, response from CDS: {}", cdsResponse);
LoggingUtils.setResponseContext("0", "Get Blueprint workflow list", this.getClass().getName());
- Date startTime = new Date();
+ var startTime = new Date();
LoggingUtils.setTimeContext(startTime, new Date());
return JsonUtils.GSON_JPA_MODEL.fromJson(cdsResponse, CdsBpWorkFlowListResponse.class);
} else {
@@ -107,8 +107,8 @@ public class CdsServices {
String workflow) {
LoggingUtils.setTargetContext("CDS", "getWorkflowInputProperties");
- try (ProducerTemplate producerTemplate = camelContext.createProducerTemplate()) {
- Exchange exchangeResponse = producerTemplate
+ try (var producerTemplate = camelContext.createProducerTemplate()) {
+ var exchangeResponse = producerTemplate
.send("direct:get-blueprint-workflow-input-properties", ExchangeBuilder.anExchange(camelContext)
.withBody(getCdsPayloadForWorkFlow(blueprintName, blueprintVersion, workflow))
.withProperty("raiseHttpExceptionFlag", false).build());
@@ -118,7 +118,7 @@ public class CdsServices {
logger.info("getWorkflowInputProperties, response from CDS: {}", cdsResponse);
LoggingUtils
.setResponseContext("0", "Get Blueprint workflow input properties", this.getClass().getName());
- Date startTime = new Date();
+ var startTime = new Date();
LoggingUtils.setTimeContext(startTime, new Date());
return parseCdsResponse(cdsResponse);
} else {
@@ -131,11 +131,11 @@ public class CdsServices {
}
protected JsonObject parseCdsResponse(String response) {
- JsonObject root = JsonParser.parseString(response).getAsJsonObject();
- JsonObject inputs = root.getAsJsonObject("workFlowData").getAsJsonObject("inputs");
- JsonObject dataTypes = root.getAsJsonObject("dataTypes");
+ var root = JsonParser.parseString(response).getAsJsonObject();
+ var inputs = root.getAsJsonObject("workFlowData").getAsJsonObject("inputs");
+ var dataTypes = root.getAsJsonObject("dataTypes");
- JsonObject workFlowProperties = new JsonObject();
+ var workFlowProperties = new JsonObject();
workFlowProperties.add("inputs", getInputProperties(inputs, dataTypes, new JsonObject()));
return workFlowProperties;
}
@@ -147,8 +147,8 @@ public class CdsServices {
for (Map.Entry<String, JsonElement> entry : inputs.entrySet()) {
String key = entry.getKey();
- JsonObject inputProperty = inputs.getAsJsonObject(key);
- String type = inputProperty.get(TYPE).getAsString();
+ var inputProperty = inputs.getAsJsonObject(key);
+ var type = inputProperty.get(TYPE).getAsString();
if (isComplexType(type, dataTypes)) {
inputObject.add(key, handleComplexType(type, dataTypes));
} else if (LIST.equalsIgnoreCase(type)) {
@@ -168,10 +168,10 @@ public class CdsServices {
throw new CdsParametersException("Entry schema is null for " + propertyName);
}
- String type = inputProperty.get("entry_schema").getAsJsonObject().get(
+ var type = inputProperty.get("entry_schema").getAsJsonObject().get(
TYPE).getAsString();
if (dataTypes != null && dataTypes.get(type) != null) {
- JsonObject jsonObject = new JsonObject();
+ var jsonObject = new JsonObject();
jsonObject.addProperty(TYPE, LIST);
jsonObject.add(PROPERTIES, getPropertiesObject(type, dataTypes));
inputObject.add(propertyName, jsonObject);
@@ -181,15 +181,15 @@ public class CdsServices {
}
private JsonObject handleComplexType(String key, JsonObject dataTypes) {
- JsonObject jsonObject = new JsonObject();
+ var jsonObject = new JsonObject();
jsonObject.addProperty(TYPE, "object");
jsonObject.add(PROPERTIES, getPropertiesObject(key, dataTypes));
return jsonObject;
}
private JsonObject getPropertiesObject(String key, JsonObject dataTypes) {
- JsonObject properties = dataTypes.get(key).getAsJsonObject().get(PROPERTIES).getAsJsonObject();
- JsonObject object = new JsonObject();
+ var properties = dataTypes.get(key).getAsJsonObject().get(PROPERTIES).getAsJsonObject();
+ var object = new JsonObject();
getInputProperties(properties, dataTypes, object);
return object;
}
@@ -218,7 +218,7 @@ public class CdsServices {
* @return returns payload in json format
*/
public String getCdsPayloadForWorkFlow(String blueprintName, String version, String workflow) {
- JsonObject jsonObject = new JsonObject();
+ var jsonObject = new JsonObject();
jsonObject.addProperty("blueprintName", blueprintName);
jsonObject.addProperty("version", version);
jsonObject.addProperty("returnContent", "json");
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java b/runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java
index af9c1b57b..524733115 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/client/DcaeInventoryServices.java
@@ -70,7 +70,7 @@ public class DcaeInventoryServices {
}
private int getTotalCountFromDcaeInventoryResponse(String responseStr) throws ParseException {
- JSONParser parser = new JSONParser();
+ var parser = new JSONParser();
Object obj0 = parser.parse(responseStr);
JSONObject jsonObj = (JSONObject) obj0;
Long totalCount = (Long) jsonObj.get("totalCount");
@@ -78,7 +78,7 @@ public class DcaeInventoryServices {
}
private DcaeInventoryResponse getItemsFromDcaeInventoryResponse(String responseStr) throws ParseException {
- JSONParser parser = new JSONParser();
+ var parser = new JSONParser();
Object obj0 = parser.parse(responseStr);
JSONObject jsonObj = (JSONObject) obj0;
JSONArray itemsArray = (JSONArray) jsonObj.get("items");
@@ -100,18 +100,18 @@ public class DcaeInventoryServices {
throws IOException, ParseException, InterruptedException {
LoggingUtils.setTargetContext("DCAE", "getDcaeInformation");
- int retryInterval = 0;
- int retryLimit = 1;
+ var retryInterval = 0;
+ var retryLimit = 1;
if (refProp.getStringValue(DCAE_INVENTORY_RETRY_LIMIT) != null) {
retryLimit = Integer.valueOf(refProp.getStringValue(DCAE_INVENTORY_RETRY_LIMIT));
}
if (refProp.getStringValue(DCAE_INVENTORY_RETRY_INTERVAL) != null) {
retryInterval = Integer.valueOf(refProp.getStringValue(DCAE_INVENTORY_RETRY_INTERVAL));
}
- for (int i = 0; i < retryLimit; i++) {
+ for (var i = 0; i < retryLimit; i++) {
logger.info(LoggerUtils.METRIC_LOG_MARKER, "Attempt n° {} to contact DCAE inventory", i);
- try (ProducerTemplate producerTemplate = camelContext.createProducerTemplate()) {
- Exchange exchangeResponse = producerTemplate
+ try (var producerTemplate = camelContext.createProducerTemplate()) {
+ var exchangeResponse = producerTemplate
.send("direct:get-dcae-blueprint-inventory", ExchangeBuilder.anExchange(camelContext)
.withProperty("blueprintResourceId", resourceUuid)
.withProperty("blueprintServiceId", serviceUuid)
@@ -127,7 +127,7 @@ public class DcaeInventoryServices {
if (totalCount > 0) {
logger.info("getDcaeInformation, answer from DCAE inventory: {}", dcaeResponse);
LoggingUtils.setResponseContext("0", "Get Dcae Information success", this.getClass().getName());
- Date startTime = new Date();
+ var startTime = new Date();
LoggingUtils.setTimeContext(startTime, new Date());
return getItemsFromDcaeInventoryResponse(dcaeResponse);
} else {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java
index f11e16733..34f0662c7 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/ClampProperties.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -63,7 +63,7 @@ public class ClampProperties {
* @return The string with the value
*/
public String getStringValue(String key1, String key2) {
- String value = getStringValue(key1 + "." + key2);
+ var value = getStringValue(key1 + "." + key2);
if (value == null || value.length() == 0) {
value = getStringValue(key1);
}
@@ -79,7 +79,7 @@ public class ClampProperties {
* @throws IOException In case of issues with the JSON parser
*/
public String getFileContent(String key) throws IOException {
- String fileReference = getStringValue(key);
+ var fileReference = getStringValue(key);
return (fileReference != null) ? getFileContentFromPath(fileReference) : null;
}
@@ -94,12 +94,12 @@ public class ClampProperties {
* @throws IOException In case of issues with the JSON parser
*/
public String getFileContent(String key1, String key2) throws IOException {
- String fileReference = getStringValue(key1, key2);
+ var fileReference = getStringValue(key1, key2);
return (fileReference != null) ? getFileContentFromPath(fileReference) : null;
}
private String getFileContentFromPath(String filepath) throws IOException {
- URL url = appContext.getResource(filepath).getURL();
+ var url = appContext.getResource(filepath).getURL();
return IOUtils.toString(url, StandardCharsets.UTF_8);
}
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultDictionaryElements.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultDictionaryElements.java
index 27cf0b941..3b0bc68fd 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultDictionaryElements.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultDictionaryElements.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,40 +49,40 @@ public class DefaultDictionaryElements {
private void preProvisionDefaultActors() {
// Set up dictionary elements
- Dictionary actorDictionary = new Dictionary();
+ var actorDictionary = new Dictionary();
actorDictionary.setName("DefaultActors");
actorDictionary.setSecondLevelDictionary(0);
actorDictionary.setSubDictionaryType("");
- DictionaryElement elementSo = new DictionaryElement();
+ var elementSo = new DictionaryElement();
elementSo.setName("SO");
elementSo.setShortName("SO");
elementSo.setType("string");
elementSo.setDescription("SO component");
actorDictionary.addDictionaryElements(elementSo);
- DictionaryElement elementSdnc = new DictionaryElement();
+ var elementSdnc = new DictionaryElement();
elementSdnc.setName("SDNC");
elementSdnc.setShortName("SDNC");
elementSdnc.setType("string");
elementSdnc.setDescription("SDNC component");
actorDictionary.addDictionaryElements(elementSdnc);
- DictionaryElement elementAppc = new DictionaryElement();
+ var elementAppc = new DictionaryElement();
elementAppc.setName("APPC");
elementAppc.setShortName("APPC");
elementAppc.setType("string");
elementAppc.setDescription("APPC component");
actorDictionary.addDictionaryElements(elementAppc);
- DictionaryElement elementVfc = new DictionaryElement();
+ var elementVfc = new DictionaryElement();
elementVfc.setName("VFC");
elementVfc.setShortName("VFC");
elementVfc.setType("string");
elementVfc.setDescription("VFC component");
actorDictionary.addDictionaryElements(elementVfc);
- DictionaryElement elementSdnr = new DictionaryElement();
+ var elementSdnr = new DictionaryElement();
elementSdnr.setName("SDNR");
elementSdnr.setShortName("SDNR");
elementSdnr.setType("string");
@@ -94,68 +94,68 @@ public class DefaultDictionaryElements {
private void preProvisionDefaultOperations() {
// Set up dictionary elements
- Dictionary operationDictionary = new Dictionary();
+ var operationDictionary = new Dictionary();
operationDictionary.setName("DefaultOperations");
operationDictionary.setSecondLevelDictionary(0);
operationDictionary.setSubDictionaryType("");
- DictionaryElement elementRestart = new DictionaryElement();
+ var elementRestart = new DictionaryElement();
elementRestart.setName("Restart");
elementRestart.setShortName("Restart (APPC operation)");
elementRestart.setType("string");
elementRestart.setDescription("APPC operation");
operationDictionary.addDictionaryElements(elementRestart);
- DictionaryElement elementRebuild = new DictionaryElement();
+ var elementRebuild = new DictionaryElement();
elementRebuild.setName("Rebuild");
elementRebuild.setShortName("Rebuild (APPC operation)");
elementRebuild.setType("string");
elementRebuild.setDescription("APPC operation");
operationDictionary.addDictionaryElements(elementRebuild);
- DictionaryElement elementMigrate = new DictionaryElement();
+ var elementMigrate = new DictionaryElement();
elementMigrate.setName("Migrate");
elementMigrate.setShortName("Migrate (APPC operation)");
elementMigrate.setType("string");
elementMigrate.setDescription("APPC operation");
operationDictionary.addDictionaryElements(elementMigrate);
- DictionaryElement elementHealthCheck = new DictionaryElement();
+ var elementHealthCheck = new DictionaryElement();
elementHealthCheck.setName("Health-Check");
elementHealthCheck.setShortName("Health-Check (APPC operation)");
elementHealthCheck.setType("string");
elementHealthCheck.setDescription("APPC operation");
operationDictionary.addDictionaryElements(elementHealthCheck);
- DictionaryElement elementModifyConfig = new DictionaryElement();
+ var elementModifyConfig = new DictionaryElement();
elementModifyConfig.setName("ModifyConfig");
elementModifyConfig.setShortName("ModifyConfig (APPC/VFC operation)");
elementModifyConfig.setType("string");
elementModifyConfig.setDescription("APPC/VFC operation");
operationDictionary.addDictionaryElements(elementModifyConfig);
- DictionaryElement elementVfModuleCreate = new DictionaryElement();
+ var elementVfModuleCreate = new DictionaryElement();
elementVfModuleCreate.setName("VF Module Create");
elementVfModuleCreate.setShortName("VF Module Create (SO operation)");
elementVfModuleCreate.setType("string");
elementVfModuleCreate.setDescription("SO operation");
operationDictionary.addDictionaryElements(elementVfModuleCreate);
- DictionaryElement elementVfModuleDelete = new DictionaryElement();
+ var elementVfModuleDelete = new DictionaryElement();
elementVfModuleDelete.setName("VF Module Delete");
elementVfModuleDelete.setShortName("VF Module Delete (SO operation)");
elementVfModuleDelete.setType("string");
elementVfModuleDelete.setDescription("SO operation");
operationDictionary.addDictionaryElements(elementVfModuleDelete);
- DictionaryElement elementReroute = new DictionaryElement();
+ var elementReroute = new DictionaryElement();
elementReroute.setName("Reroute");
elementReroute.setShortName("Reroute (SDNC operation)");
elementReroute.setType("string");
elementReroute.setDescription("SDNC operation");
operationDictionary.addDictionaryElements(elementReroute);
- DictionaryElement elementBandwidthOnDemand = new DictionaryElement();
+ var elementBandwidthOnDemand = new DictionaryElement();
elementBandwidthOnDemand.setName("BandwidthOnDemand");
elementBandwidthOnDemand.setShortName("BandwidthOnDemand (SDNC operation)");
elementBandwidthOnDemand.setType("string");
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultUserConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultUserConfiguration.java
index 136ed3c0a..32040bd50 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultUserConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/DefaultUserConfiguration.java
@@ -95,7 +95,7 @@ public class DefaultUserConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) {
// configure algorithm used for password hashing
- final PasswordEncoder passwordEncoder = getPasswordEncoder();
+ final var passwordEncoder = getPasswordEncoder();
try {
CldsUser[] usersList = loadUsers();
@@ -137,4 +137,5 @@ public class DefaultUserConfiguration extends WebSecurityConfigurerAdapter {
"Invalid clamp.config.security.encoder value. 'bcrypt' is the only option at this time.");
}
}
-} \ No newline at end of file
+}
+
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/SslConfig.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/SslConfig.java
index a72cffd09..7ab1e8348 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/SslConfig.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/SslConfig.java
@@ -51,11 +51,11 @@ public class SslConfig {
@Bean
WebServerFactoryCustomizer<TomcatServletWebServerFactory> tomcatCustomizer(ServerProperties serverProperties,
ResourceLoader resourceLoader) {
- return (tomcat) -> tomcat.setSslStoreProvider(new SslStoreProvider() {
+ return tomcat -> tomcat.setSslStoreProvider(new SslStoreProvider() {
@Override
public KeyStore getKeyStore() throws KeyStoreException,
NoSuchAlgorithmException, CertificateException, IOException {
- KeyStore keystore = KeyStore.getInstance(env.getProperty("server.ssl.key-store-type"));
+ var keystore = KeyStore.getInstance(env.getProperty("server.ssl.key-store-type"));
String password = PassDecoder.decode(env.getProperty("server.ssl.key-store-password"),
env.getProperty("clamp.config.keyFile"));
keystore.load(ResourceFileUtils.getResourceAsStream(env.getProperty("server.ssl.key-store")),
@@ -66,7 +66,7 @@ public class SslConfig {
@Override
public KeyStore getTrustStore() throws KeyStoreException,
NoSuchAlgorithmException, CertificateException, IOException {
- KeyStore truststore = KeyStore.getInstance("JKS");
+ var truststore = KeyStore.getInstance("JKS");
String password = PassDecoder.decode(env.getProperty("server.ssl.trust-store-password"),
env.getProperty("clamp.config.keyFile"));
truststore.load(
@@ -81,7 +81,7 @@ public class SslConfig {
@Bean
WebServerFactoryCustomizer<TomcatServletWebServerFactory> tomcatSslCustomizer(ServerProperties serverProperties,
ResourceLoader resourceLoader) {
- return (tomcat) -> tomcat.setSsl(new Ssl() {
+ return tomcat -> tomcat.setSsl(new Ssl() {
@Override
public String getKeyPassword() {
return PassDecoder.decode(env.getProperty("server.ssl.key-password"),
@@ -94,4 +94,5 @@ public class SslConfig {
}
});
}
-} \ No newline at end of file
+}
+
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java
index 5d8cbb05e..71986f6fb 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcControllersConfiguration.java
@@ -69,7 +69,7 @@ public class SdcControllersConfiguration {
*/
@PostConstruct
public void loadConfiguration() throws IOException {
- try (InputStreamReader controllerFile = new InputStreamReader(
+ try (var controllerFile = new InputStreamReader(
appContext.getResource(sdcControllerFile).getInputStream(), StandardCharsets.UTF_8)) {
jsonRootNode = JsonUtils.GSON.fromJson(controllerFile, JsonObject.class);
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
index 67060d776..5119dc86e 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
@@ -108,7 +108,7 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
private String getStringConfig(String key) {
if (jsonRootNode != null && jsonRootNode.get(key) != null) {
- String config = jsonRootNode.get(key).getAsString();
+ var config = jsonRootNode.get(key).getAsString();
return config.isEmpty() ? null : config;
}
return null;
@@ -138,7 +138,7 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
@Override
public String getConsumerGroup() {
if (jsonRootNode != null && jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME) != null) {
- String config = jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME).getAsString();
+ var config = jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME).getAsString();
return "NULL".equals(config) || config.isEmpty() ? null : config;
}
return null;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/CldsConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/CldsConfiguration.java
index 72f09ce13..083147211 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/CldsConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/CldsConfiguration.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -43,13 +43,13 @@ public class CldsConfiguration {
/**
* This loads the file system.properties.
- *
+ *
* @return The PropertiesFactoryBean
*/
@Bean(name = "mapper")
public PropertiesFactoryBean mapper() {
- PropertiesFactoryBean bean = new PropertiesFactoryBean();
+ var bean = new PropertiesFactoryBean();
bean.setLocation(appContext.getResource(refProp.getStringValue("files.systemProperties")));
return bean;
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/SdcControllerConfiguration.java b/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/SdcControllerConfiguration.java
index f2a0d70d8..bee1acf2b 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/SdcControllerConfiguration.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/config/spring/SdcControllerConfiguration.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -63,10 +63,10 @@ public class SdcControllerConfiguration {
*/
@PostConstruct
public void loadSdcControllers() {
- SdcControllersConfiguration sdcControllersConfig = getSdcControllersConfiguration();
+ var sdcControllersConfig = getSdcControllersConfiguration();
sdcControllersConfig.getAllDefinedControllers().forEach((key, value) -> {
logger.info("Creating controller instance: {}", key);
- SdcSingleController sdcController = new SdcSingleController(clampProp, csarInstaller, value, null);
+ var sdcController = new SdcSingleController(clampProp, csarInstaller, value, null);
sdcControllersList.add(sdcController);
});
}
@@ -107,4 +107,4 @@ public class SdcControllerConfiguration {
public SdcControllersConfiguration getSdcControllersConfiguration() {
return new SdcControllersConfiguration();
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java b/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java
index 2c3c95885..eb9de056c 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/filter/ClampCadiFilter.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -147,7 +147,7 @@ public class ClampCadiFilter extends CadiFilter {
try {
String certHeader = ((HttpServletRequest) request).getHeader("X-SSL-Cert");
if (certHeader != null) {
- CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
+ var certificateFactory = CertificateFactory.getInstance("X.509");
X509Certificate cert = (X509Certificate) certificateFactory
.generateCertificate(new ByteArrayInputStream(
URLDecoder.decode(certHeader, StandardCharsets.UTF_8.toString()).getBytes()));
@@ -173,9 +173,9 @@ public class ClampCadiFilter extends CadiFilter {
}
private String convertSpringToPath(String fileName) {
- try (InputStream ioFile = appContext.getResource(fileName).getInputStream()) {
+ try (var ioFile = appContext.getResource(fileName).getInputStream()) {
if (!fileName.contains("file:")) {
- File targetFile = new File(appContext.getResource(fileName).getFilename());
+ var targetFile = new File(appContext.getResource(fileName).getFilename());
java.nio.file.Files.copy(ioFile, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
return targetFile.getPath();
} else {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java b/runtime/src/main/java/org/onap/policy/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java
index a3b42524e..f7945d092 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/model/cds/CdsBpWorkFlowListResponse.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2020 Huawei Technologies Co., Ltd.
* ================================================================================
+ * Modifications Copyright (c) 2021 AT&T Intellectual Property. 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
@@ -38,7 +40,7 @@ public class CdsBpWorkFlowListResponse {
private String version;
@Expose
- private List<String> workflows = new LinkedList<String>();
+ private List<String> workflows = new LinkedList<>();
public String getBlueprintName() {
return blueprintName;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java b/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java
index 72ae61359..9f5300a9f 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/model/dcae/DcaeInventoryResponse.java
@@ -6,6 +6,8 @@
* Copyright (C) 2019 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2021 AT&T Intellectual Property. 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
@@ -95,8 +97,8 @@ public class DcaeInventoryResponse implements Comparable<DcaeInventoryResponse>
@Override
public int compareTo(DcaeInventoryResponse otherResponse) {
- int thisResourceId = Integer.parseInt(this.asdcResourceId);
- int otherResourceId = Integer.parseInt(otherResponse.getAsdcResourceId());
- return (thisResourceId < otherResourceId ? -1 : (thisResourceId > otherResourceId ? 1 : 0));
+ var thisResourceId = Integer.parseInt(this.asdcResourceId);
+ var otherResourceId = Integer.parseInt(otherResponse.getAsdcResourceId());
+ return Integer.compare(thisResourceId, otherResourceId);
}
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/SdcSingleController.java b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/SdcSingleController.java
index 317929268..a2542d51e 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/SdcSingleController.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/SdcSingleController.java
@@ -93,7 +93,7 @@ public class SdcSingleController {
*/
@Override
public void activateCallback(INotificationData notificationData) {
- Date startTime = new Date();
+ var startTime = new Date();
logger.info("Receive a callback notification in SDC, nb of resources: {}",
notificationData.getResources().size());
sdcController.treatNotification(notificationData);
@@ -194,7 +194,7 @@ public class SdcSingleController {
logger.info("Attempt to start the SDC Controller: {}", sdcConfig.getSdcControllerName());
result = this.distributionClient.start();
if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
- logger.error("SDC distribution client start failed with reason:" + result.getDistributionMessageResult());
+ logger.error("SDC distribution client start failed with reason: {}", result.getDistributionMessageResult());
this.changeControllerStatus(SdcSingleControllerStatus.STOPPED);
throw new SdcControllerException(
"Startup of the SDC Controller failed with reason: " + result.getDistributionMessageResult());
@@ -329,7 +329,7 @@ public class SdcSingleController {
try {
downloadResult = distributionClient.download(artifact);
if (null == downloadResult) {
- logger.info("downloadResult is Null for: " + artifact.getArtifactUUID());
+ logger.info("downloadResult is Null for: {}", artifact.getArtifactUUID());
return null;
}
} catch (RuntimeException e) {
@@ -356,7 +356,7 @@ public class SdcSingleController {
event = event + "(" + errorReason + ")";
}
logger.info(event);
- String action = "";
+ var action = "";
try {
IDistributionStatusMessage message = new DistributionStatusMessage(artifactUrl, consumerId, distributionId,
status, timestamp);
@@ -417,7 +417,9 @@ public class SdcSingleController {
} catch (RuntimeException e) {
logger.warn("Unable to send the SDC Notification ({}) due to an exception", status.name(), e);
}
- logger.info("SDC Notification sent successfully ({})", status.name());
+ if (status.name() != null) {
+ logger.info("SDC Notification sent successfully ({})", status.name());
+ }
}
private void sendDownloadStatus(IDistributionStatusMessage message, String errorReason) {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/BlueprintParser.java b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/BlueprintParser.java
index 970c862d1..d301494d9 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/BlueprintParser.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/BlueprintParser.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 Nokia Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2021 AT&T Intellectual Property. 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
@@ -67,7 +69,7 @@ public class BlueprintParser {
/**
* Get all micro services from blueprint.
- *
+ *
* @param blueprintString the blueprint in a String
* @return A set of MircoService
* @throws BlueprintParserException In case of issues with the parsing
@@ -75,11 +77,11 @@ public class BlueprintParser {
public static Set<BlueprintMicroService> getMicroServices(String blueprintString) throws BlueprintParserException {
Set<BlueprintMicroService> microServices = new HashSet<>();
JsonObject blueprintJson = BlueprintParser.convertToJson(blueprintString);
- JsonObject nodeTemplateList = blueprintJson.get(NODE_TEMPLATES).getAsJsonObject();
- JsonObject inputList = blueprintJson.get(INPUT).getAsJsonObject();
+ var nodeTemplateList = blueprintJson.get(NODE_TEMPLATES).getAsJsonObject();
+ var inputList = blueprintJson.get(INPUT).getAsJsonObject();
for (Entry<String, JsonElement> entry : nodeTemplateList.entrySet()) {
- JsonObject nodeTemplate = entry.getValue().getAsJsonObject();
+ var nodeTemplate = entry.getValue().getAsJsonObject();
if (!nodeTemplate.get(TYPE).getAsString().contains(DCAE_NODES_POLICY)
&& nodeTemplate.get(TYPE).getAsString().contains(DCAE_NODES)) {
BlueprintMicroService microService = getNodeRepresentation(entry, nodeTemplateList, inputList);
@@ -99,7 +101,7 @@ public class BlueprintParser {
/**
* Does a fallback to TCA.
- *
+ *
* @return The list of microservices
*/
public static List<BlueprintMicroService> fallbackToOneMicroService() {
@@ -109,9 +111,9 @@ public class BlueprintParser {
static String getName(Entry<String, JsonElement> entry) {
String microServiceYamlName = entry.getKey();
- JsonObject ob = entry.getValue().getAsJsonObject();
+ var ob = entry.getValue().getAsJsonObject();
if (ob.has(PROPERTIES)) {
- JsonObject properties = ob.get(PROPERTIES).getAsJsonObject();
+ var properties = ob.get(PROPERTIES).getAsJsonObject();
if (properties.has(NAME)) {
return properties.get(NAME).getAsString();
}
@@ -120,9 +122,9 @@ public class BlueprintParser {
}
static String getInput(Entry<String, JsonElement> entry) {
- JsonObject ob = entry.getValue().getAsJsonObject();
+ var ob = entry.getValue().getAsJsonObject();
if (ob.has(RELATIONSHIPS)) {
- JsonArray relationships = ob.getAsJsonArray(RELATIONSHIPS);
+ var relationships = ob.getAsJsonArray(RELATIONSHIPS);
for (JsonElement element : relationships) {
String target = getTarget(element.getAsJsonObject());
if (!target.isEmpty()) {
@@ -142,7 +144,7 @@ public class BlueprintParser {
+ elem.getAsJsonObject().get(TARGET).getAsString());
} else {
String property = getPropertyValue(propertyName,
- new AbstractMap.SimpleEntry<String, JsonElement>(
+ new AbstractMap.SimpleEntry<>(
elem.getAsJsonObject().get(TARGET).getAsString(), blueprintNodeTemplateList
.get(elem.getAsJsonObject().get(TARGET).getAsString()).getAsJsonObject()),
blueprintNodeTemplateList, blueprintInputList);
@@ -156,7 +158,7 @@ public class BlueprintParser {
static String getDirectOrInputPropertyValue(String propertyName, JsonObject blueprintInputList,
JsonObject nodeTemplateContent) {
- JsonObject properties = nodeTemplateContent.get(PROPERTIES).getAsJsonObject();
+ var properties = nodeTemplateContent.get(PROPERTIES).getAsJsonObject();
if (properties.has(propertyName)) {
if (properties.get(propertyName).isJsonObject()) {
// it's a blueprint parameter
@@ -173,7 +175,7 @@ public class BlueprintParser {
static String getPropertyValue(String propertyName, Entry<String, JsonElement> nodeTemplateEntry,
JsonObject blueprintNodeTemplateList, JsonObject blueprintIputList) throws BlueprintParserException {
- JsonObject nodeTemplateContent = nodeTemplateEntry.getValue().getAsJsonObject();
+ var nodeTemplateContent = nodeTemplateEntry.getValue().getAsJsonObject();
// Search first in this node template
if (nodeTemplateContent.has(PROPERTIES)) {
String propValue = getDirectOrInputPropertyValue(propertyName, blueprintIputList, nodeTemplateContent);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/ChainGenerator.java b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/ChainGenerator.java
index 10e7a56a4..745d4768d 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/ChainGenerator.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/ChainGenerator.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 Nokia Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (c) 2021 AT&T Intellectual Property. 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
@@ -62,7 +64,7 @@ public class ChainGenerator {
}
private boolean postValidate(LinkedList<BlueprintMicroService> microServices) {
- for (int i = 1; i < microServices.size() - 1; i++) {
+ for (var i = 1; i < microServices.size() - 1; i++) {
BlueprintMicroService prev = microServices.get(i - 1);
BlueprintMicroService current = microServices.get(i);
if (!current.getInputFrom().equals(prev.getName())) {
@@ -74,8 +76,8 @@ public class ChainGenerator {
private void insertNodeTemplateIntoChain(BlueprintMicroService microServicetoInsert,
LinkedList<BlueprintMicroService> chainOfMicroServices) {
- int insertIndex = 0;
- for (int i = 0; i < chainOfMicroServices.size(); i++) {
+ var insertIndex = 0;
+ for (var i = 0; i < chainOfMicroServices.size(); i++) {
BlueprintMicroService current = chainOfMicroServices.get(i);
if (microServicetoInsert.getName().equals(current.getInputFrom())) {
insertIndex = i;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java
index 6591be422..89046afd1 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/sdc/controller/installer/CsarHandler.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -99,7 +99,7 @@ public class CsarHandler {
/**
* This saves the notification to disk and database.
- *
+ *
* @param resultArtifact The artifact to install
* @throws SdcArtifactInstallerException In case of issues with the installation
* @throws SdcToscaParserException In case of issues with the parsing of
@@ -109,10 +109,10 @@ public class CsarHandler {
throws SdcArtifactInstallerException, SdcToscaParserException {
try {
logger.info("Writing CSAR file to: {} UUID {}", csarFilePath, artifactElement.getArtifactUUID());
- Path path = Paths.get(csarFilePath);
+ var path = Paths.get(csarFilePath);
Files.createDirectories(path.getParent());
// Create or replace the file
- try (OutputStream out = Files.newOutputStream(path)) {
+ try (var out = Files.newOutputStream(path)) {
out.write(resultArtifact.getArtifactPayload(), 0, resultArtifact.getArtifactPayload().length);
}
sdcCsarHelper = factory.getSdcCsarHelper(csarFilePath);
@@ -126,8 +126,8 @@ public class CsarHandler {
private IResourceInstance searchForResourceByInstanceName(String blueprintResourceInstanceName)
throws SdcArtifactInstallerException {
for (IResourceInstance resource : this.sdcNotification.getResources()) {
- String filteredString = resource.getResourceInstanceName().replaceAll("-", "");
- filteredString = filteredString.replaceAll(" ", "");
+ var filteredString = resource.getResourceInstanceName().replace("-", "");
+ filteredString = filteredString.replace(" ", "");
if (filteredString.equalsIgnoreCase(blueprintResourceInstanceName)) {
return resource;
}
@@ -137,17 +137,17 @@ public class CsarHandler {
}
private void loadDcaeBlueprint() throws IOException, SdcArtifactInstallerException {
- try (ZipFile zipFile = new ZipFile(csarFilePath)) {
+ try (var zipFile = new ZipFile(csarFilePath)) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();
if (!entry.isDirectory() && entry.getName().contains(BLUEPRINT_TYPE)) {
- BlueprintArtifact blueprintArtifact = new BlueprintArtifact();
+ var blueprintArtifact = new BlueprintArtifact();
blueprintArtifact.setBlueprintArtifactName(
entry.getName().substring(entry.getName().lastIndexOf('/') + 1, entry.getName().length()));
blueprintArtifact
.setBlueprintInvariantServiceUuid(this.getSdcNotification().getServiceInvariantUUID());
- try (InputStream stream = zipFile.getInputStream(entry)) {
+ try (var stream = zipFile.getInputStream(entry)) {
blueprintArtifact.setDcaeBlueprint(IOUtils.toString(stream, StandardCharsets.UTF_8));
}
blueprintArtifact.setResourceAttached(searchForResourceByInstanceName(entry.getName().substring(
@@ -173,7 +173,8 @@ public class CsarHandler {
}
public String setFilePath(String newPath) {
- return csarFilePath = newPath;
+ csarFilePath = newPath;
+ return csarFilePath;
}
public synchronized ISdcCsarHelper getSdcCsarHelper() {
@@ -191,20 +192,20 @@ public class CsarHandler {
/**
* Get the whole policy model Yaml. It combines the content of policies.yaml and
* data.yaml.
- *
+ *
* @return The whole policy model yaml
* @throws IOException The IO Exception
*/
public Optional<String> getPolicyModelYaml() throws IOException {
String result = null;
- try (ZipFile zipFile = new ZipFile(csarFilePath)) {
+ try (var zipFile = new ZipFile(csarFilePath)) {
ZipEntry entry = zipFile.getEntry(POLICY_DEFINITION_NAME_SUFFIX);
if (entry != null) {
ZipEntry data = zipFile.getEntry(DATA_DEFINITION_NAME_SUFFIX);
if (data != null) {
- String dataStr = IOUtils.toString(zipFile.getInputStream(data), StandardCharsets.UTF_8);
- String dataStrWithoutHeader = dataStr.substring(dataStr.indexOf(DATA_DEFINITION_KEY));
- String policyStr = IOUtils.toString(zipFile.getInputStream(entry), StandardCharsets.UTF_8);
+ var dataStr = IOUtils.toString(zipFile.getInputStream(data), StandardCharsets.UTF_8);
+ var dataStrWithoutHeader = dataStr.substring(dataStr.indexOf(DATA_DEFINITION_KEY));
+ var policyStr = IOUtils.toString(zipFile.getInputStream(entry), StandardCharsets.UTF_8);
StringUtils.chomp(policyStr);
result = policyStr.concat(dataStrWithoutHeader);
} else {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/service/CldsHealthcheckService.java b/runtime/src/main/java/org/onap/policy/clamp/clds/service/CldsHealthcheckService.java
index 02481494a..43852f9dc 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/service/CldsHealthcheckService.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/service/CldsHealthcheckService.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017-2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,9 +52,9 @@ public class CldsHealthcheckService {
* @return CldsHealthCheck class containing healthcheck info
*/
public CldsHealthCheck gethealthcheck() {
- CldsHealthCheck cldsHealthCheck = new CldsHealthCheck();
- Date startTime = new Date();
- LoggingUtils util = new LoggingUtils(logger);
+ var cldsHealthCheck = new CldsHealthCheck();
+ var startTime = new Date();
+ var util = new LoggingUtils(logger);
LoggingUtils.setRequestContext("CldsService: GET healthcheck", "Clamp-Health-Check");
LoggingUtils.setTimeContext(startTime, new Date());
try {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/JsonEditorSchemaConstants.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/JsonEditorSchemaConstants.java
index 32f328079..add6ed4bd 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/JsonEditorSchemaConstants.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/JsonEditorSchemaConstants.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2018-2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,7 +23,11 @@
package org.onap.policy.clamp.clds.tosca;
-public class JsonEditorSchemaConstants {
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class JsonEditorSchemaConstants {
//Data types in JSON Schema
public static final String TYPE_OBJECT = "object";
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/ToscaSchemaConstants.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/ToscaSchemaConstants.java
index c2b5d5963..d8f7bf837 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/ToscaSchemaConstants.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/ToscaSchemaConstants.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,7 +23,11 @@
package org.onap.policy.clamp.clds.tosca;
-public class ToscaSchemaConstants {
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ToscaSchemaConstants {
// Data types in TOSCA Schema
public static final String TYPE_LIST = "list";
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ArrayField.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ArrayField.java
index fb9d66752..7ff0117d3 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ArrayField.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/elements/ArrayField.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -46,7 +46,7 @@ public class ArrayField {
*/
public JsonArray deploy() {
- JsonArray subPropertyValuesArray = new JsonArray();
+ var subPropertyValuesArray = new JsonArray();
for (Object arrayElement : complexFields) {
//Cast for each Primitive Type
String typeValue = arrayElement.getClass().getSimpleName();
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java
index 2532295d0..2d193355e 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/ToscaMetadataExecutor.java
@@ -58,10 +58,15 @@ public class ToscaMetadataExecutor {
*/
public void executeTheProcess(String processInfo, JsonObject childObject, Service serviceModel) {
String[] processParameters = (processInfo + "/ ").split("/");
+ /*
+ * NOTE: Disabling sonar, because already added / above, hence there is no need
+ * to invoke method only conditionally, as sonar suggested.
+ */
+ String trimStr = processParameters[1].trim(); // NOSONAR
logger.info("Executing the Tosca clamp process {} with parameters {}",
- processParameters[0], processParameters[1].trim());
+ processParameters[0], trimStr);
mapOfProcesses.get(processParameters[0].trim())
- .executeProcess(processParameters[1].trim(), childObject, serviceModel);
+ .executeProcess(trimStr, childObject, serviceModel);
}
/**
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
index 8ecdc1900..613d98490 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/execution/cds/ToscaMetadataCdsProcess.java
@@ -51,7 +51,7 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
switch (parameters) {
case "actor":
- JsonArray jsonArray = new JsonArray();
+ var jsonArray = new JsonArray();
jsonArray.add("CDS");
addToJsonArray(childObject, "enum", jsonArray);
break;
@@ -66,7 +66,7 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
private static void generatePayload(JsonObject childObject, Service serviceModel) {
- JsonArray schemaAnyOf = new JsonArray();
+ var schemaAnyOf = new JsonArray();
schemaAnyOf.addAll(createBlankEntry());
schemaAnyOf.addAll(generatePayloadPerResource("VF", serviceModel));
schemaAnyOf.addAll(generatePayloadPerResource("PNF", serviceModel));
@@ -80,14 +80,14 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
private static void generateOperationPerResource(JsonObject childObject, String resourceName,
Service serviceModel) {
- JsonArray schemaEnum = new JsonArray();
- JsonArray schemaTitle = new JsonArray();
+ var schemaEnum = new JsonArray();
+ var schemaTitle = new JsonArray();
for (Map.Entry<String, JsonElement> entry : serviceModel.getResourceDetails().getAsJsonObject(resourceName)
.entrySet()) {
- JsonObject controllerProperties = entry.getValue().getAsJsonObject()
+ var controllerProperties = entry.getValue().getAsJsonObject()
.getAsJsonObject("controllerProperties");
if (controllerProperties != null && controllerProperties.getAsJsonObject("workflows") != null) {
- for (String workflowsEntry : controllerProperties.getAsJsonObject("workflows").keySet()) {
+ for (var workflowsEntry : controllerProperties.getAsJsonObject("workflows").keySet()) {
schemaEnum.add(workflowsEntry);
schemaTitle.add(workflowsEntry + " (CDS operation)");
}
@@ -95,7 +95,7 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
addToJsonArray(childObject, "enum", schemaEnum);
if (childObject.get("options") == null) {
- JsonObject optionsSection = new JsonObject();
+ var optionsSection = new JsonObject();
childObject.add("options", optionsSection);
}
addToJsonArray(childObject.getAsJsonObject("options"), "enum_titles", schemaTitle);
@@ -104,16 +104,16 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
private static JsonArray generatePayloadPerResource(String resourceName,
Service serviceModel) {
- JsonArray schemaAnyOf = new JsonArray();
+ var schemaAnyOf = new JsonArray();
for (Map.Entry<String, JsonElement> entry : serviceModel.getResourceDetails().getAsJsonObject(resourceName)
.entrySet()) {
- JsonObject controllerProperties = entry.getValue().getAsJsonObject()
+ var controllerProperties = entry.getValue().getAsJsonObject()
.getAsJsonObject("controllerProperties");
if (controllerProperties != null && controllerProperties.getAsJsonObject("workflows") != null) {
for (Map.Entry<String, JsonElement> workflowsEntry : controllerProperties.getAsJsonObject("workflows")
.entrySet()) {
- JsonObject obj = new JsonObject();
+ var obj = new JsonObject();
obj.addProperty("title", workflowsEntry.getKey());
obj.add("properties",
createInputPropertiesForPayload(workflowsEntry.getValue().getAsJsonObject(),
@@ -127,8 +127,8 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
private static JsonArray createBlankEntry() {
- JsonArray result = new JsonArray();
- JsonObject blankObject = new JsonObject();
+ var result = new JsonArray();
+ var blankObject = new JsonObject();
blankObject.addProperty("title", "User defined");
blankObject.add("properties", new JsonObject());
result.add(blankObject);
@@ -138,7 +138,7 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
private static JsonObject createAnyOfJsonProperty(String name,
String defaultValue,
boolean readOnlyFlag) {
- JsonObject result = new JsonObject();
+ var result = new JsonObject();
result.addProperty("title", name);
result.addProperty("type", "string");
result.addProperty("default", defaultValue);
@@ -166,10 +166,10 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
public static JsonObject createInputPropertiesForPayload(JsonObject workFlow,
JsonObject controllerProperties,
String workFlowName) {
- String artifactName = controllerProperties.get("sdnc_model_name").getAsString();
- String artifactVersion = controllerProperties.get("sdnc_model_version").getAsString();
- JsonObject inputs = workFlow.getAsJsonObject("inputs");
- JsonObject jsonObject = new JsonObject();
+ var artifactName = controllerProperties.get("sdnc_model_name").getAsString();
+ var artifactVersion = controllerProperties.get("sdnc_model_version").getAsString();
+ var inputs = workFlow.getAsJsonObject("inputs");
+ var jsonObject = new JsonObject();
jsonObject.add("artifact_name", createAnyOfJsonProperty(
"artifact name", artifactName, true));
jsonObject.add("artifact_version", createAnyOfJsonProperty(
@@ -181,11 +181,11 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
}
private static JsonObject createDataProperty(JsonObject inputs, String workFlowName) {
- JsonObject data = new JsonObject();
+ var data = new JsonObject();
data.addProperty("title", "data");
data.addProperty("type", "string");
data.addProperty("format", "textarea");
- JsonObject defaultValue = new JsonObject();
+ var defaultValue = new JsonObject();
addDefaultValueForData(inputs, defaultValue, workFlowName);
data.addProperty("default", defaultValue.toString());
return data;
@@ -197,12 +197,12 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
Set<Map.Entry<String, JsonElement>> entrySet = inputs.entrySet();
for (Map.Entry<String, JsonElement> entry : entrySet) {
String key = entry.getKey();
- JsonObject inputProperty = inputs.getAsJsonObject(key);
+ var inputProperty = inputs.getAsJsonObject(key);
if (key.equalsIgnoreCase(workFlowName + "-properties")) {
addDefaultValueForData(entry.getValue().getAsJsonObject().get("properties")
.getAsJsonObject(), defaultValue, workFlowName);
} else if ("object".equalsIgnoreCase(inputProperty.get(ToscaSchemaConstants.TYPE).getAsString())) {
- JsonObject object = new JsonObject();
+ var object = new JsonObject();
addDefaultValueForData(entry.getValue().getAsJsonObject().get("properties")
.getAsJsonObject(), object, workFlowName);
defaultValue.add(entry.getKey(), object);
@@ -218,11 +218,11 @@ public class ToscaMetadataCdsProcess extends ToscaMetadataProcess {
private static JsonArray handleListType(JsonObject inputs,
String workFlowName) {
- JsonObject object = new JsonObject();
+ var object = new JsonObject();
if (inputs.get("properties") != null) {
addDefaultValueForData(inputs.get("properties").getAsJsonObject(), object, workFlowName);
}
- JsonArray arr = new JsonArray();
+ var arr = new JsonArray();
arr.add(object);
return arr;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateField.java b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateField.java
index d9fd11de2..575965549 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateField.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/tosca/update/templates/JsonTemplateField.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -98,7 +98,7 @@ public class JsonTemplateField {
return false;
}
- JsonTemplateField jsonTemplateField = (JsonTemplateField) otherField;
+ var jsonTemplateField = (JsonTemplateField) otherField;
if (title != null ? !title.equals(jsonTemplateField.title) : jsonTemplateField.title != null) {
return false;
@@ -122,7 +122,7 @@ public class JsonTemplateField {
return false;
}
- JsonTemplateField jsonTemplateField = (JsonTemplateField) object;
+ var jsonTemplateField = (JsonTemplateField) object;
return title != null ? title.equals(jsonTemplateField.title) : jsonTemplateField.title == null;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/util/ClampVersioning.java b/runtime/src/main/java/org/onap/policy/clamp/clds/util/ClampVersioning.java
index 3cfbc394a..03fb2bdde 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/util/ClampVersioning.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/util/ClampVersioning.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -48,8 +48,8 @@ public class ClampVersioning {
* @return Clds version from properties
*/
public static String getCldsVersionFromProps() {
- String cldsVersion = "";
- Properties props = new Properties();
+ var cldsVersion = "";
+ var props = new Properties();
try (InputStream resourceStream = ResourceFileUtils.getResourceAsStream(RESOURCE_NAME)) {
props.load(resourceStream);
cldsVersion = props.getProperty(CLDS_VERSION_PROPERTY);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/clds/util/OnapLogConstants.java b/runtime/src/main/java/org/onap/policy/clamp/clds/util/OnapLogConstants.java
index 78b16f1a0..a436c89f2 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/clds/util/OnapLogConstants.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/clds/util/OnapLogConstants.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -81,7 +81,7 @@ public final class OnapLogConstants {
* @return detached Marker.
*/
private static Marker build(final String m1, final String m2) {
- final Marker marker = MarkerFactory.getDetachedMarker(m1);
+ final var marker = MarkerFactory.getDetachedMarker(m1);
marker.add(MarkerFactory.getDetachedMarker(m2));
return marker;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java b/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java
index 975011669..946edd767 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/LoopService.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 Nokia Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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
@@ -115,9 +117,9 @@ public class LoopService {
* @param policyVersion The policy model version
* @return The loop modified
*/
- Loop addOperationalPolicy(String loopName, String policyType, String policyVersion) throws IOException {
- Loop loop = getLoop(loopName);
- PolicyModel policyModel = policyModelsService.getPolicyModel(policyType, policyVersion);
+ Loop addOperationalPolicy(String loopName, String policyType, String policyVersion) {
+ var loop = getLoop(loopName);
+ var policyModel = policyModelsService.getPolicyModel(policyType, policyVersion);
Set<OperationalPolicy> opPolicySet = loop.getOperationalPolicies();
for (OperationalPolicy opPolicy : opPolicySet) {
if (opPolicy.getPolicyModel().equals(policyModel)) {
@@ -142,8 +144,8 @@ public class LoopService {
* @return The loop modified
*/
Loop removeOperationalPolicy(String loopName, String policyType, String policyVersion) {
- Loop loop = getLoop(loopName);
- PolicyModel policyModel = policyModelsService.getPolicyModel(policyType, policyVersion);
+ var loop = getLoop(loopName);
+ var policyModel = policyModelsService.getPolicyModel(policyType, policyVersion);
if (policyModel == null) {
return null;
}
@@ -158,27 +160,27 @@ public class LoopService {
}
Loop updateAndSaveOperationalPolicies(String loopName, List<OperationalPolicy> newOperationalPolicies) {
- Loop loop = findClosedLoopByName(loopName);
+ var loop = findClosedLoopByName(loopName);
Set<OperationalPolicy> newPolicies = operationalPolicyService.updatePolicies(loop, newOperationalPolicies);
loop.setOperationalPolicies(newPolicies);
return loopsRepository.save(loop);
}
Loop updateAndSaveMicroservicePolicies(String loopName, List<MicroServicePolicy> newMicroservicePolicies) {
- Loop loop = findClosedLoopByName(loopName);
+ var loop = findClosedLoopByName(loopName);
Set<MicroServicePolicy> newPolicies = microservicePolicyService.updatePolicies(loop, newMicroservicePolicies);
loop.setMicroServicePolicies(newPolicies);
return loopsRepository.save(loop);
}
Loop updateAndSaveGlobalPropertiesJson(String loopName, JsonObject newGlobalPropertiesJson) {
- Loop loop = findClosedLoopByName(loopName);
+ var loop = findClosedLoopByName(loopName);
loop.setGlobalPropertiesJson(newGlobalPropertiesJson);
return loopsRepository.save(loop);
}
MicroServicePolicy updateMicroservicePolicy(String loopName, MicroServicePolicy newMicroservicePolicy) {
- Loop loop = findClosedLoopByName(loopName);
+ var loop = findClosedLoopByName(loopName);
return microservicePolicyService.getAndUpdateMicroServicePolicy(loop, newMicroservicePolicy);
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/cds/CdsDataInstaller.java b/runtime/src/main/java/org/onap/policy/clamp/loop/cds/CdsDataInstaller.java
index 432659ab6..d41f5359c 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/cds/CdsDataInstaller.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/cds/CdsDataInstaller.java
@@ -2,9 +2,10 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
- * * Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd.
+ * ================================================================================
+ * Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -136,7 +137,7 @@ public class CdsDataInstaller {
private JsonObject createCdsArtifactProperties(String sdncModelName, String sdncModelVersion) {
if (sdncModelName != null && !"null".equals(sdncModelName)
&& sdncModelVersion != null && !"null".equals(sdncModelVersion)) {
- JsonObject controllerProperties = new JsonObject();
+ var controllerProperties = new JsonObject();
controllerProperties.addProperty(SDNC_MODEL_NAME, sdncModelName);
controllerProperties.addProperty(SDNC_MODEL_VERSION, sdncModelVersion);
@@ -146,7 +147,7 @@ public class CdsDataInstaller {
return controllerProperties;
}
- JsonObject workFlowProps = new JsonObject();
+ var workFlowProps = new JsonObject();
for (String workFlow : response.getWorkflows()) {
logger.info("Found CDS workflow {} for model name {} and version {}",
workFlow, sdncModelName, sdncModelVersion);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/common/AuditEntity.java b/runtime/src/main/java/org/onap/policy/clamp/loop/common/AuditEntity.java
index 92c795e90..fd7adaacc 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/common/AuditEntity.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/common/AuditEntity.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -136,11 +136,4 @@ public class AuditEntity {
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
-
- /**
- * Empty constructor.
- */
- public AuditEntity() {
- }
-
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/ExternalComponentState.java b/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/ExternalComponentState.java
index a57800025..4f83ffa76 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/ExternalComponentState.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/ExternalComponentState.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -85,8 +85,8 @@ public class ExternalComponentState implements Comparable<ExternalComponentState
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((stateName == null) ? 0 : stateName.hashCode());
return result;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/PolicyComponent.java b/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/PolicyComponent.java
index 2cd8b241a..dd6526344 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/PolicyComponent.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/components/external/PolicyComponent.java
@@ -77,7 +77,7 @@ public class PolicyComponent extends ExternalComponent {
* @return The json, payload to send
*/
public static String createPoliciesPayloadPdpGroup(Loop loop, String action) {
- PdpGroupPayload pdpGroupPayload = new PdpGroupPayload();
+ var pdpGroupPayload = new PdpGroupPayload();
loop.getOperationalPolicies().stream().forEach(opPolicy -> pdpGroupPayload
.updatePdpGroupMap(opPolicy.getPdpGroup(), opPolicy.getPdpSubgroup(), opPolicy.getName(), "1.0.0",
action));
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/log/LoopLog.java b/runtime/src/main/java/org/onap/policy/clamp/loop/log/LoopLog.java
index 00f7e1f41..4540d2280 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/log/LoopLog.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/log/LoopLog.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -150,8 +150,8 @@ public class LoopLog implements Serializable, Comparable<LoopLog> {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java b/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java
index acbf716b0..53365806b 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/service/CsarServiceInstaller.java
@@ -2,8 +2,9 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
+ * ================================================================================
* Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -68,7 +69,7 @@ public class CsarServiceInstaller {
JsonObject resourcesProp = createServicePropertiesByType(csar);
resourcesProp.add("VFModule", createVfModuleProperties(csar));
- Service modelService = new Service(serviceDetails, resourcesProp,
+ var modelService = new Service(serviceDetails, resourcesProp,
csar.getSdcNotification().getServiceVersion());
serviceRepository.save(modelService);
@@ -77,10 +78,10 @@ public class CsarServiceInstaller {
}
private JsonObject createServicePropertiesByType(CsarHandler csar) {
- JsonObject resourcesProp = new JsonObject();
+ var resourcesProp = new JsonObject();
// Iterate on all types defined in the tosca lib
for (SdcTypes type : SdcTypes.values()) {
- JsonObject resourcesPropByType = new JsonObject();
+ var resourcesPropByType = new JsonObject();
// For each type, get the metadata of each nodetemplate
for (NodeTemplate nodeTemplate : csar.getSdcCsarHelper().getServiceNodeTemplateBySdcType(type)) {
resourcesPropByType.add(nodeTemplate.getName(),
@@ -92,7 +93,7 @@ public class CsarServiceInstaller {
}
private static JsonObject createVfModuleProperties(CsarHandler csar) {
- JsonObject vfModuleProps = new JsonObject();
+ var vfModuleProps = new JsonObject();
// Loop on all Groups defined in the service (VFModule entries type:
// org.openecomp.groups.VfModule)
for (IEntityDetails entity : csar.getSdcCsarHelper().getEntity(
@@ -120,7 +121,7 @@ public class CsarServiceInstaller {
*/
public boolean isServiceAlreadyDeployed(CsarHandler csar) throws SdcArtifactInstallerException {
boolean alreadyInstalled = true;
- JsonObject serviceDetails = JsonUtils.GSON.fromJson(
+ var serviceDetails = JsonUtils.GSON.fromJson(
JsonUtils.GSON.toJson(csar.getSdcCsarHelper().getServiceMetadataAllProperties()), JsonObject.class);
alreadyInstalled = serviceRepository.existsById(serviceDetails.get("UUID").getAsString());
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java b/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java
index ecc174b7f..cc4e4c2fc 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/service/Service.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -41,7 +41,7 @@ import org.slf4j.LoggerFactory;
@Entity
@Table(name = "services")
-@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)})
+@TypeDef(name = "json", typeClass = StringJsonUserType.class)
public class Service implements Serializable {
/**
@@ -136,8 +136,8 @@ public class Service implements Serializable {
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((serviceUuid == null) ? 0 : serviceUuid.hashCode());
return result;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java
index f1ab35722..7477ae31f 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopElementModel.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights
* reserved.
+ * ================================================================================
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplate.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplate.java
index ab7367aaf..abedf1896 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplate.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplate.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -234,8 +234,7 @@ public class LoopTemplate extends AuditEntity implements Serializable {
* @param listPosition The position in the flow
*/
public void addLoopElementModel(LoopElementModel loopElementModel, Integer listPosition) {
- LoopTemplateLoopElementModel jointEntry =
- new LoopTemplateLoopElementModel(this, loopElementModel, listPosition);
+ var jointEntry = new LoopTemplateLoopElementModel(this, loopElementModel, listPosition);
this.loopElementModelsUsed.add(jointEntry);
loopElementModel.getUsedByLoopTemplates().add(jointEntry);
}
@@ -294,8 +293,8 @@ public class LoopTemplate 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;
}
@@ -336,6 +335,6 @@ public class LoopTemplate extends AuditEntity implements Serializable {
StringBuilder buffer = new StringBuilder("LOOP_TEMPLATE_").append(serviceName).append("_v")
.append(serviceVersion).append("_").append(resourceName).append("_")
.append(blueprintFileName.replaceAll(".yaml", ""));
- return buffer.toString().replace('.', '_').replaceAll(" ", "");
+ return buffer.toString().replace('.', '_').replace(" ", "");
}
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplateLoopElementModel.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplateLoopElementModel.java
index c0b0c7d24..80c8e447e 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplateLoopElementModel.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/LoopTemplateLoopElementModel.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -153,8 +153,8 @@ public class LoopTemplateLoopElementModel implements Serializable, Comparable<Lo
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((loopTemplate == null) ? 0 : loopTemplate.hashCode());
result = prime * result + ((loopElementModel == null) ? 0 : loopElementModel.hashCode());
return result;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java
index 2414377d7..0d57caada 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModel.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,7 +49,7 @@ import org.onap.policy.clamp.util.SemanticVersioning;
@Entity
@Table(name = "policy_models")
@IdClass(PolicyModelId.class)
-@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)})
+@TypeDef(name = "json", typeClass = StringJsonUserType.class)
public class PolicyModel extends AuditEntity implements Serializable, Comparable<PolicyModel> {
/**
@@ -232,8 +232,8 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + ((policyModelType == null) ? 0 : policyModelType.hashCode());
result = prime * result + ((version == null) ? 0 : version.hashCode());
return result;
diff --git a/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModelsService.java b/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModelsService.java
index 2d31b3b10..ba0429fb1 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModelsService.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/loop/template/PolicyModelsService.java
@@ -80,7 +80,7 @@ public class PolicyModelsService {
* @return A JsonObject with the json schema describing the tosca
*/
public JsonObject getPolicyModelJson(String policyType, String policyTypeVersion) {
- PolicyModel thePolicyModel = getPolicyModel(policyType, policyTypeVersion);
+ var thePolicyModel = getPolicyModel(policyType, policyTypeVersion);
// In the following use case we are not in the context of a closed loop, so the enrichment
// of the json cannot be done, that's why the serviceModel provided is NULL.
return toscaConverterWithDictionarySupport
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 6c0da687c..1f2e304bc 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
@@ -5,7 +5,7 @@
* Copyright (C) 2019 Nokia Intellectual Property. All rights
* reserved.
* ================================================================================
- * Modifications Copyright (C) 2021 AT&T
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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.
@@ -242,6 +242,6 @@ public abstract class Policy extends AuditEntity {
StringBuilder buffer = new StringBuilder(policyType).append("_").append(serviceName).append("_v")
.append(serviceVersion).append("_").append(resourceName).append("_")
.append(blueprintFilename.replaceAll(".yaml", ""));
- return buffer.toString().replace('.', '_').replaceAll(" ", "");
+ return buffer.toString().replace('.', '_').replace(" ", "");
}
}
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 8c1d9b5fd..066d88724 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
@@ -101,8 +101,8 @@ public class PolicyEngineServices {
return policyModelsService.savePolicyModelInNewTransaction(
new PolicyModel(policyType, policyTosca, policyVersion));
} else {
- logger.error("Policy not found in the Policy Engine, returning null: " + policyType
- + "/" + policyVersion);
+ logger.error("Policy not found in the Policy Engine, returning null: {} / {}",
+ policyType, policyVersion);
return null;
}
} else {
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyPayload.java b/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyPayload.java
index 2eb78d240..3e53e1295 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyPayload.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/PolicyPayload.java
@@ -27,6 +27,8 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.io.UnsupportedEncodingException;
import java.util.Map;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.onap.policy.clamp.clds.util.JsonUtils;
@@ -37,7 +39,8 @@ import org.yaml.snakeyaml.Yaml;
/**
* This class is a utility class to create the policy payload.
*/
-public class PolicyPayload {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class PolicyPayload {
private static final Logger logger = LoggerFactory.getLogger(PolicyPayload.class);
@@ -56,28 +59,28 @@ public class PolicyPayload {
public static String createPolicyPayload(String policyModelType, String policyModelVersion, String policyName,
String policyVersion, JsonObject policyProperties, String toscaContent)
throws UnsupportedEncodingException {
- JsonObject policyPayloadResult = new JsonObject();
+ var policyPayloadResult = new JsonObject();
policyPayloadResult.add("tosca_definitions_version",
createJsonFromPolicyTosca(toscaContent).get("tosca_definitions_version"));
- JsonObject topologyTemplateNode = new JsonObject();
+ var topologyTemplateNode = new JsonObject();
policyPayloadResult.add("topology_template", topologyTemplateNode);
- JsonArray policiesArray = new JsonArray();
+ var policiesArray = new JsonArray();
topologyTemplateNode.add("policies", policiesArray);
- JsonObject thisPolicy = new JsonObject();
+ var thisPolicy = new JsonObject();
policiesArray.add(thisPolicy);
- JsonObject policyDetails = new JsonObject();
+ var policyDetails = new JsonObject();
thisPolicy.add(policyName, policyDetails);
policyDetails.addProperty("type", policyModelType);
policyDetails.addProperty("type_version", policyModelVersion);
policyDetails.addProperty("version", policyVersion);
policyDetails.addProperty("name", policyName);
- JsonObject policyMetadata = new JsonObject();
+ var policyMetadata = new JsonObject();
policyDetails.add("metadata", policyMetadata);
policyMetadata.addProperty("policy-id", policyName);
policyMetadata.addProperty("policy-version", policyVersion);
@@ -88,4 +91,4 @@ public class PolicyPayload {
logger.info("Policy payload: {}", policyPayload);
return policyPayload;
}
-} \ No newline at end of file
+}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java b/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java
index be5e7917c..96edfa190 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/microservice/MicroServicePolicy.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -48,7 +48,7 @@ import org.onap.policy.clamp.policy.Policy;
@Entity
@Table(name = "micro_service_policies")
-@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)})
+@TypeDef(name = "json", typeClass = StringJsonUserType.class)
public class MicroServicePolicy extends Policy implements Serializable {
/**
* The serial version ID.
@@ -246,8 +246,8 @@ public class MicroServicePolicy extends Policy 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/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java
index deb425106..c7d67bd4e 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicy.java
@@ -2,8 +2,9 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights
* reserved.
+ * ================================================================================
* Modifications Copyright (C) 2020 Huawei Technologies Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,7 +53,7 @@ import org.slf4j.LoggerFactory;
@Entity
@Table(name = "operational_policies")
-@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)})
+@TypeDef(name = "json", typeClass = StringJsonUserType.class)
public class OperationalPolicy extends Policy implements Serializable {
/**
* The serial version ID.
@@ -165,24 +166,21 @@ public class OperationalPolicy extends Policy implements Serializable {
@Override
public void updateJsonRepresentation(ToscaConverterWithDictionarySupport toscaConverter, Service serviceModel) {
- {
- this.setJsonRepresentation(new JsonObject());
- if (this.getPolicyModel() == null) {
- return;
- }
-
- // Generic Case
- this.setJsonRepresentation(toscaConverter.convertToscaToJsonSchemaObject(
- this.getPolicyModel().getPolicyModelTosca(),
- this.getPolicyModel().getPolicyModelType(), serviceModel));
-
+ this.setJsonRepresentation(new JsonObject());
+ if (this.getPolicyModel() == null) {
+ return;
}
+
+ // Generic Case
+ this.setJsonRepresentation(toscaConverter.convertToscaToJsonSchemaObject(
+ this.getPolicyModel().getPolicyModelTosca(),
+ this.getPolicyModel().getPolicyModelType(), serviceModel));
}
@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/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java
index ee8db290d..00713f78e 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyRepresentationBuilder.java
@@ -100,14 +100,14 @@ public class OperationalPolicyRepresentationBuilder {
private static JsonObject createSchemaProperty(String title, String type, String defaultValue, String readOnlyFlag,
String[] enumArray) {
- JsonObject property = new JsonObject();
+ var property = new JsonObject();
property.addProperty(TITLE, title);
property.addProperty(TYPE, type);
property.addProperty(DEFAULT, defaultValue);
property.addProperty("readOnly", readOnlyFlag);
if (enumArray != null) {
- JsonArray jsonArray = new JsonArray();
+ var jsonArray = new JsonArray();
property.add("enum", jsonArray);
for (String val : enumArray) {
jsonArray.add(val);
@@ -117,13 +117,13 @@ public class OperationalPolicyRepresentationBuilder {
}
private static JsonArray createVnfSchema(Service modelService, boolean generateType) {
- JsonArray vnfSchemaArray = new JsonArray();
+ var vnfSchemaArray = new JsonArray();
JsonObject modelVnfs = modelService.getResourceByType("VF");
for (Entry<String, JsonElement> entry : modelVnfs.entrySet()) {
- JsonObject vnfOneOfSchema = new JsonObject();
+ var vnfOneOfSchema = new JsonObject();
vnfOneOfSchema.addProperty(TITLE, "VNF" + "-" + entry.getKey());
- JsonObject properties = new JsonObject();
+ var properties = new JsonObject();
if (generateType) {
properties.add(TYPE, createSchemaProperty("Type", STRING, "VNF", "True", null));
}
@@ -137,8 +137,8 @@ public class OperationalPolicyRepresentationBuilder {
}
private static JsonArray createBlankEntry() {
- JsonArray result = new JsonArray();
- JsonObject blankObject = new JsonObject();
+ var result = new JsonArray();
+ var blankObject = new JsonObject();
blankObject.addProperty(TITLE, "User defined");
blankObject.add(PROPERTIES, new JsonObject());
result.add(blankObject);
@@ -146,13 +146,13 @@ public class OperationalPolicyRepresentationBuilder {
}
private static JsonArray createVfModuleSchema(Service modelService, boolean generateType) {
- JsonArray vfModuleOneOfSchemaArray = new JsonArray();
+ var vfModuleOneOfSchemaArray = new JsonArray();
JsonObject modelVfModules = modelService.getResourceByType("VFModule");
for (Entry<String, JsonElement> entry : modelVfModules.entrySet()) {
- JsonObject vfModuleOneOfSchema = new JsonObject();
+ var vfModuleOneOfSchema = new JsonObject();
vfModuleOneOfSchema.addProperty(TITLE, "VFMODULE" + "-" + entry.getKey());
- JsonObject properties = new JsonObject();
+ var properties = new JsonObject();
if (generateType) {
properties.add(TYPE, createSchemaProperty("Type", STRING, "VFMODULE", "True", null));
}
@@ -196,7 +196,7 @@ public class OperationalPolicyRepresentationBuilder {
* @return A JsonArray with everything inside
*/
public static JsonArray createAnyOfArray(Service modelJson, boolean generateType) {
- JsonArray targetOneOfStructure = new JsonArray();
+ var targetOneOfStructure = new JsonArray();
// First entry must be user defined
targetOneOfStructure.addAll(createBlankEntry());
targetOneOfStructure.addAll(createVnfSchema(modelJson, generateType));
@@ -205,22 +205,22 @@ public class OperationalPolicyRepresentationBuilder {
}
private static JsonArray createAnyOfArrayForCdsRecipe(Service modelJson) {
- JsonArray anyOfStructure = new JsonArray();
+ var anyOfStructure = new JsonArray();
anyOfStructure.addAll(createAnyOfCdsRecipe(modelJson.getResourceDetails().getAsJsonObject("VF")));
anyOfStructure.addAll(createAnyOfCdsRecipe(modelJson.getResourceDetails().getAsJsonObject("PNF")));
return anyOfStructure;
}
private static JsonArray createAnyOfCdsRecipe(JsonObject jsonObject) {
- JsonArray schemaArray = new JsonArray();
+ var schemaArray = new JsonArray();
for (Entry<String, JsonElement> entry : jsonObject.entrySet()) {
- JsonObject controllerProperties = entry.getValue().getAsJsonObject()
+ var controllerProperties = entry.getValue().getAsJsonObject()
.getAsJsonObject("controllerProperties");
if (controllerProperties != null && controllerProperties.getAsJsonObject("workflows") != null) {
- JsonObject workflows = controllerProperties.getAsJsonObject("workflows");
+ var workflows = controllerProperties.getAsJsonObject("workflows");
for (Entry<String, JsonElement> workflowsEntry : workflows.entrySet()) {
- JsonObject obj = new JsonObject();
+ var obj = new JsonObject();
obj.addProperty(TITLE, workflowsEntry.getKey());
obj.addProperty(TYPE, TYPE_OBJECT);
obj.add(PROPERTIES, createPayloadProperty(workflowsEntry.getValue().getAsJsonObject(),
@@ -235,23 +235,23 @@ public class OperationalPolicyRepresentationBuilder {
private static JsonObject createPayloadProperty(JsonObject workFlow,
JsonObject controllerProperties, String workFlowName) {
- JsonObject payload = new JsonObject();
+ var payload = new JsonObject();
payload.addProperty(TITLE, "Payload");
payload.addProperty(TYPE, TYPE_OBJECT);
payload.add(PROPERTIES, createInputPropertiesForPayload(workFlow, controllerProperties,
workFlowName));
- JsonObject properties = new JsonObject();
+ var properties = new JsonObject();
properties.add(RECIPE, createRecipeForCdsWorkflow(workFlowName));
properties.add("payload", payload);
return properties;
}
private static JsonObject createRecipeForCdsWorkflow(String workflow) {
- JsonObject recipe = new JsonObject();
+ var recipe = new JsonObject();
recipe.addProperty(TITLE, RECIPE);
recipe.addProperty(TYPE, STRING);
recipe.addProperty(DEFAULT, workflow);
- JsonObject options = new JsonObject();
+ var options = new JsonObject();
options.addProperty("hidden", true);
recipe.add("options", options);
return recipe;
@@ -269,10 +269,10 @@ public class OperationalPolicyRepresentationBuilder {
public static JsonObject createInputPropertiesForPayload(JsonObject workFlow,
JsonObject controllerProperties,
String workFlowName) {
- String artifactName = controllerProperties.get("sdnc_model_name").getAsString();
- String artifactVersion = controllerProperties.get("sdnc_model_version").getAsString();
- JsonObject inputs = workFlow.getAsJsonObject("inputs");
- JsonObject jsonObject = new JsonObject();
+ var artifactName = controllerProperties.get("sdnc_model_name").getAsString();
+ var artifactVersion = controllerProperties.get("sdnc_model_version").getAsString();
+ var inputs = workFlow.getAsJsonObject("inputs");
+ var jsonObject = new JsonObject();
jsonObject.add("artifact_name", createSchemaProperty(
"artifact name", STRING, artifactName, "True", null));
jsonObject.add("artifact_version", createSchemaProperty(
@@ -284,9 +284,9 @@ public class OperationalPolicyRepresentationBuilder {
}
private static JsonObject createDataProperty(JsonObject inputs, String workflowName) {
- JsonObject data = new JsonObject();
+ var data = new JsonObject();
data.addProperty(TITLE, "data");
- JsonObject dataObj = new JsonObject();
+ var dataObj = new JsonObject();
addDataFields(inputs, dataObj, workflowName);
data.add(PROPERTIES, dataObj);
return data;
@@ -298,7 +298,7 @@ public class OperationalPolicyRepresentationBuilder {
Set<Map.Entry<String, JsonElement>> entrySet = inputs.entrySet();
for (Map.Entry<String, JsonElement> entry : entrySet) {
String key = entry.getKey();
- JsonObject inputProperty = inputs.getAsJsonObject(key);
+ var inputProperty = inputs.getAsJsonObject(key);
if (key.equalsIgnoreCase(workFlowName + "-properties")) {
addDataFields(entry.getValue().getAsJsonObject().get(PROPERTIES).getAsJsonObject(),
dataObj, workFlowName);
@@ -314,13 +314,13 @@ public class OperationalPolicyRepresentationBuilder {
String type,
String defaultValue,
JsonObject cdsProperty) {
- JsonObject property = new JsonObject();
+ var property = new JsonObject();
property.addProperty(TITLE, title);
if (TYPE_LIST.equalsIgnoreCase(type)) {
property.addProperty(TYPE, TYPE_ARRAY);
if (cdsProperty != null && cdsProperty.get(PROPERTIES) != null) {
- JsonObject listProperties = new JsonObject();
+ var listProperties = new JsonObject();
listProperties.add(PROPERTIES, getProperties(cdsProperty.get(PROPERTIES).getAsJsonObject()));
property.add(ITEMS, listProperties);
}
@@ -341,7 +341,7 @@ public class OperationalPolicyRepresentationBuilder {
if (inputProperties == null) {
return null;
}
- JsonObject dataObject = new JsonObject();
+ var dataObject = new JsonObject();
addDataFields(inputProperties, dataObject, null);
return dataObject;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java
index baedc47b8..63df3a7b0 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/operational/OperationalPolicyService.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 Nokia Intellectual Property. All rights
* reserved.
* ================================================================================
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. 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
@@ -40,15 +42,10 @@ public class OperationalPolicyService implements PolicyService<OperationalPolicy
private final OperationalPolicyRepository operationalPolicyRepository;
- private final PolicyModelsRepository policyModelsRepository;
-
- private static final Logger logger = LoggerFactory.getLogger(OperationalPolicyService.class);
-
@Autowired
public OperationalPolicyService(OperationalPolicyRepository repository,
PolicyModelsRepository policyModelsRepository) {
this.operationalPolicyRepository = repository;
- this.policyModelsRepository = policyModelsRepository;
}
@Override
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java
index 63adf4a32..bbf33d54c 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PdpGroupPayload.java
@@ -111,7 +111,7 @@ public class PdpGroupPayload {
String policyName,
String policyVersion, String action) {
// create subgroup
- DeploymentSubGroup newSubGroup = new DeploymentSubGroup();
+ var newSubGroup = new DeploymentSubGroup();
newSubGroup.setPdpType(pdpSubGroup);
newSubGroup.setAction(DeploymentSubGroup.Action.valueOf(action));
newSubGroup.setPolicies(Arrays.asList(new ToscaConceptIdentifier(policyName, policyVersion)));
@@ -120,7 +120,7 @@ public class PdpGroupPayload {
group.getName().equals(pdpGroup)).findFirst()
.ifPresentOrElse(group -> group.getDeploymentSubgroups().add(newSubGroup),
() -> {
- DeploymentGroup newGroup = new DeploymentGroup();
+ var newGroup = new DeploymentGroup();
newGroup.setName(pdpGroup);
newGroup.setDeploymentSubgroups(new ArrayList<>(Arrays.asList(newSubGroup)));
this.deploymentGroups.getGroups().add(newGroup);
diff --git a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java
index 6775eb0c6..8eca11c66 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/policy/pdpgroup/PoliciesPdpMerger.java
@@ -74,8 +74,8 @@ public class PoliciesPdpMerger {
* @return It returns a JsonObject containing the policies list enriched with PdpGroup info
*/
public static JsonObject mergePoliciesAndPdpGroupStates(String jsonPoliciesList, String pdpGroupsJson) {
- PdpGroups pdpGroups = JsonUtils.GSON.fromJson(pdpGroupsJson, PdpGroups.class);
- JsonObject policiesListJson =
+ var pdpGroups = JsonUtils.GSON.fromJson(pdpGroupsJson, PdpGroups.class);
+ var policiesListJson =
JsonUtils.GSON.fromJson(jsonPoliciesList, JsonObject.class).get("topology_template")
.getAsJsonObject();
StreamSupport.stream(policiesListJson.get("policies").getAsJsonArray().spliterator(), true)
@@ -90,7 +90,7 @@ public class PoliciesPdpMerger {
* @param policyJsonNode The policy json node that must be enriched
*/
private static void enrichOnePolicy(PdpGroups pdpGroups, JsonObject policyJsonNode) {
- PdpGroupsAnalyzer pdpGroupAnalyzer = new PdpGroupsAnalyzer(pdpGroups);
+ var pdpGroupAnalyzer = new PdpGroupsAnalyzer(pdpGroups);
JsonObject deploymentPdpJson = pdpGroupAnalyzer
.getPdpGroupsForPolicy(policyJsonNode.get("name").getAsString(),
policyJsonNode.get("version").getAsString());
@@ -101,4 +101,5 @@ public class PoliciesPdpMerger {
policyJsonNode.get("type_version").getAsString());
mergeJsonElement(policyJsonNode, supportedPdpGroupsJson);
}
-} \ No newline at end of file
+}
+
diff --git a/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryElement.java b/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryElement.java
index ecf4b876c..d4d314305 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryElement.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryElement.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -224,8 +224,8 @@ public class DictionaryElement 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 + ((shortName == null) ? 0 : shortName.hashCode());
return result;
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryService.java b/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryService.java
index 849d4baae..ac2651d9c 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryService.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/tosca/DictionaryService.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -60,7 +60,7 @@ public class DictionaryService {
* @return updated Dictionary object with all dictionary elements
*/
public Dictionary saveOrUpdateDictionaryElement(String dictionaryName, Dictionary dictionary) {
- Dictionary dict = getDictionary(dictionaryName);
+ var dict = getDictionary(dictionaryName);
Set<DictionaryElement> newDictionaryElements = dictionary.getDictionaryElements();
@@ -122,7 +122,7 @@ public class DictionaryService {
DictionaryElement element =
dictionaryElementsRepository.findById(dictionaryElementShortName).orElse(null);
if (element != null) {
- Dictionary dict = getDictionary(dictionaryName);
+ var dict = getDictionary(dictionaryName);
dict.removeDictionaryElement(element);
dictionaryRepository.saveAndFlush(dict);
}
diff --git a/runtime/src/main/java/org/onap/policy/clamp/util/SemanticVersioning.java b/runtime/src/main/java/org/onap/policy/clamp/util/SemanticVersioning.java
index 58367193f..c1f4111d5 100644
--- a/runtime/src/main/java/org/onap/policy/clamp/util/SemanticVersioning.java
+++ b/runtime/src/main/java/org/onap/policy/clamp/util/SemanticVersioning.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP CLAMP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights
* reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -23,10 +23,14 @@
package org.onap.policy.clamp.util;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
/**
* This class is the base class for object that requires semantic versioning.
* ... This class supports also a.b.c.d... etc ... as a version.
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class SemanticVersioning {
public static final int BEFORE = -1;
public static final int EQUAL = 0;
@@ -57,7 +61,7 @@ public class SemanticVersioning {
int smalestStringLength = Math.min(arg0Array.length, arg1Array.length);
- for (int currentVersionIndex =
+ for (var currentVersionIndex =
0; currentVersionIndex < smalestStringLength; ++currentVersionIndex) {
if (Integer.parseInt(arg0Array[currentVersionIndex]) < Integer
.parseInt(arg1Array[currentVersionIndex])) {
diff --git a/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml
index 2e71c58ca..f800efe8d 100644
--- a/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml
+++ b/runtime/src/main/resources/clds/camel/rest/clamp-api-v2.xml
@@ -1553,7 +1553,7 @@
<removeHeaders pattern="*"
excludePattern="name|version|requestId"/>
<setProperty name="raiseHttpExceptionFlag">
- <simple resultType="java.lang.Boolean">true</simple>
+ <simple resultType="java.lang.Boolean">false</simple>
</setProperty>
<setHeader name="Content-Type">
<constant>application/json</constant>
@@ -1760,6 +1760,49 @@
</route>
</get>
+ <post uri="/v2/toscaControlLoop/postToscaInstanceProperties"
+ type="java.lang.String"
+ consumes="plain/text"
+ outType="java.lang.String"
+ produces="application/json"
+ bindingMode="off">
+ <route>
+ <removeHeaders pattern="*"/>
+ <setProperty name="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <setHeader name="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <doTry>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=startLog(*, 'Update the global properties')"/>
+ <to
+ uri="bean:org.onap.policy.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')"/>
+ <to uri="direct:post-tosca-instance-properties"/>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=endLog()"/>
+ <doCatch>
+ <exception>java.lang.Exception</exception>
+ <handled>
+ <constant>true</constant>
+ </handled>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=errorLog()"/>
+ <log loggingLevel="ERROR"
+ message="Creating Instance Properties FAILED"/>
+
+ <setHeader name="CamelHttpResponseCode">
+ <constant>500</constant>
+ </setHeader>
+ <setBody>
+ <simple>Creating Instance Properties FAILED</simple>
+ </setBody>
+ </doCatch>
+ </doTry>
+ </route>
+ </post>
+
<get uri="/v2/toscaControlLoop/getCommonOrInstanceProperties" outType="java.lang.String" bindingMode="off" produces="application/json">
<route>
<removeHeaders pattern="*"
diff --git a/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml b/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml
index 230aea142..12b43dd9f 100644
--- a/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml
+++ b/runtime/src/main/resources/clds/camel/routes/controlloop-flows.xml
@@ -110,6 +110,31 @@
</doFinally>
</doTry>
</route>
+ <route id="post-tosca-instance-properties">
+ <from uri="direct:post-tosca-instance-properties"/>
+ <doTry>
+ <log loggingLevel="INFO"
+ message="Creating the tosca instance properties"/>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeLog('Controlloop', 'Creating the tosca instance properties')"/>
+ <setHeader name="CamelHttpMethod">
+ <constant>POST</constant>
+ </setHeader>
+ <setHeader name="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <log loggingLevel="INFO"
+ message="Endpoint to send Tosca Instance Properties: {{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/instanceProperties"></log>
+ <toD
+ uri="{{clamp.config.controlloop.runtime.url}}/onap/controlloop/v2/instanceProperties? bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.controlloop.runtime.userName}}&amp;authPassword={{clamp.config.controlloop.runtime.password}}&amp;authenticationPreemptive=true&amp;connectionClose=true"/>
+ <convertBodyTo type="java.lang.String"/>
+ <doFinally>
+ <to uri="direct:reset-raise-http-exception-flag"/>
+ <to
+ uri="bean:org.onap.policy.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()"/>
+ </doFinally>
+ </doTry>
+ </route>
<route id="post-tosca-instantiation">
<from uri="direct:post-tosca-instantiation"/>
<doTry>