23b5d372f928e0005fc3ce80f70eda8afc7d3f1a
[appc.git] / appc-dispatcher / appc-request-handler / appc-request-handler-api / src / main / java / org / openecomp / appc / requesthandler / RequestHandler.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.openecomp.appc.requesthandler;
23
24 import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
25 import org.openecomp.appc.executor.UnstableVNFException;
26 import org.openecomp.appc.requesthandler.objects.RequestHandlerInput;
27 import org.openecomp.appc.requesthandler.objects.RequestHandlerOutput;
28
29 /**
30  * This class provides application logic for the Request/Response Handler Component.
31  *
32  */
33 public interface RequestHandler {
34     /**
35      * It receives requests from the north-bound REST API (Communication) Layer and
36      * performs following validations.
37      * 1. VNF exists in A&AI for the given targetID (VnfID)
38      * 2. For the current VNF  Orchestration Status, the command can be executed
39      * 3. For the given VNF type and Operation, there exists work-flow definition in the APPC database
40      * If any of the validation fails, it returns appropriate response
41      *
42      * @param input RequestHandlerInput object which contains request header and  other request parameters like command , target Id , payload etc.
43      * @return response for request as enum with Return code and message.
44      */
45     RequestHandlerOutput handleRequest(RequestHandlerInput input);
46
47     /**
48      * 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.
49      * @param vnf_id vnf id or target Id on which updates required
50      * @param  requestIdentifierString - string contains id uniquely represents the request
51      * @param forceFlag
52      * @return true in case AAI updates are successful. false for any error or exception.
53      */
54     void onRequestExecutionStart(String vnf_id, boolean readOnlyActivity, String requestIdentifierString, boolean forceFlag) throws UnstableVNFException;
55
56     /**
57      * This method perform following operations required after execution of workflow.
58      * It posts asynchronous response to message bus (DMaaP).
59      * Unlock VNF Id
60      * Removes request from request registry.
61      * Generate audit logs.
62      * Adds transaction record to database id if transaction logging is enabled.
63      * @param runtimeContext RuntimeContext object which contains all parameters from request, response and few parameters from AA&I
64      * @param isAAIUpdated boolean flag which indicate AAI upodate status after request completion.
65      */
66     void onRequestExecutionEnd(RuntimeContext runtimeContext, boolean isAAIUpdated);
67
68     /**
69      * This method perform following operations required if TTL ends when request still waiting in execution queue .
70      * It posts asynchronous response to message bus (DMaaP).
71      * Unlock VNF Id
72      * Removes request from request registry.
73      * @param runtimeContext RuntimeContext object which contains all parameters from request, response and few parameters from AA&I;
74      * @param updateAAI boolean flag which indicate AAI upodate status after request completion.
75      */
76      void onRequestTTLEnd(RuntimeContext runtimeContext, boolean updateAAI);
77
78     /**
79      * This method returns the count of in progress requests
80      * * @return in progress requests count
81      */
82      int getInprogressRequestCount();
83 }