From eb500fa88c9e8973b04f3b085993158c585201bb Mon Sep 17 00:00:00 2001 From: Lucio Lelii Date: Tue, 15 Jan 2019 16:00:37 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/common/common-jaxrs-client/1.0@176575 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 2 +- .settings/org.eclipse.jdt.core.prefs | 6 ++--- pom.xml | 2 +- .../common/calls/jaxrs/TargetFactory.java | 23 +++++++------------ 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/.classpath b/.classpath index 953de0b..ace8266 100644 --- a/.classpath +++ b/.classpath @@ -27,7 +27,7 @@ - + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index ec4300d..714351a 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,5 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/pom.xml b/pom.xml index e2f5c75..ae86876 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.gcube.common common-jaxrs-client - 1.0.2-SNAPSHOT + 1.0.3-SNAPSHOT gcube-jaxrs-client diff --git a/src/main/java/org/gcube/common/calls/jaxrs/TargetFactory.java b/src/main/java/org/gcube/common/calls/jaxrs/TargetFactory.java index ead81d8..d969813 100644 --- a/src/main/java/org/gcube/common/calls/jaxrs/TargetFactory.java +++ b/src/main/java/org/gcube/common/calls/jaxrs/TargetFactory.java @@ -29,23 +29,14 @@ public class TargetFactory implements TargetFactoryDSL.AtClause{ public GXWebTargetAdapterRequest getAsGxRest(String address) { try{ - - - /* - String resourceAddress = address.substring(0, address.indexOf("/service")); - - WebTarget resourcetarget = client.target(resourceAddress).path("/resource/"); - - int status = resourcetarget.request().get().getStatus(); - - if (status!=200) - throw new Exception();*/ - //WebTarget webTarget = client.target(address).path(target.path()); + GXWebTargetAdapterRequest webTarget = null; + if (address.startsWith("https")) { + log.info("using secure call"); + webTarget = GXWebTargetAdapterRequest.newHTTPSRequest(address).path(target.path()); + } else webTarget = GXWebTargetAdapterRequest.newRequest(address).path(target.path()); - - - GXWebTargetAdapterRequest webTarget = GXWebTargetAdapterRequest.newRequest(address).path(target.path()); + webTarget.configProperty(ClientProperties.REQUEST_ENTITY_PROCESSING, "CHUNKED"); @@ -64,6 +55,7 @@ public class TargetFactory implements TargetFactoryDSL.AtClause{ try{ + Client client = ClientBuilder.newClient() .property(ClientProperties.FOLLOW_REDIRECTS, Boolean.FALSE) .property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024*1024).property(ClientProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, -1) @@ -88,5 +80,6 @@ public class TargetFactory implements TargetFactoryDSL.AtClause{ return at(new JaxRSEndpointReference(endpoint).address); } + }