2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Orange
6 * =============================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.appc.provider.lcm.service;
24 import org.onap.appc.executor.objects.LCMCommandStatus;
25 import org.onap.appc.requesthandler.objects.RequestHandlerInput;
26 import org.onap.appc.util.JsonUtil;
27 import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
28 import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.DistributeTrafficCheckInput;
29 import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.DistributeTrafficCheckOutputBuilder;
31 import java.io.IOException;
36 * Provide LCM command service to check conditions and the result of DistributeTraffic.
38 public class DistributeTrafficCheckService extends AbstractBaseService {
40 private static final String PAYLOAD = "payload";
45 public DistributeTrafficCheckService() {
46 super(Action.DistributeTrafficCheck);
47 logger.debug("DistributeTrafficCheckService starts");
51 * Process the DistributeTrafficCheck request
52 * @param input of DistributeTrafficCheckInput from the REST API input
53 * @return DistributeTrafficCheckOutputBuilder which has the process results
55 public DistributeTrafficCheckOutputBuilder process(DistributeTrafficCheckInput input) {
62 DistributeTrafficCheckOutputBuilder outputBuilder = new DistributeTrafficCheckOutputBuilder();
63 outputBuilder.setStatus(status);
64 outputBuilder.setCommonHeader(input.getCommonHeader());
71 * Set status if any error detected. Otherwise, status == null.
72 * @param input of DistributeTrafficCheckInput from the REST API input
74 void validate(DistributeTrafficCheckInput input) {
75 status = validateVnfId(input.getCommonHeader(), input.getAction(), input.getActionIdentifiers());
80 if (input.getPayload() == null) {
81 status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, PAYLOAD);
84 String payloadString = input.getPayload().getValue();
85 status = validateMustHaveParamValue(payloadString == null ? payloadString : payloadString.trim(), PAYLOAD);
92 * Execute the distribute-traffic-check action.
93 * @param input of DistributeTrafficCheckInput from the REST API input
95 void proceedAction(DistributeTrafficCheckInput input) {
96 RequestHandlerInput requestHandlerInput = getRequestHandlerInput(
97 input.getCommonHeader(), input.getActionIdentifiers(), input.getPayload(), this.getClass().getName());
98 if (requestHandlerInput != null) {
99 executeAction(requestHandlerInput);