1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
17 package org.oran.otf.api.config;
\r
19 import org.oran.otf.api.service.impl.*;
\r
20 import com.fasterxml.jackson.annotation.JsonInclude;
\r
21 import com.fasterxml.jackson.databind.DeserializationFeature;
\r
22 import com.fasterxml.jackson.databind.MapperFeature;
\r
23 import com.fasterxml.jackson.databind.ObjectMapper;
\r
24 import com.fasterxml.jackson.databind.SerializationFeature;
\r
25 import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource;
\r
27 import java.util.logging.Level;
\r
28 import java.util.logging.Logger;
\r
29 import javax.ws.rs.ApplicationPath;
\r
30 import org.glassfish.jersey.logging.LoggingFeature;
\r
31 import org.glassfish.jersey.media.multipart.MultiPartFeature;
\r
32 import org.glassfish.jersey.server.ResourceConfig;
\r
33 import org.glassfish.jersey.server.ServerProperties;
\r
34 import org.glassfish.jersey.servlet.ServletProperties;
\r
35 import org.oran.otf.api.service.impl.*;
\r
36 import org.springframework.beans.factory.annotation.Autowired;
\r
37 import org.springframework.context.annotation.Bean;
\r
38 import org.springframework.context.annotation.Primary;
\r
39 import org.springframework.stereotype.Component;
\r
42 @ApplicationPath("/otf/api")
\r
43 public class JerseyConfiguration extends ResourceConfig {
\r
44 private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName());
\r
46 // @Value("${spring.jersey.application-path}")
\r
47 // private String apiPath;
\r
49 // @Value("${springfox.documentation.swagger.v2.path}")
\r
50 // private String swagger2Endpoint;
\r
53 public JerseyConfiguration() {
\r
55 registerEndpoints();
\r
62 private void registerFeatures() {
\r
63 register(MultiPartFeature.class);
\r
64 register(new OTFLoggingFeature(Logger.getLogger(getClass().getName()), Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 8192));
\r
68 private void registerEndpoints() {
\r
69 register(TestInstanceServiceImpl.class);
\r
70 register(HealthServiceImpl.class);
\r
71 register(TestStrategyServiceImpl.class);
\r
72 register(TestExecutionServiceImpl.class);
\r
73 register(VirtualTestHeadServiceImpl.class);
\r
75 register(OtfOpenServiceImpl.class);
\r
78 private void setProperties() {
\r
79 property(ServletProperties.FILTER_FORWARD_ON_404, true);
\r
80 property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, true);
\r
83 private void configureSwagger() {
\r
84 OpenApiResource openApiResource = new OpenApiResource();
\r
86 register(openApiResource);
\r
91 public ObjectMapper objectMapper() {
\r
92 ObjectMapper objectMapper = new ObjectMapper();
\r
93 objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
\r
94 objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
\r
95 objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
\r
96 objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
\r
97 return objectMapper;
\r