View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.core.rest.cxf.service;
20  
21  import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
22  import com.fasterxml.jackson.jaxrs.xml.JacksonXMLProvider;
23  import com.fasterxml.jackson.jaxrs.yaml.JacksonYAMLProvider;
24  import org.apache.cxf.jaxrs.ext.search.SearchContextProvider;
25  import org.apache.cxf.jaxrs.validation.JAXRSBeanValidationInInterceptor;
26  import org.apache.cxf.transport.common.gzip.GZIPInInterceptor;
27  import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor;
28  import org.apache.cxf.validation.BeanValidationProvider;
29  import org.apache.syncope.common.lib.jackson.SyncopeJsonMapper;
30  import org.apache.syncope.common.lib.jackson.SyncopeXmlMapper;
31  import org.apache.syncope.common.lib.jackson.SyncopeYAMLMapper;
32  import org.apache.syncope.common.rest.api.DateParamConverterProvider;
33  import org.apache.syncope.core.rest.cxf.AddETagFilter;
34  import org.apache.syncope.core.rest.cxf.RestServiceExceptionMapper;
35  import org.springframework.beans.factory.annotation.Autowired;
36  import org.springframework.context.annotation.Bean;
37  import org.springframework.context.annotation.Configuration;
38  import org.springframework.core.env.Environment;
39  
40  @Configuration(proxyBeanMethods = false)
41  public class IdRepoRESTCXFTestContext {
42  
43      @Autowired
44      private Environment env;
45  
46      @Bean
47      public DateParamConverterProvider dateParamConverterProvider() {
48          return new DateParamConverterProvider();
49      }
50  
51      @Bean
52      public JacksonXMLProvider xmlProvider() {
53          return new JacksonXMLProvider(new SyncopeXmlMapper());
54      }
55  
56      @Bean
57      public JacksonJsonProvider jsonProvider() {
58          return new JacksonJsonProvider(new SyncopeJsonMapper());
59      }
60  
61      @Bean
62      public JacksonYAMLProvider yamlProvider() {
63          return new JacksonYAMLProvider(new SyncopeYAMLMapper());
64      }
65  
66      @Bean
67      public BeanValidationProvider validationProvider() {
68          return new BeanValidationProvider();
69      }
70  
71      @Bean
72      public JAXRSBeanValidationInInterceptor validationInInterceptor(final BeanValidationProvider validationProvider) {
73          JAXRSBeanValidationInInterceptor validationInInterceptor = new JAXRSBeanValidationInInterceptor();
74          validationInInterceptor.setProvider(validationProvider);
75          return validationInInterceptor;
76      }
77  
78      @Bean
79      public GZIPInInterceptor gzipInInterceptor() {
80          return new GZIPInInterceptor();
81      }
82  
83      @Bean
84      public GZIPOutInterceptor gzipOutInterceptor() {
85          GZIPOutInterceptor gzipOutInterceptor = new GZIPOutInterceptor();
86          gzipOutInterceptor.setThreshold(0);
87          gzipOutInterceptor.setForce(true);
88          return gzipOutInterceptor;
89      }
90  
91      @Bean
92      public RestServiceExceptionMapper restServiceExceptionMapper() {
93          return new RestServiceExceptionMapper(env);
94      }
95  
96      @Bean
97      public SearchContextProvider searchContextProvider() {
98          return new SearchContextProvider();
99      }
100 
101     @Bean
102     public AddETagFilter addETagFilter() {
103         return new AddETagFilter();
104     }
105 }