2019-10-14 10:18:54 +02:00
|
|
|
package org.gcube.common.storagehub.client.dsl;
|
|
|
|
|
2020-01-15 19:10:33 +01:00
|
|
|
import java.util.List;
|
|
|
|
|
2019-10-14 10:18:54 +02:00
|
|
|
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;
|
|
|
|
|
2020-01-15 19:10:33 +01:00
|
|
|
private String vreTitle;
|
|
|
|
|
|
|
|
public VREFolderManager(WorkspaceManagerClient wsClient, GroupManagerClient groupClient, String vreTitle) {
|
2019-10-14 10:18:54 +02:00
|
|
|
super();
|
|
|
|
this.wsClient = wsClient;
|
|
|
|
this.groupClient = groupClient;
|
2020-01-15 19:10:33 +01:00
|
|
|
this.vreTitle = vreTitle;
|
2019-10-14 10:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void removeUser(String userId) throws StorageHubException{
|
2020-01-15 19:10:33 +01:00
|
|
|
groupClient.removeUserFromGroup(userId, vreTitle);
|
2019-10-14 10:18:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addUser(String userId) throws StorageHubException{
|
2020-01-15 19:10:33 +01:00
|
|
|
groupClient.addUserToGroup(userId, vreTitle);
|
2019-10-14 10:18:54 +02:00
|
|
|
}
|
|
|
|
|
2020-01-15 19:10:33 +01:00
|
|
|
public List<String> getUsers() throws StorageHubException{
|
|
|
|
return groupClient.getUsersOfGroup(vreTitle);
|
2019-10-14 10:18:54 +02:00
|
|
|
}
|
2020-01-15 19:10:33 +01:00
|
|
|
|
2019-10-14 10:18:54 +02:00
|
|
|
private Item getVreFolder() {
|
|
|
|
return wsClient.getVreFolder(Excludes.ALL.toArray(new String[0]));
|
|
|
|
}
|
2020-01-15 19:10:33 +01:00
|
|
|
|
|
|
|
public void setAdmin(String userId) throws StorageHubException{
|
|
|
|
groupClient.addAdmin(vreTitle, userId);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void removeAdmin(String userId) throws StorageHubException{
|
|
|
|
groupClient.removeAdmin(vreTitle, userId);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<String> getAdmins() throws StorageHubException{
|
|
|
|
return groupClient.getAdmins(vreTitle);
|
|
|
|
}
|
|
|
|
|
2019-10-14 10:18:54 +02:00
|
|
|
}
|