SO-3720 BuildingBlockRollback lookup table
[so.git] / adapters / mso-catalog-db-adapter / src / main / java / org / onap / so / adapters / catalogdb / 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.adapters.catalogdb;
22
23 import java.util.stream.Collectors;
24 import java.util.stream.Stream;
25 import javax.annotation.PostConstruct;
26 import javax.ws.rs.ApplicationPath;
27 import org.glassfish.jersey.server.ResourceConfig;
28 import org.onap.logging.filter.base.Constants;
29 import org.onap.logging.filter.base.ONAPComponents;
30 import org.onap.so.adapters.catalogdb.rest.BuildingBlockRollbackRestImpl;
31 import org.onap.so.adapters.catalogdb.rest.CatalogDbAdapterRest;
32 import org.onap.so.adapters.catalogdb.rest.ServiceRestImpl;
33 import org.onap.so.adapters.catalogdb.rest.VnfRestImpl;
34 import org.onap.so.logging.jaxrs.filter.SOAuditLogContainerFilter;
35 import org.springframework.context.annotation.Configuration;
36 import io.swagger.v3.jaxrs2.integration.JaxrsOpenApiContextBuilder;
37 import io.swagger.v3.jaxrs2.integration.resources.AcceptHeaderOpenApiResource;
38 import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource;
39 import io.swagger.v3.oas.integration.OpenApiConfigurationException;
40 import io.swagger.v3.oas.integration.SwaggerConfiguration;
41 import io.swagger.v3.oas.models.OpenAPI;
42 import io.swagger.v3.oas.models.info.Info;
43
44 @Configuration
45 @ApplicationPath("/ecomp/mso/catalog")
46 public class JerseyConfiguration extends ResourceConfig {
47
48     @PostConstruct
49     public void setUp() {
50         System.setProperty(Constants.Property.PARTNER_NAME, ONAPComponents.CATALOG_DB.toString());
51         register(CatalogDbAdapterRest.class);
52         register(SOAuditLogContainerFilter.class);
53         register(OpenApiResource.class);
54         register(AcceptHeaderOpenApiResource.class);
55         register(ServiceRestImpl.class);
56         register(VnfRestImpl.class);
57         register(BuildingBlockRollbackRestImpl.class);
58
59         OpenAPI oas = new OpenAPI();
60         Info info = new Info();
61         info.title("Swagger catalog-db-adapter bootstrap code");
62         info.setVersion("1.0.2");
63
64         SwaggerConfiguration oasConfig = new SwaggerConfiguration().openAPI(oas).prettyPrint(true)
65                 .resourcePackages(Stream.of("org.onap.so.adapters.catalogdb.rest").collect(Collectors.toSet()));
66
67         try {
68             new JaxrsOpenApiContextBuilder().application(this).openApiConfiguration(oasConfig).buildContext(true);
69         } catch (OpenApiConfigurationException e) {
70             throw new RuntimeException(e.getMessage(), e);
71         }
72     }
73 }
74