2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.appc.provider.lcm.service;
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.QueryInput;
28 import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QueryOutputBuilder;
29 import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.query.output.QueryResults;
30 import org.onap.appc.requesthandler.objects.RequestHandlerInput;
31 import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
33 import java.util.List;
36 * Provide LCM command service for Query of VNF state/status
38 public class QueryService extends AbstractBaseService {
39 private List<QueryResults> queryResultList;
44 public QueryService() {
46 logger.debug("QueryService starts");
50 * Process the input for the query service
51 * @param input of QueryInput from the REST API input
52 * @return QueryOutputBuilder which has the query results
54 public QueryOutputBuilder process(QueryInput input) {
60 QueryOutputBuilder outputBuilder = new QueryOutputBuilder();
61 outputBuilder.setStatus(status);
62 outputBuilder.setQueryResults(queryResultList);
63 outputBuilder.setCommonHeader(input.getCommonHeader());
69 * Set Status if any error occurs.
71 * @param input of QueryInput from the REST API input
73 void validate(QueryInput input) {
74 status = validateVnfId(input.getCommonHeader(), input.getAction(), input.getActionIdentifiers());
78 * Proceed to action for the query service.
80 * @param input of QueryInput from the REST API input
82 void proceedAction(QueryInput input) {
83 RequestHandlerInput requestHandlerInput = getRequestHandlerInput(
84 input.getCommonHeader(), input.getActionIdentifiers(), null, this.getClass().getName());
85 if (requestHandlerInput != null) {
86 RequestHandlerOutput requestHandlerOutput = executeAction(requestHandlerInput);
87 queryResultList = (List<QueryResults>) requestHandlerOutput.getResponseContext().getPayloadObject();