diff options
author | 2022-01-25 19:55:43 +0000 | |
---|---|---|
committer | 2022-02-18 15:54:40 +0000 | |
commit | 43098043c4ef31d9d5dead66568d7d9482a6b165 (patch) | |
tree | 6f6ea4812ff93d65e7c64e12a3ec6ab4462a64e2 /common/src/main/java/org | |
parent | f401b5099bcb64f3e21de608d0207dd69d8043cd (diff) |
Rename TOSCA Control Loop to ACM
This commit renames the TOSCA Control Loop functionality in CLAMP to
Automation Composition Management.
This review is a direct renaming review and, as everything is renamed
together it is large.
Issue-ID: POLICY-3939
Change-Id: I28f0a6dd889bf3570a4c1365ae9e71fc58db6d6c
Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'common/src/main/java/org')
-rw-r--r-- | common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionException.java (renamed from common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java) | 23 | ||||
-rw-r--r-- | common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionRuntimeException.java (renamed from common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopRuntimeException.java) | 38 | ||||
-rw-r--r-- | common/src/main/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMesageConverter.java (renamed from common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMesageConverter.java) | 8 | ||||
-rw-r--r-- | common/src/main/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilter.java (renamed from common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilter.java) | 2 | ||||
-rw-r--r-- | common/src/main/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArguments.java (renamed from common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java) | 35 | ||||
-rw-r--r-- | common/src/main/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtils.java | 152 |
6 files changed, 55 insertions, 203 deletions
diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java b/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionException.java index 58b5368a9..c22aa920e 100644 --- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopException.java +++ b/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionException.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.common.exception; +package org.onap.policy.clamp.common.acm.exception; import javax.ws.rs.core.Response; import lombok.Getter; @@ -28,11 +28,11 @@ import org.onap.policy.models.errors.concepts.ErrorResponseInfo; import org.onap.policy.models.errors.concepts.ErrorResponseUtils; /** - * This class is a base exception from which all control loop exceptions are sub classes. + * This class is a base exception from which all automation composition exceptions are sub classes. */ @Getter @ToString -public class ControlLoopException extends Exception implements ErrorResponseInfo { +public class AutomationCompositionException extends Exception implements ErrorResponseInfo { private static final long serialVersionUID = -8507246953751956974L; // The error response of the exception @@ -42,23 +42,23 @@ public class ControlLoopException extends Exception implements ErrorResponseInfo private final transient Object object; /** - * Instantiates a new control loop exception. + * Instantiates a new automation composition exception. * * @param statusCode the status code for the response as a HTTP status code * @param message the message on the exception */ - public ControlLoopException(final Response.Status statusCode, final String message) { + public AutomationCompositionException(final Response.Status statusCode, final String message) { this(statusCode, message, null); } /** - * Instantiates a new control loop exception. + * Instantiates a new automation composition exception. * * @param statusCode the return code for the exception * @param message the message on the exception * @param object the object that the exception was thrown on */ - public ControlLoopException(final Response.Status statusCode, final String message, final Object object) { + public AutomationCompositionException(final Response.Status statusCode, final String message, final Object object) { super(message); errorResponse.setResponseCode(statusCode); ErrorResponseUtils.getExceptionMessages(errorResponse, this); @@ -66,13 +66,14 @@ public class ControlLoopException extends Exception implements ErrorResponseInfo } /** - * Instantiates a new control loop exception. + * Instantiates a new automation composition exception. * * @param statusCode the return code for the exception * @param message the message on the exception * @param exception the exception that caused this exception */ - public ControlLoopException(final Response.Status statusCode, final String message, final Exception exception) { + public AutomationCompositionException(final Response.Status statusCode, final String message, + final Exception exception) { this(statusCode, message, exception, null); } @@ -84,8 +85,8 @@ public class ControlLoopException extends Exception implements ErrorResponseInfo * @param exception the exception that caused this exception * @param object the object that the exception was thrown on */ - public ControlLoopException(final Response.Status statusCode, final String message, final Exception exception, - final Object object) { + public AutomationCompositionException(final Response.Status statusCode, final String message, + final Exception exception, final Object object) { super(message, exception); errorResponse.setResponseCode(statusCode); ErrorResponseUtils.getExceptionMessages(errorResponse, this); diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopRuntimeException.java b/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionRuntimeException.java index b110a4362..2fc427db8 100644 --- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/exception/ControlLoopRuntimeException.java +++ b/common/src/main/java/org/onap/policy/clamp/common/acm/exception/AutomationCompositionRuntimeException.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.common.exception; +package org.onap.policy.clamp.common.acm.exception; import javax.ws.rs.core.Response; import lombok.Getter; @@ -28,11 +28,12 @@ import org.onap.policy.models.errors.concepts.ErrorResponseInfo; import org.onap.policy.models.errors.concepts.ErrorResponseUtils; /** - * This class is a base control loop run time exception from which all control loop run time exceptions are sub classes. + * This class is a base automation composition run time exception from which all automation composition run time + * exceptions are sub classes. */ @Getter @ToString -public class ControlLoopRuntimeException extends RuntimeException implements ErrorResponseInfo { +public class AutomationCompositionRuntimeException extends RuntimeException implements ErrorResponseInfo { private static final long serialVersionUID = -8507246953751956974L; // The error response of the exception @@ -42,23 +43,24 @@ public class ControlLoopRuntimeException extends RuntimeException implements Err private final transient Object object; /** - * Instantiates a new control loop runtime exception. + * Instantiates a new automation composition runtime exception. * * @param statusCode the return code for the exception * @param message the message on the exception */ - public ControlLoopRuntimeException(final Response.Status statusCode, final String message) { + public AutomationCompositionRuntimeException(final Response.Status statusCode, final String message) { this(statusCode, message, null); } /** - * Instantiates a new control loop runtime exception. + * Instantiates a new automation composition runtime exception. * * @param statusCode the return code for the exception * @param message the message on the exception * @param object the object that the exception was thrown on */ - public ControlLoopRuntimeException(final Response.Status statusCode, final String message, final Object object) { + public AutomationCompositionRuntimeException(final Response.Status statusCode, final String message, + final Object object) { super(message); this.object = object; errorResponse.setResponseCode(statusCode); @@ -66,23 +68,23 @@ public class ControlLoopRuntimeException extends RuntimeException implements Err } /** - * Instantiates a new control loop runtime exception. + * Instantiates a new automation composition runtime exception. * * @param statusCode the return code for the exception * @param message the message on the exception - * @param exception the exception that caused this control loop exception + * @param exception the exception that caused this automation composition exception */ - public ControlLoopRuntimeException(final Response.Status statusCode, final String message, - final Exception exception) { + public AutomationCompositionRuntimeException(final Response.Status statusCode, final String message, + final Exception exception) { this(statusCode, message, exception, null); } /** - * Instantiates a new model runtime exception from a ControlLoopException instance. + * Instantiates a new model runtime exception from an AutomationCompositionException instance. * - * @param exception the exception that caused this control loop exception + * @param exception the exception that caused this automation composition exception */ - public ControlLoopRuntimeException(final ControlLoopException exception) { + public AutomationCompositionRuntimeException(final AutomationCompositionException exception) { super(exception.getMessage(), exception); this.object = exception.getObject(); errorResponse.setResponseCode(exception.getErrorResponse().getResponseCode()); @@ -90,15 +92,15 @@ public class ControlLoopRuntimeException extends RuntimeException implements Err } /** - * Instantiates a new control loop runtime exception. + * Instantiates a new automation composition runtime exception. * * @param statusCode the return code for the exception * @param message the message on the exception - * @param exception the exception that caused this control loop exception + * @param exception the exception that caused this automation composition exception * @param object the object that the exception was thrown on */ - public ControlLoopRuntimeException(final Response.Status statusCode, final String message, - final Exception exception, final Object object) { + public AutomationCompositionRuntimeException(final Response.Status statusCode, final String message, + final Exception exception, final Object object) { super(message, exception); this.object = object; errorResponse.setResponseCode(statusCode); diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMesageConverter.java b/common/src/main/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMesageConverter.java index 9eb43fd6f..f445364ad 100644 --- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/CoderHttpMesageConverter.java +++ b/common/src/main/java/org/onap/policy/clamp/common/acm/rest/CoderHttpMesageConverter.java @@ -18,14 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.common.rest; +package org.onap.policy.clamp.common.acm.rest; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.nio.charset.StandardCharsets; import javax.ws.rs.core.Response; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopRuntimeException; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionRuntimeException; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -57,7 +57,7 @@ public class CoderHttpMesageConverter<T> extends AbstractHttpMessageConverter<T> try (var is = new InputStreamReader(inputMessage.getBody(), StandardCharsets.UTF_8)) { return coder.decode(is, clazz); } catch (CoderException e) { - throw new ControlLoopRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e); + throw new AutomationCompositionRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e); } } @@ -67,7 +67,7 @@ public class CoderHttpMesageConverter<T> extends AbstractHttpMessageConverter<T> try (var writer = new OutputStreamWriter(outputMessage.getBody(), StandardCharsets.UTF_8)) { coder.encode(writer, t); } catch (CoderException e) { - throw new ControlLoopRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e); + throw new AutomationCompositionRuntimeException(Response.Status.BAD_REQUEST, e.getMessage(), e); } } diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilter.java b/common/src/main/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilter.java index 915cdf0b2..4b6dce46d 100644 --- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/rest/RequestResponseLoggingFilter.java +++ b/common/src/main/java/org/onap/policy/clamp/common/acm/rest/RequestResponseLoggingFilter.java @@ -20,7 +20,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.common.rest; +package org.onap.policy.clamp.common.acm.rest; import java.io.IOException; import java.util.UUID; diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java b/common/src/main/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArguments.java index 525da259f..6f6fb6a4b 100644 --- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/startstop/CommonCommandLineArguments.java +++ b/common/src/main/java/org/onap/policy/clamp/common/acm/startstop/CommonCommandLineArguments.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.clamp.controlloop.common.startstop; +package org.onap.policy.clamp.common.acm.startstop; import java.io.File; import java.io.PrintWriter; @@ -28,7 +28,7 @@ import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.lang3.StringUtils; -import org.onap.policy.clamp.controlloop.common.exception.ControlLoopException; +import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; import org.onap.policy.common.utils.resources.ResourceUtils; /** @@ -75,9 +75,9 @@ public class CommonCommandLineArguments { * Validate the command line options. * * @param configurationFilePath the path to the configuration file - * @throws ControlLoopException on command argument validation errors + * @throws AutomationCompositionException on command argument validation errors */ - public void validate(final String configurationFilePath) throws ControlLoopException { + public void validate(final String configurationFilePath) throws AutomationCompositionException { validateReadableFile("policy participant configuration", configurationFilePath); } @@ -103,7 +103,7 @@ public class CommonCommandLineArguments { final var printWriter = new PrintWriter(stringWriter); helpFormatter.printHelp(printWriter, HELP_LINE_LENGTH, mainClassName + " [options...]", "options", options, 0, - 0, ""); + 0, ""); return stringWriter.toString(); } @@ -113,33 +113,34 @@ public class CommonCommandLineArguments { * * @param fileTag the file tag * @param fileName the file name - * @throws ControlLoopException on the file name passed as a parameter + * @throws AutomationCompositionException on the file name passed as a parameter */ - private void validateReadableFile(final String fileTag, final String fileName) throws ControlLoopException { + private void validateReadableFile(final String fileTag, final String fileName) + throws AutomationCompositionException { if (StringUtils.isEmpty(fileName)) { - throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, - fileTag + " file was not specified as an argument"); + throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE, + fileTag + " file was not specified as an argument"); } // The file name refers to a resource on the local file system final var fileUrl = ResourceUtils.getUrl4Resource(fileName); if (fileUrl == null) { - throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, - fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist"); + throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE, + fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist"); } final var theFile = new File(fileUrl.getPath()); if (!theFile.exists()) { - throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, - fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist"); + throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE, + fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" does not exist"); } if (!theFile.isFile()) { - throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, - fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is not a normal file"); + throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE, + fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is not a normal file"); } if (!theFile.canRead()) { - throw new ControlLoopException(Response.Status.NOT_ACCEPTABLE, - fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is unreadable"); + throw new AutomationCompositionException(Response.Status.NOT_ACCEPTABLE, + fileTag + FILE_MESSAGE_PREAMBLE + fileName + "\" is unreadable"); } } } diff --git a/common/src/main/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtils.java b/common/src/main/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtils.java deleted file mode 100644 index 4ebd0aaa8..000000000 --- a/common/src/main/java/org/onap/policy/clamp/controlloop/common/utils/CommonUtils.java +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2021 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.clamp.controlloop.common.utils; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElement; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ControlLoopElementDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantDefinition; -import org.onap.policy.clamp.controlloop.models.controlloop.concepts.ParticipantUpdates; -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.ToscaNodeType; -import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.authorative.concepts.ToscaTopologyTemplate; - -/** - * Utility functions used in controlloop-runtime and participants. - * - */ -public class CommonUtils { - - private CommonUtils() { - throw new IllegalStateException("Utility class"); - } - - /** - * Prepare participant updates map. - * - * @param clElement controlloop element - * @param participantUpdates list of participantUpdates - */ - public static void prepareParticipantUpdate(ControlLoopElement clElement, - List<ParticipantUpdates> participantUpdates) { - if (participantUpdates.isEmpty()) { - participantUpdates.add(getControlLoopElementList(clElement)); - return; - } - - var participantExists = false; - for (ParticipantUpdates participantUpdate : participantUpdates) { - if (participantUpdate.getParticipantId().equals(clElement.getParticipantId())) { - participantUpdate.setControlLoopElementList(List.of(clElement)); - participantExists = true; - } - } - if (!participantExists) { - participantUpdates.add(getControlLoopElementList(clElement)); - } - } - - private static ParticipantUpdates getControlLoopElementList(ControlLoopElement clElement) { - var participantUpdate = new ParticipantUpdates(); - participantUpdate.setParticipantId(clElement.getParticipantId()); - participantUpdate.setControlLoopElementList(List.of(clElement)); - return participantUpdate; - } - - /** - * Set the Policy information in the service template for the controlloopelement. - * - * @param clElement controlloop element - * @param toscaServiceTemplate ToscaServiceTemplate - */ - public static void setServiceTemplatePolicyInfo(ControlLoopElement clElement, - ToscaServiceTemplate toscaServiceTemplate) { - // Pass respective PolicyTypes or Policies as part of toscaServiceTemplateFragment - if (toscaServiceTemplate.getPolicyTypes() == null - && toscaServiceTemplate.getToscaTopologyTemplate().getPolicies() == null) { - return; - } - ToscaServiceTemplate toscaServiceTemplateFragment = new ToscaServiceTemplate(); - toscaServiceTemplateFragment.setPolicyTypes(toscaServiceTemplate.getPolicyTypes()); - ToscaTopologyTemplate toscaTopologyTemplate = new ToscaTopologyTemplate(); - toscaTopologyTemplate.setPolicies(toscaServiceTemplate.getToscaTopologyTemplate().getPolicies()); - toscaServiceTemplateFragment.setToscaTopologyTemplate(toscaTopologyTemplate); - toscaServiceTemplateFragment.setDataTypes(toscaServiceTemplate.getDataTypes()); - clElement.setToscaServiceTemplateFragment(toscaServiceTemplateFragment); - } - - /** - * Prepare ParticipantDefinitionUpdate to set in the message. - * - * @param clParticipantType controlloop element - * @param entryKey key for the entry - * @param entryValue value relates to toscaNodeTemplate - * @param participantDefinitionUpdates list of participantDefinitionUpdates - * @param commonPropertiesMap common properties map - */ - public static void prepareParticipantDefinitionUpdate(ToscaConceptIdentifier clParticipantType, String entryKey, - ToscaNodeTemplate entryValue, List<ParticipantDefinition> participantDefinitionUpdates, - Map<String, ToscaNodeType> commonPropertiesMap) { - - var clDefinition = new ControlLoopElementDefinition(); - clDefinition.setClElementDefinitionId(new ToscaConceptIdentifier(entryKey, entryValue.getVersion())); - clDefinition.setControlLoopElementToscaNodeTemplate(entryValue); - if (commonPropertiesMap != null) { - ToscaNodeType nodeType = commonPropertiesMap.get(entryValue.getType()); - if (nodeType != null) { - clDefinition.setCommonPropertiesMap(nodeType.getProperties()); - } - } - - List<ControlLoopElementDefinition> controlLoopElementDefinitionList = new ArrayList<>(); - - if (participantDefinitionUpdates.isEmpty()) { - participantDefinitionUpdates - .add(getParticipantDefinition(clDefinition, clParticipantType, controlLoopElementDefinitionList)); - } else { - var participantExists = false; - for (ParticipantDefinition participantDefinitionUpdate : participantDefinitionUpdates) { - if (participantDefinitionUpdate.getParticipantType().equals(clParticipantType)) { - participantDefinitionUpdate.getControlLoopElementDefinitionList().add(clDefinition); - participantExists = true; - } - } - if (!participantExists) { - participantDefinitionUpdates.add( - getParticipantDefinition(clDefinition, clParticipantType, controlLoopElementDefinitionList)); - } - } - } - - private static ParticipantDefinition getParticipantDefinition(ControlLoopElementDefinition clDefinition, - ToscaConceptIdentifier clParticipantType, - List<ControlLoopElementDefinition> controlLoopElementDefinitionList) { - var participantDefinition = new ParticipantDefinition(); - participantDefinition.setParticipantType(clParticipantType); - controlLoopElementDefinitionList.add(clDefinition); - participantDefinition.setControlLoopElementDefinitionList(controlLoopElementDefinitionList); - return participantDefinition; - } -} |