summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.so/src/main
diff options
context:
space:
mode:
authorkrishnaa96 <krishna.moorthy6@wipro.com>2020-08-26 14:59:04 +0530
committerkrishnaa96 <krishna.moorthy6@wipro.com>2020-09-01 19:00:35 +0530
commit0690ef13433cb30d3d6c475990a818a714f0538d (patch)
treebb0ec20c49777f224057b2bb929b64aa79c6b456 /models-interactions/model-actors/actor.so/src/main
parentb13f57c283bf7e90db88e159d0e3e8bd6ba6f698 (diff)
Add Modify NSSI operation in SO actor
Issue-ID: POLICY-2586 Signed-off-by: krishnaa96 <krishna.moorthy6@wipro.com> Change-Id: I6ac184a6e731767f06401a0ac984c6b448c5d82f
Diffstat (limited to 'models-interactions/model-actors/actor.so/src/main')
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/ModifyNssi.java81
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActor.java2
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java44
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java4
-rw-r--r--models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java5
5 files changed, 124 insertions, 12 deletions
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/ModifyNssi.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/ModifyNssi.java
new file mode 100644
index 000000000..69d11fd14
--- /dev/null
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/ModifyNssi.java
@@ -0,0 +1,81 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2020 Wipro Limited.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controlloop.actor.so;
+
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.MediaType;
+import org.onap.policy.common.endpoints.event.comm.Topic;
+import org.onap.policy.common.endpoints.utils.NetLoggerUtil;
+import org.onap.policy.common.utils.coder.CoderException;
+import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
+import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams;
+import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpPollingConfig;
+import org.onap.policy.so.SoRequest3gpp;
+
+public class ModifyNssi extends SoOperation {
+ public static final String NAME = "Modify NSSI";
+
+ private static final List<String> PROPERTY_NAMES = List.of(
+ OperationProperties.AAI_SERVICE,
+ OperationProperties.EVENT_PAYLOAD);
+
+ /**
+ * Constructs the object.
+ *
+ * @param params operation parameters
+ * @param config configuration for this operation
+ */
+ public ModifyNssi(ControlLoopOperationParams params, HttpPollingConfig config) {
+ super(params, config, PROPERTY_NAMES);
+ }
+
+ @Override
+ protected CompletableFuture<OperationOutcome> startOperationAsync(int attempt, OperationOutcome outcome) {
+
+ SoRequest3gpp soRequest = makeRequest();
+
+ String path = getPath();
+ String url = getClient().getBaseUrl() + path;
+
+ String strRequest = prettyPrint(soRequest);
+ logMessage(NetLoggerUtil.EventType.OUT, Topic.CommInfrastructure.REST, url, strRequest);
+
+ Entity<String> entity = Entity.entity(strRequest, MediaType.APPLICATION_JSON);
+ Map<String, Object> headers = createSimpleHeaders();
+
+ return handleResponse(outcome, url, callback -> getClient().put(callback, path, entity, headers));
+ }
+
+ private SoRequest3gpp makeRequest() {
+
+ Map<String, Object> payload = params.getPayload();
+
+ try {
+ return getCoder().convert(payload, SoRequest3gpp.class);
+ } catch (CoderException e) {
+ throw new IllegalArgumentException("invalid payload value: " + payload, e);
+ }
+ }
+}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActor.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActor.java
index a6619710e..195fbcb96 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActor.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoActor.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2020 Wipro Limited.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,5 +37,6 @@ public class SoActor extends HttpActor<HttpPollingActorParams> {
addOperator(new HttpPollingOperator(NAME, VfModuleCreate.NAME, VfModuleCreate::new));
addOperator(new HttpPollingOperator(NAME, VfModuleDelete.NAME, VfModuleDelete::new));
+ addOperator(new HttpPollingOperator(NAME, ModifyNssi.NAME, ModifyNssi::new));
}
}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
index 8a0cb703b..ac25c841e 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SoOperation.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Wipro Limited.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -75,13 +76,16 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
public static final String REQ_PARAM_NM = "requestParameters";
public static final String CONFIG_PARAM_NM = "configurationParameters";
- // values extracted from the parameter Target
+ /* Values extracted from the parameter Target. These fields are required by any
+ subclasses that make use of prepareSoModelInfo().
+ */
private final String modelCustomizationId;
private final String modelInvariantId;
private final String modelVersionId;
private final String modelName;
private final String modelVersion;
+
private final String vfCountKey;
@@ -95,25 +99,45 @@ public abstract class SoOperation extends HttpOperation<SoResponse> {
public SoOperation(ControlLoopOperationParams params, HttpPollingConfig config, List<String> propertyNames) {
super(params, config, SoResponse.class, propertyNames);
- setUsePolling();
+ this.modelCustomizationId = null;
+ this.modelInvariantId = null;
+ this.modelVersionId = null;
+ this.modelVersion = null;
+ this.modelName = null;
+ this.vfCountKey = null;
verifyNotNull("Target information", params.getTargetType());
+ }
- verifyNotNull("Target entity Ids information", params.getTargetEntityIds());
+ /**
+ * Constructs the object.
+ *
+ * @param params operation parameters
+ * @param config configuration for this operation
+ * @param propertyNames names of properties required by this operation
+ * @param targetEntityIds Target Entity information
+ */
+ public SoOperation(ControlLoopOperationParams params, HttpPollingConfig config, List<String> propertyNames,
+ Map<String, String> targetEntityIds) {
+ super(params, config, SoResponse.class, propertyNames);
- this.modelCustomizationId = params.getTargetEntityIds()
+ verifyNotNull("Target entity Ids information", targetEntityIds);
+
+ this.modelCustomizationId = targetEntityIds
.get(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_CUSTOMIZATION_ID);
- this.modelInvariantId = params.getTargetEntityIds()
+ this.modelInvariantId = targetEntityIds
.get(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_INVARIANT_ID);
- this.modelVersionId = params.getTargetEntityIds()
+ this.modelVersionId = targetEntityIds
.get(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_VERSION_ID);
- this.modelVersion = params.getTargetEntityIds()
+ this.modelVersion = targetEntityIds
.get(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_VERSION);
- this.modelName = params.getTargetEntityIds()
+ this.modelName = targetEntityIds
.get(ControlLoopOperationParams.PARAMS_ENTITY_MODEL_NAME);
- vfCountKey = SoConstants.VF_COUNT_PREFIX + "[" + modelCustomizationId + "][" + modelInvariantId + "]["
- + modelVersionId + "]";
+ this.vfCountKey = SoConstants.VF_COUNT_PREFIX + "[" + modelCustomizationId + "][" + modelInvariantId + "]["
+ + modelVersionId + "]";
+
+ verifyNotNull("Target information", params.getTargetType());
}
@Override
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
index 7e95bda03..af06c9184 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleCreate.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Wipro Limited.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -78,8 +79,9 @@ public class VfModuleCreate extends SoOperation {
* @param config configuration for this operation
*/
public VfModuleCreate(ControlLoopOperationParams params, HttpPollingConfig config) {
- super(params, config, PROPERTY_NAMES);
+ super(params, config, PROPERTY_NAMES, params.getTargetEntityIds());
+ setUsePolling();
// ensure we have the necessary parameters
validateTarget();
}
diff --git a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
index 0ff833c59..f35cdb4e1 100644
--- a/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
+++ b/models-interactions/model-actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/VfModuleDelete.java
@@ -3,6 +3,7 @@
* ONAP
* ================================================================================
* Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2020 Wipro Limited.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -84,7 +85,9 @@ public class VfModuleDelete extends SoOperation {
* @param config configuration for this operation
*/
public VfModuleDelete(ControlLoopOperationParams params, HttpPollingConfig config) {
- super(params, config, PROPERTY_NAMES);
+ super(params, config, PROPERTY_NAMES, params.getTargetEntityIds());
+
+ setUsePolling();
// ensure we have the necessary parameters
validateTarget();