You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2015/10/09 16:58:42 UTC
[1/2] syncope git commit: [SYNCOPE-704] Adjusting after CXF-6633
Repository: syncope
Updated Branches:
refs/heads/master 62dd125d0 -> a1f85be2e
[SYNCOPE-704] Adjusting after CXF-6633
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/dd4dd571
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/dd4dd571
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/dd4dd571
Branch: refs/heads/master
Commit: dd4dd571c8544803a99124cbc0a992b14a18ec7a
Parents: 62dd125
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Oct 9 14:27:56 2015 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Oct 9 14:27:56 2015 +0200
----------------------------------------------------------------------
.../core/rest/cxf/SyncopeSwagger2Feature.java | 137 -----------------
.../rest/cxf/SyncopeSwaggerSerializers.java | 153 -------------------
.../src/main/resources/restCXFContext.xml | 2 +-
3 files changed, 1 insertion(+), 291 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd4dd571/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/SyncopeSwagger2Feature.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/SyncopeSwagger2Feature.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/SyncopeSwagger2Feature.java
deleted file mode 100644
index 8f29f60..0000000
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/SyncopeSwagger2Feature.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.syncope.core.rest.cxf;
-
-import io.swagger.jaxrs.config.BeanConfig;
-import io.swagger.jaxrs.config.DefaultReaderConfig;
-import io.swagger.jaxrs.config.ReaderConfig;
-import io.swagger.jaxrs.listing.ApiListingResource;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerRequestFilter;
-import javax.ws.rs.core.Context;
-import org.apache.cxf.BusFactory;
-import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
-import org.apache.cxf.jaxrs.ext.MessageContext;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.model.wadl.DocumentationProvider;
-import org.apache.cxf.jaxrs.model.wadl.JavaDocProvider;
-import org.apache.cxf.jaxrs.provider.ServerProviderFactory;
-import org.apache.cxf.jaxrs.swagger.Swagger2Feature;
-import org.apache.cxf.jaxrs.utils.InjectionUtils;
-
-public class SyncopeSwagger2Feature extends Swagger2Feature {
-
- private boolean dynamicBasePath;
-
- private boolean replaceTags;
-
- private DocumentationProvider javadocProvider;
-
- public void setDynamicBasePath(final boolean dynamicBasePath) {
- this.dynamicBasePath = dynamicBasePath;
- }
-
- public void setReplaceTags(final boolean replaceTags) {
- this.replaceTags = replaceTags;
- }
-
- public void setJavaDocPath(final String javaDocPath) throws Exception {
- this.javadocProvider = new JavaDocProvider(BusFactory.getDefaultBus(), javaDocPath);
- }
-
- @Override
- protected void addSwaggerResource(final Server server) {
- List<ClassResourceInfo> cris = Collections.emptyList();
- if (!runAsFilter) {
- List<Object> serviceBeans = new ArrayList<>();
- ApiListingResource apiListingResource = new ApiListingResource();
- serviceBeans.add(apiListingResource);
- JAXRSServiceFactoryBean sfb =
- (JAXRSServiceFactoryBean) server.getEndpoint().get(JAXRSServiceFactoryBean.class.getName());
- sfb.setResourceClassesFromBeans(serviceBeans);
- cris = sfb.getClassResourceInfo();
- for (ClassResourceInfo cri : cris) {
- if (ApiListingResource.class == cri.getResourceClass()) {
- InjectionUtils.injectContextProxiesAndApplication(cri, apiListingResource, null);
- }
- }
- }
- List<Object> providers = new ArrayList<>();
- providers.add(new SyncopeSwaggerSerializers(dynamicBasePath, replaceTags, javadocProvider, cris));
- providers.add(new ReaderConfigFilter());
- ((ServerProviderFactory) server.getEndpoint().get(
- ServerProviderFactory.class.getName())).setUserProviders(providers);
-
- BeanConfig beanConfig = new BeanConfig();
- beanConfig.setResourcePackage(getResourcePackage());
- beanConfig.setVersion(getVersion());
- beanConfig.setBasePath(getBasePath());
- beanConfig.setHost(getHost());
- beanConfig.setSchemes(getSchemes());
- beanConfig.setTitle(getTitle());
- beanConfig.setDescription(getDescription());
- beanConfig.setContact(getContact());
- beanConfig.setLicense(getLicense());
- beanConfig.setLicenseUrl(getLicenseUrl());
- beanConfig.setTermsOfServiceUrl(getTermsOfServiceUrl());
- beanConfig.setScan(isScan());
- beanConfig.setPrettyPrint(isPrettyPrint());
- beanConfig.setFilterClass(getFilterClass());
- }
-
- private class ReaderConfigFilter implements ContainerRequestFilter {
-
- @Context
- private MessageContext mc;
-
- @Override
- public void filter(final ContainerRequestContext requestContext) throws IOException {
- if (mc.getServletContext().getAttribute(ReaderConfig.class.getName()) == null) {
- if (mc.getServletConfig() != null
- && Boolean.valueOf(mc.getServletConfig().getInitParameter("scan.all.resources"))) {
-
- addReaderConfig(mc.getServletConfig().getInitParameter("ignore.routes"));
- } else if (isScanAllResources()) {
- addReaderConfig(getIgnoreRoutes());
- }
- }
- }
-
- private void addReaderConfig(final String ignoreRoutesParam) {
- DefaultReaderConfig rc = new DefaultReaderConfig();
- rc.setScanAllResources(true);
- if (ignoreRoutesParam != null) {
- Set<String> routes = new LinkedHashSet<>();
- for (String route : StringUtils.split(ignoreRoutesParam, ",")) {
- routes.add(route.trim());
- }
- rc.setIgnoredRoutes(routes);
- }
- mc.getServletContext().setAttribute(ReaderConfig.class.getName(), rc);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd4dd571/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/SyncopeSwaggerSerializers.java
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/SyncopeSwaggerSerializers.java b/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/SyncopeSwaggerSerializers.java
deleted file mode 100644
index 5596c2a..0000000
--- a/core/rest-cxf/src/main/java/org/apache/syncope/core/rest/cxf/SyncopeSwaggerSerializers.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.syncope.core.rest.cxf;
-
-import io.swagger.jaxrs.listing.SwaggerSerializers;
-import io.swagger.models.HttpMethod;
-import io.swagger.models.Operation;
-import io.swagger.models.Path;
-import io.swagger.models.Swagger;
-import io.swagger.models.Tag;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.apache.commons.lang3.tuple.Pair;
-import org.apache.cxf.jaxrs.ext.MessageContext;
-import org.apache.cxf.jaxrs.model.ClassResourceInfo;
-import org.apache.cxf.jaxrs.model.OperationResourceInfo;
-import org.apache.cxf.jaxrs.model.wadl.DocumentationProvider;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
-
-public class SyncopeSwaggerSerializers extends SwaggerSerializers {
-
- private final boolean dynamicBasePath;
-
- private final boolean replaceTags;
-
- private final DocumentationProvider javadocProvider;
-
- private final List<ClassResourceInfo> cris;
-
- public SyncopeSwaggerSerializers(
- final boolean dynamicBasePath,
- final boolean replaceTags,
- final DocumentationProvider javadocProvider,
- final List<ClassResourceInfo> cris) {
-
- super();
-
- this.dynamicBasePath = dynamicBasePath;
- this.replaceTags = replaceTags;
- this.javadocProvider = javadocProvider;
- this.cris = cris;
- }
-
- @Override
- public void writeTo(
- final Swagger data,
- final Class<?> type,
- final Type genericType,
- final Annotation[] annotations,
- final MediaType mediaType,
- final MultivaluedMap<String, Object> headers,
- final OutputStream out) throws IOException {
-
- if (dynamicBasePath) {
- MessageContext ctx = JAXRSUtils.createContextValue(
- JAXRSUtils.getCurrentMessage(), null, MessageContext.class);
- data.setBasePath(StringUtils.substringBeforeLast(ctx.getHttpServletRequest().getRequestURI(), "/"));
- }
-
- if (replaceTags || javadocProvider != null) {
- Map<String, ClassResourceInfo> operations = new HashMap<>();
- Map<Pair<String, String>, OperationResourceInfo> methods = new HashMap<>();
- for (ClassResourceInfo cri : cris) {
- for (OperationResourceInfo ori : cri.getMethodDispatcher().getOperationResourceInfos()) {
- StringBuilder fullPath = new StringBuilder().
- append(cri.getURITemplate().getValue()).
- append(ori.getURITemplate().getValue());
- if (fullPath.charAt(fullPath.length() - 1) == '/') {
- fullPath.setLength(fullPath.length() - 1);
- }
- // Adapt to Swagger's path expression
- if (fullPath.toString().endsWith(":.*}")) {
- fullPath.setLength(fullPath.length() - 4);
- fullPath.append('}');
- }
-
- operations.put(fullPath.toString(), cri);
- methods.put(ImmutablePair.of(ori.getHttpMethod(), fullPath.toString()), ori);
- }
- }
-
- if (replaceTags && data.getTags() != null) {
- data.getTags().clear();
- }
- for (final Map.Entry<String, Path> entry : data.getPaths().entrySet()) {
- Tag tag = null;
- if (replaceTags && operations.containsKey(entry.getKey())) {
- ClassResourceInfo cri = operations.get(entry.getKey());
-
- tag = new Tag();
- tag.setName(cri.getURITemplate().getValue());
- if (javadocProvider != null) {
- tag.setDescription(javadocProvider.getClassDoc(cri));
- }
-
- data.addTag(tag);
- }
-
- for (Map.Entry<HttpMethod, Operation> subentry : entry.getValue().getOperationMap().entrySet()) {
- if (replaceTags && tag != null) {
- subentry.getValue().setTags(Collections.singletonList(tag.getName()));
- }
-
- Pair<String, String> key = ImmutablePair.of(subentry.getKey().name(), entry.getKey());
- if (methods.containsKey(key) && javadocProvider != null) {
- OperationResourceInfo ori = methods.get(key);
-
- subentry.getValue().setSummary(javadocProvider.getMethodDoc(ori));
- for (int i = 0; i < subentry.getValue().getParameters().size(); i++) {
- subentry.getValue().getParameters().get(i).
- setDescription(javadocProvider.getMethodParameterDoc(ori, i));
- }
-
- if (subentry.getValue().getResponses() != null
- && !subentry.getValue().getResponses().isEmpty()) {
-
- subentry.getValue().getResponses().entrySet().iterator().next().getValue().
- setDescription(javadocProvider.getMethodResponseDoc(ori));
- }
- }
- }
- }
- }
-
- super.writeTo(data, type, genericType, annotations, mediaType, headers, out);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/dd4dd571/core/rest-cxf/src/main/resources/restCXFContext.xml
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/resources/restCXFContext.xml b/core/rest-cxf/src/main/resources/restCXFContext.xml
index b12c9d4..da615a1 100644
--- a/core/rest-cxf/src/main/resources/restCXFContext.xml
+++ b/core/rest-cxf/src/main/resources/restCXFContext.xml
@@ -92,7 +92,7 @@ under the License.
<property name="javaDocPath" value="/WEB-INF/lib/syncope-common-rest-api-${syncope.version}-javadoc.jar"/>
</bean>
- <bean id="swagger2Feature" class="org.apache.syncope.core.rest.cxf.SyncopeSwagger2Feature">
+ <bean id="swagger2Feature" class="org.apache.cxf.jaxrs.swagger.Swagger2Feature">
<property name="title" value="Apache Syncope"/>
<property name="version" value="${syncope.version}"/>
<property name="description" value="Apache Syncope ${syncope.version}"/>
[2/2] syncope git commit: [SYNCOPE-705] Put CXF's GZIPInInterceptor
and GZIPOutInterceptor on both client and core
Posted by il...@apache.org.
[SYNCOPE-705] Put CXF's GZIPInInterceptor and GZIPOutInterceptor on both client and core
Project: http://git-wip-us.apache.org/repos/asf/syncope/repo
Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/a1f85be2
Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/a1f85be2
Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/a1f85be2
Branch: refs/heads/master
Commit: a1f85be2eddf90524cec0a9eeb51341fae00f1f4
Parents: dd4dd57
Author: Francesco Chicchiriccò <il...@apache.org>
Authored: Fri Oct 9 16:58:20 2015 +0200
Committer: Francesco Chicchiriccò <il...@apache.org>
Committed: Fri Oct 9 16:58:20 2015 +0200
----------------------------------------------------------------------
.../client/console/SyncopeConsoleSession.java | 4 +--
.../client/lib/RestClientFactoryBean.java | 34 ++++++++++++++++----
.../syncope/client/lib/SyncopeClient.java | 12 +++----
.../client/lib/SyncopeClientFactoryBean.java | 20 +++++++++++-
.../src/main/resources/restCXFContext.xml | 8 +++++
5 files changed, 62 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/syncope/blob/a1f85be2/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleSession.java
----------------------------------------------------------------------
diff --git a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleSession.java b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleSession.java
index 8d71645..93aa39a 100644
--- a/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleSession.java
+++ b/client/console/src/main/java/org/apache/syncope/client/console/SyncopeConsoleSession.java
@@ -100,7 +100,7 @@ public class SyncopeConsoleSession extends AuthenticatedWebSession {
version = ctx.getBean("version", String.class);
- SyncopeClient anonymousClient = clientFactory.create(anonymousUser, anonymousKey);
+ SyncopeClient anonymousClient = clientFactory.setUseCompression(true).create(anonymousUser, anonymousKey);
syncopeTO = anonymousClient.getService(SyncopeService.class).info();
domains = new ArrayList<>();
domains.add(SyncopeConstants.MASTER_DOMAIN);
@@ -139,7 +139,7 @@ public class SyncopeConsoleSession extends AuthenticatedWebSession {
boolean authenticated = false;
try {
- client = clientFactory.setDomain(getDomain()).create(username, password);
+ client = clientFactory.setDomain(getDomain()).setUseCompression(true).create(username, password);
Pair<Map<String, Set<String>>, UserTO> self = client.self();
auth = self.getKey();
http://git-wip-us.apache.org/repos/asf/syncope/blob/a1f85be2/client/lib/src/main/java/org/apache/syncope/client/lib/RestClientFactoryBean.java
----------------------------------------------------------------------
diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/RestClientFactoryBean.java b/client/lib/src/main/java/org/apache/syncope/client/lib/RestClientFactoryBean.java
index 754a745..c126deb 100644
--- a/client/lib/src/main/java/org/apache/syncope/client/lib/RestClientFactoryBean.java
+++ b/client/lib/src/main/java/org/apache/syncope/client/lib/RestClientFactoryBean.java
@@ -20,11 +20,16 @@ package org.apache.syncope.client.lib;
import javax.ws.rs.core.MediaType;
import org.apache.commons.lang3.StringUtils;
+import org.apache.cxf.jaxrs.client.Client;
+import org.apache.cxf.jaxrs.client.ClientConfiguration;
import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.transport.common.gzip.GZIPInInterceptor;
+import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor;
+import org.apache.cxf.transport.http.URLConnectionHTTPConduit;
/**
- * Provides shortcuts for creating JAX-RS service instances via CXF's <tt>JAXRSClientFactoryBean</tt>.
+ * Provides shortcuts for creating JAX-RS service instances via CXF's {@link JAXRSClientFactoryBean}.
*/
public class RestClientFactoryBean extends JAXRSClientFactoryBean {
@@ -39,7 +44,7 @@ public class RestClientFactoryBean extends JAXRSClientFactoryBean {
* @return anonymous service instance of the given reference class
*/
public <T> T createServiceInstance(final Class<T> serviceClass, final MediaType mediaType) {
- return createServiceInstance(serviceClass, mediaType, null, null);
+ return createServiceInstance(serviceClass, mediaType, null, null, false);
}
/**
@@ -50,10 +55,15 @@ public class RestClientFactoryBean extends JAXRSClientFactoryBean {
* @param mediaType XML or JSON are supported
* @param username username for REST authentication
* @param password password for REST authentication
+ * @param useCompression whether transparent gzip <tt>Content-Encoding</tt> handling is to be enabled
* @return anonymous service instance of the given reference class
*/
public <T> T createServiceInstance(
- final Class<T> serviceClass, final MediaType mediaType, final String username, final String password) {
+ final Class<T> serviceClass,
+ final MediaType mediaType,
+ final String username,
+ final String password,
+ final boolean useCompression) {
if (StringUtils.isNotBlank(username)) {
setUsername(username);
@@ -61,11 +71,21 @@ public class RestClientFactoryBean extends JAXRSClientFactoryBean {
if (StringUtils.isNotBlank(password)) {
setPassword(password);
}
+
setServiceClass(serviceClass);
- final T serviceInstance = create(serviceClass);
- WebClient.client(serviceInstance).type(mediaType).accept(mediaType);
- WebClient.getConfig(WebClient.client(serviceInstance)).
- getRequestContext().put(HEADER_SPLIT_PROPERTY, true);
+ T serviceInstance = create(serviceClass);
+
+ Client client = WebClient.client(serviceInstance);
+ client.type(mediaType).accept(mediaType);
+
+ ClientConfiguration config = WebClient.getConfig(client);
+ config.getRequestContext().put(HEADER_SPLIT_PROPERTY, true);
+ config.getRequestContext().put(URLConnectionHTTPConduit.HTTPURL_CONNECTION_METHOD_REFLECTION, true);
+ if (useCompression) {
+ config.getInInterceptors().add(new GZIPInInterceptor());
+ config.getOutInterceptors().add(new GZIPOutInterceptor());
+ }
+
return serviceInstance;
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/a1f85be2/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java
----------------------------------------------------------------------
diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java b/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java
index 9717d53..ca9f1c3 100644
--- a/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java
+++ b/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClient.java
@@ -30,7 +30,6 @@ import javax.ws.rs.core.Response;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.transport.http.URLConnectionHTTPConduit;
import org.apache.syncope.client.lib.builders.AnyQueryBuilder;
import org.apache.syncope.client.lib.builders.AnyListQueryBuilder;
import org.apache.syncope.client.lib.builders.AnySearchQueryBuilder;
@@ -61,17 +60,21 @@ public class SyncopeClient {
private final String password;
+ private final boolean useCompression;
+
public SyncopeClient(
final MediaType mediaType,
final RestClientFactoryBean restClientFactory,
final RestClientExceptionMapper exceptionMapper,
- final String username, final String password) {
+ final String username, final String password,
+ final boolean useCompression) {
this.mediaType = mediaType;
this.restClientFactory = restClientFactory;
this.exceptionMapper = exceptionMapper;
this.username = username;
this.password = password;
+ this.useCompression = useCompression;
}
/**
@@ -169,10 +172,7 @@ public class SyncopeClient {
*/
public <T> T getService(final Class<T> serviceClass) {
synchronized (restClientFactory) {
- T service = restClientFactory.createServiceInstance(serviceClass, mediaType, username, password);
- WebClient.getConfig(WebClient.client(service)).getRequestContext().
- put(URLConnectionHTTPConduit.HTTPURL_CONNECTION_METHOD_REFLECTION, true);
- return service;
+ return restClientFactory.createServiceInstance(serviceClass, mediaType, username, password, useCompression);
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/a1f85be2/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClientFactoryBean.java
----------------------------------------------------------------------
diff --git a/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClientFactoryBean.java b/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClientFactoryBean.java
index 968260f..01a36ec 100644
--- a/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClientFactoryBean.java
+++ b/client/lib/src/main/java/org/apache/syncope/client/lib/SyncopeClientFactoryBean.java
@@ -74,6 +74,8 @@ public class SyncopeClientFactoryBean {
private String domain;
+ private boolean useCompression;
+
private RestClientFactoryBean restClientFactoryBean;
protected JacksonJaxbJsonProvider defaultJsonProvider() {
@@ -197,6 +199,21 @@ public class SyncopeClientFactoryBean {
return this;
}
+ /**
+ * Sets the given service instance for transparent gzip <tt>Content-Encoding</tt> handling.
+ *
+ * @param useCompression whether transparent gzip <tt>Content-Encoding</tt> handling is to be enabled
+ * @return the current instance
+ */
+ public SyncopeClientFactoryBean setUseCompression(final boolean useCompression) {
+ this.useCompression = useCompression;
+ return this;
+ }
+
+ public boolean isUseCompression() {
+ return useCompression;
+ }
+
public RestClientFactoryBean getRestClientFactoryBean() {
return restClientFactoryBean == null
? defaultRestClientFactoryBean()
@@ -218,6 +235,7 @@ public class SyncopeClientFactoryBean {
getRestClientFactoryBean(),
getExceptionMapper(),
username,
- password);
+ password,
+ useCompression);
}
}
http://git-wip-us.apache.org/repos/asf/syncope/blob/a1f85be2/core/rest-cxf/src/main/resources/restCXFContext.xml
----------------------------------------------------------------------
diff --git a/core/rest-cxf/src/main/resources/restCXFContext.xml b/core/rest-cxf/src/main/resources/restCXFContext.xml
index da615a1..cdfea0d 100644
--- a/core/rest-cxf/src/main/resources/restCXFContext.xml
+++ b/core/rest-cxf/src/main/resources/restCXFContext.xml
@@ -76,6 +76,12 @@ under the License.
<property name="provider" ref="validationProvider"/>
</bean>
+ <bean id="gzipInInterceptor" class="org.apache.cxf.transport.common.gzip.GZIPInInterceptor"/>
+ <bean id="gzipOutInterceptor" class="org.apache.cxf.transport.common.gzip.GZIPOutInterceptor">
+ <property name="threshold" value="0"/>
+ <property name="force" value="true"/>
+ </bean>
+
<bean id="searchContextProvider" class="org.apache.cxf.jaxrs.ext.search.SearchContextProvider"/>
<bean id="addDomainFilter" class="org.apache.syncope.core.rest.cxf.AddDomainFilter"/>
@@ -114,9 +120,11 @@ under the License.
<entry key="convert.wadl.resources.to.dom" value="false"/>
</jaxrs:properties>
<jaxrs:inInterceptors>
+ <ref bean="gzipInInterceptor"/>
<ref bean="validationInInterceptor"/>
</jaxrs:inInterceptors>
<jaxrs:outInterceptors>
+ <ref bean="gzipOutInterceptor"/>
<ref bean="validationOutInterceptor"/>
</jaxrs:outInterceptors>
<jaxrs:providers>