summaryrefslogtreecommitdiffstats
path: root/appc-provider/appc-provider-bundle/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'appc-provider/appc-provider-bundle/src/main/java/org')
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java127
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/GetConfigService.java124
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/LicenseManagementService.java122
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PostEvacuateService.java100
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PostMigrateService.java104
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PostRebuild.java124
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreConfigure.java124
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreEvacuate.java162
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreMigrateService.java104
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreRebuild.java124
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ProvisioningService.java122
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/StartTraffic.java122
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/StatusTraffic.java122
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/StopTraffic.java162
14 files changed, 1743 insertions, 0 deletions
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java
index 2006b4967..d37da6529 100644
--- a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java
@@ -46,8 +46,21 @@ import org.onap.appc.provider.lcm.service.ResumeTrafficService;
import org.onap.appc.provider.lcm.service.UpgradeService;
import org.onap.appc.provider.lcm.service.VolumeService;
import org.onap.appc.provider.lcm.service.ConfigScaleOutService;
+import org.onap.appc.provider.lcm.service.PreConfigure;
+import org.onap.appc.provider.lcm.service.PreRebuild;
+import org.onap.appc.provider.lcm.service.GetConfigService;
+import org.onap.appc.provider.lcm.service.PostRebuild;
+import org.onap.appc.provider.lcm.service.PostEvacuateService;
+import org.onap.appc.provider.lcm.service.PreMigrateService;
+import org.onap.appc.provider.lcm.service.PostMigrateService;
import org.onap.appc.provider.lcm.service.DistributeTrafficService;
import org.onap.appc.provider.lcm.service.DistributeTrafficCheckService;
+import org.onap.appc.provider.lcm.service.PreEvacuate;
+import org.onap.appc.provider.lcm.service.ProvisioningService;
+import org.onap.appc.provider.lcm.service.LicenseManagementService;
+import org.onap.appc.provider.lcm.service.StartTraffic;
+import org.onap.appc.provider.lcm.service.StatusTraffic;
+import org.onap.appc.provider.lcm.service.StopTraffic;
import org.onap.appc.provider.lcm.util.RequestInputBuilder;
import org.onap.appc.provider.lcm.util.ValidationService;
import org.onap.appc.requesthandler.objects.RequestHandlerInput;
@@ -556,6 +569,96 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable,
}
@Override
+ public ListenableFuture<RpcResult<PreConfigureOutput>> preConfigure(PreConfigureInput input) {
+ logger.debug(String.format("LCM PreConfigure received input: %s", input.toString()));
+ PreConfigureOutputBuilder outputBuilder = new PreConfigure().process(input);
+ RpcResult<PreConfigureOutput> result =
+ RpcResultBuilder.<PreConfigureOutput>status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<GetConfigOutput>> getConfig(GetConfigInput input) {
+ logger.debug(String.format("LCM getConfig received input: %s", input.toString()));
+ GetConfigOutputBuilder outputBuilder = new GetConfigService().process(input);
+ RpcResult<GetConfigOutput> result =
+ RpcResultBuilder.<GetConfigOutput>status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<PreRebuildOutput>> preRebuild(PreRebuildInput input) {
+ logger.debug(String.format("LCM PreRebuild received input: %s", input.toString()));
+ PreRebuildOutputBuilder outputBuilder = new PreRebuild().process(input);
+ RpcResult<PreRebuildOutput> result =
+ RpcResultBuilder.<PreRebuildOutput>status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<PostRebuildOutput>> postRebuild(PostRebuildInput input) {
+ logger.debug(String.format("LCM PostRebuild received input: %s", input.toString()));
+ PostRebuildOutputBuilder outputBuilder = new PostRebuild().process(input);
+ RpcResult<PostRebuildOutput> result =
+ RpcResultBuilder.<PostRebuildOutput>status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<PreEvacuateOutput>> preEvacuate(PreEvacuateInput input) {
+ logger.debug(String.format("LCM PreEvacuate received input: %s", input.toString()));
+ PreEvacuateOutputBuilder outputBuilder = new PreEvacuate().process(input);
+ RpcResult<PreEvacuateOutput> result =
+ RpcResultBuilder.<PreEvacuateOutput>status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<ProvisioningOutput>> provisioning(ProvisioningInput input) {
+ logger.debug(String.format("LCM ProvisioningService received input: %s", input.toString()));
+ ProvisioningOutputBuilder outputBuilder = new ProvisioningService().process(input);
+ RpcResult<ProvisioningOutput> result =
+ RpcResultBuilder.<ProvisioningOutput>status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<LicenseManagementOutput>> licenseManagement(LicenseManagementInput input) {
+ logger.debug(String.format("LCM licensemangementService received input: %s", input.toString()));
+ LicenseManagementOutputBuilder outputBuilder = new LicenseManagementService().process(input);
+ RpcResult<LicenseManagementOutput> result =
+ RpcResultBuilder.<LicenseManagementOutput>status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<StartTrafficOutput>> startTraffic(StartTrafficInput input) {
+ logger.debug(String.format("LCM StartTraffic received input: %s", input.toString()));
+ StartTrafficOutputBuilder outputBuilder = new StartTraffic().process(input);
+ RpcResult<StartTrafficOutput> result =
+ RpcResultBuilder.<StartTrafficOutput>status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<StatusTrafficOutput>> statusTraffic(StatusTrafficInput input) {
+ logger.debug(String.format("LCM StatusTraffic received input: %s", input.toString()));
+ StatusTrafficOutputBuilder outputBuilder = new StatusTraffic().process(input);
+ RpcResult<StatusTrafficOutput> result =
+ RpcResultBuilder.<StatusTrafficOutput>status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<StopTrafficOutput>> stopTraffic(StopTrafficInput input) {
+ logger.debug(String.format("LCM StopTraffic received input: %s", input.toString()));
+ StopTrafficOutputBuilder outputBuilder = new StopTraffic().process(input);
+ RpcResult<StopTrafficOutput> result =
+ RpcResultBuilder.<StopTrafficOutput>status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
public ListenableFuture<RpcResult<TerminateOutput>> terminate(TerminateInput input) {
logger.debug("Input received : " + input.toString());
TerminateOutputBuilder outputBuilder = new TerminateOutputBuilder();
@@ -674,6 +777,30 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable,
}
@Override
+ public ListenableFuture<RpcResult<PostEvacuateOutput>> postEvacuate(PostEvacuateInput input) {
+ logger.debug("Input received : " + input.toString());
+ PostEvacuateOutputBuilder outputBuilder = new PostEvacuateService().process(input);
+ RpcResult<PostEvacuateOutput> result = RpcResultBuilder.<PostEvacuateOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<PreMigrateOutput>> preMigrate(PreMigrateInput input) {
+ logger.debug("Input received : " + input.toString());
+ PreMigrateOutputBuilder outputBuilder = new PreMigrateService().process(input);
+ RpcResult<PreMigrateOutput> result = RpcResultBuilder.<PreMigrateOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<PostMigrateOutput>> postMigrate(PostMigrateInput input) {
+ logger.debug("Input received : " + input.toString());
+ PostMigrateOutputBuilder outputBuilder = new PostMigrateService().process(input);
+ RpcResult<PostMigrateOutput> result = RpcResultBuilder.<PostMigrateOutput> status(true).withResult(outputBuilder.build()).build();
+ return Futures.immediateFuture(result);
+ }
+
+ @Override
public ListenableFuture<RpcResult<ConfigRestoreOutput>> configRestore(ConfigRestoreInput input) {
logger.debug("Input received : " + input.toString());
ConfigRestoreOutputBuilder outputBuilder = new ConfigRestoreOutputBuilder();
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/GetConfigService.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/GetConfigService.java
new file mode 100644
index 000000000..05b13d15b
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/GetConfigService.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018-19 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.GetConfigInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.GetConfigOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.GetConfigOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.util.JsonUtil;
+
+import java.io.IOException;
+import java.util.Map;
+/**
+ * Provide LCM command service for GetConfig VNF Service
+ */
+public class GetConfigService extends AbstractBaseService {
+
+ /**
+ * Constructor
+ */
+ public GetConfigService() {
+ super(Action.GetConfig);
+ logger.debug("GetConfigService starts");
+ }
+
+ /**
+ * Process the getConfig request
+ * @param input of GetConfigInput from the REST API input
+ * @return GetConfigOutputBuilder which has the process results
+ */
+ public GetConfigOutputBuilder process(GetConfigInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ proceedAction(commonHeader,actionIdentifiers,payload);
+ }
+
+ GetConfigOutputBuilder outputBuilder = new GetConfigOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ return outputBuilder;
+ }
+
+ /**
+ * Validate the input.
+ * Set Status if any error occurs.
+ *
+ * @param input of GetConfigInput from the REST API input
+ */
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+ if (payload == null) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ return;
+ }
+ String payloadString = payload.getValue();
+ status = validateMustHaveParamValue(payloadString == null ? payloadString : payloadString.trim(), "payload");
+ if (status != null) {
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("GetConfigService (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+
+ /**
+ * Proceed to action for the getConfig VNF action.
+ *
+ * @param input of GetConfigInput from the REST API input
+ */
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput = getRequestHandlerInput(commonHeader, actionIdentifiers, payload,
+ this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/LicenseManagementService.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/LicenseManagementService.java
new file mode 100644
index 000000000..3583f636d
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/LicenseManagementService.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LicenseManagementInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LicenseManagementOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.LicenseManagementOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.util.JsonUtil;
+
+import java.io.IOException;
+import java.util.Map;
+/**
+ * Provide LCM command service for LicenseManagement VNF Service
+ */
+public class LicenseManagementService extends AbstractBaseService {
+
+ /**
+ * Constructor
+ */
+ public LicenseManagementService() {
+ super(Action.LicenseManagement);
+ logger.debug("LicenseManagementService starts");
+ }
+
+ /**
+ * Process the LicenseManagement request
+ * @param input of LicenseManagementInput from the REST API input
+ * @return LicenseManagementOutputBuilder which has the process results
+ */
+ public LicenseManagementOutputBuilder process(LicenseManagementInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ proceedAction(commonHeader,actionIdentifiers,payload);
+ }
+
+ LicenseManagementOutputBuilder outputBuilder = new LicenseManagementOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ return outputBuilder;
+ }
+
+ /**
+ * Validate the input.
+ * Set Status if any error occurs.
+ *
+ * @param input of LicenseManagementInput from the REST API input
+ */
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+ if (payload == null) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ return;
+ }
+ String payloadString = payload.getValue();
+ status = validateMustHaveParamValue(payloadString == null ? payloadString : payloadString.trim(), "payload");
+ if (status != null) {
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("LicenseManagementService (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+
+ /**
+ * Proceed to action for the LicenseManagement VNF action.
+ *
+ * @param input of LicenseManagementInput from the REST API input
+ */
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput = getRequestHandlerInput(commonHeader, actionIdentifiers, payload,
+ this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+} \ No newline at end of file
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PostEvacuateService.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PostEvacuateService.java
new file mode 100644
index 000000000..b63d7e840
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PostEvacuateService.java
@@ -0,0 +1,100 @@
+
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PostEvacuateInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PostEvacuateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.util.JsonUtil;
+import java.io.IOException;
+import java.util.Map;
+
+public class PostEvacuateService extends AbstractBaseService {
+
+ public PostEvacuateService() {
+ super(Action.PostEvacuate);
+ logger.debug("PostEvacuateService starts");
+ }
+ public PostEvacuateOutputBuilder process(PostEvacuateInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ proceedAction(commonHeader,actionIdentifiers,payload);
+ }
+
+ PostEvacuateOutputBuilder outputBuilder = new PostEvacuateOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ return outputBuilder;
+ }
+
+
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+
+ String keyName = "payload";
+ if (payload !=null) {
+ String payloadString = payload.getValue();
+ status = validateMustHaveParamValue(
+ payloadString == null ? payloadString : payloadString.trim(), "payload");
+ if (status != null) {
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("PostEvacuateServiceService (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+ }
+
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput =
+ getRequestHandlerInput(commonHeader, actionIdentifiers, payload, this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+}
+
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PostMigrateService.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PostMigrateService.java
new file mode 100644
index 000000000..002235933
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PostMigrateService.java
@@ -0,0 +1,104 @@
+
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PostMigrateInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PostMigrateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.util.JsonUtil;
+import java.io.IOException;
+import java.util.Map;
+
+public class PostMigrateService extends AbstractBaseService {
+
+ public PostMigrateService() {
+ super(Action.PostMigrate);
+ logger.debug("PostMigrateService starts");
+ }
+ public PostMigrateOutputBuilder process(PostMigrateInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ proceedAction(commonHeader,actionIdentifiers,payload);
+ }
+
+ PostMigrateOutputBuilder outputBuilder = new PostMigrateOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ return outputBuilder;
+ }
+
+
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+// if (payload == null) {
+// status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+// return;
+// }
+ if (payload !=null) {
+ String payloadString = payload.getValue();
+ status = validateMustHaveParamValue(
+ payloadString == null ? payloadString : payloadString.trim(), "payload");
+ if (status != null) {
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("PostMigrateService (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+ }
+
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput =
+ getRequestHandlerInput(commonHeader, actionIdentifiers, payload, this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+}
+
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PostRebuild.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PostRebuild.java
new file mode 100644
index 000000000..27a1e158e
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PostRebuild.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PostRebuildInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PostRebuildOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PostRebuildOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.util.JsonUtil;
+
+import java.io.IOException;
+import java.util.Map;
+/**
+ * Provide LCM command service for PostRebuild VNF
+ */
+public class PostRebuild extends AbstractBaseService {
+
+ /**
+ * Constructor
+ */
+ public PostRebuild() {
+ super(Action.PostRebuild);
+ logger.debug("PostRebuild starts");
+ }
+
+ /**
+ * Process the PostRebuild request
+ * @param input of PostRebuildInput from the REST API input
+ * @return PostRebuildOutputBuilder which has the process results
+ */
+ public PostRebuildOutputBuilder process(PostRebuildInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ proceedAction(commonHeader,actionIdentifiers,payload);
+ }
+
+ PostRebuildOutputBuilder outputBuilder = new PostRebuildOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ return outputBuilder;
+ }
+
+ /**
+ * Validate the input.
+ * Set Status if any error occurs.
+ *
+ * @param input of PostRebuildInput from the REST API input
+ */
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+ if (payload == null) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ return;
+ }
+ String payloadString = payload.getValue();
+ status = validateMustHaveParamValue(payloadString == null ? payloadString : payloadString.trim(), "payload");
+ if (status != null) {
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("PostRebuild (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+
+ /**
+ * Proceed to action for the PostRebuild VNF traffic.
+ *
+ * @param input of PostRebuildInput from the REST API input
+ */
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput = getRequestHandlerInput(commonHeader, actionIdentifiers, payload,
+ this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreConfigure.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreConfigure.java
new file mode 100644
index 000000000..81be549dd
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreConfigure.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PreConfigureInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PreConfigureOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PreConfigureOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.util.JsonUtil;
+
+import java.io.IOException;
+import java.util.Map;
+/**
+ * Provide LCM command service for PreConfigure VNF
+ */
+public class PreConfigure extends AbstractBaseService {
+
+ /**
+ * Constructor
+ */
+ public PreConfigure() {
+ super(Action.PreConfigure);
+ logger.debug("PreConfigure starts");
+ }
+
+ /**
+ * Process the PreConfigure request
+ * @param input of PreConfigureInput from the REST API input
+ * @return PreConfigureOutputBuilder which has the process results
+ */
+ public PreConfigureOutputBuilder process(PreConfigureInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ proceedAction(commonHeader,actionIdentifiers,payload);
+ }
+
+ PreConfigureOutputBuilder outputBuilder = new PreConfigureOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ return outputBuilder;
+ }
+
+ /**
+ * Validate the input.
+ * Set Status if any error occurs.
+ *
+ * @param input of PreConfigureInput from the REST API input
+ */
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+ if (payload == null) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ return;
+ }
+ String payloadString = payload.getValue();
+ status = validateMustHaveParamValue(payloadString == null ? payloadString : payloadString.trim(), "payload");
+ if (status != null) {
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("PreConfigure (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+
+ /**
+ * Proceed to action for the PreConfigure VNF traffic.
+ *
+ * @param input of PreConfigureInput from the REST API input
+ */
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput = getRequestHandlerInput(commonHeader, actionIdentifiers, payload,
+ this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreEvacuate.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreEvacuate.java
new file mode 100644
index 000000000..4a19e6be8
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreEvacuate.java
@@ -0,0 +1,162 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.apache.commons.lang.StringUtils;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PreEvacuateInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PreEvacuateOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PreEvacuateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.util.JsonUtil;
+
+import java.io.IOException;
+import java.util.Map;
+/**
+ * Provide LCM command service for PreEvacuate VNF
+ */
+public class PreEvacuate extends AbstractBaseService {
+
+ /**
+ * Constructor
+ */
+ public PreEvacuate() {
+ super(Action.PreEvacuate);
+ logger.debug("PreEvacuate starts");
+ }
+
+ /**
+ * Constants for characterizing payload handling
+ */
+ static final byte PAYLOAD_ACCEPT_NULL = 1;
+ static final byte PAYLOAD_AUTO_TRIM = 2;
+ static final byte PAYLOAD_TREAT_EMPTY_AS_NULL = 4;
+
+ /**
+ * Payload handling configuration for all object instances
+ */
+ static final byte payloadConfig = PAYLOAD_ACCEPT_NULL | PAYLOAD_AUTO_TRIM | PAYLOAD_TREAT_EMPTY_AS_NULL;
+
+ /**
+ * Process the PreEvacuate request
+ * @param input of PreEvacuateInput from the REST API input
+ * @return PreEvacuateOutputBuilder which has the process results
+ */
+ public PreEvacuateOutputBuilder process(PreEvacuateInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ if (payload != null) {
+ String payloadStr = payload.getValue();
+ if (StringUtils.isEmpty(payloadStr)) {
+ if ((payloadConfig & PAYLOAD_TREAT_EMPTY_AS_NULL) != 0) {
+ payload = null;
+ }
+ } else if ((payloadConfig & PAYLOAD_AUTO_TRIM) != 0) {
+ payloadStr = payloadStr.trim();
+ if (StringUtils.isEmpty(payloadStr) && (payloadConfig & PAYLOAD_TREAT_EMPTY_AS_NULL) != 0) {
+ payload = null;
+ } else {
+ payload = new Payload(payloadStr);
+ }
+ }
+ }
+ proceedAction(commonHeader, actionIdentifiers, payload);
+ }
+
+ PreEvacuateOutputBuilder outputBuilder = new PreEvacuateOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(commonHeader);
+ return outputBuilder;
+ }
+
+ /**
+ * Validate the input.
+ * Set Status if any error occurs.
+ *
+ * @param input of PreEvacuateInput from the REST API input
+ */
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+ if (payload == null) {
+ if ((payloadConfig & PAYLOAD_ACCEPT_NULL) == 0) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ }
+ return;
+ }
+ String payloadString = payload.getValue();
+ if (payloadString != null && (payloadConfig & PAYLOAD_AUTO_TRIM) != 0) {
+ payloadString = payloadString.trim();
+ }
+ if ((payloadConfig & PAYLOAD_TREAT_EMPTY_AS_NULL) == 0) {
+ status = validateMustHaveParamValue(payloadString, "payload");
+ if (status != null) {
+ return;
+ }
+ } else if (StringUtils.isEmpty(payloadString)) {
+ if ((payloadConfig & PAYLOAD_ACCEPT_NULL) == 0) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ }
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ // validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("PreEvacuate (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+
+ /**
+ * Proceed to action for the PreEvacuate VNF traffic.
+ *
+ * @param input of PreEvacuateInput from the REST API input
+ */
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput =
+ getRequestHandlerInput(commonHeader, actionIdentifiers, payload, this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreMigrateService.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreMigrateService.java
new file mode 100644
index 000000000..661374a05
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreMigrateService.java
@@ -0,0 +1,104 @@
+
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PreMigrateInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PreMigrateOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.util.JsonUtil;
+import java.io.IOException;
+import java.util.Map;
+
+public class PreMigrateService extends AbstractBaseService {
+
+ public PreMigrateService() {
+ super(Action.PreMigrate);
+ logger.debug("PreMigrateService starts");
+ }
+ public PreMigrateOutputBuilder process(PreMigrateInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ proceedAction(commonHeader,actionIdentifiers,payload);
+ }
+
+ PreMigrateOutputBuilder outputBuilder = new PreMigrateOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ return outputBuilder;
+ }
+
+
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+// if (payload == null) {
+// status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+// return;
+// }
+ if (payload !=null) {
+ String payloadString = payload.getValue();
+ status = validateMustHaveParamValue(
+ payloadString == null ? payloadString : payloadString.trim(), "payload");
+ if (status != null) {
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("PreMigrateService (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+ }
+
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput =
+ getRequestHandlerInput(commonHeader, actionIdentifiers, payload, this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+}
+
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreRebuild.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreRebuild.java
new file mode 100644
index 000000000..cbcd61077
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/PreRebuild.java
@@ -0,0 +1,124 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PreRebuildInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PreRebuildOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.PreRebuildOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.util.JsonUtil;
+
+import java.io.IOException;
+import java.util.Map;
+/**
+ * Provide LCM command service for PreRebuild VNF
+ */
+public class PreRebuild extends AbstractBaseService {
+
+ /**
+ * Constructor
+ */
+ public PreRebuild() {
+ super(Action.PreRebuild);
+ logger.debug("PreRebuild starts");
+ }
+
+ /**
+ * Process the PreRebuild request
+ * @param input of PreRebuildInput from the REST API input
+ * @return PreRebuildOutputBuilder which has the process results
+ */
+ public PreRebuildOutputBuilder process(PreRebuildInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ proceedAction(commonHeader,actionIdentifiers,payload);
+ }
+
+ PreRebuildOutputBuilder outputBuilder = new PreRebuildOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ return outputBuilder;
+ }
+
+ /**
+ * Validate the input.
+ * Set Status if any error occurs.
+ *
+ * @param input of PreRebuildInput from the REST API input
+ */
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+ if (payload == null) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ return;
+ }
+ String payloadString = payload.getValue();
+ status = validateMustHaveParamValue(payloadString == null ? payloadString : payloadString.trim(), "payload");
+ if (status != null) {
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("PreRebuild (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+
+ /**
+ * Proceed to action for the PreRebuild VNF traffic.
+ *
+ * @param input of PreRebuildInput from the REST API input
+ */
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput = getRequestHandlerInput(commonHeader, actionIdentifiers, payload,
+ this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ProvisioningService.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ProvisioningService.java
new file mode 100644
index 000000000..f9fc8eb55
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ProvisioningService.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ProvisioningInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ProvisioningOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ProvisioningOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.util.JsonUtil;
+
+import java.io.IOException;
+import java.util.Map;
+/**
+ * Provide LCM command service for Provisioning VNF Service
+ */
+public class ProvisioningService extends AbstractBaseService {
+
+ /**
+ * Constructor
+ */
+ public ProvisioningService() {
+ super(Action.Provisioning);
+ logger.debug("ProvisioningService starts");
+ }
+
+ /**
+ * Process the Provisioning request
+ * @param input of ProvisioningInput from the REST API input
+ * @return ProvisioningOutputBuilder which has the process results
+ */
+ public ProvisioningOutputBuilder process(ProvisioningInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ proceedAction(commonHeader,actionIdentifiers,payload);
+ }
+
+ ProvisioningOutputBuilder outputBuilder = new ProvisioningOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ return outputBuilder;
+ }
+
+ /**
+ * Validate the input.
+ * Set Status if any error occurs.
+ *
+ * @param input of ProvisioningInput from the REST API input
+ */
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+ if (payload == null) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ return;
+ }
+ String payloadString = payload.getValue();
+ status = validateMustHaveParamValue(payloadString == null ? payloadString : payloadString.trim(), "payload");
+ if (status != null) {
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("ProvisioningService (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+
+ /**
+ * Proceed to action for the Provisioning VNF action.
+ *
+ * @param input of ProvisioningInput from the REST API input
+ */
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput = getRequestHandlerInput(commonHeader, actionIdentifiers, payload,
+ this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+} \ No newline at end of file
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/StartTraffic.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/StartTraffic.java
new file mode 100644
index 000000000..9d9886cfc
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/StartTraffic.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StartTrafficInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StartTrafficOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StartTrafficOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.util.JsonUtil;
+
+import java.io.IOException;
+import java.util.Map;
+/**
+ * Provide LCM command service for StartTraffic VNF
+ */
+public class StartTraffic extends AbstractBaseService {
+
+ /**
+ * Constructor
+ */
+ public StartTraffic() {
+ super(Action.StartTraffic);
+ logger.debug("StartTraffic starts");
+ }
+
+ /**
+ * Process the StartTraffic request
+ * @param input of StartTrafficInput from the REST API input
+ * @return StartTrafficOutputBuilder which has the process results
+ */
+ public StartTrafficOutputBuilder process(StartTrafficInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ proceedAction(commonHeader,actionIdentifiers,payload);
+ }
+
+ StartTrafficOutputBuilder outputBuilder = new StartTrafficOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ return outputBuilder;
+ }
+
+ /**
+ * Validate the input.
+ * Set Status if any error occurs.
+ *
+ * @param input of StartTrafficInput from the REST API input
+ */
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+ if (payload == null) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ return;
+ }
+ String payloadString = payload.getValue();
+ status = validateMustHaveParamValue(payloadString == null ? payloadString : payloadString.trim(), "payload");
+ if (status != null) {
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("StartTraffic (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+
+ /**
+ * Proceed to action for the StartTraffic VNF traffic.
+ *
+ * @param input of StartTrafficInput from the REST API input
+ */
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput = getRequestHandlerInput(commonHeader, actionIdentifiers, payload,
+ this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+} \ No newline at end of file
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/StatusTraffic.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/StatusTraffic.java
new file mode 100644
index 000000000..19898805e
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/StatusTraffic.java
@@ -0,0 +1,122 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StatusTrafficInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StatusTrafficOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StatusTrafficOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.util.JsonUtil;
+
+import java.io.IOException;
+import java.util.Map;
+/**
+ * Provide LCM command service for StatusTraffic VNF
+ */
+public class StatusTraffic extends AbstractBaseService {
+
+ /**
+ * Constructor
+ */
+ public StatusTraffic() {
+ super(Action.StatusTraffic);
+ logger.debug("StatusTraffic starts");
+ }
+
+ /**
+ * Process the StatusTraffic request
+ * @param input of StatusTrafficInput from the REST API input
+ * @return StatusTrafficOutputBuilder which has the process results
+ */
+ public StatusTrafficOutputBuilder process(StatusTrafficInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ proceedAction(commonHeader,actionIdentifiers,payload);
+ }
+
+ StatusTrafficOutputBuilder outputBuilder = new StatusTrafficOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ return outputBuilder;
+ }
+
+ /**
+ * Validate the input.
+ * Set Status if any error occurs.
+ *
+ * @param input of StatusTrafficInput from the REST API input
+ */
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+ if (payload == null) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ return;
+ }
+ String payloadString = payload.getValue();
+ status = validateMustHaveParamValue(payloadString == null ? payloadString : payloadString.trim(), "payload");
+ if (status != null) {
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("StatusTraffic (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+
+ /**
+ * Proceed to action for the StatusTraffic VNF traffic.
+ *
+ * @param input of StatusTrafficInput from the REST API input
+ */
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput = getRequestHandlerInput(commonHeader, actionIdentifiers, payload,
+ this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+} \ No newline at end of file
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/StopTraffic.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/StopTraffic.java
new file mode 100644
index 000000000..f2c211e2d
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/StopTraffic.java
@@ -0,0 +1,162 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.apache.commons.lang.StringUtils;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StopTrafficInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StopTrafficOutput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.StopTrafficOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.util.JsonUtil;
+
+import java.io.IOException;
+import java.util.Map;
+/**
+ * Provide LCM command service for StopTraffic VNF
+ */
+public class StopTraffic extends AbstractBaseService {
+
+ /**
+ * Constructor
+ */
+ public StopTraffic() {
+ super(Action.StopTraffic);
+ logger.debug("StopTraffic starts");
+ }
+
+ /**
+ * Constants for characterizing payload handling
+ */
+ static final byte PAYLOAD_ACCEPT_NULL = 1;
+ static final byte PAYLOAD_AUTO_TRIM = 2;
+ static final byte PAYLOAD_TREAT_EMPTY_AS_NULL = 4;
+
+ /**
+ * Payload handling configuration for all object instances
+ */
+ static final byte payloadConfig = PAYLOAD_ACCEPT_NULL | PAYLOAD_AUTO_TRIM | PAYLOAD_TREAT_EMPTY_AS_NULL;
+
+ /**
+ * Process the StopTraffic request
+ * @param input of StopTrafficInput from the REST API input
+ * @return StopTrafficOutputBuilder which has the process results
+ */
+ public StopTrafficOutputBuilder process(StopTrafficInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ if (payload != null) {
+ String payloadStr = payload.getValue();
+ if (StringUtils.isEmpty(payloadStr)) {
+ if ((payloadConfig & PAYLOAD_TREAT_EMPTY_AS_NULL) != 0) {
+ payload = null;
+ }
+ } else if ((payloadConfig & PAYLOAD_AUTO_TRIM) != 0) {
+ payloadStr = payloadStr.trim();
+ if (StringUtils.isEmpty(payloadStr) && (payloadConfig & PAYLOAD_TREAT_EMPTY_AS_NULL) != 0) {
+ payload = null;
+ } else {
+ payload = new Payload(payloadStr);
+ }
+ }
+ }
+ proceedAction(commonHeader, actionIdentifiers, payload);
+ }
+
+ StopTrafficOutputBuilder outputBuilder = new StopTrafficOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(commonHeader);
+ return outputBuilder;
+ }
+
+ /**
+ * Validate the input.
+ * Set Status if any error occurs.
+ *
+ * @param input of StopTrafficInput from the REST API input
+ */
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+ if (payload == null) {
+ if ((payloadConfig & PAYLOAD_ACCEPT_NULL) == 0) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ }
+ return;
+ }
+ String payloadString = payload.getValue();
+ if (payloadString != null && (payloadConfig & PAYLOAD_AUTO_TRIM) != 0) {
+ payloadString = payloadString.trim();
+ }
+ if ((payloadConfig & PAYLOAD_TREAT_EMPTY_AS_NULL) == 0) {
+ status = validateMustHaveParamValue(payloadString, "payload");
+ if (status != null) {
+ return;
+ }
+ } else if (StringUtils.isEmpty(payloadString)) {
+ if ((payloadConfig & PAYLOAD_ACCEPT_NULL) == 0) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ }
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ // validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("StopTraffic (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+
+ /**
+ * Proceed to action for the StopTraffic VNF traffic.
+ *
+ * @param input of StopTrafficInput from the REST API input
+ */
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput =
+ getRequestHandlerInput(commonHeader, actionIdentifiers, payload, this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+}