Merge remote-tracking branch 'origin/dublin' into 'origin/master'
[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 import org.glassfish.jersey.server.ResourceConfig;
26 import org.glassfish.jersey.servlet.ServletProperties;
27 import org.onap.so.apihandler.filters.RequestIdFilter;
28 import org.onap.so.apihandler.filters.RequestUriFilter;
29 import org.onap.so.apihandlerinfra.exceptions.ApiExceptionMapper;
30 import org.onap.so.apihandlerinfra.infra.rest.Network;
31 import org.onap.so.apihandlerinfra.infra.rest.ServiceInstance;
32 import org.onap.so.apihandlerinfra.infra.rest.VfModules;
33 import org.onap.so.apihandlerinfra.infra.rest.Vnf;
34 import org.onap.so.apihandlerinfra.infra.rest.Volumes;
35 import org.onap.so.apihandlerinfra.infra.rest.exception.mapper.AAIEntityNotFoundMapper;
36 import org.onap.so.apihandlerinfra.infra.rest.exception.mapper.CloudConfigurationNotFoundMapper;
37 import org.onap.so.apihandlerinfra.infra.rest.exception.mapper.NoRecipeExceptionMapper;
38 import org.onap.so.apihandlerinfra.infra.rest.exception.mapper.RequestConflictMapper;
39 import org.onap.so.apihandlerinfra.infra.rest.exception.mapper.WorkflowEngineConnectionMapper;
40 import org.onap.so.apihandlerinfra.tenantisolation.CloudOrchestration;
41 import org.onap.so.apihandlerinfra.tenantisolation.CloudResourcesOrchestration;
42 import org.onap.so.apihandlerinfra.tenantisolation.ModelDistributionRequest;
43 import org.onap.so.logging.jaxrs.filter.JaxRsFilterLogging;
44 import org.onap.so.web.exceptions.RuntimeExceptionMapper;
45 import org.springframework.context.annotation.Configuration;
46 import io.swagger.jaxrs.config.BeanConfig;
47 import io.swagger.jaxrs.listing.ApiListingResource;
48 import io.swagger.jaxrs.listing.SwaggerSerializers;
49
50 @Configuration
51 @ApplicationPath("/")
52 public class JerseyConfiguration extends ResourceConfig {
53
54     @PostConstruct
55     public void setUp() {
56         register(GlobalHealthcheckHandler.class);
57         register(NodeHealthcheckHandler.class);
58         register(ServiceInstances.class);
59         register(TasksHandler.class);
60         register(CloudOrchestration.class);
61         register(CloudResourcesOrchestration.class);
62         register(OrchestrationRequests.class);
63         register(VfModules.class);
64         register(Vnf.class);
65         register(Network.class);
66         register(Volumes.class);
67         register(ServiceInstance.class);
68         register(JaxRsFilterLogging.class);
69         register(ManualTasks.class);
70         register(TasksHandler.class);
71         register(ApiListingResource.class);
72         register(SwaggerSerializers.class);
73         register(ApiExceptionMapper.class);
74         register(RuntimeExceptionMapper.class);
75         register(RequestUriFilter.class);
76         register(RequestIdFilter.class);
77         register(E2EServiceInstances.class);
78         register(WorkflowSpecificationsHandler.class);
79         register(InstanceManagement.class);
80         register(ResumeOrchestrationRequest.class);
81         register(AAIEntityNotFoundMapper.class);
82         register(CloudConfigurationNotFoundMapper.class);
83         register(NoRecipeExceptionMapper.class);
84         register(RequestConflictMapper.class);
85         register(WorkflowEngineConnectionMapper.class);
86         // this registration seems to be needed to get predictable
87         // execution behavior for the above JSON Exception Mappers
88         register(com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider.class);
89         register(ModelDistributionRequest.class);
90         property(ServletProperties.FILTER_FORWARD_ON_404, true);
91         BeanConfig beanConfig = new BeanConfig();
92         beanConfig.setVersion("1.0.2");
93         beanConfig.setSchemes(new String[] {"https"});
94         beanConfig.setResourcePackage("org.onap.so.apihandlerinfra");
95         beanConfig.setPrettyPrint(true);
96         beanConfig.setScan(true);
97     }
98
99 }