upload file by url added and bug on set Message property solved
This commit is contained in:
parent
6f96bab4ed
commit
433e075326
2
pom.xml
2
pom.xml
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>storagehub-client-library</artifactId>
|
<artifactId>storagehub-client-library</artifactId>
|
||||||
<version>1.3.0</version>
|
<version>1.3.0-SNAPSHOT</version>
|
||||||
<name>storagehub-client-library</name>
|
<name>storagehub-client-library</name>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.common.storagehub.client.proxies;
|
package org.gcube.common.storagehub.client.proxies;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -618,7 +619,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
public String uploadFile(InputStream stream, String parentId, String fileName, String description) throws StorageHubException {
|
public String uploadFile(InputStream stream, String parentId, String fileName, String description) throws StorageHubException {
|
||||||
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
|
@ -661,6 +662,93 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
throw new RuntimeException(e1);
|
throw new RuntimeException(e1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String uploadFile(InputStream stream, String parentId, String fileName, String description) throws StorageHubException {
|
||||||
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
|
@Override
|
||||||
|
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
|
Objects.requireNonNull(stream, "stream cannot be null");
|
||||||
|
Objects.requireNonNull(parentId, "parentId cannot be null");
|
||||||
|
Objects.requireNonNull(fileName, "parentId cannot be null");
|
||||||
|
Objects.requireNonNull(description, "parentId cannot be null");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GXWebTargetAdapterRequest myManager = manager.register(MultiPartFeature.class).path(parentId)
|
||||||
|
.path("create").path("FILE");
|
||||||
|
|
||||||
|
GXInboundResponse response =null;
|
||||||
|
Entity<InputStream> entity = Entity.entity(stream, MediaType.APPLICATION_OCTET_STREAM_TYPE);
|
||||||
|
|
||||||
|
Map<String, Object[]> params = new HashMap<>();
|
||||||
|
|
||||||
|
params.put("name", new Object[] {fileName});
|
||||||
|
params.put("description", new Object[] {description});
|
||||||
|
|
||||||
|
response = myManager.post(entity);
|
||||||
|
|
||||||
|
if (response.isErrorResponse()) {
|
||||||
|
if (response.hasException()) {
|
||||||
|
throw response.getException();
|
||||||
|
}else
|
||||||
|
throw new BackendGenericError("HTTP error code is "+response.getHTTPCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.getSource().readEntity(String.class);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return delegate.make(call);
|
||||||
|
}catch(StorageHubException e) {
|
||||||
|
throw e;
|
||||||
|
}catch(Exception e1) {
|
||||||
|
throw new RuntimeException(e1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String uploadFile(URI uri, String parentId, String fileName, String description) throws StorageHubException {
|
||||||
|
Call<GXWebTargetAdapterRequest, String> call = new Call<GXWebTargetAdapterRequest, String>() {
|
||||||
|
@Override
|
||||||
|
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
|
Objects.requireNonNull(uri, "uri cannot be null");
|
||||||
|
Objects.requireNonNull(parentId, "parentId cannot be null");
|
||||||
|
Objects.requireNonNull(fileName, "parentId cannot be null");
|
||||||
|
Objects.requireNonNull(description, "parentId cannot be null");
|
||||||
|
|
||||||
|
GXWebTargetAdapterRequest myManager = manager.register(MultiPartFeature.class).path(parentId)
|
||||||
|
.path("create").path("FILE");
|
||||||
|
|
||||||
|
MultivaluedMap<String, String> formData = new MultivaluedHashMap<String, String>();
|
||||||
|
formData.add("url", uri.toString());
|
||||||
|
formData.add("name", fileName);
|
||||||
|
formData.add("description", description);
|
||||||
|
|
||||||
|
|
||||||
|
GXInboundResponse response = myManager.post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED));
|
||||||
|
|
||||||
|
|
||||||
|
if (response.isErrorResponse()) {
|
||||||
|
if (response.hasException()) {
|
||||||
|
throw response.getException();
|
||||||
|
}else
|
||||||
|
throw new BackendGenericError("HTTP error code is "+response.getHTTPCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.getSource().readEntity(String.class);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
return delegate.make(call);
|
||||||
|
}catch(StorageHubException e) {
|
||||||
|
throw e;
|
||||||
|
}catch(Exception e1) {
|
||||||
|
throw new RuntimeException(e1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String uploadArchive(InputStream stream, String parentId, String extractionFolderName) throws StorageHubException {
|
public String uploadArchive(InputStream stream, String parentId, String extractionFolderName) throws StorageHubException {
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class DefaultMessageManager implements MessageManagerClient {
|
||||||
public Void call(GXWebTargetAdapterRequest manager) throws Exception {
|
public Void call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path(prop);
|
GXWebTargetAdapterRequest myManager = manager.path(id).path(prop);
|
||||||
|
|
||||||
GXInboundResponse response = myManager.put(Entity.json(Boolean.TRUE));
|
GXInboundResponse response = myManager.put(Entity.json(bool));
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
throw response.getException();
|
throw response.getException();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.common.storagehub.client.proxies;
|
package org.gcube.common.storagehub.client.proxies;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -42,6 +43,8 @@ public interface ItemManagerClient {
|
||||||
|
|
||||||
String uploadFile(InputStream stream, String parentId, String fileName, String description) throws StorageHubException;
|
String uploadFile(InputStream stream, String parentId, String fileName, String description) throws StorageHubException;
|
||||||
|
|
||||||
|
String uploadFile(URI uri, String parentId, String fileName, String description) throws StorageHubException;
|
||||||
|
|
||||||
String createFolder(String parentId, String name, String description, boolean hidden) throws StorageHubException;
|
String createFolder(String parentId, String name, String description, boolean hidden) throws StorageHubException;
|
||||||
|
|
||||||
String createURL(String parentId, String name, String description, URL url) throws StorageHubException;
|
String createURL(String parentId, String name, String description, URL url) throws StorageHubException;
|
||||||
|
|
|
@ -5,21 +5,29 @@ import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.common.storagehub.client.StreamDescriptor;
|
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.ContainerType;
|
||||||
import org.gcube.common.storagehub.client.dsl.FileContainer;
|
import org.gcube.common.storagehub.client.dsl.FileContainer;
|
||||||
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
||||||
import org.gcube.common.storagehub.client.dsl.ItemContainer;
|
import org.gcube.common.storagehub.client.dsl.ItemContainer;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.OpenResolver;
|
||||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.VREFolderManager;
|
||||||
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||||
import org.gcube.common.storagehub.client.proxies.UserManagerClient;
|
import org.gcube.common.storagehub.client.proxies.UserManagerClient;
|
||||||
import org.gcube.common.storagehub.model.Metadata;
|
import org.gcube.common.storagehub.model.Metadata;
|
||||||
|
@ -36,7 +44,7 @@ public class Items {
|
||||||
|
|
||||||
private static final String propFile = "C:\\Users\\tilli\\Documents\\eclipse\\tokens.properties";
|
private static final String propFile = "C:\\Users\\tilli\\Documents\\eclipse\\tokens.properties";
|
||||||
|
|
||||||
private static final String tokens = "dev-root";
|
private static final String tokens = "prod-root";
|
||||||
//private static final String tokens = "prod-root";
|
//private static final String tokens = "prod-root";
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
|
@ -57,10 +65,12 @@ public class Items {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addUserToVRe() throws StorageHubException {
|
public void addUserToVRe() throws StorageHubException {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
|
|
||||||
String vresFile = "C:\\Users\\tilli\\Downloads\\vresToAddGCat.txt";
|
String vresFile = "C:\\Users\\tilli\\Downloads\\vresToAddGCat.txt";
|
||||||
|
|
||||||
try(InputStream is = new FileInputStream(new File(vresFile))){
|
try(InputStream is = new FileInputStream(new File(vresFile))){
|
||||||
|
@ -85,6 +95,7 @@ public class Items {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void search() {
|
public void search() {
|
||||||
try {
|
try {
|
||||||
|
@ -108,9 +119,19 @@ public class Items {
|
||||||
public void changeAcls() throws Exception{
|
public void changeAcls() throws Exception{
|
||||||
|
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
//System.out.println(shc.open("65e502ff-92ef-46cc-afbd-3e91f4b680be").asFolder().canWrite());
|
||||||
|
OpenResolver openResolver= shc.open("1322e7b2-bad6-4d64-a063-db0d05b16a67");
|
||||||
|
if(openResolver.resolve().getType()==ContainerType.FILE) {
|
||||||
|
String publicLink = openResolver.asFile().getPublicLink().toString();
|
||||||
|
String itemName = openResolver.asFile().get().getTitle();
|
||||||
|
|
||||||
System.out.println(shc.open("65e502ff-92ef-46cc-afbd-3e91f4b680be").asFolder().canWrite());
|
builder.append(itemName + " ("+publicLink+")");
|
||||||
|
builder.append("\n");
|
||||||
|
} else {
|
||||||
|
System.out.println("\n\n\nNON e' un FILE cosè? = " + openResolver.resolve().getType());
|
||||||
|
}
|
||||||
|
System.out.println(builder.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,40 +159,25 @@ public class Items {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void renameFile() throws Exception{
|
public void uploadFile() throws Exception{
|
||||||
|
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
|
|
||||||
FolderContainer myRoot = shc.getWSRoot();
|
FolderContainer myRoot = shc.getWSRoot();
|
||||||
|
|
||||||
myRoot.findByName("");
|
|
||||||
|
|
||||||
|
try(InputStream is = new FileInputStream(new File("C:\\\\Users\\\\tilli\\\\Downloads\\\\Blue-Cloud_order_2021_10_15_1.zip"))){
|
||||||
FolderContainer children = myRoot.newFolder("build", "build folder");
|
myRoot.uploadFile(is, "testUpload.zip", "file");
|
||||||
|
|
||||||
|
|
||||||
FileContainer file = null;
|
|
||||||
|
|
||||||
|
|
||||||
try(InputStream is = new FileInputStream(new File("/home/lucio/Downloads/mg.jpg"))){
|
|
||||||
file = myRoot.uploadFile(is, "mg.jpg", "file");
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FileContainer copiedFile = file.copy(children, "mg.jpg");
|
|
||||||
|
|
||||||
try(InputStream is = new FileInputStream(new File("/home/lucio/Downloads/bck.jpg"))){
|
|
||||||
file = myRoot.uploadFile(is, "mg.jpg", "file");
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
FileContainer secodncopiedFile = file.copy(children, "mg.jpg");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -216,14 +222,23 @@ public class Items {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void emptyTrash() throws Exception {
|
public void addUser() throws Exception {
|
||||||
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
shc.createUserAccount("service-account-sergencovid19");
|
||||||
|
|
||||||
|
shc.getVreFolderManager("d4science.research-infrastructures.eu-FARM-SerGen-Covid19_Ricercatore").addUser("service-account-sergencovid19");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void removeUser() throws Exception {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
shc.emptyTrash();
|
shc.deleteUserAccount("_sergencovid19");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void changeProp() throws Exception {
|
public void changeProp() throws Exception {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
@ -251,18 +266,53 @@ public class Items {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*private InputStream urlToInputStream(URL url, Map<String, String> args) {
|
||||||
|
HttpURLConnection con = null;
|
||||||
|
InputStream inputStream = null;
|
||||||
|
try {
|
||||||
|
con = (HttpURLConnection) url.openConnection();
|
||||||
|
con.setConnectTimeout(15000);
|
||||||
|
con.setReadTimeout(15000);
|
||||||
|
if (args != null) {
|
||||||
|
for (Entry<String, String> e : args.entrySet()) {
|
||||||
|
con.setRequestProperty(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
con.connect();
|
||||||
|
int responseCode = con.getResponseCode();
|
||||||
|
|
||||||
|
if (responseCode < 400 && responseCode > 299) {
|
||||||
|
String redirectUrl = con.getHeaderField("Location");
|
||||||
|
try {
|
||||||
|
URL newUrl = new URL(redirectUrl);
|
||||||
|
return urlToInputStream(newUrl, args);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
URL newUrl = new URL(url.getProtocol() + "://" + url.getHost() + redirectUrl);
|
||||||
|
return urlToInputStream(newUrl, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inputStream = con.getInputStream();
|
||||||
|
return inputStream;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void uploadArchive() throws Exception {
|
public void uploadArchive() throws Exception {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
String afi = null;
|
URL remote = new URI("https://data.bluecloud.cineca.it/api/download/gAAAAABhaSJN8TUA71la3mKMOL9D"
|
||||||
|
+ "mioSBvOehbZlu54_jvscz8Zu3LXgqhr8RfJemd83QIh47z6TyMn3mD0OjpcG5g0qf9WUZCeW1J4btEqNObkaWv"
|
||||||
|
+ "pMhabvswweyFn1Jg4m5GpwCoKayvgsYYwjbjsGsQW5Hileiw==").toURL();
|
||||||
|
|
||||||
|
|
||||||
|
try(InputStream is = remote.openStream() ){
|
||||||
|
shc.getWSRoot().uploadArchive(is, "testUploadArchive");
|
||||||
|
|
||||||
try(InputStream is = new FileInputStream(new File("/tmp/down724121986692880606my new folder.zip"))){
|
|
||||||
shc.getWSRoot().uploadArchive(is, "testUpload2");
|
|
||||||
|
|
||||||
System.out.println(afi);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -428,6 +478,12 @@ public class Items {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void removeGroup() throws Exception{
|
||||||
|
StorageHubClient sh = new StorageHubClient();
|
||||||
|
VREFolderManager vreMan = sh.getVreFolderManager("d4science.research-infrastructures.eu-OpenAIRE-OpenAIRE-Connect_EAB");
|
||||||
|
vreMan.removeVRE();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -41,11 +42,13 @@ import org.gcube.common.storagehub.model.expressions.logical.ISDescendant;
|
||||||
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
||||||
import org.gcube.common.storagehub.model.items.GCubeItem;
|
import org.gcube.common.storagehub.model.items.GCubeItem;
|
||||||
import org.gcube.common.storagehub.model.items.Item;
|
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.Queries;
|
||||||
import org.gcube.common.storagehub.model.query.Query;
|
import org.gcube.common.storagehub.model.query.Query;
|
||||||
import org.glassfish.jersey.client.ClientProperties;
|
import org.glassfish.jersey.client.ClientProperties;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
||||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||||
|
import org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -79,26 +82,16 @@ public class TestCall {
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void sendMessages() throws StorageHubException {
|
public void sendMessagesWithAttachment() throws Exception {
|
||||||
MessageManagerClient client = AbstractPlugin.messages().build();
|
MessageManagerClient client = AbstractPlugin.messages().build();
|
||||||
for (int i=1500; i<3000; i++ ) {
|
client.sendMessage(Arrays.asList("massimiliano.assante"), "subject encodato ? è ", "è econdato ??", Arrays.asList("4827dd33-6eea-4bba-b78b-b98e2fd2ddfa"));
|
||||||
try {
|
|
||||||
Thread.sleep(200);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// TODO Auto-generated catch block
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
client.sendMessage(Arrays.asList("andrea.rossi"), "testMessage"+i, "body for ttrtetatrtrrttrtrtrar\ndfafsdfadsfafdsdsfafdsafaddsffdsf\nfsdafdjdjskhjghshjhdahjkasdhjjhsd"
|
|
||||||
+ "\ndfsjkfdasjklòjffafadjksò\ndfskfjklaajjfadsjkòfjòfdsajòfadòjk\ndsaffadsffbdsfajfdsbsafdsjkfdsakjlsdafjfkdsjklajlkfadsjfsasjd\n"
|
|
||||||
+ "dsfjkfdsajhdsfsdfahhflhjfdkshlkjfhjafdsjhlkjkhfjkdshjkfhsjklsdah fhadfjahlfdsjfdhjfads fdsfdhsajdfsahjfdsaljhhfahafshjsfdalhlfash\n"
|
|
||||||
+ "dfsakldfjdajfdsjòdsfaj fdsajkadskk dfsjòkdsfaj sjdfsjdja aòfs jsfadfsdò saj òa fafòadsj jsafads\n"
|
|
||||||
+ "dsfjfdhdsaljkhfdsljhdfsajkhsf fdshsajkhshjksdfhjkfdsh dsfjkh h dfshj ds\n"
|
|
||||||
+ "dfjdfahjklhjhaajkshkshjdsafhldslhkdsfaljkadsfhlfjasjkhdasfjhkhfdf ads hldfsasahfdsdfshjfdsa jjhfdsh dfhjs hsajfdhdfhfdshhjdfsjhdf\n"
|
|
||||||
+ "fdsjadsjkdfahjlkdfshkjdshjkfsdhjklsadfjkhjsaslfdhjalkdsfhjfshkfjlsldshjfsdhj\ndastest\n\n\nMessage"+i, null );
|
|
||||||
System.out.println("sending message "+i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void setUnread() throws Exception {
|
||||||
|
MessageManagerClient client = AbstractPlugin.messages().build();
|
||||||
|
client.setRead("f3b7ce40-28df-40b3-ad17-f0b9bd658016", false);
|
||||||
|
}
|
||||||
|
|
||||||
public void addUserToGroup() throws StorageHubException {
|
public void addUserToGroup() throws StorageHubException {
|
||||||
GroupManagerClient client = AbstractPlugin.groups().build();
|
GroupManagerClient client = AbstractPlugin.groups().build();
|
||||||
|
@ -136,6 +129,8 @@ public class TestCall {
|
||||||
System.out.println(client.restoreFromTrash("4fc0a9df-9a51-42ef-98f2-06c21bd0669b", "f3d336cc-cd00-48ba-8339-2bffcbef825e"));
|
System.out.println(client.restoreFromTrash("4fc0a9df-9a51-42ef-98f2-06c21bd0669b", "f3d336cc-cd00-48ba-8339-2bffcbef825e"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void unshareFolder() throws Exception{
|
public void unshareFolder() throws Exception{
|
||||||
ItemManagerClient itemclient = AbstractPlugin.item().build();
|
ItemManagerClient itemclient = AbstractPlugin.item().build();
|
||||||
itemclient.unshareFolder("86e8472a-6f66-4608-9d70-20102c9172ce", new HashSet<>(Arrays.asList("giancarlo.panichi")));
|
itemclient.unshareFolder("86e8472a-6f66-4608-9d70-20102c9172ce", new HashSet<>(Arrays.asList("giancarlo.panichi")));
|
||||||
|
@ -188,23 +183,16 @@ public class TestCall {
|
||||||
client.createGcubeItem(ws.getId(), item);
|
client.createGcubeItem(ws.getId(), item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void upload() throws Exception{
|
public void upload() throws Exception{
|
||||||
//final ItemManagerClient client = AbstractPlugin.item().at(new URI("http://workspace-repository1-d.d4science.org:8080/storagehub")).build();
|
final ItemManagerClient client = AbstractPlugin.item().build();
|
||||||
|
|
||||||
Client client = ClientBuilder.newClient();
|
URI remote = new URI("https://data.bluecloud.cineca.it/api/download/gAAAAABhaSJN8TUA71la3mKMOL9D"
|
||||||
client.register(MultiPartFeature.class).property(ClientProperties.CHUNKED_ENCODING_SIZE, 1024).property(ClientProperties.OUTBOUND_CONTENT_LENGTH_BUFFER, -1)
|
+ "mioSBvOehbZlu54_jvscz8Zu3LXgqhr8RfJemd83QIh47z6TyMn3mD0OjpcG5g0qf9WUZCeW1J4btEqNObkaWv"
|
||||||
.property(ClientProperties.REQUEST_ENTITY_PROCESSING, "CHUNKED");
|
+ "pMhabvswweyFn1Jg4m5GpwCoKayvgsYYwjbjsGsQW5Hileiw==");
|
||||||
WebTarget target = client.target("http://workspace-repository1-d.d4science.org:8080/storagehub/workspace/items/bc1c9525-43f7-4565-b5ea-0a0f9d7853a0/create/test-upload?gcube-token=595ca591-9921-423c-bfca-f8be19f05882-98187548");
|
|
||||||
|
|
||||||
FormDataMultiPart multipart = new FormDataMultiPart();
|
|
||||||
|
|
||||||
multipart.field("name", "test1Gb2.db");
|
client.uploadFile(remote, "bc1c9525-43f7-4565-b5ea-0a0f9d7853a0", "5gb.zip", "description");
|
||||||
multipart.field("description", "description");
|
|
||||||
multipart.field("file", new FileInputStream("/home/lucio/Downloads/ar_bigdata_201705.csv"), MediaType.APPLICATION_OCTET_STREAM_TYPE);
|
|
||||||
|
|
||||||
target.request().post(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA));
|
|
||||||
|
|
||||||
//client.uploadFile(new FileInputStream("/home/lucio/Downloads/test5Gb.zip"), "bc1c9525-43f7-4565-b5ea-0a0f9d7853a0", "5gb.zip", "description");
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -269,8 +257,8 @@ public class TestCall {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void getRecents() {
|
public void getRecents() {
|
||||||
ItemManagerClient itemclient = AbstractPlugin.item().build();
|
|
||||||
|
|
||||||
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
|
WorkspaceManagerClient wsclient = AbstractPlugin.workspace().build();
|
||||||
List<? extends Item> items = wsclient.getRecentModifiedFilePerVre();
|
List<? extends Item> items = wsclient.getRecentModifiedFilePerVre();
|
||||||
|
@ -278,7 +266,7 @@ public class TestCall {
|
||||||
System.out.println("items are "+items.size());
|
System.out.println("items are "+items.size());
|
||||||
|
|
||||||
for (Item item: items)
|
for (Item item: items)
|
||||||
System.out.println(item.getName()+ " "+item.getPath());
|
System.out.println(item.getName()+ " "+item.getLastModificationTime().getTimeInMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createFolder() throws Exception{
|
public void createFolder() throws Exception{
|
||||||
|
|
Loading…
Reference in New Issue