--- /dev/null
+/* Copyright (c) 2019 AT&T Intellectual Property. #\r
+# #\r
+# Licensed under the Apache License, Version 2.0 (the "License"); #\r
+# you may not use this file except in compliance with the License. #\r
+# You may obtain a copy of the License at #\r
+# #\r
+# http://www.apache.org/licenses/LICENSE-2.0 #\r
+# #\r
+# Unless required by applicable law or agreed to in writing, software #\r
+# distributed under the License is distributed on an "AS IS" BASIS, #\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #\r
+# See the License for the specific language governing permissions and #\r
+# limitations under the License. #\r
+##############################################################################*/\r
+\r
+\r
+package org.oran.otf.api.config;\r
+\r
+import org.oran.otf.api.service.impl.*;\r
+import com.fasterxml.jackson.annotation.JsonInclude;\r
+import com.fasterxml.jackson.databind.DeserializationFeature;\r
+import com.fasterxml.jackson.databind.MapperFeature;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+import com.fasterxml.jackson.databind.SerializationFeature;\r
+import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource;\r
+\r
+import java.util.logging.Level;\r
+import java.util.logging.Logger;\r
+import javax.ws.rs.ApplicationPath;\r
+import org.glassfish.jersey.logging.LoggingFeature;\r
+import org.glassfish.jersey.media.multipart.MultiPartFeature;\r
+import org.glassfish.jersey.server.ResourceConfig;\r
+import org.glassfish.jersey.server.ServerProperties;\r
+import org.glassfish.jersey.servlet.ServletProperties;\r
+import org.oran.otf.api.service.impl.*;\r
+import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.context.annotation.Bean;\r
+import org.springframework.context.annotation.Primary;\r
+import org.springframework.stereotype.Component;\r
+\r
+@Component\r
+@ApplicationPath("/otf/api")\r
+public class JerseyConfiguration extends ResourceConfig {\r
+ private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName());\r
+\r
+ // @Value("${spring.jersey.application-path}")\r
+ // private String apiPath;\r
+\r
+ // @Value("${springfox.documentation.swagger.v2.path}")\r
+ // private String swagger2Endpoint;\r
+\r
+ @Autowired\r
+ public JerseyConfiguration() {\r
+ registerFeatures();\r
+ registerEndpoints();\r
+ setProperties();\r
+\r
+ configureSwagger();\r
+ }\r
+\r
+\r
+ private void registerFeatures() {\r
+ register(MultiPartFeature.class);\r
+ register(new OTFLoggingFeature(Logger.getLogger(getClass().getName()), Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 8192));\r
+\r
+ }\r
+\r
+ private void registerEndpoints() {\r
+ register(TestInstanceServiceImpl.class);\r
+ register(HealthServiceImpl.class);\r
+ register(TestStrategyServiceImpl.class);\r
+ register(TestExecutionServiceImpl.class);\r
+ register(VirtualTestHeadServiceImpl.class);\r
+\r
+ register(OtfOpenServiceImpl.class);\r
+ }\r
+\r
+ private void setProperties() {\r
+ property(ServletProperties.FILTER_FORWARD_ON_404, true);\r
+ property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, true);\r
+ }\r
+\r
+ private void configureSwagger() {\r
+ OpenApiResource openApiResource = new OpenApiResource();\r
+\r
+ register(openApiResource);\r
+ }\r
+\r
+ @Bean\r
+ @Primary\r
+ public ObjectMapper objectMapper() {\r
+ ObjectMapper objectMapper = new ObjectMapper();\r
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);\r
+ objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);\r
+ objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);\r
+ objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);\r
+ return objectMapper;\r
+ }\r
+}\r