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=========================================================
20 package org.onap.policy.pdp.rest.config;
22 import javax.servlet.MultipartConfigElement;
24 import org.onap.policy.common.logging.eelf.PolicyLogger;
25 import org.onap.policy.pdp.rest.api.controller.PolicyEngineServices;
26 import org.springframework.context.annotation.Bean;
27 import org.springframework.context.annotation.ComponentScan;
28 import org.springframework.context.annotation.Configuration;
29 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
30 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
31 import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
33 import springfox.documentation.builders.ApiInfoBuilder;
34 import springfox.documentation.builders.PathSelectors;
35 import springfox.documentation.builders.RequestHandlerSelectors;
36 import springfox.documentation.service.ApiInfo;
37 import springfox.documentation.spi.DocumentationType;
38 import springfox.documentation.spring.web.plugins.Docket;
39 import springfox.documentation.swagger2.annotations.EnableSwagger2;
44 @ComponentScan(basePackageClasses = PolicyEngineServices.class)
45 public class PDPRestConfig extends WebMvcConfigurerAdapter{
47 public void addResourceHandlers(ResourceHandlerRegistry registry) {
48 registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
49 registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
52 private ApiInfo apiInfo(){
53 return new ApiInfoBuilder()
54 .title("Policy Engine REST API")
55 .description("This API helps to make queries against Policy Engine")
61 public Docket policyAPI(){
62 PolicyLogger.info("Setting up Swagger... ");
63 return new Docket(DocumentationType.SWAGGER_2)
65 .apis(RequestHandlerSelectors.basePackage("org.onap.policy.pdp.rest.api"))
66 .paths(PathSelectors.any())
72 public MultipartConfigElement multipartConfigElement(){
73 String location = System.getProperty("java.io.tmpdir");
74 MultipartConfigElement mp = new MultipartConfigElement(location);