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.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
27 import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.DistributeTrafficCheckInput;
28 import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.DistributeTrafficCheckOutputBuilder;
32 * Provide LCM command service to check conditions and the result of DistributeTraffic.
34 public class DistributeTrafficCheckService extends AbstractBaseService {
36 private static final String PAYLOAD = "payload";
41 public DistributeTrafficCheckService() {
42 super(Action.DistributeTrafficCheck);
43 logger.debug("DistributeTrafficCheckService starts");
47 * Process the DistributeTrafficCheck request
48 * @param input of DistributeTrafficCheckInput from the REST API input
49 * @return DistributeTrafficCheckOutputBuilder which has the process results
51 public DistributeTrafficCheckOutputBuilder process(DistributeTrafficCheckInput input) {
58 DistributeTrafficCheckOutputBuilder outputBuilder = new DistributeTrafficCheckOutputBuilder();
59 outputBuilder.setStatus(status);
60 outputBuilder.setCommonHeader(input.getCommonHeader());
67 * Set status if any error detected. Otherwise, status == null.
68 * @param input of DistributeTrafficCheckInput from the REST API input
70 void validate(DistributeTrafficCheckInput input) {
71 status = validateVnfId(input.getCommonHeader(), input.getAction(), input.getActionIdentifiers());
76 if (input.getPayload() == null) {
77 status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, PAYLOAD);
80 String payloadString = input.getPayload().getValue();
81 status = validateMustHaveParamValue(payloadString == null ? payloadString : payloadString.trim(), PAYLOAD);
88 * Execute the distribute-traffic-check action.
89 * @param input of DistributeTrafficCheckInput from the REST API input
91 void proceedAction(DistributeTrafficCheckInput input) {
92 RequestHandlerInput requestHandlerInput = getRequestHandlerInput(
93 input.getCommonHeader(), input.getActionIdentifiers(), input.getPayload(), this.getClass().getName());
94 if (requestHandlerInput != null) {
95 executeAction(requestHandlerInput);