Update Logging
[so.git] / bpmn / mso-infrastructure-bpmn / src / main / java / org / onap / so / bpmn / infrastructure / CXFConfiguration.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
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;
22
23 import java.util.Arrays;
24
25 import javax.xml.ws.Endpoint;
26
27 import org.apache.cxf.Bus;
28 import org.apache.cxf.endpoint.Server;
29 import org.apache.cxf.feature.LoggingFeature;
30 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
31 import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
32 import org.apache.cxf.jaxws.EndpointImpl;
33 import org.apache.cxf.transport.servlet.CXFServlet;
34 import org.onap.so.bpmn.common.adapter.sdnc.SDNCCallbackAdapterPortType;
35 import org.onap.so.bpmn.common.adapter.vnf.VnfAdapterNotify;
36 import org.onap.so.bpmn.common.workflow.service.WorkflowAsyncResource;
37 import org.onap.so.bpmn.common.workflow.service.WorkflowMessageResource;
38 import org.onap.so.bpmn.common.workflow.service.WorkflowResource;
39 import org.onap.so.logger.MsoLogger;
40 import org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor;
41 import org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor;
42 import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging;
43 import org.springframework.beans.factory.annotation.Autowired;
44 import org.springframework.boot.web.servlet.ServletRegistrationBean;
45 import org.springframework.context.annotation.Bean;
46 import org.springframework.context.annotation.Configuration;
47
48 import com.fasterxml.jackson.databind.ObjectMapper;
49 import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
50
51
52 @Configuration
53 public class CXFConfiguration {
54     
55         private static final MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,CXFConfiguration.class);
56         
57     @Autowired
58     private Bus bus;    
59
60         @Autowired
61         private WorkflowMessageResource wmr;
62         
63         @Autowired
64         private WorkflowResource workflowResource;
65
66         @Autowired
67         private WorkflowAsyncResource workflowAsyncResource;
68         
69         @Autowired
70         private JaxRsFilterLogging jaxRsFilterLogging;
71         
72         @Autowired
73         private ObjectMapper mapper; 
74         
75         @Autowired
76         private SDNCCallbackAdapterPortType sdncAdapterCallbackServiceImpl;
77         
78         @Autowired
79         private VnfAdapterNotify vnfAdapterNotifyServiceImpl;
80         
81         @Autowired
82         private SOAPLoggingInInterceptor soapInInterceptor;
83
84         @Autowired
85         private SOAPLoggingOutInterceptor soapOutInterceptor;
86         
87         @Bean
88     public ServletRegistrationBean cxfServlet() {
89         return new ServletRegistrationBean(new CXFServlet(), "/mso/*");
90     }
91     
92     @Bean
93     public Endpoint vnfAdapterCallback() {
94         EndpointImpl endpoint = new EndpointImpl(bus, vnfAdapterNotifyServiceImpl);
95         endpoint.publish("/VNFAdaptercallback");
96         endpoint.getInInterceptors().add(soapInInterceptor);
97         endpoint.getOutInterceptors().add(soapOutInterceptor);
98         endpoint.getOutFaultInterceptors().add(soapOutInterceptor);
99         return endpoint;
100     }
101         
102     @Bean
103     public Endpoint sndcAdapterCallback() {
104         EndpointImpl endpoint = new EndpointImpl(bus, sdncAdapterCallbackServiceImpl);
105         endpoint.publish("/SDNCAdapterCallbackService");
106         endpoint.getInInterceptors().add(soapInInterceptor);
107         endpoint.getOutInterceptors().add(soapOutInterceptor);
108         endpoint.getOutFaultInterceptors().add(soapOutInterceptor);
109         return endpoint;
110     }
111                 
112     @Bean
113     public Server rsServer() {
114         JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean();
115         endpoint.setBus(bus);
116         endpoint.setServiceBeans(Arrays.<Object>asList(wmr, workflowResource, workflowAsyncResource));
117         endpoint.setAddress("/");       
118         endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature()));
119         endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(mapper),jaxRsFilterLogging));
120        
121         return endpoint.create();
122     }
123
124     @Bean
125     public Swagger2Feature createSwaggerFeature() {
126         Swagger2Feature swagger2Feature= new Swagger2Feature();
127         swagger2Feature.setPrettyPrint(true);
128         swagger2Feature.setTitle("SO Orchestration Application");
129         swagger2Feature.setContact("The ONAP SO team");
130         swagger2Feature.setDescription("This project is the SO Orchestration Engine");
131         swagger2Feature.setVersion("1.0.0");
132         swagger2Feature.setResourcePackage("org.onap.so.bpmn.common.workflow.service");
133         swagger2Feature.setScan(true);
134         return swagger2Feature;
135     }
136 }