aboutsummaryrefslogtreecommitdiffstats
path: root/runtime-acm/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'runtime-acm/src/main/java')
-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/main/rest/CommissioningController.java10
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/stub/CommissioningControllerStub.java8
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java3
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java5
5 files changed, 31 insertions, 34 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 9f898d88d..450c75564 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -24,7 +24,10 @@ package org.onap.policy.clamp.acm.runtime.commissioning;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.ws.rs.core.Response.Status;
+import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.acm.runtime.supervision.SupervisionHandler;
+import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
import org.onap.policy.clamp.models.acm.messages.rest.commissioning.CommissioningResponse;
import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider;
import org.onap.policy.clamp.models.acm.persistence.provider.AutomationCompositionProvider;
@@ -42,29 +45,14 @@ import org.springframework.transaction.annotation.Transactional;
*/
@Service
@Transactional
+@RequiredArgsConstructor
public class CommissioningProvider {
public static final String AUTOMATION_COMPOSITION_NODE_TYPE = "org.onap.policy.clamp.acm.AutomationComposition";
private final AcDefinitionProvider acDefinitionProvider;
private final AutomationCompositionProvider acProvider;
- private final ParticipantProvider participantProvider;
private final SupervisionHandler supervisionHandler;
-
- /**
- * Create a commissioning provider.
- *
- * @param acDefinitionProvider the ServiceTemplate Provider
- * @param acProvider the AutomationComposition Provider
- * @param supervisionHandler the Supervision Handler
- * @param participantProvider the Participant Provider
- */
- public CommissioningProvider(AcDefinitionProvider acDefinitionProvider, AutomationCompositionProvider acProvider,
- SupervisionHandler supervisionHandler, ParticipantProvider participantProvider) {
- this.acDefinitionProvider = acDefinitionProvider;
- this.acProvider = acProvider;
- this.supervisionHandler = supervisionHandler;
- this.participantProvider = participantProvider;
- }
+ private final ParticipantProvider participantProvider;
private CommissioningResponse createCommissioningResponse(UUID compositionId,
ToscaServiceTemplate serviceTemplate) {
@@ -83,12 +71,12 @@ public class CommissioningProvider {
}
/**
- * Create automation compositions from a service template.
+ * Create automation composition from a service template.
*
* @param serviceTemplate the service template
* @return the result of the commissioning operation
*/
- public CommissioningResponse createAutomationCompositionDefinitions(ToscaServiceTemplate serviceTemplate) {
+ public CommissioningResponse createAutomationCompositionDefinition(ToscaServiceTemplate serviceTemplate) {
var acmDefinition = acDefinitionProvider.createAutomationCompositionDefinition(serviceTemplate);
serviceTemplate = acmDefinition.getServiceTemplate();
@@ -107,12 +95,15 @@ public class CommissioningProvider {
* @return the result of the commissioning operation
*/
public CommissioningResponse updateCompositionDefinition(UUID compositionId, ToscaServiceTemplate serviceTemplate) {
-
- var automationCompositions = acProvider.getAcInstancesByCompositionId(compositionId);
- if (!automationCompositions.isEmpty()) {
+ if (verifyIfInstanceExists(compositionId)) {
throw new PfModelRuntimeException(Status.BAD_REQUEST,
"There are ACM instances, Update of ACM Definition not allowed");
}
+ var acDefinition = acDefinitionProvider.getAcDefinition(compositionId);
+ if (AcTypeState.COMMISSIONED.equals(acDefinition.getState())) {
+ throw new PfModelRuntimeException(Status.BAD_REQUEST,
+ "ACM not in COMMISSIONED state, Update of ACM Definition not allowed");
+ }
acDefinitionProvider.updateServiceTemplate(compositionId, serviceTemplate);
return createCommissioningResponse(compositionId, serviceTemplate);
@@ -161,7 +152,7 @@ public class CommissioningProvider {
* @return automation composition definition
*/
@Transactional(readOnly = true)
- public ToscaServiceTemplate getAutomationCompositionDefinitions(UUID compositionId) {
+ public AutomationCompositionDefinition getAutomationCompositionDefinition(UUID compositionId) {
return acDefinitionProvider.getAcDefinition(compositionId);
}
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 7f9dc8d19..6d7ae7d4d 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022 Nordix Foundation.
+ * Copyright (C) 2021-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@ import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.acm.runtime.commissioning.CommissioningProvider;
import org.onap.policy.clamp.acm.runtime.main.rest.gen.AutomationCompositionDefinitionApi;
import org.onap.policy.clamp.acm.runtime.main.web.AbstractRestController;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
import org.onap.policy.clamp.models.acm.messages.rest.commissioning.AcTypeStateUpdate;
import org.onap.policy.clamp.models.acm.messages.rest.commissioning.CommissioningResponse;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@@ -56,7 +57,7 @@ public class CommissioningController extends AbstractRestController implements A
UUID requestId) {
var compositionId = body.getMetadata() != null ? body.getMetadata().get("compositionId") : null;
if (compositionId == null) {
- var response = provider.createAutomationCompositionDefinitions(body);
+ var response = provider.createAutomationCompositionDefinition(body);
return ResponseEntity.created(createUri("/compositions/" + response.getCompositionId())).body(response);
} else {
return ResponseEntity.ok()
@@ -91,8 +92,9 @@ public class CommissioningController extends AbstractRestController implements A
}
@Override
- public ResponseEntity<ToscaServiceTemplate> getCompositionDefinition(UUID compositionId, UUID requestId) {
- return ResponseEntity.ok().body(provider.getAutomationCompositionDefinitions(compositionId));
+ public ResponseEntity<AutomationCompositionDefinition> getCompositionDefinition(UUID compositionId,
+ UUID requestId) {
+ return ResponseEntity.ok().body(provider.getAutomationCompositionDefinition(compositionId));
}
@Override
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/stub/CommissioningControllerStub.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/stub/CommissioningControllerStub.java
index 98c71dc6f..adcb1410b 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/stub/CommissioningControllerStub.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/main/rest/stub/CommissioningControllerStub.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
+ * Copyright (C) 2022-2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,7 @@ import java.util.UUID;
import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.acm.runtime.main.rest.gen.AutomationCompositionDefinitionApi;
import org.onap.policy.clamp.acm.runtime.main.web.AbstractRestController;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionDefinition;
import org.onap.policy.clamp.models.acm.messages.rest.commissioning.AcTypeStateUpdate;
import org.onap.policy.clamp.models.acm.messages.rest.commissioning.CommissioningResponse;
import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
@@ -72,8 +73,9 @@ public class CommissioningControllerStub extends AbstractRestController implemen
}
@Override
- public ResponseEntity<ToscaServiceTemplate> getCompositionDefinition(UUID compositionId, UUID xonaprequestid) {
- return stubUtils.getResponse(pathToSingleDefinition, ToscaServiceTemplate.class);
+ public ResponseEntity<AutomationCompositionDefinition> getCompositionDefinition(UUID compositionId,
+ UUID xonaprequestid) {
+ return stubUtils.getResponse(pathToSingleDefinition, AutomationCompositionDefinition.class);
}
@Override
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
index 761c3800c..2c5d48717 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/SupervisionHandler.java
@@ -305,7 +305,8 @@ public class SupervisionHandler {
}
private int getFirstStartPhase(AutomationComposition automationComposition) {
- var toscaServiceTemplate = acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId());
+ var toscaServiceTemplate =
+ acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId()).getServiceTemplate();
return ParticipantUtils.getFirstStartPhase(automationComposition, toscaServiceTemplate);
}
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java
index 7b114c920..57556e088 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/supervision/comm/AutomationCompositionUpdatePublisher.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021,2022 Nordix Foundation.
+ * Copyright (C) 2021,2023 Nordix Foundation.
* ================================================================================
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
@@ -73,7 +73,8 @@ public class AutomationCompositionUpdatePublisher extends AbstractParticipantPub
automationCompositionUpdateMsg.setAutomationCompositionId(automationComposition.getInstanceId());
automationCompositionUpdateMsg.setMessageId(UUID.randomUUID());
automationCompositionUpdateMsg.setTimestamp(Instant.now());
- var toscaServiceTemplate = acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId());
+ var toscaServiceTemplate =
+ acDefinitionProvider.getAcDefinition(automationComposition.getCompositionId()).getServiceTemplate();
List<ParticipantUpdates> participantUpdates = new ArrayList<>();
for (var element : automationComposition.getElements().values()) {