2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.common.workflow.service;
25 import javax.jws.WebMethod;
26 import javax.jws.WebParam;
27 import javax.jws.WebResult;
28 import javax.jws.WebService;
29 import javax.ws.rs.core.Context;
30 import javax.xml.ws.WebServiceContext;
32 import org.onap.so.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest;
33 import org.onap.so.bpmn.common.adapter.sdnc.SDNCAdapterResponse;
34 import org.onap.so.bpmn.common.adapter.sdnc.SDNCCallbackAdapterPortType;
35 import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackError;
36 import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackResult;
37 import org.springframework.beans.factory.annotation.Autowired;
38 import org.springframework.stereotype.Service;
41 * Implementation of SDNCAdapterCallbackService.
43 @WebService(serviceName="SDNCAdapterCallbackService", targetNamespace="http://org.onap/workflow/sdnc/adapter/schema/v1")
45 public class SDNCAdapterCallbackServiceImpl extends ProcessEngineAwareService implements SDNCCallbackAdapterPortType {
47 private final static String logMarker = "[SDNC-CALLBACK]";
49 @Context WebServiceContext wsContext;
52 CallbackHandlerService callback;
54 @WebMethod(operationName = "SDNCAdapterCallback")
55 @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse")
56 public SDNCAdapterResponse sdncAdapterCallback(
57 @WebParam(name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackRequest")
58 SDNCAdapterCallbackRequest sdncAdapterCallbackRequest) {
60 String method = "sdncAdapterCallback";
61 Object message = sdncAdapterCallbackRequest;
62 String messageEventName = "sdncAdapterCallbackRequest";
63 String messageVariable = "sdncAdapterCallbackRequest";
64 String correlationVariable = "SDNCA_requestId";
65 String correlationValue = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId();
67 CallbackResult result = callback.handleCallback(method, message, messageEventName,
68 messageVariable, correlationVariable, correlationValue, logMarker);
70 if (result instanceof CallbackError) {
71 return new SDNCAdapterErrorResponse(((CallbackError)result).getErrorMessage());
73 return new SDNCAdapterResponse();
77 // This subclass allows unit tests to extract the error
78 public class SDNCAdapterErrorResponse extends SDNCAdapterResponse {
81 public SDNCAdapterErrorResponse(String error) {
85 public String getError() {