summaryrefslogtreecommitdiffstats
path: root/runtime-acm/src/main/java/org/onap
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2022-11-14 10:49:34 +0000
committerFrancesco Fiora <francesco.fiora@est.tech>2022-11-14 14:45:18 +0000
commitc32d7926409b4c164e2a5097e7ba1bc4d766bd5b (patch)
treec0beffd2b72a7eb06db7eb0f9e3c687c24d1ded7 /runtime-acm/src/main/java/org/onap
parentcfa51e6177b801fcf456390cdaea520b6378de39 (diff)
Remove redundant endpoints in ACM
Remove redundant endpoints in ACM not present in the new generated Api code. Issue-ID: POLICY-4453 Change-Id: I4b843c2637e934f8a29f71d8031bdfe903ff20dc Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src/main/java/org/onap')
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java39
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java425
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java138
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java317
4 files changed, 0 insertions, 919 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
index 0a78c54de..55d7b0c13 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/commissioning/CommissioningProvider.java
@@ -44,7 +44,6 @@ 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.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplates;
import org.onap.policy.models.tosca.authorative.concepts.ToscaTypedEntityFilter;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -206,44 +205,6 @@ public class CommissioningProvider {
}
/**
- * Get node templates with common properties added.
- *
- * @param name the name of the definition to use, null for all definitions
- * @param version the version of the definition to use, null for all definitions
- * @param instanceName automation composition name
- * @param common boolean indicating common or instance properties to be used
- * @return the nodes templates with common or instance properties
- * @throws PfModelException on errors getting common or instance properties from node_templates
- */
- @Transactional(readOnly = true)
- public Map<String, ToscaNodeTemplate> getNodeTemplatesWithCommonOrInstanceProperties(
- final String name, final String version, final String instanceName, final boolean common)
- throws PfModelException {
-
- if (common && verifyIfInstancePropertiesExists()) {
- throw new PfModelException(Status.BAD_REQUEST,
- "Cannot create or edit common properties, delete all the instantiations first");
- }
-
- var serviceTemplateList = serviceTemplateProvider.getServiceTemplateList(name, version);
-
- if (serviceTemplateList.isEmpty()) {
- throw new PfModelException(Status.BAD_REQUEST,
- "Tosca service template has to be commissioned before saving instance properties");
- }
-
- var commonOrInstanceNodeTypeProps =
- serviceTemplateProvider.getCommonOrInstancePropertiesFromNodeTypes(common, serviceTemplateList.get(0));
-
- var serviceTemplates = new ToscaServiceTemplates();
- serviceTemplates.setServiceTemplates(filterToscaNodeTemplateInstance(serviceTemplateList, instanceName));
-
- return serviceTemplateProvider.getDerivedCommonOrInstanceNodeTemplates(
- serviceTemplates.getServiceTemplates().get(0).getToscaTopologyTemplate().getNodeTemplates(),
- commonOrInstanceNodeTypeProps);
- }
-
- /**
* Get the requested automation composition definitions.
*
* @param name the name of the definition to get, null for all definitions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
index 98b59aed7..18fd1f938 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
@@ -21,20 +21,12 @@
package org.onap.policy.clamp.acm.runtime.instantiation;
-import com.google.gson.Gson;
-import com.google.gson.internal.LinkedTreeMap;
-import com.google.gson.reflect.TypeToken;
-import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.UUID;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import lombok.AllArgsConstructor;
@@ -43,15 +35,9 @@ import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
import org.onap.policy.clamp.models.acm.concepts.AutomationComposition;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElement;
-import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionOrderedState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
import org.onap.policy.clamp.models.acm.concepts.Participant;
-import org.onap.policy.clamp.models.acm.messages.rest.GenericNameVersion;
-import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AutomationCompositionOrderStateResponse;
-import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AutomationCompositionPrimed;
-import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AutomationCompositionPrimedResponse;
-import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstancePropertiesResponse;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationCommand;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
@@ -62,9 +48,7 @@ import org.onap.policy.common.parameters.ValidationResult;
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.ToscaNameVersion;
import org.onap.policy.models.tosca.authorative.concepts.ToscaNodeTemplate;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -75,15 +59,7 @@ import org.springframework.transaction.annotation.Transactional;
@Transactional
@AllArgsConstructor
public class AutomationCompositionInstantiationProvider {
- private static final String AUTOMATION_COMPOSITION_NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition";
private static final String AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE = "AutomationCompositionElement";
- private static final String PARTICIPANT_ID_PROPERTY_KEY = "participant_id";
- private static final String PARTICIPANT_TYPE_PROPERTY_KEY = "participantType";
- private static final String AC_ELEMENT_NAME = "name";
- private static final String AC_ELEMENT_VERSION = "version";
- private static final String HYPHEN = "-";
-
- private static final Gson GSON = new Gson();
private final AutomationCompositionProvider automationCompositionProvider;
private final CommissioningProvider commissioningProvider;
@@ -92,145 +68,6 @@ public class AutomationCompositionInstantiationProvider {
private static final String ENTRY = "entry ";
/**
- * Creates Instance Properties and automation composition.
- *
- * @param serviceTemplate the service template
- * @return the result of the instantiation operation
- * @throws PfModelException on creation errors
- */
- public InstancePropertiesResponse createInstanceProperties(ToscaServiceTemplate serviceTemplate)
- throws PfModelException {
-
- String instanceName = serviceTemplate.getName();
- AutomationComposition automationComposition = new AutomationComposition();
- Map<UUID, AutomationCompositionElement> automationCompositionElements = new HashMap<>();
-
- ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getAllToscaServiceTemplate().get(0);
-
- Map<String, ToscaNodeTemplate> persistedNodeTemplateMap =
- toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates();
-
- Map<String, ToscaNodeTemplate> nodeTemplates = deepCloneNodeTemplate(serviceTemplate);
-
- nodeTemplates.forEach((key, template) -> {
- ToscaNodeTemplate newNodeTemplate = new ToscaNodeTemplate();
- String name = key + "-" + instanceName;
- String version = template.getVersion();
- String description = template.getDescription() + " " + instanceName;
- newNodeTemplate.setName(name);
- newNodeTemplate.setVersion(version);
- newNodeTemplate.setDescription(description);
- newNodeTemplate.setProperties(new HashMap<>(template.getProperties()));
- newNodeTemplate.setType(template.getType());
- newNodeTemplate.setTypeVersion(template.getTypeVersion());
- newNodeTemplate.setMetadata(template.getMetadata());
-
- crateNewAutomationCompositionInstance(instanceName, automationComposition, automationCompositionElements,
- template, newNodeTemplate);
-
- persistedNodeTemplateMap.put(name, newNodeTemplate);
- });
-
- AutomationCompositions automationCompositions = new AutomationCompositions();
-
- serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().putAll(persistedNodeTemplateMap);
-
- automationComposition.setElements(automationCompositionElements);
- automationCompositions.getAutomationCompositionList().add(automationComposition);
-
- return saveInstancePropertiesAndAutomationComposition(serviceTemplate, automationCompositions);
- }
-
- /**
- * Updates Instance Properties and Automation Composition Instance.
- *
- * @param name the name of the automation composition to update
- * @param version the version of the automation composition to update
- * @param serviceTemplate tosca service template body
- * @return InstancePropertiesResponse response from updating instance properties
- * @throws PfModelException exception if incorrect instance name
- */
- public InstancePropertiesResponse updatesInstanceProperties(
- String name, String version, ToscaServiceTemplate serviceTemplate) throws PfModelException {
-
- if (name.length() < 3) {
- throw new PfModelException(Status.BAD_REQUEST, "Instance Name cannot be empty or less than 3 characters!");
- }
-
- Map<String, ToscaNodeTemplate> nodeTemplates = deepCloneNodeTemplate(serviceTemplate);
- Map<String, ToscaNodeTemplate> updatedNodeTemplates = new HashMap<>();
-
- String instanceName = serviceTemplate.getName();
-
- nodeTemplates.forEach((key, template) -> {
- ToscaNodeTemplate toscaNodeTemplate = new ToscaNodeTemplate();
-
- String updatedName = updateInstanceNameDescription(instanceName, name, key);
- String updatedDescription = updateInstanceNameDescription(
- instanceName, name, template.getDescription());
-
- toscaNodeTemplate.setName(updatedName);
- toscaNodeTemplate.setDescription(updatedDescription);
- toscaNodeTemplate.setCapabilities(template.getCapabilities());
- toscaNodeTemplate.setRequirements(template.getRequirements());
- toscaNodeTemplate.setMetadata(template.getMetadata());
- toscaNodeTemplate.setProperties(template.getProperties());
- toscaNodeTemplate.setDerivedFrom(template.getDerivedFrom());
- toscaNodeTemplate.setVersion(template.getVersion());
- toscaNodeTemplate.setType(template.getType());
- toscaNodeTemplate.setTypeVersion(template.getTypeVersion());
-
- String updatedKey = updateInstanceNameDescription(instanceName, name, key);
-
- updatedNodeTemplates.put(updatedKey, toscaNodeTemplate);
- });
-
- serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().clear();
- serviceTemplate.getToscaTopologyTemplate().getNodeTemplates().putAll(updatedNodeTemplates);
-
- AutomationCompositions automationCompositions = updateAutomationComposition(
- name, instanceName);
-
- deleteInstanceProperties(name, version);
-
- return saveInstancePropertiesAndAutomationComposition(serviceTemplate, automationCompositions);
- }
-
- /**
- * Deletes Instance Properties.
- *
- * @param name the name of the automation composition to delete
- * @param version the version of the automation composition to delete
- * @return the result of the deletion
- * @throws PfModelException on deletion errors
- */
- public InstantiationResponse deleteInstanceProperties(String name, String version) throws PfModelException {
-
- String instanceName = getInstancePropertyName(name, version);
-
- Map<String, ToscaNodeTemplate> filteredToscaNodeTemplateMap = new HashMap<>();
-
- ToscaServiceTemplate toscaServiceTemplate = commissioningProvider.getAllToscaServiceTemplate().get(0);
-
- toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates().forEach((key, nodeTemplate) -> {
- if (!nodeTemplate.getName().contains(instanceName)) {
- filteredToscaNodeTemplateMap.put(key, nodeTemplate);
- }
- });
-
- List<ToscaNodeTemplate> filteredToscaNodeTemplateList =
- toscaServiceTemplate.getToscaTopologyTemplate().getNodeTemplates().values().stream()
- .filter(nodeTemplate -> nodeTemplate.getName().contains(instanceName)).collect(Collectors.toList());
-
- InstantiationResponse response = this.deleteAutomationComposition(name, version);
-
- automationCompositionProvider.deleteInstanceProperties(filteredToscaNodeTemplateMap,
- filteredToscaNodeTemplateList);
-
- return response;
- }
-
- /**
* Create automation compositions.
*
* @param automationCompositions the automation composition
@@ -469,266 +306,4 @@ public class AutomationCompositionInstantiationProvider {
return result;
}
-
- /**
- * Gets a list of automation compositions with it's ordered state.
- *
- * @param name the name of the automation composition to get, null for all automation compositions
- * @param version the version of the automation composition to get, null for all automation compositions
- * @return a list of Instantiation Command
- * @throws PfModelException on errors getting automation compositions
- */
- @Transactional(readOnly = true)
- public AutomationCompositionOrderStateResponse getInstantiationOrderState(String name, String version)
- throws PfModelException {
-
- List<AutomationComposition> automationCompositions =
- automationCompositionProvider.getAutomationCompositions(name, version);
-
- var response = new AutomationCompositionOrderStateResponse();
-
- automationCompositions.forEach(automationComposition -> {
- var genericNameVersion = new GenericNameVersion();
- genericNameVersion.setName(automationComposition.getName());
- genericNameVersion.setVersion(automationComposition.getVersion());
- response.getAutomationCompositionIdentifierList().add(genericNameVersion);
- });
-
- return response;
- }
-
- /**
- * Saves Instance Properties and automation composition.
- * Gets a list of automation compositions which are primed or de-primed.
- *
- * @param name the name of the automation composition to get, null for all automation compositions
- * @param version the version of the automation composition to get, null for all automation compositions
- * @return a list of Instantiation Command
- * @throws PfModelException on errors getting automation compositions
- */
- @Transactional(readOnly = true)
- public AutomationCompositionPrimedResponse getAutomationCompositionPriming(String name, String version)
- throws PfModelException {
-
- List<AutomationComposition> automationCompositions =
- automationCompositionProvider.getAutomationCompositions(name, version);
-
- var response = new AutomationCompositionPrimedResponse();
-
- automationCompositions.forEach(automationComposition -> {
- var primed = new AutomationCompositionPrimed();
- primed.setName(automationComposition.getName());
- primed.setVersion(automationComposition.getVersion());
- primed.setPrimed(automationComposition.getPrimed());
- response.getPrimedAutomationCompositionsList().add(primed);
- });
-
- return response;
- }
-
- /**
- * Creates instance element name.
- *
- * @param serviceTemplate the service template
- * @param automationCompositions a list of automation compositions
- * @return the result of the instance properties and instantiation operation
- * @throws PfModelException on creation errors
- */
- private InstancePropertiesResponse saveInstancePropertiesAndAutomationComposition(
- ToscaServiceTemplate serviceTemplate, AutomationCompositions automationCompositions) throws PfModelException {
-
- for (var automationComposition : automationCompositions.getAutomationCompositionList()) {
- var checkAutomationCompositionOpt =
- automationCompositionProvider.findAutomationComposition(automationComposition.getKey().asIdentifier());
- if (checkAutomationCompositionOpt.isPresent()) {
- throw new PfModelException(Response.Status.BAD_REQUEST, "Automation composition with id "
- + automationComposition.getKey().asIdentifier() + " already defined");
- }
- }
- Map<String, ToscaNodeTemplate> toscaSavedNodeTemplate =
- automationCompositionProvider.saveInstanceProperties(serviceTemplate);
- automationCompositionProvider.saveAutomationCompositions(automationCompositions.getAutomationCompositionList());
- List<ToscaConceptIdentifier> affectedAutomationCompositions = automationCompositions
- .getAutomationCompositionList().stream().map(ac -> ac.getKey().asIdentifier()).collect(Collectors.toList());
-
- List<ToscaConceptIdentifier> toscaAffectedProperties = toscaSavedNodeTemplate.values().stream()
- .map(template -> template.getKey().asIdentifier()).collect(Collectors.toList());
-
- var response = new InstancePropertiesResponse();
- response.setAffectedInstanceProperties(Stream.of(affectedAutomationCompositions, toscaAffectedProperties)
- .flatMap(Collection::stream).collect(Collectors.toList()));
-
- return response;
- }
-
- /**
- * Crates a new automation composition instance.
- *
- * @param instanceName automation composition Instance name
- * @param automationComposition empty automation composition
- * @param automationCompositionElements new automation composition Element map
- * @param template original Cloned Tosca Node Template
- * @param newNodeTemplate new Tosca Node Template
- */
- private void crateNewAutomationCompositionInstance(String instanceName, AutomationComposition automationComposition,
- Map<UUID, AutomationCompositionElement> automationCompositionElements, ToscaNodeTemplate template,
- ToscaNodeTemplate newNodeTemplate) {
- if (template.getType().equals(AUTOMATION_COMPOSITION_NODE_TYPE)) {
- automationComposition.setDefinition(getAutomationCompositionDefinition(newNodeTemplate));
- }
-
- if (template.getType().contains(AUTOMATION_COMPOSITION_NODE_ELEMENT_TYPE)) {
- AutomationCompositionElement automationCompositionElement =
- getAutomationCompositionElement(newNodeTemplate);
- automationCompositionElements.put(automationCompositionElement.getId(), automationCompositionElement);
- }
-
- automationComposition.setName(instanceName);
- automationComposition.setVersion(template.getVersion());
- automationComposition.setDescription("Automation composition " + instanceName);
- automationComposition.setState(AutomationCompositionState.UNINITIALISED);
- automationComposition.setOrderedState(AutomationCompositionOrderedState.UNINITIALISED);
- }
-
- /**
- * Get's the instance property name of the automation composition.
- *
- * @param name the name of the automation composition to get, null for all automation compositions
- * @param version the version of the automation composition to get, null for all automation compositions
- * @return the instance name of the automation composition instance properties
- * @throws PfModelException on errors getting automation compositions
- */
- private String getInstancePropertyName(String name, String version) throws PfModelException {
- List<String> toscaDefinitionsNames =
- automationCompositionProvider.getAutomationCompositions(name, version).stream()
- .map(AutomationComposition::getDefinition).map(ToscaNameVersion::getName).collect(Collectors.toList());
-
- return toscaDefinitionsNames.stream().reduce("", (s1, s2) -> {
-
- if (s2.contains(HYPHEN)) {
- String[] instances = s2.split(HYPHEN);
-
- return HYPHEN + instances[1];
- }
-
- return s1;
- });
- }
-
- /**
- * Retrieves automation composition Definition.
- *
- * @param template tosca node template
- * @return automation composition definition
- */
- private ToscaConceptIdentifier getAutomationCompositionDefinition(ToscaNodeTemplate template) {
- ToscaConceptIdentifier definition = new ToscaConceptIdentifier();
- definition.setName(template.getName());
- definition.setVersion(template.getVersion());
- return definition;
- }
-
- /**
- * Retrieves automation composition Element.
- *
- * @param template tosca node template
- * @return a automation composition element
- */
- @SuppressWarnings("unchecked")
- private AutomationCompositionElement getAutomationCompositionElement(ToscaNodeTemplate template) {
- AutomationCompositionElement automationCompositionElement = new AutomationCompositionElement();
- ToscaConceptIdentifier definition = new ToscaConceptIdentifier();
- definition.setName(template.getName());
- definition.setVersion(template.getVersion());
- automationCompositionElement.setDefinition(definition);
- LinkedTreeMap<String, Object> participantId =
- (LinkedTreeMap<String, Object>) template.getProperties().get(PARTICIPANT_ID_PROPERTY_KEY);
- if (participantId != null) {
- ToscaConceptIdentifier participantIdProperty = new ToscaConceptIdentifier();
- participantIdProperty.setName(String.valueOf(participantId.get(AC_ELEMENT_NAME)));
- participantIdProperty.setVersion(String.valueOf(participantId.get(AC_ELEMENT_VERSION)));
- automationCompositionElement.setParticipantId(participantIdProperty);
- }
- LinkedTreeMap<String, Object> participantType =
- (LinkedTreeMap<String, Object>) template.getProperties().get(PARTICIPANT_TYPE_PROPERTY_KEY);
- if (participantType != null) {
- ToscaConceptIdentifier participantTypeProperty = new ToscaConceptIdentifier();
- participantTypeProperty.setName(String.valueOf(participantType.get(AC_ELEMENT_NAME)));
- participantTypeProperty.setVersion(participantType.get(AC_ELEMENT_VERSION).toString());
- automationCompositionElement.setParticipantType(participantTypeProperty);
- }
- return automationCompositionElement;
- }
-
- /**
- * Deep clones ToscaNodeTemplate.
- *
- * @param serviceTemplate ToscaServiceTemplate
- * @return a cloned Hash Map of ToscaNodeTemplate
- */
- private Map<String, ToscaNodeTemplate> deepCloneNodeTemplate(ToscaServiceTemplate serviceTemplate) {
- String jsonString = GSON.toJson(serviceTemplate.getToscaTopologyTemplate().getNodeTemplates());
- Type type = new TypeToken<HashMap<String, ToscaNodeTemplate>>() {}.getType();
- return GSON.fromJson(jsonString, type);
- }
-
- /**
- * Updates Automation composition instance name.
- *
- * @param oldInstanceName previous saved instance name
- * @param newInstanceName new instance name to replace the previous one
- * @return AutomationCompositions updated
- * @throws PfModelException exception to compositions is not defined
- */
- private AutomationCompositions updateAutomationComposition(
- String oldInstanceName, String newInstanceName) throws PfModelException {
-
- List<AutomationComposition> filteredAcmList = automationCompositionProvider.getAutomationCompositions()
- .stream().filter(acm -> acm.getName().contains(oldInstanceName)).collect(Collectors.toList());
-
- if (filteredAcmList.isEmpty()) {
- throw new PfModelException(Status.BAD_REQUEST, "Automation compositions not defined!");
- }
-
- AutomationComposition automationComposition = filteredAcmList.get(0);
-
- automationComposition.getDefinition()
- .setName(updateInstanceNameDescription(newInstanceName, oldInstanceName,
- automationComposition.getDefinition().getName()));
-
- automationComposition.setName(newInstanceName);
-
- automationComposition.setDescription(
- updateInstanceNameDescription(newInstanceName, oldInstanceName,
- automationComposition.getDescription()));
-
- automationComposition.getElements().forEach((uuid, automationCompositionElement) -> {
- automationCompositionElement.getDefinition()
- .setName(updateInstanceNameDescription(newInstanceName, oldInstanceName,
- automationCompositionElement.getDefinition().getName()));
- });
-
- AutomationCompositions automationCompositions = new AutomationCompositions();
- automationCompositions.getAutomationCompositionList().add(automationComposition);
-
- return automationCompositions;
-
- }
-
- /**
- * Updates instance and description.
- *
- * @param newInstanceName new instance name to replace the previous one
- * @param oldInstanceName previous saved instance name
- * @param value to be updated
- * @return String updated instance name or description
- */
- private String updateInstanceNameDescription(
- String newInstanceName, String oldInstanceName, String value) {
- String toBeReplaced = value.substring(value.indexOf(oldInstanceName));
-
- String replace = value.replace(toBeReplaced, newInstanceName);
-
- return replace;
- }
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java
index 4cd384ede..fef1e6de9 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/CommissioningController.java
@@ -29,9 +29,7 @@ import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import io.swagger.annotations.ResponseHeader;
import java.util.List;
-import java.util.Map;
import java.util.UUID;
-import javax.ws.rs.core.Response.Status;
import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.acm.runtime.commissioning.CommissioningProvider;
import org.onap.policy.clamp.acm.runtime.main.web.AbstractRestController;
@@ -312,140 +310,4 @@ public class CommissioningController extends AbstractRestController {
return ResponseEntity.ok().body(provider.getToscaServiceTemplateReduced(name, version, instanceName));
}
-
- /**
- * Retrieves the Common or Instance Properties for the specified Tosca Service Template.
- *
- * @param requestId request ID used in ONAP logging
- * @param common a flag, true to get common properties, false to get instance properties
- * @param name the name of the tosca service template to retrieve
- * @param version the version of the tosca service template to get
- * @return the specified tosca service template or section Json Schema
- * @throws PfModelException on errors getting the Common or Instance Properties
- */
- // @formatter:off
- @GetMapping(value = "/commission/getCommonOrInstanceProperties",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested tosca service template common or instance properties",
- notes = "Queries details of the requested commissioned tosca service template json common"
- + "or instance properties, returning all tosca service template common or instance property details",
- response = ToscaServiceTemplate.class,
- tags = {"Clamp Automation Composition Commissioning API"},
- authorizations = @Authorization(value = AUTHORIZATION_TYPE),
- responseHeaders = {
- @ResponseHeader(
- name = VERSION_MINOR_NAME, description = VERSION_MINOR_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_PATCH_NAME, description = VERSION_PATCH_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = VERSION_LATEST_NAME, description = VERSION_LATEST_DESCRIPTION,
- response = String.class),
- @ResponseHeader(name = REQUEST_ID_NAME, description = REQUEST_ID_HDR_DESCRIPTION,
- response = UUID.class)},
- extensions = {
- @Extension
- (
- name = EXTENSION_NAME,
- properties = {
- @ExtensionProperty(name = API_VERSION_NAME, value = API_VERSION),
- @ExtensionProperty(name = LAST_MOD_NAME, value = LAST_MOD_RELEASE)
- }
- )
- }
- )
- @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<Map<String, ToscaNodeTemplate>> queryToscaServiceCommonOrInstanceProperties(
- @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Tosca service template name", required = false) @RequestParam(
- value = "name",
- required = false) String name,
- @ApiParam(value = "Tosca service template version", required = false) @RequestParam(
- value = "version",
- required = false) String version,
- @ApiParam(value = "Automation composition name", required = false) @RequestParam(
- value = "instanceName",
- required = false) String instanceName,
- @ApiParam(
- value = "Flag, true for common properties, false for instance",
- required = false)
- @RequestParam(value = "common", defaultValue = "false", required = false) boolean common)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider
- .getNodeTemplatesWithCommonOrInstanceProperties(name, version, instanceName, common));
- }
-
- /**
- * Queries the elements of a specific automation composition.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the automation composition definition to get
- * @param version the version of the automation composition definition to get
- * @return the automation composition element definitions
- * @throws PfModelException on errors getting the elements of a specific automation composition
- */
- // @formatter:off
- @GetMapping(value = "/commission/elements",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested commissioned automation composition element definitions",
- notes = "Queries details of the requested commissioned automation composition element definitions, "
- + "returning all automation composition elements' details",
- response = ToscaNodeTemplate.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<List<ToscaNodeTemplate>> queryElements(
- @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Automation composition definition name", required = false) @RequestParam(
- value = "name",
- required = false) String name,
- @ApiParam(value = "Automation composition definition version", required = false) @RequestParam(
- value = "version",
- required = false) String version)
- throws PfModelException {
-
- List<ToscaNodeTemplate> nodeTemplate = provider.getAutomationCompositionDefinitions(name, version);
- // Prevent ambiguous queries with multiple returns
- if (nodeTemplate.size() > 1) {
- throw new PfModelException(Status.NOT_ACCEPTABLE, "Multiple automation compositions are not supported");
- }
-
- List<ToscaNodeTemplate> response = provider.getAutomationCompositionElementDefinitions(nodeTemplate.get(0));
- return ResponseEntity.ok().body(response);
- }
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java
index b4d978d77..ba00c0ede 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/InstantiationController.java
@@ -35,13 +35,9 @@ import org.onap.policy.clamp.acm.runtime.instantiation.AutomationCompositionInst
import org.onap.policy.clamp.acm.runtime.main.web.AbstractRestController;
import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException;
import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions;
-import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AutomationCompositionOrderStateResponse;
-import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AutomationCompositionPrimedResponse;
-import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstancePropertiesResponse;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationCommand;
import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse;
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;
@@ -131,201 +127,6 @@ public class InstantiationController extends AbstractRestController {
}
/**
- * Saves instance properties.
- *
- * @param requestId request ID used in ONAP logging
- * @param body the body of automation composition 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.createInstanceProperties(body));
- }
-
- /**
- * Updates instance properties.
- *
- * @param name the name of the automation composition to update
- * @param version the version of the automation composition to update
- * @param body the body of automation composition following TOSCA definition
- * @return a response
- */
- // @formatter:off
- @PutMapping(value = "/instanceProperties",
- consumes = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML},
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(
- value = "Updates instance properties",
- notes = "Updates 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> updatesInstanceProperties(
- @RequestHeader(name = REQUEST_ID_NAME, required = false)
- @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Automation composition definition name", required = true)
- @RequestParam("name") String name,
- @ApiParam(value = "Automation composition definition version", required = true)
- @RequestParam("version") String version,
- @ApiParam(value = "Body of instance properties", required = true) @RequestBody ToscaServiceTemplate body)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.updatesInstanceProperties(name, version, body));
- }
-
- /**
- * Deletes a automation composition definition and instance properties.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the automation composition to delete
- * @param version the version of the automation composition to delete
- * @return a response
- * @throws PfModelException on errors deleting of automation composition and instance properties
- */
- // @formatter:off
- @DeleteMapping(value = "/instanceProperties",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Delete a automation composition and instance properties",
- notes = "Deletes a automation composition and instance properties, returning optional error details",
- response = InstantiationResponse.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<InstantiationResponse> deleteInstanceProperties(
- @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Automation composition definition name", required = true) @RequestParam("name") String name,
- @ApiParam(value = "Automation composition definition version") @RequestParam(
- value = "version",
- required = true) String version)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.deleteInstanceProperties(name, version));
- }
-
- /**
* Queries details of all automation compositions.
*
* @param requestId request ID used in ONAP logging
@@ -570,122 +371,4 @@ public class InstantiationController extends AbstractRestController {
return ResponseEntity.accepted().body(provider.issueAutomationCompositionCommand(command));
}
-
- /**
- * Queries details of all automation compositions.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the automation composition to get, null for all automation compositions
- * @param version the version of the automation composition to get, null for all automation compositions
- * @return the automation compositions
- * @throws PfModelException on errors getting commissioning of automation composition
- */
- // @formatter:off
- @GetMapping(value = "/instantiationState",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query details of the requested automation compositions",
- notes = "Queries details of requested automation compositions, returning all automation composition details",
- response = AutomationCompositions.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<AutomationCompositionOrderStateResponse> getInstantiationOrderState(
- @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Automation composition name", required = false) @RequestParam(
- value = "name",
- required = false) String name,
- @ApiParam(value = "Automation composition version", required = false) @RequestParam(
- value = "version",
- required = false) String version)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.getInstantiationOrderState(name, version));
- }
-
- /**
- * Queries Primed/De-Primed status of a automation composition.
- *
- * @param requestId request ID used in ONAP logging
- * @param name the name of the automation composition to get, null for all automation compositions
- * @param version the version of the automation composition to get, null for all automation compositions
- * @return the automation compositions
- * @throws PfModelException on errors getting priming of automation composition
- */
- // @formatter:off
- @GetMapping(value = "/automationCompositionPriming",
- produces = {MediaType.APPLICATION_JSON_VALUE, APPLICATION_YAML})
- @ApiOperation(value = "Query priming details of the requested automation compositions",
- notes = "Queries priming details of requested automation compositions, returning primed/deprimed compositions",
- response = AutomationCompositionPrimedResponse.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<AutomationCompositionPrimedResponse> getAutomationCompositionPriming(
- @RequestHeader(name = REQUEST_ID_NAME, required = false) @ApiParam(REQUEST_ID_PARAM_DESCRIPTION) UUID requestId,
- @ApiParam(value = "Automation composition definition name", required = false) @RequestParam(
- value = "name",
- required = false) String name,
- @ApiParam(value = "Automation composition definition version", required = false) @RequestParam(
- value = "version",
- required = false) String version)
- throws PfModelException {
-
- return ResponseEntity.ok().body(provider.getAutomationCompositionPriming(name, version));
- }
}