This commit is contained in:
Lucio Lelii 2018-12-18 14:08:40 +00:00
parent 94b95f1422
commit 0c898b051f
5 changed files with 28 additions and 25 deletions

View File

@ -71,12 +71,7 @@
<artifactId>jersey-media-multipart</artifactId>
<version>2.13</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-gcube-calls</artifactId>

View File

@ -6,11 +6,13 @@ public class StreamDescriptor {
private InputStream stream;
private String fileName;
private String contentType;
public StreamDescriptor(InputStream stream, String fileName) {
public StreamDescriptor(InputStream stream, String fileName, String contentType) {
super();
this.stream = stream;
this.fileName = fileName;
this.contentType= contentType;
}
public InputStream getStream() {
@ -20,5 +22,9 @@ public class StreamDescriptor {
public String getFileName() {
return fileName;
}
public String getContentType() {
return contentType;
}
}

View File

@ -36,7 +36,9 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature;
public class DefaultItemManager implements ItemManagerClient {
private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
private static final String CONTENT_DISPOSITION= "Content-Disposition";
private static final String CONTENT_TYPE= "Content-Type";
public DefaultItemManager(ProxyDelegate<GXWebTargetAdapterRequest> config){
this.delegate = config;
@ -62,11 +64,9 @@ public class DefaultItemManager implements ItemManagerClient {
Response resp = response.getSource();
InputStream stream = resp.readEntity(InputStream.class);
String disposition = resp.getHeaderString("Content-Disposition");
String fileName = disposition.replaceFirst("attachment; filename = ([^/s]+)?", "$1");
return new StreamDescriptor(stream, fileName);
return createStreamDescriptor(resp);
}
};
try {
StreamDescriptor result = delegate.make(call);
@ -230,10 +230,7 @@ public class DefaultItemManager implements ItemManagerClient {
Response resp = response.getSource();
InputStream stream = resp.readEntity(InputStream.class);
String disposition = resp.getHeaderString("Content-Disposition");
String fileName = disposition.replaceFirst("attachment; filename = ([^/s]+)?", "$1");
return new StreamDescriptor(stream, fileName);
return createStreamDescriptor(resp);
}
};
try {
@ -262,10 +259,7 @@ public class DefaultItemManager implements ItemManagerClient {
Response resp = response.getSource();
InputStream stream = resp.readEntity(InputStream.class);
String disposition = resp.getHeaderString("Content-Disposition");
String fileName = disposition.replaceFirst("attachment; filename = ([^/s]+)?", "$1");
return new StreamDescriptor(stream, fileName);
return createStreamDescriptor(resp);
}
};
try {
@ -829,4 +823,12 @@ public class DefaultItemManager implements ItemManagerClient {
}
}
private StreamDescriptor createStreamDescriptor(Response resp) {
InputStream stream = resp.readEntity(InputStream.class);
String disposition = resp.getHeaderString(CONTENT_DISPOSITION);
String fileName = disposition.replaceFirst("attachment; filename = ([^/s]+)?", "$1");
String contentType = resp.getHeaderString(CONTENT_TYPE);
return new StreamDescriptor(stream, fileName, contentType);
}
}

View File

@ -29,10 +29,10 @@ public class Items {
@BeforeClass
public static void setUp(){
SecurityTokenProvider.instance.set("18fed2d9-030b-4c77-93af-af2015d945f7-843339462");
SecurityTokenProvider.instance.set("b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548");
//SecurityTokenProvider.instance.set("a5b623b6-6577-4271-aba6-7ada687d29cf-98187548");
ScopeProvider.instance.set("/d4science.research-infrastructures.eu");
ScopeProvider.instance.set("/gcube");
}

View File

@ -51,8 +51,8 @@ public class TestCall {
//SecurityTokenProvider.instance.set("0e2c7963-8d3e-4ea6-a56d-ffda530dd0fa-98187548");
//token costantino 9ca79556-54b0-4bbf-ab0f-151ae326f4cf-98187548
SecurityTokenProvider.instance.set("04269c7d-dab7-498a-841d-8d38ae2d482b-98187548");
ScopeProvider.instance.set("/gcube/preprod");
SecurityTokenProvider.instance.set("e03bfbc4-a144-48e3-aa37-b07bafdf8822-98187548");
ScopeProvider.instance.set("/gcube/devsec");
}
@Test
@ -64,7 +64,7 @@ public class TestCall {
}catch (Exception e) {
e.printStackTrace();
}
/*System.out.println("ws id is "+ws.getId());
/*
List<? extends Item> items = itemclient.getChildren(ws.getId(),10, 5, "hl:accounting", "jcr:content");
List<? extends Item> Vreitems = client.getVreFolders("hl:accounting");
List<? extends Item> VreitemsPaged = client.getVreFolders(5,5, "hl:accounting");