2 * Copyright © 2017-2018 AT&T Intellectual Property.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.ccsdk.apps.controllerblueprints;
19 import com.fasterxml.jackson.annotation.JsonInclude;
20 import com.fasterxml.jackson.databind.DeserializationFeature;
21 import com.fasterxml.jackson.databind.MapperFeature;
22 import com.fasterxml.jackson.databind.ObjectMapper;
23 import com.fasterxml.jackson.databind.SerializationFeature;
24 import org.glassfish.jersey.logging.LoggingFeature;
25 import org.glassfish.jersey.server.ResourceConfig;
26 import org.glassfish.jersey.servlet.ServletProperties;
27 import org.onap.ccsdk.apps.controllerblueprints.service.common.ServiceExceptionMapper;
28 import org.onap.ccsdk.apps.controllerblueprints.service.rs.ConfigModelRestImpl;
29 import org.onap.ccsdk.apps.controllerblueprints.service.rs.ModelTypeRestImpl;
30 import org.onap.ccsdk.apps.controllerblueprints.service.rs.ResourceDictionaryRestImpl;
31 import org.onap.ccsdk.apps.controllerblueprints.service.rs.ServiceTemplateRestImpl;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.context.annotation.Bean;
34 import org.springframework.context.annotation.Primary;
35 import org.springframework.stereotype.Component;
37 import java.util.logging.Logger;
41 public class JerseyConfiguration extends ResourceConfig {
42 private static final Logger log = Logger.getLogger(JerseyConfiguration.class.getName());
46 public ObjectMapper objectMapper() {
47 ObjectMapper objectMapper = new ObjectMapper();
48 objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
49 objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
50 objectMapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
51 objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
52 objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
57 public JerseyConfiguration() {
58 register(ConfigModelRestImpl.class);
59 register(ModelTypeRestImpl.class);
60 register(ResourceDictionaryRestImpl.class);
61 register(ServiceTemplateRestImpl.class);
63 register(ServiceExceptionMapper.class);
64 property(ServletProperties.FILTER_FORWARD_ON_404, true);
65 register(new LoggingFeature(log));