6bfe6184607507a08c9633e91c189a8d1d2b542a
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.bpmn.infrastructure.manualhandling.tasks;
22
23 import org.onap.so.logger.LoggingAnchor;
24 import org.camunda.bpm.engine.delegate.BpmnError;
25 import org.onap.so.bpmn.common.BuildingBlockExecution;
26 import org.onap.so.client.ticket.ExternalTicket;
27 import org.onap.so.logger.ErrorCode;
28 import org.onap.so.logger.MessageEnum;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31 import org.springframework.stereotype.Component;
32
33 @Component
34 public class ExternalTicketTasks implements ExternalTicketCreation {
35     private static final Logger logger = LoggerFactory.getLogger(ExternalTicketTasks.class);
36
37     protected static final String VNF_TYPE = "vnfType";
38     protected static final String DESCRIPTION = "description";
39     protected static final String SERVICE_TYPE = "serviceType";
40     protected static final String MSO_REQUEST_ID = "mso-request-id";
41     protected static final String REQUESTOR_ID = "requestorId";
42     protected static final String ERROR_CODE = "errorCode";
43     protected static final String VALID_RESPONSES = "validResponses";
44     protected static final String TASK_TIMEOUT = "taskTimeout";
45     protected static final String RESPONSE_VALUE_TASK = "responseValueTask";
46     protected static final String RESPONSE_VALUE = "responseValue";
47     protected static final String WORKSTEP = "workStep";
48
49     protected static final String TASK_VARIABLE_TYPE = "type";
50     protected static final String TASK_VARIABLE_NFROLE = "nfRole";
51     protected static final String TASK_VARIABLE_SUBSCRIPTION_SERVICE_TYPE = "subscriptionServiceType";
52     protected static final String TASK_VARIABLE_ORIGINAL_REQUEST_ID = "originalRequestId";
53     protected static final String TASK_VARIABLE_ORIGINAL_REQUESTOR_ID = "originalRequestorId";
54     protected static final String TASK_VARIABLE_ERROR_SOURCE = "errorSource";
55     protected static final String TASK_VARIABLE_ERROR_CODE = "errorCode";
56     protected static final String TASK_VARIABLE_ERROR_MESSAGE = "errorMessage";
57     protected static final String TASK_VARIABLE_BUILDING_BLOCK_NAME = "buildingBlockName";
58     protected static final String TASK_VARIABLE_BUILDING_BLOCK_STEP = "buildingBlockStep";
59     protected static final String TASK_VARIABLE_DESCRIPTION = "description";
60     protected static final String TASK_VARIABLE_TIMEOUT = "timeout";
61     protected static final String TASK_VARIABLE_VALID_RESPONSES = "validResponses";
62
63     protected static final String BPMN_EXCEPTION = "BPMN exception: ";
64     protected static final String RAINY_DAY_SERVICE_TYPE = "rainyDayServiceType";
65     protected static final String RAINY_DAY_VNF_TYPE = "rainyDayVnfType";
66     protected static final String RAINY_DAY_VNF_NAME = "rainyDayVnfName";
67     protected static final String G_BUILDING_BLOCK_EXECUTION = "gBuildingBlockExecution";
68     protected static final String WORKFLOW_EXCEPTION = "WorkflowException";
69
70     public void createExternalTicket(BuildingBlockExecution execution) {
71
72         logger.debug("Creating ExternalTicket()");
73         try {
74             ExternalTicket ticket = getExternalTicket();
75
76             ticket.setRequestId((String) execution.getVariable(MSO_REQUEST_ID));
77             ticket.setCurrentActivity((String) execution.getVariable("currentActivity"));
78             ticket.setNfRole((String) execution.getVariable(VNF_TYPE));
79             ticket.setDescription((String) execution.getVariable(DESCRIPTION));
80             ticket.setSubscriptionServiceType((String) execution.getVariable(SERVICE_TYPE));
81             ticket.setRequestorId((String) execution.getVariable(REQUESTOR_ID));
82             ticket.setTimeout((String) execution.getVariable(TASK_TIMEOUT));
83             ticket.setErrorSource((String) execution.getVariable("failedActivity"));
84             ticket.setErrorCode((String) execution.getVariable(ERROR_CODE));
85             ticket.setErrorMessage((String) execution.getVariable("errorText"));
86             ticket.setWorkStep((String) execution.getVariable(WORKSTEP));
87
88             ticket.createTicket();
89         } catch (BpmnError e) {
90             String msg = "BPMN error in createExternalTicket " + e.getMessage();
91             logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN",
92                     ErrorCode.UnknownError.getValue());
93         } catch (Exception ex) {
94             String msg = "Exception in createExternalTicket " + ex.getMessage();
95             logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN",
96                     ErrorCode.UnknownError.getValue());
97         }
98
99     }
100
101     protected ExternalTicket getExternalTicket() {
102         return new ExternalTicket();
103     }
104
105
106 }