2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.provider.lcm.service;
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.QueryInput;
29 import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.QueryOutputBuilder;
30 import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.query.output.QueryResults;
31 import org.onap.appc.requesthandler.objects.RequestHandlerInput;
32 import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
34 import java.util.List;
37 * Provide LCM command service for Query of VNF state/status
39 public class QueryService extends AbstractBaseService {
40 private List<QueryResults> queryResultList;
45 public QueryService() {
47 logger.debug("QueryService starts");
51 * Process the input for the query service
52 * @param input of QueryInput from the REST API input
53 * @return QueryOutputBuilder which has the query results
55 public QueryOutputBuilder process(QueryInput input) {
61 QueryOutputBuilder outputBuilder = new QueryOutputBuilder();
62 outputBuilder.setStatus(status);
63 outputBuilder.setQueryResults(queryResultList);
64 outputBuilder.setCommonHeader(input.getCommonHeader());
70 * Set Status if any error occurs.
72 * @param input of QueryInput from the REST API input
74 void validate(QueryInput input) {
75 status = validateVnfId(input.getCommonHeader(), input.getAction(), input.getActionIdentifiers());
79 * Proceed to action for the query service.
81 * @param input of QueryInput from the REST API input
83 void proceedAction(QueryInput input) {
84 RequestHandlerInput requestHandlerInput = getRequestHandlerInput(
85 input.getCommonHeader(), input.getActionIdentifiers(), null, this.getClass().getName());
86 if (requestHandlerInput != null) {
87 RequestHandlerOutput requestHandlerOutput = executeAction(requestHandlerInput);
88 queryResultList = (List<QueryResults>) requestHandlerOutput.getResponseContext().getPayloadObject();