|
|
|
@ -4,9 +4,10 @@ import java.io.BufferedInputStream;
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
import java.io.OutputStream;
|
|
|
|
|
import java.net.URI;
|
|
|
|
|
import java.net.URL;
|
|
|
|
|
import java.nio.file.Files;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
@ -16,11 +17,14 @@ import java.util.Properties;
|
|
|
|
|
import java.util.regex.Matcher;
|
|
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
|
|
|
|
|
import javax.ws.rs.WebApplicationException;
|
|
|
|
|
import javax.ws.rs.client.Client;
|
|
|
|
|
import javax.ws.rs.client.ClientBuilder;
|
|
|
|
|
import javax.ws.rs.client.Entity;
|
|
|
|
|
import javax.ws.rs.client.WebTarget;
|
|
|
|
|
import javax.ws.rs.core.MediaType;
|
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
import javax.ws.rs.core.StreamingOutput;
|
|
|
|
|
|
|
|
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
@ -42,13 +46,9 @@ import org.gcube.common.storagehub.model.expressions.logical.ISDescendant;
|
|
|
|
|
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
|
|
|
|
import org.gcube.common.storagehub.model.items.GCubeItem;
|
|
|
|
|
import org.gcube.common.storagehub.model.items.Item;
|
|
|
|
|
import org.gcube.common.storagehub.model.messages.Message;
|
|
|
|
|
import org.gcube.common.storagehub.model.query.Queries;
|
|
|
|
|
import org.gcube.common.storagehub.model.query.Query;
|
|
|
|
|
import org.glassfish.jersey.client.ClientProperties;
|
|
|
|
|
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
|
|
|
|
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
|
|
|
|
import org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException;
|
|
|
|
|
import org.junit.BeforeClass;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
@ -80,19 +80,19 @@ public class TestCall {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void sendMessagesWithAttachment() throws Exception {
|
|
|
|
|
MessageManagerClient client = AbstractPlugin.messages().build();
|
|
|
|
|
client.sendMessage(Arrays.asList("massimiliano.assante"), "subject encodato ? è ", "è econdato ??", Arrays.asList("4827dd33-6eea-4bba-b78b-b98e2fd2ddfa"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void setUnread() throws Exception {
|
|
|
|
|
MessageManagerClient client = AbstractPlugin.messages().build();
|
|
|
|
|
client.setRead("f3b7ce40-28df-40b3-ad17-f0b9bd658016", false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void addUserToGroup() throws StorageHubException {
|
|
|
|
|
GroupManagerClient client = AbstractPlugin.groups().build();
|
|
|
|
|
client.addUserToGroup("andrea.rossi", "gcube-devsec-devVRE");
|
|
|
|
@ -128,8 +128,8 @@ public class TestCall {
|
|
|
|
|
WorkspaceManagerClient client = AbstractPlugin.workspace().build();
|
|
|
|
|
System.out.println(client.restoreFromTrash("4fc0a9df-9a51-42ef-98f2-06c21bd0669b", "f3d336cc-cd00-48ba-8339-2bffcbef825e"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void unshareFolder() throws Exception{
|
|
|
|
|
ItemManagerClient itemclient = AbstractPlugin.item().build();
|
|
|
|
@ -183,6 +183,34 @@ public class TestCall {
|
|
|
|
|
client.createGcubeItem(ws.getId(), item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void uploadDirectJersey() throws Exception {
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
|
Client client = ClientBuilder.newClient();
|
|
|
|
|
client.property(ClientProperties.REQUEST_ENTITY_PROCESSING, "CHUNKED").property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024).property(ClientProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, -1);
|
|
|
|
|
WebTarget target = client.target("https://workspace-repository.dev.d4science.org/storagehub/workspace/items/cc7513e7-fd93-4bfb-8e1b-bc9b32938c77/create/"
|
|
|
|
|
+ "FILE?gcube-token=b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548");
|
|
|
|
|
|
|
|
|
|
target = target.queryParam("name", "test2Gb.zip").queryParam("description", "description");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File inFile = new File("C:\\Users\\tilli\\Downloads\\testup.zip");
|
|
|
|
|
InputStream fileInStream = new FileInputStream(inFile);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//String contentDisposition = "attachment; filename=\"" + inFile.getName() + "\"";
|
|
|
|
|
System.out.println("sending: " + inFile.length() + " bytes...");
|
|
|
|
|
System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
|
|
|
|
|
Response response = target
|
|
|
|
|
.request(MediaType.APPLICATION_OCTET_STREAM_TYPE)
|
|
|
|
|
//.header("Content-Disposition", contentDisposition)
|
|
|
|
|
//.header("Content-Length", inFile.length())
|
|
|
|
|
.post(Entity.entity(fileInStream, MediaType.APPLICATION_OCTET_STREAM_TYPE));
|
|
|
|
|
System.out.println("Response status: " + response.getStatus()+ " in "+(System.currentTimeMillis()-start));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void upload() throws Exception{
|
|
|
|
|
final ItemManagerClient client = AbstractPlugin.item().build();
|
|
|
|
@ -191,7 +219,7 @@ public class TestCall {
|
|
|
|
|
+ "mioSBvOehbZlu54_jvscz8Zu3LXgqhr8RfJemd83QIh47z6TyMn3mD0OjpcG5g0qf9WUZCeW1J4btEqNObkaWv"
|
|
|
|
|
+ "pMhabvswweyFn1Jg4m5GpwCoKayvgsYYwjbjsGsQW5Hileiw==");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
client.uploadFile(remote, "bc1c9525-43f7-4565-b5ea-0a0f9d7853a0", "5gb.zip", "description");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -259,7 +287,7 @@ public class TestCall {
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void getRecents() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
|
|
|
|
|
List<? extends Item> items = wsclient.getRecentModifiedFilePerVre();
|
|
|
|
|
|
|
|
|
|