aboutsummaryrefslogtreecommitdiffstats
path: root/models/src
diff options
context:
space:
mode:
Diffstat (limited to 'models/src')
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java3
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java3
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantRestartAc.java2
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/element/ElementMessage.java59
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/element/ElementMessageType.java25
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/element/ElementStatus.java36
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestart.java74
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java24
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/element/ElementConfig.java36
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/element/ElementType.java26
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/element/KafkaConfig.java39
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java11
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java5
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java5
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionElementRepository.java15
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java17
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestartTest.java84
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java5
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java4
-rw-r--r--models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java10
20 files changed, 65 insertions, 418 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java
index 005d8a147..61610bb47 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationComposition.java
@@ -44,8 +44,6 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut
private UUID compositionTargetId;
- private Boolean restarting;
-
private Boolean precheck;
@NonNull
@@ -75,7 +73,6 @@ public class AutomationComposition extends ToscaEntity implements Comparable<Aut
this.instanceId = otherAutomationComposition.instanceId;
this.compositionId = otherAutomationComposition.compositionId;
this.compositionTargetId = otherAutomationComposition.compositionTargetId;
- this.restarting = otherAutomationComposition.restarting;
this.precheck = otherAutomationComposition.precheck;
this.deployState = otherAutomationComposition.deployState;
this.lockState = otherAutomationComposition.lockState;
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java
index 987cb8832..57b6837af 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/AutomationCompositionDefinition.java
@@ -41,8 +41,6 @@ public class AutomationCompositionDefinition {
@NonNull
private ToscaServiceTemplate serviceTemplate;
- private Boolean restarting;
-
@NonNull
private AcTypeState state;
@@ -63,7 +61,6 @@ public class AutomationCompositionDefinition {
public AutomationCompositionDefinition(final AutomationCompositionDefinition otherAcmDefinition) {
this.compositionId = otherAcmDefinition.compositionId;
this.serviceTemplate = new ToscaServiceTemplate(otherAcmDefinition.serviceTemplate);
- this.restarting = otherAcmDefinition.restarting;
this.state = otherAcmDefinition.state;
this.lastMsg = otherAcmDefinition.lastMsg;
this.elementStateMap = PfUtils.mapMap(otherAcmDefinition.elementStateMap, NodeTemplateState::new);
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantRestartAc.java b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantRestartAc.java
index 3312752fa..5d4b8ac77 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantRestartAc.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/concepts/ParticipantRestartAc.java
@@ -39,6 +39,7 @@ public class ParticipantRestartAc {
private DeployState deployState;
private LockState lockState;
+ private StateChangeResult stateChangeResult;
private List<AcElementRestart> acElementList = new ArrayList<>();
@@ -51,6 +52,7 @@ public class ParticipantRestartAc {
this.automationCompositionId = copyConstructor.automationCompositionId;
this.deployState = copyConstructor.deployState;
this.lockState = copyConstructor.lockState;
+ this.stateChangeResult = copyConstructor.stateChangeResult;
this.acElementList = PfUtils.mapList(copyConstructor.acElementList, AcElementRestart::new);
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/element/ElementMessage.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/element/ElementMessage.java
deleted file mode 100644
index 13a1b735b..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/element/ElementMessage.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022,2024 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.models.acm.messages.kafka.element;
-
-import java.time.Instant;
-import java.util.UUID;
-import lombok.AccessLevel;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-@Getter
-@Setter
-@ToString
-public class ElementMessage {
-
- @Setter(AccessLevel.NONE)
- private ElementMessageType messageType;
-
- private ToscaConceptIdentifier elementId;
-
- private String message;
-
- private UUID messageId = UUID.randomUUID();
-
- /**
- * Time-stamp, in milliseconds, when the message was created. Defaults to the
- * current time.
- */
- private Instant timestamp = Instant.now();
-
- /**
- * Constructor for instantiating a element message class.
- *
- * @param messageType the message type
- */
- public ElementMessage(ElementMessageType messageType) {
- this.messageType = messageType;
- }
-}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/element/ElementMessageType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/element/ElementMessageType.java
deleted file mode 100644
index cb2eaae95..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/element/ElementMessageType.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022,2024 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.models.acm.messages.kafka.element;
-
-public enum ElementMessageType {
- STATUS, ACK_MSG
-}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/element/ElementStatus.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/element/ElementStatus.java
deleted file mode 100644
index 497dca408..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/element/ElementStatus.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2021-2022,2024 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.models.acm.messages.kafka.element;
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-@Getter
-@Setter
-@ToString(callSuper = true)
-public class ElementStatus extends ElementMessage {
-
- public ElementStatus() {
- super(ElementMessageType.STATUS);
- }
-
-}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestart.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestart.java
deleted file mode 100644
index ff9755ec1..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestart.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2023-2024 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.models.acm.messages.kafka.participant;
-
-import java.util.ArrayList;
-import java.util.List;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantRestartAc;
-import org.onap.policy.models.base.PfUtils;
-
-@Getter
-@Setter
-@ToString(callSuper = true)
-public class ParticipantRestart extends ParticipantMessage {
-
- // composition state
- private AcTypeState state;
-
- // element definition
- private List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
-
- // automation composition instances list
- private List<ParticipantRestartAc> automationcompositionList = new ArrayList<>();
-
- /**
- * Constructor.
- */
- public ParticipantRestart() {
- super(ParticipantMessageType.PARTICIPANT_RESTART);
- }
-
- /**
- * Constructor with message type.
- * @param messageType messageType
- */
- public ParticipantRestart(ParticipantMessageType messageType) {
- super(messageType);
- }
-
- /**
- * Constructs the object, making a deep copy.
- *
- * @param source source from which to copy
- */
- public ParticipantRestart(ParticipantRestart source) {
- super(source);
- this.state = source.state;
- this.participantDefinitionUpdates =
- PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new);
- this.automationcompositionList = PfUtils.mapList(source.automationcompositionList, ParticipantRestartAc::new);
- }
-}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java
index 962b6137c..2780a5b1e 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantSync.java
@@ -20,21 +20,38 @@
package org.onap.policy.clamp.models.acm.messages.kafka.participant;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
+import org.onap.policy.clamp.models.acm.concepts.AcTypeState;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
+import org.onap.policy.clamp.models.acm.concepts.ParticipantRestartAc;
+import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
+import org.onap.policy.models.base.PfUtils;
@Getter
@Setter
@ToString(callSuper = true)
-public class ParticipantSync extends ParticipantRestart {
+public class ParticipantSync extends ParticipantMessage {
+
+ // composition state
+ private AcTypeState state;
+
+ // element definition
+ private List<ParticipantDefinition> participantDefinitionUpdates = new ArrayList<>();
+
+ // automation composition instances list
+ private List<ParticipantRestartAc> automationcompositionList = new ArrayList<>();
private Set<UUID> excludeReplicas = new HashSet<>();
private boolean restarting = false;
private boolean delete = false;
+ private StateChangeResult stateChangeResult;
/**
* Constructor.
@@ -50,8 +67,13 @@ public class ParticipantSync extends ParticipantRestart {
*/
public ParticipantSync(ParticipantSync source) {
super(source);
+ this.state = source.state;
+ this.participantDefinitionUpdates =
+ PfUtils.mapList(source.participantDefinitionUpdates, ParticipantDefinition::new);
+ this.automationcompositionList = PfUtils.mapList(source.automationcompositionList, ParticipantRestartAc::new);
this.excludeReplicas = new HashSet<>(source.excludeReplicas);
this.restarting = source.restarting;
this.delete = source.delete;
+ this.stateChangeResult = source.getStateChangeResult();
}
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/element/ElementConfig.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/element/ElementConfig.java
deleted file mode 100644
index bb3670cb7..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/element/ElementConfig.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022,2024 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.models.acm.messages.rest.element;
-
-import lombok.Data;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-@Data
-public class ElementConfig {
-
- private ToscaConceptIdentifier receiverId;
-
- private ElementType elementType;
-
- private Integer timerMs;
-
- private KafkaConfig topicParameterGroup;
-}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/element/ElementType.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/element/ElementType.java
deleted file mode 100644
index 4bc08a36e..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/element/ElementType.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022 Nordix Foundation.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * 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.models.acm.messages.rest.element;
-
-public enum ElementType {
-
- STARTER, BRIDGE, SINK
-}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/element/KafkaConfig.java b/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/element/KafkaConfig.java
deleted file mode 100644
index 35871fcbf..000000000
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/messages/rest/element/KafkaConfig.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2022,2024 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.models.acm.messages.rest.element;
-
-import lombok.Data;
-
-@Data
-public class KafkaConfig {
- private String server;
-
- private String listenerTopic;
-
- private String publisherTopic;
-
- private Integer fetchTimeout;
-
- private String topicCommInfrastructure;
-
- private boolean useHttps;
-
-}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
index 1f4768ea8..001f2e7f3 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationComposition.java
@@ -87,9 +87,6 @@ public class JpaAutomationComposition extends Validated
private String compositionTargetId;
@Column
- private Boolean restarting;
-
- @Column
@NotNull
private DeployState deployState;
@@ -163,7 +160,6 @@ public class JpaAutomationComposition extends Validated
this.version = copyConcept.version;
this.compositionId = copyConcept.compositionId;
this.compositionTargetId = copyConcept.compositionTargetId;
- this.restarting = copyConcept.restarting;
this.deployState = copyConcept.deployState;
this.lockState = copyConcept.lockState;
this.lastMsg = copyConcept.lastMsg;
@@ -194,7 +190,6 @@ public class JpaAutomationComposition extends Validated
if (compositionTargetId != null) {
automationComposition.setCompositionTargetId(UUID.fromString(compositionTargetId));
}
- automationComposition.setRestarting(restarting);
automationComposition.setDeployState(deployState);
automationComposition.setLockState(lockState);
automationComposition.setLastMsg(lastMsg.toString());
@@ -235,7 +230,6 @@ public class JpaAutomationComposition extends Validated
if (automationComposition.getCompositionTargetId() != null) {
this.compositionTargetId = automationComposition.getCompositionTargetId().toString();
}
- this.restarting = automationComposition.getRestarting();
this.deployState = automationComposition.getDeployState();
this.lockState = automationComposition.getLockState();
this.lastMsg = TimestampHelper.toTimestamp(automationComposition.getLastMsg());
@@ -289,11 +283,6 @@ public class JpaAutomationComposition extends Validated
return result;
}
- result = ObjectUtils.compare(restarting, other.restarting);
- if (result != 0) {
- return result;
- }
-
result = ObjectUtils.compare(deployState, other.deployState);
if (result != 0) {
return result;
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java
index 1cab89d5d..3d61c4ed9 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionDefinition.java
@@ -79,9 +79,6 @@ public class JpaAutomationCompositionDefinition extends Validated
private String version;
@Column
- private Boolean restarting;
-
- @Column
@NotNull
private AcTypeState state;
@@ -107,7 +104,6 @@ public class JpaAutomationCompositionDefinition extends Validated
public AutomationCompositionDefinition toAuthorative() {
var acmDefinition = new AutomationCompositionDefinition();
acmDefinition.setCompositionId(UUID.fromString(this.compositionId));
- acmDefinition.setRestarting(this.restarting);
acmDefinition.setState(this.state);
acmDefinition.setStateChangeResult(this.stateChangeResult);
acmDefinition.setLastMsg(this.lastMsg.toString());
@@ -122,7 +118,6 @@ public class JpaAutomationCompositionDefinition extends Validated
@Override
public void fromAuthorative(final AutomationCompositionDefinition copyConcept) {
this.compositionId = copyConcept.getCompositionId().toString();
- this.restarting = copyConcept.getRestarting();
this.state = copyConcept.getState();
this.stateChangeResult = copyConcept.getStateChangeResult();
this.lastMsg = TimestampHelper.toTimestamp(copyConcept.getLastMsg());
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java
index 46b43f950..bb05c46c6 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProvider.java
@@ -138,10 +138,8 @@ public class AcDefinitionProvider {
* @param compositionId The UUID of the automation composition definition to update
* @param state the AcTypeState
* @param stateChangeResult the StateChangeResult
- * @param restarting restarting process
*/
- public void updateAcDefinitionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult,
- Boolean restarting) {
+ public void updateAcDefinitionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult) {
var jpaUpdate = acmDefinitionRepository.findById(compositionId.toString());
if (jpaUpdate.isEmpty()) {
String errorMessage = "update of Automation Composition Definition \"" + compositionId
@@ -151,7 +149,6 @@ public class AcDefinitionProvider {
var acDefinition = jpaUpdate.get();
acDefinition.setState(state);
acDefinition.setStateChangeResult(stateChangeResult);
- acDefinition.setRestarting(restarting);
acmDefinitionRepository.save(acDefinition);
acmDefinitionRepository.flush();
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionElementRepository.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionElementRepository.java
index 19d791e6c..d0a996e20 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionElementRepository.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/repository/AutomationCompositionElementRepository.java
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2023 Nordix Foundation.
+ * Copyright (C) 2024 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,14 +20,19 @@
package org.onap.policy.clamp.models.acm.persistence.repository;
+import jakarta.persistence.LockModeType;
import java.util.List;
import org.onap.policy.clamp.models.acm.persistence.concepts.JpaAutomationCompositionElement;
import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.repository.query.QueryByExampleExecutor;
+import org.springframework.data.jpa.repository.Lock;
+import org.springframework.lang.NonNull;
-public interface AutomationCompositionElementRepository extends
- JpaRepository<JpaAutomationCompositionElement, String>,
- QueryByExampleExecutor<JpaAutomationCompositionElement> {
+public interface AutomationCompositionElementRepository extends JpaRepository<JpaAutomationCompositionElement, String> {
+
+ @NonNull
+ @Override
+ @Lock(LockModeType.PESSIMISTIC_READ)
+ JpaAutomationCompositionElement getReferenceById(@NonNull String id);
List<JpaAutomationCompositionElement> findByParticipantId(String participantId);
}
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
index aaf41ddeb..172de34fe 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/utils/AcmUtils.java
@@ -65,6 +65,8 @@ 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.ToscaTopologyTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Utility functions used in acm-runtime and participants.
@@ -75,6 +77,8 @@ public final class AcmUtils {
public static final String ENTRY = "entry ";
private static final StringToMapConverter MAP_CONVERTER = new StringToMapConverter();
+ private static final Logger LOGGER = LoggerFactory.getLogger(AcmUtils.class);
+
/**
* Get the Policy information in the service template for the deploy message to participants.
*
@@ -536,6 +540,19 @@ public final class AcmUtils {
return list;
}
+ /**
+ * Validated the Message field.
+ *
+ * @param message the message
+ * @return a validated message
+ */
+ public static String validatedMessage(String message) {
+ if (message != null && message.length() > 255) {
+ LOGGER.warn("message too long {}", message);
+ return message.substring(0, 255);
+ }
+ return message;
+ }
/**
* Recursive Merge.
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestartTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestartTest.java
deleted file mode 100644
index 95b718e68..000000000
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/messages/kafka/participant/ParticipantRestartTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * Copyright (C) 2023-2024 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.models.acm.messages.kafka.participant;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageUtils.assertSerializable;
-import static org.onap.policy.clamp.models.acm.messages.kafka.participant.ParticipantMessageUtils.removeVariableFields;
-
-import java.time.Instant;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import org.junit.jupiter.api.Test;
-import org.onap.policy.clamp.models.acm.concepts.AcElementRestart;
-import org.onap.policy.clamp.models.acm.concepts.DeployState;
-import org.onap.policy.clamp.models.acm.concepts.LockState;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantDefinition;
-import org.onap.policy.clamp.models.acm.concepts.ParticipantRestartAc;
-import org.onap.policy.clamp.models.acm.utils.CommonTestData;
-import org.onap.policy.common.utils.coder.CoderException;
-import org.onap.policy.models.tosca.authorative.concepts.ToscaConceptIdentifier;
-
-class ParticipantRestartTest {
-
- @Test
- void testCopyConstructor() throws CoderException {
-
- final var orig = new ParticipantRestart();
- // verify with null values
- assertEquals(removeVariableFields(orig.toString()),
- removeVariableFields(new ParticipantRestart(orig).toString()));
-
- orig.setMessageId(UUID.randomUUID());
- orig.setCompositionId(UUID.randomUUID());
- orig.setTimestamp(Instant.ofEpochMilli(3000));
- orig.setParticipantId(CommonTestData.getParticipantId());
-
- var participantDefinitionUpdate = new ParticipantDefinition();
- var type = new ToscaConceptIdentifier("id", "1.2.3");
- var acDefinition = CommonTestData.getAcElementDefinition(type);
- participantDefinitionUpdate.setAutomationCompositionElementDefinitionList(List.of(acDefinition));
- orig.setParticipantDefinitionUpdates(List.of(participantDefinitionUpdate));
-
- var acElement = new AcElementRestart();
- acElement.setId(UUID.randomUUID());
- var id = new ToscaConceptIdentifier("id", "1.2.3");
- acElement.setDefinition(id);
- acElement.setDeployState(DeployState.DEPLOYED);
- acElement.setLockState(LockState.LOCKED);
- acElement.setOperationalState("OperationalState");
- acElement.setUseState("UseState");
- acElement.setProperties(Map.of("key", "value"));
- acElement.setOutProperties(Map.of("keyOut", "valueOut"));
-
- var acRestart = new ParticipantRestartAc();
- acRestart.setAcElementList(List.of(acElement));
- acRestart.setAutomationCompositionId(UUID.randomUUID());
-
- orig.setAutomationcompositionList(List.of(acRestart));
-
- assertEquals(removeVariableFields(orig.toString()),
- removeVariableFields(new ParticipantRestart(orig).toString()));
-
- assertSerializable(orig, ParticipantRestart.class);
- }
-}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
index 541e9ba6f..38153d488 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/concepts/JpaAutomationCompositionTest.java
@@ -213,11 +213,6 @@ class JpaAutomationCompositionTest {
jpaAutomationComposition.setDescription(null);
assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- jpaAutomationComposition.setRestarting(true);
- assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
- jpaAutomationComposition.setRestarting(null);
- assertEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
-
jpaAutomationComposition.setStateChangeResult(StateChangeResult.NO_ERROR);
assertNotEquals(0, jpaAutomationComposition.compareTo(otherJpaAutomationComposition));
jpaAutomationComposition.setStateChangeResult(null);
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java
index 85dadc3de..95811917d 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/persistence/provider/AcDefinitionProviderTest.java
@@ -83,7 +83,7 @@ class AcDefinitionProviderTest {
.hasMessageStartingWith("\"AutomationCompositionDefinition\" INVALID, item has status INVALID");
assertThatThrownBy(() -> acDefinitionProvider.updateAcDefinitionState(compositionId, AcTypeState.PRIMED,
- StateChangeResult.NO_ERROR, false))
+ StateChangeResult.NO_ERROR))
.hasMessageStartingWith("update of Automation Composition Definition");
}
@@ -195,7 +195,7 @@ class AcDefinitionProviderTest {
when(acmDefinitionRepository.findById(acmDefinition.getCompositionId().toString()))
.thenReturn(Optional.of(jpa));
acDefinitionProvider.updateAcDefinitionState(acmDefinition.getCompositionId(), AcTypeState.PRIMED,
- StateChangeResult.NO_ERROR, false);
+ StateChangeResult.NO_ERROR);
verify(acmDefinitionRepository).save(jpa);
}
diff --git a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
index 5d0a7d95a..97af64cf7 100644
--- a/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
+++ b/models/src/test/java/org/onap/policy/clamp/models/acm/utils/AcmUtilsTest.java
@@ -238,6 +238,16 @@ class AcmUtilsTest {
assertEquals(element.getOutProperties(), result.getOutProperties());
}
+ @Test
+ void testValidatedMessage() {
+ var message = "completed";
+ assertEquals(message, AcmUtils.validatedMessage(message));
+
+ var serviceTemplate = CommonTestData.getToscaServiceTemplate(TOSCA_TEMPLATE_YAML);
+ message = serviceTemplate.toString();
+ assertEquals(message.substring(0, 255), AcmUtils.validatedMessage(message));
+ }
+
private AutomationComposition getDummyAutomationComposition() {
var automationComposition = new AutomationComposition();
automationComposition.setCompositionId(UUID.randomUUID());