1700e121f0a52ac65ff12ef1d3986880782d1073
[so.git] / mso-api-handlers / mso-api-handler-infra / src / main / java / org / onap / so / apihandlerinfra / JerseyConfiguration.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.apihandlerinfra;
22
23 import javax.annotation.PostConstruct;
24 import javax.ws.rs.ApplicationPath;
25
26 import org.glassfish.jersey.server.ResourceConfig;
27 import org.glassfish.jersey.servlet.ServletProperties;
28 import org.onap.so.apihandler.filters.RequestUriFilter;
29 import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper;
30 import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestration;
31 import org.onap.so.apihandlerinfra.tenantisolation.CloudResourcesOrchestration;
32 import org.onap.so.logging.jaxrs.filter.jersey.JaxRsFilterLogging;
33 import org.onap.so.web.exceptions.RuntimeExceptionMapper;
34 import org.springframework.context.annotation.Configuration;
35
36 import io.swagger.jaxrs.config.BeanConfig;
37 import io.swagger.jaxrs.listing.ApiListingResource;
38 import io.swagger.jaxrs.listing.SwaggerSerializers;
39
40 @Configuration
41 @ApplicationPath("/")
42 public class JerseyConfiguration extends ResourceConfig {
43
44
45
46         @PostConstruct
47         public void setUp() {
48                 register(GlobalHealthcheckHandler.class);               
49                 register(NodeHealthcheckHandler.class);
50                 register(ServiceInstances.class);
51                 register(TasksHandler.class);
52                 register(CloudOrchestration.class);
53                 register(CloudResourcesOrchestration.class);
54                 register(OrchestrationRequests.class);          
55                 register(JaxRsFilterLogging.class);
56                 register(ManualTasks.class);
57                 register(TasksHandler.class);
58                 register(ApiListingResource.class);
59                 register(SwaggerSerializers.class);
60                 register(ApiExceptionMapper.class);
61                 register(RuntimeExceptionMapper.class);
62                 register(RequestUriFilter.class);
63                 register(E2EServiceInstances.class);
64                 // this registration seems to be needed to get predictable
65                 // execution behavior for the above JSON Exception Mappers
66                 register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class);
67                 property(ServletProperties.FILTER_FORWARD_ON_404, true);
68                 BeanConfig beanConfig = new BeanConfig();
69                 beanConfig.setVersion("1.0.2");
70                 beanConfig.setSchemes(new String[] { "https" });
71                 beanConfig.setResourcePackage("org.onap.so.apihandlerinfra");
72                 beanConfig.setPrettyPrint(true);
73                 beanConfig.setScan(true);
74         }
75
76 }