git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/Common/storagehub-client@169404 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9952e9efff
commit
5ec8908f0a
|
@ -1,5 +1,7 @@
|
||||||
package org.gcube.common.storagehub.client.dsl;
|
package org.gcube.common.storagehub.client.dsl;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||||
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
import org.gcube.common.storagehub.model.items.AbstractFileItem;
|
||||||
|
|
||||||
|
@ -17,4 +19,8 @@ public class FileContainer extends ItemContainer<AbstractFileItem> {
|
||||||
return ContainerType.FILE;
|
return ContainerType.FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public URL getPublicLink() {
|
||||||
|
return itemclient.getPublickLink(this.itemId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,8 @@ public class FolderContainer extends ItemContainer<FolderItem>{
|
||||||
return new ListResolver(itemclient, itemId);
|
return new ListResolver(itemclient, itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: change the return to file container
|
public FileContainer uploadFile(InputStream stream, String filename, String description) {
|
||||||
public String uploadFile(InputStream stream, String filename, String description) {
|
return new FileContainer(itemclient, itemclient.uploadFile(stream, this.itemId , filename, description));
|
||||||
return itemclient.uploadFile(stream, this.itemId , filename, description);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public FolderContainer newFolder(String name, String description) throws Exception {
|
public FolderContainer newFolder(String name, String description) throws Exception {
|
||||||
|
|
|
@ -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.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.ws.rs.client.Entity;
|
import javax.ws.rs.client.Entity;
|
||||||
|
@ -100,6 +101,25 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public URL getPublickLink(String id) {
|
||||||
|
Call<WebTarget, URL> call = new Call<WebTarget, URL>() {
|
||||||
|
@Override
|
||||||
|
public URL call(WebTarget manager) throws Exception {
|
||||||
|
WebTarget myManager = manager.path(id).path("publicklink");
|
||||||
|
Invocation.Builder builder = myManager.request(MediaType.APPLICATION_JSON);
|
||||||
|
URL response = builder.get(URL.class);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
URL result = delegate.make(call);
|
||||||
|
return result;
|
||||||
|
}catch(Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Item> getChildren(String id, int start, int limit, String... excludeNodes) {
|
public List<? extends Item> getChildren(String id, int start, int limit, String... excludeNodes) {
|
||||||
Call<WebTarget, ItemList> call = new Call<WebTarget, ItemList>() {
|
Call<WebTarget, ItemList> call = new Call<WebTarget, ItemList>() {
|
||||||
|
|
|
@ -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.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.common.storagehub.client.StreamDescriptor;
|
import org.gcube.common.storagehub.client.StreamDescriptor;
|
||||||
|
@ -32,5 +33,7 @@ public interface ItemManagerClient {
|
||||||
List<ACL> getACL(String id);
|
List<ACL> getACL(String id);
|
||||||
|
|
||||||
void moveToTrash(String id);
|
void moveToTrash(String id);
|
||||||
|
|
||||||
|
URL getPublickLink(String id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,25 +32,15 @@ public class Items {
|
||||||
public void uploadFile() {
|
public void uploadFile() {
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
try (InputStream is = new FileInputStream(new File("/home/lucio/Downloads/fattunite.pdf"))){
|
try (InputStream is = new FileInputStream(new File("/home/lucio/Downloads/rockandroll.jpeg"))){
|
||||||
String afi = shc.getWSRoot().uploadFile(is, "fattureTest2.pdf", "descr");
|
String afi = shc.getWSRoot().uploadFile(is, "tes-image.jpeg", "descr").get().getId();
|
||||||
|
|
||||||
System.out.println(afi);
|
System.out.println(afi);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getVreFolder() {
|
|
||||||
StorageHubClient shc = new StorageHubClient();
|
|
||||||
|
|
||||||
try (InputStream is = new FileInputStream(new File("/home/lucio/Downloads/bonifico ferrara anricipo.pdf"))){
|
|
||||||
String newId = shc.getWSRoot().uploadFile(is, "bonificopdf", "descr");
|
|
||||||
System.out.println(newId);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void downloadFile() {
|
public void downloadFile() {
|
||||||
|
|
Loading…
Reference in New Issue