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 org.onap.so.bpmn.common.workflow.service;
23 import javax.jws.WebMethod;
24 import javax.jws.WebParam;
25 import javax.jws.WebResult;
26 import javax.jws.WebService;
27 import javax.ws.rs.core.Context;
28 import javax.xml.ws.WebServiceContext;
30 import org.onap.so.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest;
31 import org.onap.so.bpmn.common.adapter.sdnc.SDNCAdapterResponse;
32 import org.onap.so.bpmn.common.adapter.sdnc.SDNCCallbackAdapterPortType;
33 import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackError;
34 import org.onap.so.bpmn.common.workflow.service.CallbackHandlerService.CallbackResult;
35 import org.onap.so.logger.MsoLogger;
36 import org.springframework.beans.factory.annotation.Autowired;
37 import org.springframework.stereotype.Service;
40 * Implementation of SDNCAdapterCallbackService.
42 @WebService(serviceName="SDNCAdapterCallbackService", targetNamespace="http://org.onap/workflow/sdnc/adapter/schema/v1")
44 public class SDNCAdapterCallbackServiceImpl extends ProcessEngineAwareService implements SDNCCallbackAdapterPortType {
46 private final static String logMarker = "[SDNC-CALLBACK]";
48 @Context WebServiceContext wsContext;
51 CallbackHandlerService callback;
53 @WebMethod(operationName = "SDNCAdapterCallback")
54 @WebResult(name = "SDNCAdapterResponse", targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackResponse")
55 public SDNCAdapterResponse sdncAdapterCallback(
56 @WebParam(name = "SDNCAdapterCallbackRequest", targetNamespace = "http://org.onap/workflow/sdnc/adapter/schema/v1", partName = "SDNCAdapterCallbackRequest")
57 SDNCAdapterCallbackRequest sdncAdapterCallbackRequest) {
59 String method = "sdncAdapterCallback";
60 Object message = sdncAdapterCallbackRequest;
61 String messageEventName = "sdncAdapterCallbackRequest";
62 String messageVariable = "sdncAdapterCallbackRequest";
63 String correlationVariable = "SDNCA_requestId";
64 String correlationValue = sdncAdapterCallbackRequest.getCallbackHeader().getRequestId();
66 MsoLogger.setServiceName("MSO." + method);
67 MsoLogger.setLogContext(correlationValue, "N/A");
69 CallbackResult result = callback.handleCallback(method, message, messageEventName,
70 messageVariable, correlationVariable, correlationValue, logMarker);
72 if (result instanceof CallbackError) {
73 return new SDNCAdapterErrorResponse(((CallbackError)result).getErrorMessage());
75 return new SDNCAdapterResponse();
79 // This subclass allows unit tests to extract the error
80 public class SDNCAdapterErrorResponse extends SDNCAdapterResponse {
83 public SDNCAdapterErrorResponse(String error) {
87 public String getError() {