VREManager folder feature addded

This commit is contained in:
lucio 2019-10-14 10:18:54 +02:00
parent eb8aa51a00
commit c036bb3d95
8 changed files with 103 additions and 24 deletions

View File

@ -18,7 +18,7 @@
<groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-library</artifactId>
<version>1.0.7-SNAPSHOT</version>
<version>1.0.8-SNAPSHOT</version>
<name>storagehub-client-library</name>
<dependencyManagement>

View File

@ -155,10 +155,10 @@ public class FolderContainer extends ItemContainer<FolderItem>{
* @throws {@InvalidItemException}
* @throws {@UserNotAuthorizedException} if user is not administrator of this folder
*/
/*public FolderContainer changeAcls(String user, AccessType accessType) throws StorageHubException {
public FolderContainer changeAcls(String user, AccessType accessType) throws StorageHubException {
itemclient.changeACL(this.itemId, user, accessType);
return this;
}*/
}
public boolean canWrite() throws Exception {
return itemclient.canWriteInto(this.itemId);

View File

@ -1,6 +1,7 @@
package org.gcube.common.storagehub.client.dsl;
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
import org.gcube.common.storagehub.client.proxies.GroupManagerClient;
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
@ -10,6 +11,7 @@ public class StorageHubClient {
private WorkspaceManagerClient wsClient = AbstractPlugin.workspace().build();
private ItemManagerClient itemclient = AbstractPlugin.item().build();
private GroupManagerClient groupClient = AbstractPlugin.groups().build();
public FolderContainer getWSRoot(){
return new FolderContainer(itemclient, wsClient.getWorkspace());
@ -28,11 +30,15 @@ public class StorageHubClient {
public FolderContainer openVREFolder() {
return new FolderContainer(itemclient, wsClient.getVreFolder());
}
public ListResolver getVREFolders() {
return new ListResolver((onlyType, includeHidden, excludes) -> wsClient.getVreFolders(excludes), itemclient);
}
public VREFolderManager getVreFolderManager() {
return new VREFolderManager(wsClient, groupClient);
}
public FolderContainer openTrash() {
return new FolderContainer(itemclient, wsClient.getTrashFolder());
}
@ -48,9 +54,7 @@ public class StorageHubClient {
public long getTotalItemCount() {
return wsClient.getTotalItemCount();
}
public GenericItemContainer restoreThrashItem(String itemId) {
return new GenericItemContainer(itemclient, wsClient.restoreFromTrash(itemId));
}

View File

@ -0,0 +1,36 @@
package org.gcube.common.storagehub.client.dsl;
import org.gcube.common.storagehub.client.proxies.GroupManagerClient;
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
import org.gcube.common.storagehub.model.Excludes;
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
import org.gcube.common.storagehub.model.items.Item;
public class VREFolderManager {
private WorkspaceManagerClient wsClient;
private GroupManagerClient groupClient;
public VREFolderManager(WorkspaceManagerClient wsClient, GroupManagerClient groupClient) {
super();
this.wsClient = wsClient;
this.groupClient = groupClient;
}
public void removeUser(String userId) throws StorageHubException{
groupClient.removeUserFromGroup(userId, getVreFolder().getTitle());
}
public void addUser(String userId) throws StorageHubException{
groupClient.addUserToGroup(userId, getVreFolder().getTitle());
}
public void getUsers() throws StorageHubException{
getVreFolder();
groupClient.getUsersOfGroup(getVreFolder().getTitle());
}
private Item getVreFolder() {
return wsClient.getVreFolder(Excludes.ALL.toArray(new String[0]));
}
}

View File

@ -48,8 +48,10 @@ private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
try {
delegate.make(call);
return;
}catch(Exception e) {
throw new RuntimeException(e);
}catch(StorageHubException e) {
throw e;
}catch(Exception e1) {
throw new RuntimeException(e1);
}
}
@ -75,8 +77,10 @@ private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
try {
delegate.make(call);
return;
}catch(Exception e) {
throw new RuntimeException(e);
}catch(StorageHubException e) {
throw e;
}catch(Exception e1) {
throw new RuntimeException(e1);
}
}
@ -103,8 +107,10 @@ private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
try {
List<String> users = delegate.make(call);
return users;
}catch(Exception e) {
throw new RuntimeException(e);
}catch(StorageHubException e) {
throw e;
}catch(Exception e1) {
throw new RuntimeException(e1);
}
}
@ -130,8 +136,10 @@ private final ProxyDelegate<GXWebTargetAdapterRequest> delegate;
try {
delegate.make(call);
return;
}catch(Exception e) {
throw new RuntimeException(e);
}catch(StorageHubException e) {
throw e;
}catch(Exception e1) {
throw new RuntimeException(e1);
}

View File

@ -48,8 +48,10 @@ public class DefaultUserManager implements UserManagerClient {
try {
delegate.make(call);
return;
}catch(Exception e) {
throw new RuntimeException(e);
}catch(StorageHubException e) {
throw e;
}catch(Exception e1) {
throw new RuntimeException(e1);
}
}
@ -75,8 +77,10 @@ public class DefaultUserManager implements UserManagerClient {
try {
delegate.make(call);
return;
}catch(Exception e) {
throw new RuntimeException(e);
}catch(StorageHubException e) {
throw e;
}catch(Exception e1) {
throw new RuntimeException(e1);
}
}
@ -102,8 +106,10 @@ public class DefaultUserManager implements UserManagerClient {
try {
List<String> users = delegate.make(call);
return users;
}catch(Exception e) {
throw new RuntimeException(e);
}catch(StorageHubException e) {
throw e;
}catch(Exception e1) {
throw new RuntimeException(e1);
}
}

View File

@ -30,10 +30,21 @@ public class Items {
@BeforeClass
public static void setUp(){
SecurityTokenProvider.instance.set("9bec07ef-5d19-42ad-8a56-0af28c9b08ed-98187548");
ScopeProvider.instance.set("/gcube");
SecurityTokenProvider.instance.set("d9431600-9fef-41a7-946d-a5b402de30d6-98187548");
ScopeProvider.instance.set("/gcube/devsec/devVRE");
}
@Test
public void removeUserFromVRE() throws StorageHubException {
StorageHubClient shc = new StorageHubClient();
shc.getVreFolderManager().removeUser("andrea.rossi");
}
@Test
public void addUserFromVRE() throws StorageHubException {
StorageHubClient shc = new StorageHubClient();
shc.getVreFolderManager().addUser("andrea.rossi");
}
@Test
public void emptyStatisticaManagerTrash() {

View File

@ -23,12 +23,14 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.storagehub.client.StreamDescriptor;
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
import org.gcube.common.storagehub.client.proxies.GroupManagerClient;
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
import org.gcube.common.storagehub.client.proxies.WorkspaceManagerClient;
import org.gcube.common.storagehub.model.Metadata;
import org.gcube.common.storagehub.model.Paths;
import org.gcube.common.storagehub.model.acls.ACL;
import org.gcube.common.storagehub.model.acls.AccessType;
import org.gcube.common.storagehub.model.exceptions.StorageHubException;
import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException;
import org.gcube.common.storagehub.model.expressions.GenericSearchableItem;
import org.gcube.common.storagehub.model.expressions.OrderField;
@ -53,10 +55,22 @@ public class TestCall {
@BeforeClass
public static void setUp(){
SecurityTokenProvider.instance.set("b7c80297-e4ed-42ab-ab42-fdc0b8b0eabf-98187548");
SecurityTokenProvider.instance.set("d9431600-9fef-41a7-946d-a5b402de30d6-98187548");
ScopeProvider.instance.set("/gcube");
}
@Test
public void removeUserFromGroup() throws StorageHubException {
GroupManagerClient client = AbstractPlugin.groups().build();
client.removeUserFromGroup("andrea.rossi", "gcube-devsec-devVRE");
}
@Test
public void addUserToGroup() throws StorageHubException {
GroupManagerClient client = AbstractPlugin.groups().build();
client.addUserToGroup("andrea.rossi", "gcube-devsec-devVRE");
}
@Test(expected=UserNotAuthorizedException.class)
public void createNotAuthorized() throws Exception{
ItemManagerClient itemclient = AbstractPlugin.item().build();