Include impacted changes for APPC-346,APPC-348
[appc.git] / appc-dispatcher / appc-request-handler / appc-request-handler-api / src / main / java / org / onap / appc / requesthandler / RequestHandler.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
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
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
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.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.onap.appc.requesthandler;
26
27 import org.onap.appc.domainmodel.lcm.RuntimeContext;
28 import org.onap.appc.exceptions.APPCException;
29 import org.onap.appc.requesthandler.objects.RequestHandlerInput;
30 import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
31
32 /**
33  * This class provides application logic for the Request/Response Handler Component.
34  *
35  */
36 public interface RequestHandler {
37     /**
38      * It receives requests from the north-bound REST API (Communication) Layer and
39      * performs following validations.
40      * 1. VNF exists in A&AI for the given targetID (VnfID)
41      * 2. For the current VNF  Orchestration Status, the command can be executed
42      * 3. For the given VNF type and Operation, there exists work-flow definition in the APPC database
43      * If any of the validation fails, it returns appropriate response
44      *
45      * @param input RequestHandlerInput object which contains request header and  other request parameters like command , target Id , payload etc.
46      * @return response for request as enum with Return code and message.
47      */
48     RequestHandlerOutput handleRequest(RequestHandlerInput input);
49
50     /**
51      * This method perform operations required before execution of workflow starts. It retrieves next state for current operation from Lifecycle manager and update it in AAI.
52      * @param vnf_id vnf id or target Id on which updates required
53      * @param forceFlag
54      * @return true in case AAI updates are successful. false for any error or exception.
55      */
56     void onRequestExecutionStart(String vnf_id, boolean readOnlyActivity, boolean forceFlag) ;
57
58     /**
59      * This method perform following operations required after execution of workflow.
60      * It posts asynchronous response to message bus (DMaaP).
61      * Unlock VNF Id
62      * Removes request from request registry.
63      * Generate audit logs.
64      * Adds transaction record to database id if transaction logging is enabled.
65      * @param runtimeContext RuntimeContext object which contains all parameters from request, response and few parameters from AA&I
66      */
67     void onRequestExecutionEnd(RuntimeContext runtimeContext);
68
69     /**
70      * This method returns the count of in progress requests
71      * * @return in progress requests count
72      */
73      int getInprogressRequestCount() throws APPCException;
74 }