2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package com.att.bpm.scripts
23 import org.camunda.bpm.engine.delegate.BpmnError
24 import org.camunda.bpm.engine.runtime.Execution;
26 class VnfAdapterUtils {
28 private AbstractServiceTaskProcessor taskProcessor
30 public VnfAdapterUtils(AbstractServiceTaskProcessor taskProcessor) {
31 this.taskProcessor = taskProcessor
34 ExceptionUtil exceptionUtil = new ExceptionUtil()
36 public void validateVnfResponse(Execution execution, String responseVar, String responseCodeVar, String errorResponseVar) {
37 def method = getClass().getSimpleName() + '.validateVnfResponse(' +
38 'execution=' + execution.getId() +
39 ', responseVar=' + responseVar +
40 ', responseCodeVar=' + responseCodeVar +
41 ', errorResponseVar=' + errorResponseVar +
43 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
44 taskProcessor.logDebug('Entered ' + method, isDebugLogEnabled)
47 def prefix = execution.getVariable('prefix')
49 def response = execution.getVariable(responseVar)
50 def responseCode = execution.getVariable(responseCodeVar)
51 def errorResponse = execution.getVariable(errorResponseVar)
53 if (response.contains("WorkflowException")) {
54 execution.setVariable(prefix + "ErrorResponse", response)
55 //execution.setVariable(prefix + "ResponseCode", responseCode)
56 taskProcessor.logDebug(" Sub Vnf flow Error WorkflowException Response - " + "\n" + response, isDebugLogEnabled)
57 throw new BpmnError("MSOWorkflowException")
59 } catch (BpmnError e) {
61 } catch (Exception e) {
62 taskProcessor.logError('Caught exception in ' + method, e)
63 taskProcessor.workflowException(execution, 'Internal Error- Unable to validate VNF Response ' + e.getMessage(), 500)