231e97dd98e6c4bf7cc96a0a05b310f7b4e0aec4
[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  * 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.openecomp.appc.requesthandler;
26
27 import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
28 import org.openecomp.appc.executor.UnstableVNFException;
29 import org.openecomp.appc.requesthandler.objects.RequestHandlerInput;
30 import org.openecomp.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  requestIdentifierString - string contains id uniquely represents the request
54      * @param forceFlag
55      * @return true in case AAI updates are successful. false for any error or exception.
56      */
57     void onRequestExecutionStart(String vnf_id, boolean readOnlyActivity, String requestIdentifierString, boolean forceFlag) throws UnstableVNFException;
58
59     /**
60      * This method perform following operations required after execution of workflow.
61      * It posts asynchronous response to message bus (DMaaP).
62      * Unlock VNF Id
63      * Removes request from request registry.
64      * Generate audit logs.
65      * Adds transaction record to database id if transaction logging is enabled.
66      * @param runtimeContext RuntimeContext object which contains all parameters from request, response and few parameters from AA&I
67      * @param isAAIUpdated boolean flag which indicate AAI upodate status after request completion.
68      */
69     void onRequestExecutionEnd(RuntimeContext runtimeContext, boolean isAAIUpdated);
70
71     /**
72      * This method perform following operations required if TTL ends when request still waiting in execution queue .
73      * It posts asynchronous response to message bus (DMaaP).
74      * Unlock VNF Id
75      * Removes request from request registry.
76      * @param runtimeContext RuntimeContext object which contains all parameters from request, response and few parameters from AA&I;
77      * @param updateAAI boolean flag which indicate AAI upodate status after request completion.
78      */
79      void onRequestTTLEnd(RuntimeContext runtimeContext, boolean updateAAI);
80
81     /**
82      * This method returns the count of in progress requests
83      * * @return in progress requests count
84      */
85      int getInprogressRequestCount();
86 }