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.onap.so.logger.MsoLogger;
38 import org.springframework.beans.factory.annotation.Autowired;
39 import org.springframework.stereotype.Service;
42 * Implementation of SDNCAdapterCallbackService.
44 @WebService(serviceName="SDNCAdapterCallbackService", targetNamespace="http://org.onap/workflow/sdnc/adapter/schema/v1")
46 public class SDNCAdapterCallbackServiceImpl extends ProcessEngineAwareService implements SDNCCallbackAdapterPortType {
48 private final static String logMarker = "[SDNC-CALLBACK]";
50 @Context WebServiceContext wsContext;
53 CallbackHandlerService callback;
55 @WebMethod(operationName = "SDNCAdapterCallback")
56 @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse")
57 public SDNCAdapterResponse sdncAdapterCallback(
58 @WebParam(name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackRequest")
59 SDNCAdapterCallbackRequest sdncAdapterCallbackRequest) {
61 String method = "sdncAdapterCallback";
62 Object message = sdncAdapterCallbackRequest;
63 String messageEventName = "sdncAdapterCallbackRequest";
64 String messageVariable = "sdncAdapterCallbackRequest";
65 String correlationVariable = "SDNCA_requestId";
66 String correlationValue = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId();
68 MsoLogger.setLogContext(correlationValue, "N/A");
70 CallbackResult result = callback.handleCallback(method, message, messageEventName,
71 messageVariable, correlationVariable, correlationValue, logMarker);
73 if (result instanceof CallbackError) {
74 return new SDNCAdapterErrorResponse(((CallbackError)result).getErrorMessage());
76 return new SDNCAdapterResponse();
80 // This subclass allows unit tests to extract the error
81 public class SDNCAdapterErrorResponse extends SDNCAdapterResponse {
84 public SDNCAdapterErrorResponse(String error) {
88 public String getError() {