X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=otf-camunda%2Fsrc%2Fmain%2Fjava%2Forg%2Foran%2Fotf%2Fspring%2Fconfiguration%2FJerseyConfiguration.java;fp=otf-camunda%2Fsrc%2Fmain%2Fjava%2Forg%2Foran%2Fotf%2Fspring%2Fconfiguration%2FJerseyConfiguration.java;h=487a8da7fb6f2f51073cc32c24fd140e76af5394;hb=14f6f95c84a4a1fa8774190db4a03fd0214ec55f;hp=0000000000000000000000000000000000000000;hpb=f49bd1efeaaddd4891c1f329b18d8cfb28b3e75b;p=it%2Fotf.git diff --git a/otf-camunda/src/main/java/org/oran/otf/spring/configuration/JerseyConfiguration.java b/otf-camunda/src/main/java/org/oran/otf/spring/configuration/JerseyConfiguration.java new file mode 100644 index 0000000..487a8da --- /dev/null +++ b/otf-camunda/src/main/java/org/oran/otf/spring/configuration/JerseyConfiguration.java @@ -0,0 +1,83 @@ +/* Copyright (c) 2019 AT&T Intellectual Property. # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); # +# you may not use this file except in compliance with the License. # +# You may obtain a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +##############################################################################*/ + + +package org.oran.otf.spring.configuration; + +import org.oran.otf.service.impl.DeleteProcessInstanceServiceImpl; +import org.oran.otf.service.impl.DeleteTestDefinitionServiceImpl; +import org.oran.otf.service.impl.DeveloperServiceImpl; +import org.oran.otf.service.impl.HealthServiceImpl; +import org.oran.otf.service.impl.ProcessInstanceCompletionServiceImpl; +import org.oran.otf.service.impl.TestControlUnitServiceImpl; +import org.oran.otf.service.impl.TestDefinitionDeploymentServiceImpl; + +import java.util.logging.Logger; +import org.glassfish.jersey.logging.LoggingFeature; +import org.glassfish.jersey.media.multipart.MultiPartFeature; +import org.glassfish.jersey.server.ResourceConfig; +import org.glassfish.jersey.server.ServerProperties; +import org.glassfish.jersey.servlet.ServletContainer; +import org.glassfish.jersey.servlet.ServletProperties; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/* + * Note: JerseyAutoConfiguration is used to incorporate camunda rest api In this configuration class + * we create a new servletregistrationbean to serve at /service/* while camunda serves at /rest/* + */ +@Configuration +public class JerseyConfiguration { + + private static final Logger logger = Logger.getLogger(JerseyConfiguration.class.getName()); + + @Bean + public ServletRegistrationBean applicationJersey() { + ServletRegistrationBean applicationJersey = + new ServletRegistrationBean<>(new ServletContainer(new ApplicationJerseyConfig())); + applicationJersey.addUrlMappings("/otf/*"); + applicationJersey.setName("Open Test Framework - Test Control Unit"); + applicationJersey.setLoadOnStartup(0); + return applicationJersey; + } + + public class ApplicationJerseyConfig extends ResourceConfig { + + public ApplicationJerseyConfig() { + register(MultiPartFeature.class); +// register( +// new OTFLoggingFeature( +// Logger.getLogger(getClass().getName()), +// Level.INFO, +// LoggingFeature.Verbosity.PAYLOAD_ANY, +// 8192)); + + logger.info("Registering REST resources."); + register(TestControlUnitServiceImpl.class); + register(HealthServiceImpl.class); + register(DeleteTestDefinitionServiceImpl.class); + register(ProcessInstanceCompletionServiceImpl.class); + register(TestDefinitionDeploymentServiceImpl.class); + register(DeleteProcessInstanceServiceImpl.class); + register(DeveloperServiceImpl.class); + + property(ServletProperties.FILTER_FORWARD_ON_404, true); + property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, true); + register(new LoggingFeature(logger)); + logger.info("Finished registering REST resources."); + } + } +}