update
This commit is contained in:
parent
b75672f081
commit
3dce6154d2
|
@ -3,6 +3,12 @@
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [v2.0.0-SNAPSHOT] - [2022-02-07]
|
||||||
|
|
||||||
|
### Feature
|
||||||
|
|
||||||
|
porting to model 2.0
|
||||||
|
|
||||||
## [v1.3.0] - [2021-06-18]
|
## [v1.3.0] - [2021-06-18]
|
||||||
|
|
||||||
### Feature
|
### Feature
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -39,7 +39,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.10</version>
|
<version>4.11</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.common.storagehub.client.dsl;
|
package org.gcube.common.storagehub.client.dsl;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -58,6 +59,20 @@ public class FolderContainer extends ItemContainer<FolderItem>{
|
||||||
return new FileContainer(itemclient, itemclient.uploadFile(stream, this.itemId , filename, description));
|
return new FileContainer(itemclient, itemclient.uploadFile(stream, this.itemId , filename, description));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* creates a {@AbstractFileItem} inside the folder represented by this FolderContainer
|
||||||
|
*
|
||||||
|
* @param file the file
|
||||||
|
* @param description the description of the item in the workspace
|
||||||
|
* @return {@FileContainer} of the Item created
|
||||||
|
* @throws {@InvalidItemException}
|
||||||
|
* @throws {@UserNotAuthorizedException} if user is not authorized to write in this folder
|
||||||
|
*/
|
||||||
|
public FileContainer uploadFile(File file, String description) throws StorageHubException {
|
||||||
|
return new FileContainer(itemclient, itemclient.uploadFile(file, this.itemId , file.getName(), description));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* creates a {@ExternalLink} inside the folder represented by this FolderContainer
|
* creates a {@ExternalLink} inside the folder represented by this FolderContainer
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
package org.gcube.common.storagehub.client.dsl;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.gcube.common.storagehub.client.dsl;
|
package org.gcube.common.storagehub.client.dsl;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||||
import org.gcube.common.storagehub.client.proxies.GroupManagerClient;
|
import org.gcube.common.storagehub.client.proxies.GroupManagerClient;
|
||||||
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||||
|
@ -10,10 +12,24 @@ import org.gcube.common.storagehub.model.items.Item;
|
||||||
|
|
||||||
public class StorageHubClient {
|
public class StorageHubClient {
|
||||||
|
|
||||||
private WorkspaceManagerClient wsClient = AbstractPlugin.workspace().build();
|
protected WorkspaceManagerClient wsClient = AbstractPlugin.workspace().build();
|
||||||
private ItemManagerClient itemclient = AbstractPlugin.item().build();
|
protected ItemManagerClient itemclient = AbstractPlugin.item().build();
|
||||||
private GroupManagerClient groupClient = AbstractPlugin.groups().build();
|
protected GroupManagerClient groupClient = AbstractPlugin.groups().build();
|
||||||
private UserManagerClient userClient = AbstractPlugin.users().build();
|
protected UserManagerClient userClient = AbstractPlugin.users().build();
|
||||||
|
|
||||||
|
public StorageHubClient() {}
|
||||||
|
|
||||||
|
public StorageHubClient(URI uri) {
|
||||||
|
wsClient = AbstractPlugin.workspace().at(uri).build();
|
||||||
|
itemclient = AbstractPlugin.item().at(uri).build();
|
||||||
|
groupClient = AbstractPlugin.groups().at(uri).build();
|
||||||
|
userClient = AbstractPlugin.users().at(uri).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void impersonate(String user){
|
||||||
|
wsClient.impersonate(user);
|
||||||
|
itemclient.impersonate(user);
|
||||||
|
}
|
||||||
|
|
||||||
public FolderContainer getWSRoot(){
|
public FolderContainer getWSRoot(){
|
||||||
return new FolderContainer(itemclient, wsClient.getWorkspace());
|
return new FolderContainer(itemclient, wsClient.getWorkspace());
|
||||||
|
|
|
@ -9,14 +9,14 @@ import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||||
|
|
||||||
public class VREFolderManager {
|
public class VREFolderManager {
|
||||||
|
|
||||||
private WorkspaceManagerClient wsClient;
|
//private WorkspaceManagerClient wsClient;
|
||||||
private GroupManagerClient groupClient;
|
private GroupManagerClient groupClient;
|
||||||
|
|
||||||
private String vreTitle;
|
private String vreTitle;
|
||||||
|
|
||||||
public VREFolderManager(WorkspaceManagerClient wsClient, GroupManagerClient groupClient, String vreTitle) {
|
protected VREFolderManager(WorkspaceManagerClient wsClient, GroupManagerClient groupClient, String vreTitle) {
|
||||||
super();
|
super();
|
||||||
this.wsClient = wsClient;
|
//this.wsClient = wsClient;
|
||||||
this.groupClient = groupClient;
|
this.groupClient = groupClient;
|
||||||
this.vreTitle = vreTitle;
|
this.vreTitle = vreTitle;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package org.gcube.common.storagehub.client.plugins;
|
package org.gcube.common.storagehub.client.plugins;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.common.clients.Plugin;
|
import org.gcube.common.clients.Plugin;
|
||||||
import org.gcube.common.clients.ProxyBuilder;
|
import org.gcube.common.clients.ProxyBuilder;
|
||||||
import org.gcube.common.clients.ProxyBuilderImpl;
|
import org.gcube.common.clients.ProxyBuilderImpl;
|
||||||
|
@ -16,7 +20,6 @@ import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
|
||||||
public abstract class AbstractPlugin<S,P> implements Plugin<S,P> {
|
public abstract class AbstractPlugin<S,P> implements Plugin<S,P> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static final ItemManagerPlugin item_plugin = new ItemManagerPlugin();
|
private static final ItemManagerPlugin item_plugin = new ItemManagerPlugin();
|
||||||
private static final WorkspaceManagerPlugin workspace_plugin = new WorkspaceManagerPlugin();
|
private static final WorkspaceManagerPlugin workspace_plugin = new WorkspaceManagerPlugin();
|
||||||
private static final UserManagerPlugin user_plugin = new UserManagerPlugin();
|
private static final UserManagerPlugin user_plugin = new UserManagerPlugin();
|
||||||
|
@ -29,6 +32,7 @@ public abstract class AbstractPlugin<S,P> implements Plugin<S,P> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProxyBuilder<GroupManagerClient> groups() {
|
public static ProxyBuilder<GroupManagerClient> groups() {
|
||||||
|
|
||||||
return new ProxyBuilderImpl<GXWebTargetAdapterRequest,GroupManagerClient>(group_plugin);
|
return new ProxyBuilderImpl<GXWebTargetAdapterRequest,GroupManagerClient>(group_plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +50,8 @@ public abstract class AbstractPlugin<S,P> implements Plugin<S,P> {
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
|
|
||||||
|
protected List<Class<?>> customClasses = Collections.emptyList();
|
||||||
|
|
||||||
public AbstractPlugin(String name) {
|
public AbstractPlugin(String name) {
|
||||||
this.name=name;
|
this.name=name;
|
||||||
}
|
}
|
||||||
|
@ -70,4 +76,7 @@ public abstract class AbstractPlugin<S,P> implements Plugin<S,P> {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void register(Class<?> ... _classes) {
|
||||||
|
customClasses = Arrays.asList(_classes);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -27,6 +27,7 @@ public class GroupManagerPlugin extends AbstractPlugin<GXWebTargetAdapterRequest
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GroupManagerClient newProxy(ProxyDelegate<GXWebTargetAdapterRequest> delegate) {
|
public GroupManagerClient newProxy(ProxyDelegate<GXWebTargetAdapterRequest> delegate) {
|
||||||
return new DefaultGroupManager(delegate);
|
return new DefaultGroupManager(delegate);
|
||||||
|
@ -46,6 +47,10 @@ public class GroupManagerPlugin extends AbstractPlugin<GXWebTargetAdapterRequest
|
||||||
requestAdapter.register(SerializableErrorEntityTextReader.class);
|
requestAdapter.register(SerializableErrorEntityTextReader.class);
|
||||||
requestAdapter.register(MyInputStreamProvider.class);
|
requestAdapter.register(MyInputStreamProvider.class);
|
||||||
requestAdapter.register(MultiPartFeature.class);
|
requestAdapter.register(MultiPartFeature.class);
|
||||||
|
customClasses.forEach(c -> requestAdapter.register(c));
|
||||||
return requestAdapter;
|
return requestAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -47,6 +47,7 @@ public class ItemManagerPlugin extends AbstractPlugin<GXWebTargetAdapterRequest,
|
||||||
requestAdapter.register(SerializableErrorEntityTextReader.class);
|
requestAdapter.register(SerializableErrorEntityTextReader.class);
|
||||||
requestAdapter.register(MyInputStreamProvider.class);
|
requestAdapter.register(MyInputStreamProvider.class);
|
||||||
requestAdapter.register(MultiPartFeature.class);
|
requestAdapter.register(MultiPartFeature.class);
|
||||||
|
customClasses.forEach(c -> requestAdapter.register(c));
|
||||||
return requestAdapter;
|
return requestAdapter;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class MessageManagerPlugin extends AbstractPlugin<GXWebTargetAdapterReque
|
||||||
requestAdapter.register(SerializableErrorEntityTextReader.class);
|
requestAdapter.register(SerializableErrorEntityTextReader.class);
|
||||||
requestAdapter.register(MyInputStreamProvider.class);
|
requestAdapter.register(MyInputStreamProvider.class);
|
||||||
requestAdapter.register(MultiPartFeature.class);
|
requestAdapter.register(MultiPartFeature.class);
|
||||||
|
customClasses.forEach(c -> requestAdapter.register(c));
|
||||||
return requestAdapter;
|
return requestAdapter;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ public class UserManagerPlugin extends AbstractPlugin<GXWebTargetAdapterRequest,
|
||||||
requestAdapter.register(SerializableErrorEntityTextReader.class);
|
requestAdapter.register(SerializableErrorEntityTextReader.class);
|
||||||
requestAdapter.register(MyInputStreamProvider.class);
|
requestAdapter.register(MyInputStreamProvider.class);
|
||||||
requestAdapter.register(MultiPartFeature.class);
|
requestAdapter.register(MultiPartFeature.class);
|
||||||
|
customClasses.forEach(c -> requestAdapter.register(c));
|
||||||
return requestAdapter;
|
return requestAdapter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class WorkspaceManagerPlugin extends AbstractPlugin<GXWebTargetAdapterReq
|
||||||
|
|
||||||
GXWebTargetAdapterRequest requestAdapter = TargetFactory.stubFor(service).getAsGxRest(address);
|
GXWebTargetAdapterRequest requestAdapter = TargetFactory.stubFor(service).getAsGxRest(address);
|
||||||
requestAdapter.register(SerializableErrorEntityTextReader.class);
|
requestAdapter.register(SerializableErrorEntityTextReader.class);
|
||||||
|
customClasses.forEach(c -> requestAdapter.register(c));
|
||||||
return requestAdapter;
|
return requestAdapter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,14 +17,14 @@ import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||||
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
||||||
|
|
||||||
public class DefaultGroupManager implements GroupManagerClient {
|
public class DefaultGroupManager extends DefaultManagerClient implements GroupManagerClient {
|
||||||
|
|
||||||
private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
|
||||||
|
|
||||||
public DefaultGroupManager(ProxyDelegate<GXWebTargetAdapterRequest> delegate) {
|
public DefaultGroupManager(ProxyDelegate<GXWebTargetAdapterRequest> delegate) {
|
||||||
this.delegate = delegate;
|
super(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addUserToGroup(String userId, String groupId) throws StorageHubException {
|
public void addUserToGroup(String userId, String groupId) throws StorageHubException {
|
||||||
Call<GXWebTargetAdapterRequest, Void> call = new Call<GXWebTargetAdapterRequest, Void>() {
|
Call<GXWebTargetAdapterRequest, Void> call = new Call<GXWebTargetAdapterRequest, Void>() {
|
||||||
|
|
|
@ -6,7 +6,6 @@ import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -43,19 +42,20 @@ import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||||
import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
|
import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
|
||||||
import org.glassfish.jersey.media.multipart.file.StreamDataBodyPart;
|
import org.glassfish.jersey.media.multipart.file.StreamDataBodyPart;
|
||||||
|
|
||||||
public class DefaultItemManager implements ItemManagerClient {
|
public class DefaultItemManager extends DefaultManagerClient implements ItemManagerClient {
|
||||||
|
|
||||||
private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
|
||||||
|
|
||||||
private static final String CONTENT_DISPOSITION= "Content-Disposition";
|
private static final String CONTENT_DISPOSITION= "Content-Disposition";
|
||||||
private static final String CONTENT_TYPE= "Content-Type";
|
private static final String CONTENT_TYPE= "Content-Type";
|
||||||
private static final String CONTENT_LENGHT= "Content-Length";
|
private static final String CONTENT_LENGHT= "Content-Length";
|
||||||
|
|
||||||
public DefaultItemManager(ProxyDelegate<GXWebTargetAdapterRequest> config){
|
public DefaultItemManager(ProxyDelegate<GXWebTargetAdapterRequest> delegate) {
|
||||||
this.delegate = config;
|
super(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StreamDescriptor resolvePublicLink(String identifier) throws StorageHubException{
|
public StreamDescriptor resolvePublicLink(String identifier) throws StorageHubException{
|
||||||
Call<GXWebTargetAdapterRequest, StreamDescriptor> call = new Call<GXWebTargetAdapterRequest, StreamDescriptor>() {
|
Call<GXWebTargetAdapterRequest, StreamDescriptor> call = new Call<GXWebTargetAdapterRequest, StreamDescriptor>() {
|
||||||
|
@ -64,7 +64,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
Objects.requireNonNull(identifier, "id cannot be null");
|
Objects.requireNonNull(identifier, "id cannot be null");
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path("publiclink").path(identifier);
|
GXWebTargetAdapterRequest myManager = manager.path("publiclink").path(identifier);
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
GXInboundResponse response = myManager.queryParams(params).get();
|
GXInboundResponse response = myManager.queryParams(params).get();
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
public ItemList call(GXWebTargetAdapterRequest manager) throws StorageHubException, Exception {
|
public ItemList call(GXWebTargetAdapterRequest manager) throws StorageHubException, Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("children");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("children");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
params.put("exclude",excludeNodes);
|
params.put("exclude",excludeNodes);
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
params.put("onlyType", new Object[] {resolveNodeType(onlyOfType)});
|
params.put("onlyType", new Object[] {resolveNodeType(onlyOfType)});
|
||||||
params.put("showHidden", new Object[] {showHidden});
|
params.put("showHidden", new Object[] {showHidden});
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.queryParams(params).get();
|
GXInboundResponse response = myManager.queryParams(params).get();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
|
@ -145,7 +146,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
try {
|
try {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("children").path("paged");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("children").path("paged");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
|
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
|
@ -158,6 +159,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
params.put("limit", new Object[] {limit});
|
params.put("limit", new Object[] {limit});
|
||||||
params.put("showHidden", new Object[] {showHidden});
|
params.put("showHidden", new Object[] {showHidden});
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.queryParams(params).get();
|
GXInboundResponse response = myManager.queryParams(params).get();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
|
@ -211,7 +213,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
public ItemList call(GXWebTargetAdapterRequest manager) throws StorageHubException, Exception {
|
public ItemList call(GXWebTargetAdapterRequest manager) throws StorageHubException, Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("search");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("search");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
params.put("exclude",excludeNodes);
|
params.put("exclude",excludeNodes);
|
||||||
|
|
||||||
|
@ -221,6 +223,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
params.put("name", new String[] {URLEncoder.encode( nameToMatch, "UTF-8" )});
|
params.put("name", new String[] {URLEncoder.encode( nameToMatch, "UTF-8" )});
|
||||||
params.put("excludeTrashed", new Object[] {excludeTrashed});
|
params.put("excludeTrashed", new Object[] {excludeTrashed});
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.queryParams(params).get();
|
GXInboundResponse response = myManager.queryParams(params).get();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
|
@ -259,12 +262,13 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
public Integer call(GXWebTargetAdapterRequest manager) throws Exception {
|
public Integer call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("children").path("count");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("children").path("count");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
if (onlyOfType!=null)
|
if (onlyOfType!=null)
|
||||||
params.put("onlyType", new Object[] {resolveNodeType(onlyOfType)});
|
params.put("onlyType", new Object[] {resolveNodeType(onlyOfType)});
|
||||||
|
|
||||||
params.put("showHidden", new Object[] {showHidden});
|
params.put("showHidden", new Object[] {showHidden});
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.queryParams(params).get();
|
GXInboundResponse response = myManager.queryParams(params).get();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
|
@ -312,7 +316,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
public StreamDescriptor call(GXWebTargetAdapterRequest manager) throws Exception {
|
public StreamDescriptor call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("download");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("download");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
params.put("exclude",excludeNodes);
|
params.put("exclude",excludeNodes);
|
||||||
|
@ -349,7 +353,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
Objects.requireNonNull(version, "version cannot be null");
|
Objects.requireNonNull(version, "version cannot be null");
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("versions").path(version).path("download");
|
GXWebTargetAdapterRequest myManager = manager.path(id).queryParams(initQueryParameters()).path("versions").path(version).path("download");
|
||||||
|
|
||||||
GXInboundResponse response = myManager.get();
|
GXInboundResponse response = myManager.get();
|
||||||
|
|
||||||
|
@ -384,7 +388,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("versions");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("versions");
|
||||||
|
|
||||||
GXInboundResponse response = myManager.get();
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).get();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -415,7 +419,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
public ItemWrapper<Item> call(GXWebTargetAdapterRequest manager) throws Exception {
|
public ItemWrapper<Item> call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id);
|
GXWebTargetAdapterRequest myManager = manager.path(id);
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
params.put("exclude",excludeNodes);
|
params.put("exclude",excludeNodes);
|
||||||
|
@ -454,7 +458,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
Objects.requireNonNull(path, "path cannot be null");
|
Objects.requireNonNull(path, "path cannot be null");
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("path");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("path");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
params.put("path",new String[] {path});
|
params.put("path",new String[] {path});
|
||||||
|
|
||||||
|
@ -492,7 +496,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
@Override
|
@Override
|
||||||
public ItemWrapper<Item> call(GXWebTargetAdapterRequest manager) throws Exception {
|
public ItemWrapper<Item> call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("rootSharedFolder");
|
GXWebTargetAdapterRequest myManager = manager.path(id).queryParams(initQueryParameters()).path("rootSharedFolder");
|
||||||
GXInboundResponse response = myManager.get();
|
GXInboundResponse response = myManager.get();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
|
@ -526,7 +530,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
public URL call(GXWebTargetAdapterRequest manager) throws Exception {
|
public URL call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("publiclink");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("publiclink");
|
||||||
GXInboundResponse response = myManager.get();
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).get();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -559,7 +563,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
Objects.requireNonNull(version, "version cannot be null");
|
Objects.requireNonNull(version, "version cannot be null");
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("publiclink");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("publiclink");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
params.put("version",new Object[] {version});
|
params.put("version",new Object[] {version});
|
||||||
GXInboundResponse response = myManager.queryParams(params).get();
|
GXInboundResponse response = myManager.queryParams(params).get();
|
||||||
|
|
||||||
|
@ -595,7 +599,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
Objects.requireNonNull(id, "name cannot be null");
|
Objects.requireNonNull(id, "name cannot be null");
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("items");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("items");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
params.put("exclude",excludeNodes);
|
params.put("exclude",excludeNodes);
|
||||||
|
@ -657,13 +661,12 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
|
|
||||||
|
|
||||||
BodyPart fdp = new StreamDataBodyPart("file", stream);
|
BodyPart fdp = new StreamDataBodyPart("file", stream);
|
||||||
fdp.getHeaders().put("Content-Disposition",Arrays.asList(contentDisposition.toString()));
|
|
||||||
|
|
||||||
multipart.bodyPart(fdp);
|
multipart.bodyPart(fdp);
|
||||||
|
|
||||||
Entity<FormDataMultiPart> entity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA);
|
Entity<FormDataMultiPart> entity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA);
|
||||||
|
|
||||||
response = myManager.post(entity);
|
response = myManager.queryParams(initQueryParameters()).header("Content-Disposition",Arrays.asList(contentDisposition.toString())).post(entity);
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException()) {
|
if (response.hasException()) {
|
||||||
|
@ -709,7 +712,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
|
|
||||||
Entity<FormDataMultiPart> entity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA);
|
Entity<FormDataMultiPart> entity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA);
|
||||||
|
|
||||||
response = myManager.post(entity);
|
response = myManager.queryParams(initQueryParameters()).post(entity);
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException()) {
|
if (response.hasException()) {
|
||||||
|
@ -749,7 +752,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
formData.add("description", description);
|
formData.add("description", description);
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED));
|
||||||
|
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
|
@ -791,7 +794,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
if (contentLength >0)
|
if (contentLength >0)
|
||||||
myManager = myManager.header("Content-Length", contentLength);
|
myManager = myManager.header("Content-Length", contentLength);
|
||||||
|
|
||||||
GXInboundResponse response = myManager.post(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).post(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -856,7 +859,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
formData.add("hidden", Boolean.toString(hidden));
|
formData.add("hidden", Boolean.toString(hidden));
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -897,7 +900,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
formData.add("value", url.toString());
|
formData.add("value", url.toString());
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -932,7 +935,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
.path("create").path("GCUBEITEM");
|
.path("create").path("GCUBEITEM");
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.post(Entity.json(item));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).post(Entity.json(item));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -970,7 +973,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
multipart.field("defaultAccessType", accessType, MediaType.APPLICATION_JSON_TYPE);
|
multipart.field("defaultAccessType", accessType, MediaType.APPLICATION_JSON_TYPE);
|
||||||
multipart.field("users", users, MediaType.APPLICATION_JSON_TYPE);
|
multipart.field("users", users, MediaType.APPLICATION_JSON_TYPE);
|
||||||
|
|
||||||
GXInboundResponse response = myManager.put(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).put(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -1005,7 +1008,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
|
|
||||||
try (FormDataMultiPart multipart = new FormDataMultiPart()){
|
try (FormDataMultiPart multipart = new FormDataMultiPart()){
|
||||||
multipart.field("users", users, MediaType.APPLICATION_JSON_TYPE);
|
multipart.field("users", users, MediaType.APPLICATION_JSON_TYPE);
|
||||||
GXInboundResponse response = myManager.put(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).put(Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -1040,7 +1043,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
public Void call(GXWebTargetAdapterRequest manager) throws Exception {
|
public Void call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
|
|
||||||
HashMap<String, Object[]> queryParam = new HashMap<String, Object[]>();
|
Map<String, Object[]> queryParam = initQueryParameters();
|
||||||
queryParam.put("force", new Object[] {force});
|
queryParam.put("force", new Object[] {force});
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id);
|
GXWebTargetAdapterRequest myManager = manager.path(id);
|
||||||
|
@ -1074,7 +1077,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("anchestors");
|
GXWebTargetAdapterRequest myManager = manager.path(id).path("anchestors");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
params.put("exclude",excludeNodes);
|
params.put("exclude",excludeNodes);
|
||||||
|
@ -1108,7 +1111,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
public ACLList call(GXWebTargetAdapterRequest manager) throws Exception {
|
public ACLList call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("acls");
|
GXWebTargetAdapterRequest myManager = manager.queryParams(initQueryParameters()).path(id).path("acls");
|
||||||
GXInboundResponse response = myManager.get();
|
GXInboundResponse response = myManager.get();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
|
@ -1139,7 +1142,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
public Boolean call(GXWebTargetAdapterRequest manager) throws Exception {
|
public Boolean call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
Objects.requireNonNull(id, "id cannot be null");
|
Objects.requireNonNull(id, "id cannot be null");
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("acls").path("write");
|
GXWebTargetAdapterRequest myManager = manager.queryParams(initQueryParameters()).path(id).path("acls").path("write");
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.get();
|
GXInboundResponse response = myManager.get();
|
||||||
|
@ -1177,7 +1180,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
Objects.requireNonNull(user, "user cannot be null");
|
Objects.requireNonNull(user, "user cannot be null");
|
||||||
|
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("acls");
|
GXWebTargetAdapterRequest myManager = manager.queryParams(initQueryParameters()).path(id).path("acls");
|
||||||
|
|
||||||
try (FormDataMultiPart multipart = new FormDataMultiPart()){
|
try (FormDataMultiPart multipart = new FormDataMultiPart()){
|
||||||
multipart.field("access", accessType, MediaType.APPLICATION_JSON_TYPE);
|
multipart.field("access", accessType, MediaType.APPLICATION_JSON_TYPE);
|
||||||
|
@ -1216,7 +1219,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
Objects.requireNonNull(user, "user cannot be null");
|
Objects.requireNonNull(user, "user cannot be null");
|
||||||
|
|
||||||
|
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id).path("acls").path(user);
|
GXWebTargetAdapterRequest myManager = manager.queryParams(initQueryParameters()).path(id).path("acls").path(user);
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.delete();
|
GXInboundResponse response = myManager.delete();
|
||||||
|
@ -1260,7 +1263,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
formData.add("fileName", newFilename);
|
formData.add("fileName", newFilename);
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.put(Entity.form(formData));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).put(Entity.form(formData));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -1298,7 +1301,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
formData.add("publish", Boolean.toString(publish));
|
formData.add("publish", Boolean.toString(publish));
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.put(Entity.form(formData));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).put(Entity.form(formData));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -1336,7 +1339,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
formData.add("destinationId", destinationFolderId);
|
formData.add("destinationId", destinationFolderId);
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.put(Entity.form(formData));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).put(Entity.form(formData));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -1372,7 +1375,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
formData.add("newName", newName);
|
formData.add("newName", newName);
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.put(Entity.form(formData));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).put(Entity.form(formData));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -1408,7 +1411,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id)
|
GXWebTargetAdapterRequest myManager = manager.path(id)
|
||||||
.path("hidden");
|
.path("hidden");
|
||||||
|
|
||||||
GXInboundResponse response = myManager.put(Entity.json(value));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).put(Entity.json(value));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -1442,7 +1445,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path(id)
|
GXWebTargetAdapterRequest myManager = manager.path(id)
|
||||||
.path("description");
|
.path("description");
|
||||||
|
|
||||||
GXInboundResponse response = myManager.put(Entity.json(description));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).put(Entity.json(description));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -1477,7 +1480,7 @@ public class DefaultItemManager implements ItemManagerClient {
|
||||||
.path("metadata");
|
.path("metadata");
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.put(Entity.json(metadata));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).put(Entity.json(metadata));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.gcube.common.storagehub.client.proxies;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.gcube.common.clients.delegates.ProxyDelegate;
|
||||||
|
import org.gcube.common.gxrest.request.GXWebTargetAdapterRequest;
|
||||||
|
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||||
|
|
||||||
|
public abstract class DefaultManagerClient implements ManagerClient{
|
||||||
|
|
||||||
|
protected ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
||||||
|
|
||||||
|
private String impersonedUser= null;
|
||||||
|
|
||||||
|
public DefaultManagerClient(ProxyDelegate<GXWebTargetAdapterRequest> delegate) {
|
||||||
|
this.delegate = delegate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void register(Class<?> _classes) {
|
||||||
|
((AbstractPlugin<?,?>) delegate.config().plugin()).register(_classes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void impersonate(String user) {
|
||||||
|
this.impersonedUser = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Map<String, Object[]> initQueryParameters() {
|
||||||
|
Map<String, Object[]> params = new HashMap<String, Object[]>();
|
||||||
|
if (impersonedUser != null)
|
||||||
|
params.put("impersonate", new Object[] {impersonedUser});
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,16 +21,13 @@ import org.gcube.common.storagehub.model.messages.Message;
|
||||||
import org.gcube.common.storagehub.model.service.ItemList;
|
import org.gcube.common.storagehub.model.service.ItemList;
|
||||||
import org.gcube.common.storagehub.model.types.MessageList;
|
import org.gcube.common.storagehub.model.types.MessageList;
|
||||||
|
|
||||||
public class DefaultMessageManager implements MessageManagerClient {
|
public class DefaultMessageManager extends DefaultManagerClient implements MessageManagerClient {
|
||||||
|
|
||||||
private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
|
||||||
|
|
||||||
|
|
||||||
public DefaultMessageManager(ProxyDelegate<GXWebTargetAdapterRequest> config){
|
public DefaultMessageManager(ProxyDelegate<GXWebTargetAdapterRequest> delegate) {
|
||||||
this.delegate = config;
|
super(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Message get(String id) throws StorageHubException {
|
public Message get(String id) throws StorageHubException {
|
||||||
Call<GXWebTargetAdapterRequest, Message> call = new Call<GXWebTargetAdapterRequest, Message>() {
|
Call<GXWebTargetAdapterRequest, Message> call = new Call<GXWebTargetAdapterRequest, Message>() {
|
||||||
|
|
|
@ -16,12 +16,12 @@ import org.gcube.common.storagehub.model.exceptions.IdNotFoundException;
|
||||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||||
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
|
||||||
|
|
||||||
public class DefaultUserManager implements UserManagerClient {
|
public class DefaultUserManager extends DefaultManagerClient implements UserManagerClient {
|
||||||
|
|
||||||
|
|
||||||
private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
|
||||||
|
|
||||||
public DefaultUserManager(ProxyDelegate<GXWebTargetAdapterRequest> delegate) {
|
public DefaultUserManager(ProxyDelegate<GXWebTargetAdapterRequest> delegate) {
|
||||||
this.delegate = delegate;
|
super(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.gcube.common.storagehub.client.proxies;
|
||||||
|
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
@ -27,13 +26,10 @@ import org.gcube.common.storagehub.model.service.ItemWrapper;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
public class DefaultWorkspaceManager extends DefaultManagerClient implements WorkspaceManagerClient {
|
||||||
|
|
||||||
private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
|
public DefaultWorkspaceManager(ProxyDelegate<GXWebTargetAdapterRequest> delegate) {
|
||||||
|
super(delegate);
|
||||||
|
|
||||||
public DefaultWorkspaceManager(ProxyDelegate<GXWebTargetAdapterRequest> config){
|
|
||||||
this.delegate = config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,7 +39,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
public ItemWrapper<T> call(GXWebTargetAdapterRequest manager) throws Exception {
|
public ItemWrapper<T> call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
GXWebTargetAdapterRequest myManager = manager;
|
GXWebTargetAdapterRequest myManager = manager;
|
||||||
|
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
params.put("exclude",excludeNodes);
|
params.put("exclude",excludeNodes);
|
||||||
|
@ -98,7 +94,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
@Override
|
@Override
|
||||||
public ItemList call(GXWebTargetAdapterRequest manager) throws Exception {
|
public ItemList call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path("vrefolders");
|
GXWebTargetAdapterRequest myManager = manager.path("vrefolders");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
params.put("exclude",excludeNodes);
|
params.put("exclude",excludeNodes);
|
||||||
|
@ -129,7 +125,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
@Override
|
@Override
|
||||||
public ItemList call(GXWebTargetAdapterRequest manager) throws Exception {
|
public ItemList call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path("vrefolders").path("paged");
|
GXWebTargetAdapterRequest myManager = manager.path("vrefolders").path("paged");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
params.put("exclude",excludeNodes);
|
params.put("exclude",excludeNodes);
|
||||||
|
@ -165,7 +161,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
@Override
|
@Override
|
||||||
public ItemWrapper<T> call(GXWebTargetAdapterRequest manager) throws Exception {
|
public ItemWrapper<T> call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path("vrefolder");
|
GXWebTargetAdapterRequest myManager = manager.path("vrefolder");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
params.put("exclude",excludeNodes);
|
params.put("exclude",excludeNodes);
|
||||||
|
@ -197,7 +193,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
public ItemList call(GXWebTargetAdapterRequest manager) throws Exception {
|
public ItemList call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path("vrefolder").path("recents");
|
GXWebTargetAdapterRequest myManager = manager.path("vrefolder").path("recents");
|
||||||
|
|
||||||
GXInboundResponse response = myManager.get();
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).get();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -225,7 +221,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
@Override
|
@Override
|
||||||
public ItemWrapper<T> call(GXWebTargetAdapterRequest manager) throws Exception {
|
public ItemWrapper<T> call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path("trash");
|
GXWebTargetAdapterRequest myManager = manager.path("trash");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
params.put("exclude",excludeNodes);
|
params.put("exclude",excludeNodes);
|
||||||
|
@ -257,7 +253,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
public Void call(GXWebTargetAdapterRequest manager) throws Exception {
|
public Void call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path("trash").path("empty");
|
GXWebTargetAdapterRequest myManager = manager.path("trash").path("empty");
|
||||||
|
|
||||||
GXInboundResponse response = myManager.delete();
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).delete();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -292,7 +288,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
formData.add("destinationId", destinationFolderId);
|
formData.add("destinationId", destinationFolderId);
|
||||||
|
|
||||||
|
|
||||||
GXInboundResponse response = myManager.put(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED));
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).put(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED));
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -319,7 +315,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
@Override
|
@Override
|
||||||
public ItemList call(GXWebTargetAdapterRequest manager) throws Exception {
|
public ItemList call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path("query");
|
GXWebTargetAdapterRequest myManager = manager.path("query");
|
||||||
Map<String, Object[]> params = new HashMap<>();
|
Map<String, Object[]> params = initQueryParameters();
|
||||||
|
|
||||||
if (excludeNodes !=null && excludeNodes.length>0)
|
if (excludeNodes !=null && excludeNodes.length>0)
|
||||||
params.put("exclude",excludeNodes);
|
params.put("exclude",excludeNodes);
|
||||||
|
@ -373,7 +369,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path("count");
|
GXWebTargetAdapterRequest myManager = manager.path("count");
|
||||||
|
|
||||||
GXInboundResponse response = myManager.get();
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).get();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
@ -400,7 +396,7 @@ public class DefaultWorkspaceManager implements WorkspaceManagerClient {
|
||||||
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
public String call(GXWebTargetAdapterRequest manager) throws Exception {
|
||||||
GXWebTargetAdapterRequest myManager = manager.path("size");
|
GXWebTargetAdapterRequest myManager = manager.path("size");
|
||||||
|
|
||||||
GXInboundResponse response = myManager.get();
|
GXInboundResponse response = myManager.queryParams(initQueryParameters()).get();
|
||||||
|
|
||||||
if (response.isErrorResponse()) {
|
if (response.isErrorResponse()) {
|
||||||
if (response.hasException())
|
if (response.hasException())
|
||||||
|
|
|
@ -5,7 +5,7 @@ import java.util.List;
|
||||||
import org.gcube.common.storagehub.model.acls.AccessType;
|
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||||
|
|
||||||
public interface GroupManagerClient {
|
public interface GroupManagerClient extends ManagerClient{
|
||||||
|
|
||||||
void addUserToGroup(String userId, String groupId) throws StorageHubException;
|
void addUserToGroup(String userId, String groupId) throws StorageHubException;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import org.gcube.common.storagehub.model.service.Version;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface ItemManagerClient {
|
public interface ItemManagerClient extends ManagerClient{
|
||||||
|
|
||||||
List<? extends Item> getChildren(String id, boolean includeHidden, String ... excludeNodes) throws StorageHubException;
|
List<? extends Item> getChildren(String id, boolean includeHidden, String ... excludeNodes) throws StorageHubException;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
package org.gcube.common.storagehub.client.proxies;
|
||||||
|
|
||||||
|
public interface ManagerClient {
|
||||||
|
|
||||||
|
void register(Class<?> _classes);
|
||||||
|
|
||||||
|
void impersonate(String user);
|
||||||
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||||
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.messages.Message;
|
||||||
|
|
||||||
public interface MessageManagerClient {
|
public interface MessageManagerClient extends ManagerClient{
|
||||||
|
|
||||||
Message get(String id) throws StorageHubException;
|
Message get(String id) throws StorageHubException;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
|
||||||
|
|
||||||
public interface UserManagerClient {
|
public interface UserManagerClient extends ManagerClient{
|
||||||
|
|
||||||
void createUser(String userId) throws StorageHubException;
|
void createUser(String userId) throws StorageHubException;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import org.gcube.common.storagehub.model.expressions.SearchableItem;
|
||||||
import org.gcube.common.storagehub.model.items.Item;
|
import org.gcube.common.storagehub.model.items.Item;
|
||||||
import org.gcube.common.storagehub.model.query.Query;
|
import org.gcube.common.storagehub.model.query.Query;
|
||||||
|
|
||||||
public interface WorkspaceManagerClient {
|
public interface WorkspaceManagerClient extends ManagerClient{
|
||||||
|
|
||||||
<T extends Item> T getWorkspace(String ... excludeNodes);
|
<T extends Item> T getWorkspace(String ... excludeNodes);
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class Items {
|
||||||
|
|
||||||
private static final String propFile = "/home/lucio/tokens.properties";
|
private static final String propFile = "/home/lucio/tokens.properties";
|
||||||
|
|
||||||
private static final String tokens = "prod-root";
|
private static final String tokens = "dev-root";
|
||||||
//private static final String tokens = "prod-root";
|
//private static final String tokens = "prod-root";
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
|
@ -169,17 +169,15 @@ public class Items {
|
||||||
|
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
|
|
||||||
FolderContainer myRoot = shc.getWSRoot();
|
FolderContainer myRoot = shc.open("11cbdc0c-e873-418c-bc53-5f6329eb88fb").asFolder();
|
||||||
|
|
||||||
|
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
File inFile = new File("C:\\Users\\tilli\\Downloads\\testup.zip");
|
File inFile = new File("/home/lucio/Downloads/scimmia braccia aperte.mp4");
|
||||||
try(InputStream is = new FileInputStream(inFile)){
|
try(InputStream is = new FileInputStream(inFile)){
|
||||||
myRoot.uploadFile(is, "testUp.zip", "file");
|
myRoot.uploadFile(is, "scimmia braccia aperte.mp4", "file");
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
System.out.println("Response in "+(System.currentTimeMillis()-start));
|
System.out.println("Response in "+(System.currentTimeMillis()-start));
|
||||||
|
|
||||||
|
@ -228,10 +226,11 @@ public class Items {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addUser() throws Exception {
|
public void addUser() throws Exception {
|
||||||
|
ScopeProvider.instance.set("/gcube");
|
||||||
|
SecurityTokenProvider.instance.set("b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548");
|
||||||
StorageHubClient shc = new StorageHubClient();
|
StorageHubClient shc = new StorageHubClient();
|
||||||
shc.createUserAccount("service-account-sergencovid19");
|
|
||||||
|
|
||||||
shc.getVreFolderManager("d4science.research-infrastructures.eu-FARM-SerGen-Covid19_Ricercatore").addUser("service-account-sergencovid19");
|
shc.getVreFolderManager("gcube-devsec-devVre").addUser("vincenzo.cestone");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -5,7 +5,6 @@ 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.URI;
|
|
||||||
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;
|
||||||
|
@ -15,13 +14,6 @@ import java.util.Properties;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
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 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;
|
||||||
|
@ -44,7 +36,6 @@ 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.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.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -54,7 +45,7 @@ public class TestCall {
|
||||||
|
|
||||||
private static Logger log = LoggerFactory.getLogger(TestCall.class);
|
private static Logger log = LoggerFactory.getLogger(TestCall.class);
|
||||||
|
|
||||||
private static final String propFile = "/home/lucio/tokens.properties";
|
private static final String propFile = "/home/lucio/secret.properties";
|
||||||
|
|
||||||
private static final String tokens = "dev-root";
|
private static final String tokens = "dev-root";
|
||||||
|
|
||||||
|
@ -67,8 +58,9 @@ public class TestCall {
|
||||||
String value =(String)prop.get(tokens);
|
String value =(String)prop.get(tokens);
|
||||||
String[] splitValue = value.split(",");
|
String[] splitValue = value.split(",");
|
||||||
String context = splitValue[0];
|
String context = splitValue[0];
|
||||||
String token = splitValue[1];
|
String clientID = splitValue[1];
|
||||||
SecurityTokenProvider.instance.set(token);
|
String secret = splitValue[2];
|
||||||
|
|
||||||
ScopeProvider.instance.set(context);
|
ScopeProvider.instance.set(context);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
package org.gcube.data.access.fs;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
||||||
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||||
|
import org.gcube.common.storagehub.client.dsl.VREFolderManager;
|
||||||
|
import org.gcube.common.storagehub.model.acls.AccessType;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class TestWithLocalContainer {
|
||||||
|
|
||||||
|
private static StorageHubClient client;
|
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(TestWithLocalContainer.class);
|
||||||
|
|
||||||
|
public static URI storagehubUri;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void initialize() throws Exception{
|
||||||
|
storagehubUri = new URL(String.format("http://%s:%d/storagehub", "localhost",8080)).toURI();
|
||||||
|
AccessTokenProvider.instance.set("eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJSSklZNEpoNF9qdDdvNmREY0NlUDFfS1l0akcxVExXVW9oMkQ2Tzk1bFNBIn0.eyJleHAiOjE2NDQyNDM4ODUsImlhdCI6MTY0NDI0MzU4NSwiYXV0aF90aW1lIjoxNjQ0MjQzNTg1LCJqdGkiOiI1NWQ4ZDc5OS1kNTIzLTQ0YmEtYTRkMC1iZjIyYzVlMTg4NzQiLCJpc3MiOiJodHRwczovL2FjY291bnRzLmRldi5kNHNjaWVuY2Uub3JnL2F1dGgvcmVhbG1zL2Q0c2NpZW5jZSIsImF1ZCI6IiUyRmdjdWJlIiwic3ViIjoiNGMxMWRlODQtZGRjOS00ZGQxLWI5N2EtZWE4MmQyZDEzOGE2IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoibmV4dC5kNHNjaWVuY2Uub3JnIiwic2Vzc2lvbl9zdGF0ZSI6ImZkZTA3MGE2LTVkOTUtNDc3Ni1hMTFiLTBhZTI1MzQ5NGQyMyIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiLyoiXSwicmVzb3VyY2VfYWNjZXNzIjp7IiUyRmdjdWJlIjp7InJvbGVzIjpbIkluZnJhc3RydWN0dXJlLU1hbmFnZXIiLCJNZW1iZXIiXX19LCJhdXRob3JpemF0aW9uIjp7InBlcm1pc3Npb25zIjpbeyJyc2lkIjoiMTU5ZDcyMDQtNjlmYS00ZmY0LTlhOTQtMzVlMWUyMzA5MDQyIiwicnNuYW1lIjoiRGVmYXVsdCBSZXNvdXJjZSJ9XX0sInNjb3BlIjoiZW1haWwgcHJvZmlsZSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJuYW1lIjoiTHVjaW8gTGVsaWkiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJsdWNpby5sZWxpaSIsImdpdmVuX25hbWUiOiJMdWNpbyIsImZhbWlseV9uYW1lIjoiTGVsaWkiLCJlbWFpbCI6Imx1Y2lvLmxlbGlpQGlzdGkuY25yLml0In0.SGuGXnY63WJ45tdypywaopO--FCxY6ZWAX74MGVw_zdNMMQI5zgtGfhZQewFWQ6HhVINDStXqvdSDluhF9JwFXCUGvxB2BipfKQYsAQnm3I4K3kgMl26kuQIL5Im-apw2XWvImTgLshX1AzpyqzFR1Jpf_p65GCMpcHLEwo_nTGLkrZNtfRdtqakZ8S8lowGaV2J2mNf4AHhtARSLJF3GqwynF5pPUXR2iOMUrjw_FLnIuPMfAjk_jHMeYKIxXNBLsoEpELju3pr2gEkv1ZRH9bZkyg7_3hW4mGzxq_Ea9w1FBVJOlkp6vypuISLNyJZcVOnBa4Dg1KRxxlp3aZ6vA");
|
||||||
|
ScopeProvider.instance.set("/gcube");
|
||||||
|
//client = new StorageHubClient(storagehubUri);
|
||||||
|
//createUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void reset() throws Exception {
|
||||||
|
AccessTokenProvider.instance.set("eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJSSklZNEpoNF9qdDdvNmREY0NlUDFfS1l0akcxVExXVW9oMkQ2Tzk1bFNBIn0.eyJleHAiOjE2NDQyNDM4ODUsImlhdCI6MTY0NDI0MzU4NSwiYXV0aF90aW1lIjoxNjQ0MjQzNTg1LCJqdGkiOiI1NWQ4ZDc5OS1kNTIzLTQ0YmEtYTRkMC1iZjIyYzVlMTg4NzQiLCJpc3MiOiJodHRwczovL2FjY291bnRzLmRldi5kNHNjaWVuY2Uub3JnL2F1dGgvcmVhbG1zL2Q0c2NpZW5jZSIsImF1ZCI6IiUyRmdjdWJlIiwic3ViIjoiNGMxMWRlODQtZGRjOS00ZGQxLWI5N2EtZWE4MmQyZDEzOGE2IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoibmV4dC5kNHNjaWVuY2Uub3JnIiwic2Vzc2lvbl9zdGF0ZSI6ImZkZTA3MGE2LTVkOTUtNDc3Ni1hMTFiLTBhZTI1MzQ5NGQyMyIsImFjciI6IjEiLCJhbGxvd2VkLW9yaWdpbnMiOlsiLyoiXSwicmVzb3VyY2VfYWNjZXNzIjp7IiUyRmdjdWJlIjp7InJvbGVzIjpbIkluZnJhc3RydWN0dXJlLU1hbmFnZXIiLCJNZW1iZXIiXX19LCJhdXRob3JpemF0aW9uIjp7InBlcm1pc3Npb25zIjpbeyJyc2lkIjoiMTU5ZDcyMDQtNjlmYS00ZmY0LTlhOTQtMzVlMWUyMzA5MDQyIiwicnNuYW1lIjoiRGVmYXVsdCBSZXNvdXJjZSJ9XX0sInNjb3BlIjoiZW1haWwgcHJvZmlsZSIsImVtYWlsX3ZlcmlmaWVkIjp0cnVlLCJuYW1lIjoiTHVjaW8gTGVsaWkiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJsdWNpby5sZWxpaSIsImdpdmVuX25hbWUiOiJMdWNpbyIsImZhbWlseV9uYW1lIjoiTGVsaWkiLCJlbWFpbCI6Imx1Y2lvLmxlbGlpQGlzdGkuY25yLml0In0.SGuGXnY63WJ45tdypywaopO--FCxY6ZWAX74MGVw_zdNMMQI5zgtGfhZQewFWQ6HhVINDStXqvdSDluhF9JwFXCUGvxB2BipfKQYsAQnm3I4K3kgMl26kuQIL5Im-apw2XWvImTgLshX1AzpyqzFR1Jpf_p65GCMpcHLEwo_nTGLkrZNtfRdtqakZ8S8lowGaV2J2mNf4AHhtARSLJF3GqwynF5pPUXR2iOMUrjw_FLnIuPMfAjk_jHMeYKIxXNBLsoEpELju3pr2gEkv1ZRH9bZkyg7_3hW4mGzxq_Ea9w1FBVJOlkp6vypuISLNyJZcVOnBa4Dg1KRxxlp3aZ6vA");
|
||||||
|
ScopeProvider.instance.set("/gcube");
|
||||||
|
client = new StorageHubClient(storagehubUri);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createUser() throws Exception{
|
||||||
|
client.createUserAccount("test.user");
|
||||||
|
client.createUserAccount("test.user2");
|
||||||
|
VREFolderManager vremanager = client.getVreFolderManager("gcube-devVre-myvre");
|
||||||
|
vremanager.createVRE(AccessType.WRITE_OWNER, "test.user");
|
||||||
|
vremanager.addUser("test.user2");
|
||||||
|
}
|
||||||
|
|
||||||
|
//impersonating test.user
|
||||||
|
@Test
|
||||||
|
public void uploadFile() throws Exception{
|
||||||
|
|
||||||
|
client.impersonate("test.user");
|
||||||
|
FolderContainer vreFolder = (FolderContainer) client.getVREFolders().getContainers().stream().findFirst().get();
|
||||||
|
try(InputStream stream = this.getClass().getResourceAsStream("/output.xlsx")){
|
||||||
|
vreFolder.uploadFile(stream, "userTestfile2", "userTestfile" );
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(vreFolder.list().getItems().size()>0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue