2018-06-26 14:58:41 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
package org.gcube.common.storagehubwrapper.server;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import org.apache.commons.lang.Validate;
|
|
|
|
import org.gcube.common.storagehub.model.items.FolderItem;
|
|
|
|
import org.gcube.common.storagehub.model.items.Item;
|
|
|
|
import org.gcube.common.storagehub.model.types.GenericItemType;
|
|
|
|
import org.gcube.common.storagehubwrapper.server.converter.HLMapper;
|
|
|
|
import org.gcube.common.storagehubwrapper.server.tohl.Workspace;
|
|
|
|
import org.gcube.common.storagehubwrapper.shared.ACLType;
|
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
|
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
|
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceVREFolder;
|
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InsufficientPrivilegesException;
|
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
|
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemAlreadyExistException;
|
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
|
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WorkspaceFolderNotFoundException;
|
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongDestinationException;
|
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.WrongItemTypeException;
|
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.impl.WorkspaceFolder;
|
2018-06-26 16:13:03 +02:00
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.items.URLFileItem;
|
2018-06-26 14:58:41 +02:00
|
|
|
import org.gcube.common.storagehubwrapper.shared.tohl.trash.WorkspaceTrashItem;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Class WorkspaceStorageHubClientService.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
* Jun 20, 2018
|
|
|
|
*/
|
|
|
|
public final class WorkspaceStorageHubClientService implements Workspace{
|
|
|
|
|
|
|
|
//public static final String ACCOUNTING_HL_NODE_NAME = "hl:accounting";
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(WorkspaceStorageHubClientService.class);
|
|
|
|
private StorageHubClientService storageHubClientService;
|
|
|
|
private boolean withAccounting;
|
|
|
|
private boolean withFileDetails;
|
|
|
|
private boolean withMapProperties;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the storage hub client service.
|
|
|
|
*
|
|
|
|
* @return the storageHubClientService
|
|
|
|
*/
|
|
|
|
public StorageHubClientService getStorageHubClientService() {
|
|
|
|
|
|
|
|
return storageHubClientService;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-09-14 15:34:12 +02:00
|
|
|
* Checks if is with accounting.
|
|
|
|
*
|
2018-06-26 14:58:41 +02:00
|
|
|
* @return the withAccounting
|
|
|
|
*/
|
|
|
|
public boolean isWithAccounting() {
|
|
|
|
|
|
|
|
return withAccounting;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-09-14 15:34:12 +02:00
|
|
|
* Checks if is with file details.
|
|
|
|
*
|
2018-06-26 14:58:41 +02:00
|
|
|
* @return the withFileDetails
|
|
|
|
*/
|
|
|
|
public boolean isWithFileDetails() {
|
|
|
|
|
|
|
|
return withFileDetails;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-09-14 15:34:12 +02:00
|
|
|
* Checks if is with map properties.
|
|
|
|
*
|
2018-06-26 14:58:41 +02:00
|
|
|
* @return the withMapProperties
|
|
|
|
*/
|
|
|
|
public boolean isWithMapProperties() {
|
|
|
|
|
|
|
|
return withMapProperties;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new workspace storage hub client service.
|
|
|
|
*
|
|
|
|
* @param storageHubClientService the storage hub client service
|
|
|
|
*/
|
|
|
|
private WorkspaceStorageHubClientService(StorageHubClientService storageHubClientService) {
|
|
|
|
this.storageHubClientService = storageHubClientService;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new workspace storage hub client service.
|
|
|
|
*
|
|
|
|
* @param storageHubClientService the storage hub client service
|
|
|
|
* @param withAccounting the with accounting
|
|
|
|
* @param withFileDetails the with file details
|
|
|
|
* @param withMapProperties the with map properties
|
|
|
|
*/
|
|
|
|
private WorkspaceStorageHubClientService(
|
|
|
|
StorageHubClientService storageHubClientService,
|
|
|
|
boolean withAccounting, boolean withFileDetails,
|
|
|
|
boolean withMapProperties) {
|
|
|
|
|
|
|
|
super();
|
|
|
|
this.storageHubClientService = storageHubClientService;
|
|
|
|
this.withAccounting = withAccounting;
|
|
|
|
this.withFileDetails = withFileDetails;
|
|
|
|
this.withMapProperties = withMapProperties;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Class WorkspaceStorageHubClientServiceBuilder.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
* Jun 22, 2018
|
|
|
|
*/
|
|
|
|
public static class WorkspaceStorageHubClientServiceBuilder{
|
|
|
|
private StorageHubClientService storageHubClientService;
|
|
|
|
private boolean withAccounting;
|
|
|
|
private boolean withFileDetails;
|
|
|
|
private boolean withMapProperties;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new workspace storage hub client service builder.
|
|
|
|
*
|
|
|
|
* @param storageHubClientService the storage hub client service
|
|
|
|
* @param withAccounting the with accounting
|
|
|
|
* @param withFileDetails the with file details
|
|
|
|
* @param withMapProperties the with map properties
|
|
|
|
*/
|
|
|
|
public WorkspaceStorageHubClientServiceBuilder(
|
|
|
|
final StorageHubClientService storageHubClientService,
|
|
|
|
final boolean withAccounting, final boolean withFileDetails,
|
|
|
|
final boolean withMapProperties) {
|
|
|
|
|
|
|
|
this.storageHubClientService = storageHubClientService;
|
|
|
|
this.withAccounting = withAccounting;
|
|
|
|
this.withFileDetails = withFileDetails;
|
|
|
|
this.withMapProperties = withMapProperties;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiates a new workspace storage hub client service builder.
|
|
|
|
*
|
|
|
|
* @param storageHubClientService the storage hub client service
|
|
|
|
*/
|
|
|
|
public WorkspaceStorageHubClientServiceBuilder(
|
|
|
|
final StorageHubClientService storageHubClientService) {
|
|
|
|
|
|
|
|
this.storageHubClientService = storageHubClientService;
|
|
|
|
this.withAccounting = false;
|
|
|
|
this.withFileDetails = false;
|
|
|
|
this.withMapProperties = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the with accounting.
|
|
|
|
*
|
|
|
|
* @param withAccounting the withAccounting to set
|
|
|
|
* @return the workspace storage hub client service builder
|
|
|
|
*/
|
|
|
|
public WorkspaceStorageHubClientServiceBuilder withAccounting(final boolean withAccounting) {
|
|
|
|
|
|
|
|
this.withAccounting = withAccounting;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the with file details.
|
|
|
|
*
|
|
|
|
* @param withFileDetails the withFileDetails to set
|
|
|
|
* @return the workspace storage hub client service builder
|
|
|
|
*/
|
|
|
|
public WorkspaceStorageHubClientServiceBuilder withFileDetails(final boolean withFileDetails) {
|
|
|
|
|
|
|
|
this.withFileDetails = withFileDetails;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the with map properties.
|
|
|
|
*
|
|
|
|
* @param withMapProperties the withMapProperties to set
|
|
|
|
* @return the workspace storage hub client service builder
|
|
|
|
*/
|
|
|
|
public WorkspaceStorageHubClientServiceBuilder withMapProperties(final boolean withMapProperties) {
|
|
|
|
|
|
|
|
this.withMapProperties = withMapProperties;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-09-14 15:34:12 +02:00
|
|
|
* Builds the WorkspaceStorageHubClientService.
|
2018-06-26 14:58:41 +02:00
|
|
|
*
|
|
|
|
* @return the workspace storage hub client service
|
|
|
|
*/
|
|
|
|
public WorkspaceStorageHubClientService build(){
|
|
|
|
return new WorkspaceStorageHubClientService(storageHubClientService,
|
|
|
|
withAccounting,
|
|
|
|
withFileDetails,
|
|
|
|
withMapProperties);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getOwner()
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String getOwner()
|
|
|
|
throws InternalErrorException {
|
|
|
|
|
|
|
|
WorkspaceFolder root = getRoot();
|
|
|
|
return root.getOwner();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getRoot()
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceFolder getRoot() throws InternalErrorException{
|
|
|
|
logger.debug("Getting root");
|
|
|
|
FolderItem root;
|
|
|
|
try {
|
|
|
|
root = storageHubClientService.getRoot();
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
logger.error("Error on getting root: ", e);
|
|
|
|
throw new InternalErrorException("Sorry an error occurred when getting the workspace root. Refresh and try again");
|
|
|
|
}
|
|
|
|
WorkspaceFolder workspaceFolder = (WorkspaceFolder) HLMapper.toWorkspaceItem(root);
|
|
|
|
workspaceFolder.setRoot(true);
|
|
|
|
return workspaceFolder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.tohl.Workspace#getChildren(java.lang.String)
|
|
|
|
*/
|
|
|
|
public List<? extends WorkspaceItem> getChildren(String id){
|
|
|
|
|
|
|
|
Validate.notNull(id,"The input id is null");
|
|
|
|
List<? extends Item> children = storageHubClientService.getChildren(id);
|
|
|
|
List<WorkspaceItem> toChildren = new ArrayList<WorkspaceItem>(children.size());
|
|
|
|
|
|
|
|
for (Item item : children) {
|
|
|
|
WorkspaceItem child = HLMapper.toWorkspaceItem(item);
|
|
|
|
toChildren.add(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
return toChildren;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getParentsById(java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<? extends WorkspaceItem> getParentsById(String id)
|
|
|
|
throws InternalErrorException {
|
|
|
|
|
|
|
|
Validate.notNull(id,"The input id is null");
|
|
|
|
List<? extends Item> parents = storageHubClientService.getParents(id);
|
|
|
|
List<WorkspaceItem> toParents = new ArrayList<WorkspaceItem>(parents.size());
|
|
|
|
|
|
|
|
for (Item item : parents) {
|
|
|
|
WorkspaceItem child = HLMapper.toWorkspaceItem(item);
|
|
|
|
toParents.add(child);
|
|
|
|
}
|
|
|
|
|
|
|
|
return toParents;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createFolder(java.lang.String, java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceFolder createFolder(
|
|
|
|
String name, String description, String destinationFolderId)
|
|
|
|
throws InternalErrorException, InsufficientPrivilegesException,
|
|
|
|
ItemAlreadyExistException, WrongDestinationException,
|
|
|
|
ItemNotFoundException, WorkspaceFolderNotFoundException {
|
|
|
|
|
|
|
|
Validate.notNull(destinationFolderId,"The destinationFolderId id is null");
|
|
|
|
Validate.notNull(name,"The folderName is null");
|
|
|
|
Item item;
|
|
|
|
try {
|
|
|
|
item = storageHubClientService.createFolder(destinationFolderId, name, description);
|
|
|
|
return (WorkspaceFolder) HLMapper.toWorkspaceItem(item);
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
logger.error("Error on creting the folde: ",e);
|
|
|
|
throw new InternalErrorException(e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getItem(java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceItem getItem(String itemId) throws ItemNotFoundException, InternalErrorException {
|
|
|
|
|
|
|
|
/*Validate.notNull(itemId,"The input itemId is null");
|
|
|
|
Item item;
|
|
|
|
try {
|
|
|
|
item = storageHubClientService.getItem(itemId);
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
logger.error("Error during get item with id: "+itemId,e);
|
|
|
|
throw new InternalErrorException(e.getMessage());
|
|
|
|
}
|
|
|
|
return HLMapper.toWorkspaceItem(item, withAccounting, withFileDetails, withMapProperties);*/
|
|
|
|
|
|
|
|
return getItem(itemId, withAccounting, withFileDetails, withMapProperties);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#getItem(java.lang.String, boolean, boolean, boolean)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceItem getItem(
|
|
|
|
String itemId, boolean withAccounting, boolean withFileDetails,
|
|
|
|
boolean withMapProperties)
|
|
|
|
throws ItemNotFoundException, InternalErrorException {
|
|
|
|
|
|
|
|
Validate.notNull(itemId,"The input itemId is null");
|
|
|
|
Item item;
|
|
|
|
try {
|
|
|
|
item = storageHubClientService.getItem(itemId);
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
logger.error("Error during get item with id: "+itemId,e);
|
|
|
|
throw new InternalErrorException(e.getMessage());
|
|
|
|
}
|
|
|
|
return HLMapper.toWorkspaceItem(item, withAccounting, withFileDetails, withMapProperties);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createFolder(java.lang.String, java.lang.String, java.lang.String, java.util.Map)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceFolder createFolder(
|
|
|
|
String name, String description, String destinationFolderId,
|
|
|
|
Map<String, String> properties)
|
|
|
|
throws InternalErrorException, InsufficientPrivilegesException,
|
|
|
|
ItemAlreadyExistException, WrongDestinationException,
|
|
|
|
ItemNotFoundException, WorkspaceFolderNotFoundException {
|
|
|
|
|
|
|
|
WorkspaceFolder folder = createFolder(name, description, destinationFolderId);
|
|
|
|
//TODO set gcube properties
|
|
|
|
return folder;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#uploadFile(java.lang.String, java.io.InputStream, java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceItem uploadFile(
|
|
|
|
String folderId, InputStream is, String fileName, String fileDescription)
|
|
|
|
throws InsufficientPrivilegesException,
|
|
|
|
WorkspaceFolderNotFoundException, InternalErrorException,
|
|
|
|
ItemAlreadyExistException, WrongDestinationException {
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = null;
|
|
|
|
try {
|
|
|
|
Item item = storageHubClientService.uploadFile(folderId, is, fileName, fileDescription);
|
|
|
|
wsItem = HLMapper.toWorkspaceItem(item);
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
logger.error("Error during upload file ",e);
|
|
|
|
throw new InternalErrorException(e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return wsItem;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#getSharedFolderMembers(java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<String> getSharedFolderMembers(String folderId) throws Exception {
|
|
|
|
|
|
|
|
Validate.notNull(folderId,"The input folderid is null");
|
2018-06-26 15:45:52 +02:00
|
|
|
return storageHubClientService.getSharedFolderMembers(folderId);
|
2018-06-26 14:58:41 +02:00
|
|
|
}
|
|
|
|
|
2018-06-26 17:23:09 +02:00
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#exists(java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean exists(String name, String folderId)
|
|
|
|
throws InternalErrorException, ItemNotFoundException,
|
|
|
|
WrongItemTypeException {
|
|
|
|
|
|
|
|
List<WorkspaceItem> foundItems = find(name, folderId);
|
|
|
|
|
|
|
|
return foundItems!=null && foundItems.size()>0?true:false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#find(java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<WorkspaceItem> find(String name, String folderId)
|
|
|
|
throws InternalErrorException, ItemNotFoundException,
|
|
|
|
WrongItemTypeException {
|
|
|
|
|
|
|
|
Validate.notNull(folderId,"The input folderid is null");
|
|
|
|
try {
|
|
|
|
List<? extends Item> items = storageHubClientService.findByName(name, folderId);
|
|
|
|
List<WorkspaceItem> wsItems = null;
|
|
|
|
if(items!=null){
|
|
|
|
wsItems = new ArrayList<WorkspaceItem>(items.size());
|
|
|
|
for (Item item : items) {
|
|
|
|
wsItems.add(HLMapper.toWorkspaceItem(item));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return wsItems;
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
logger.error("Error during search items with name "+name+" in the parent id: "+folderId, e);
|
|
|
|
throw new InternalErrorException(e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-14 15:34:12 +02:00
|
|
|
/**
|
|
|
|
* Gets the root shared folder.
|
|
|
|
*
|
|
|
|
* @param itemId the item id
|
|
|
|
* @return the root shared folder
|
|
|
|
* @throws Exception the exception
|
|
|
|
*/
|
|
|
|
public WorkspaceItem getRootSharedFolder(String itemId) throws Exception {
|
|
|
|
Validate.notNull(itemId,"The input itemId is null");
|
|
|
|
|
|
|
|
try{
|
|
|
|
FolderItem folderItem = storageHubClientService.getRootSharedFolder(itemId);
|
|
|
|
return HLMapper.toWorkspaceItem(folderItem);
|
|
|
|
}catch(Exception e){
|
|
|
|
logger.error("Get root shared folder error: "+e.getMessage());
|
|
|
|
throw new Exception("Get root shared folder error: "+e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#removeItem(java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void deleteItem(String itemId)
|
|
|
|
throws Exception {
|
|
|
|
|
|
|
|
Validate.notNull(itemId,"The input itemId is null");
|
|
|
|
|
|
|
|
try{
|
|
|
|
storageHubClientService.deleteItemById(itemId);
|
|
|
|
|
|
|
|
}catch(Exception e){
|
|
|
|
logger.error("Delete item by id error: "+e.getMessage());
|
|
|
|
throw new Exception("Delete item by id error: "+e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-18 16:47:48 +02:00
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.server.tohl.Workspace#uploadFile(java.lang.String, java.io.InputStream, java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceItem uploadArchive(
|
|
|
|
String folderId, InputStream is, String extractionFolderName)
|
|
|
|
throws
|
|
|
|
WorkspaceFolderNotFoundException, InternalErrorException,
|
|
|
|
ItemAlreadyExistException, WrongDestinationException, InsufficientPrivilegesException{
|
|
|
|
|
|
|
|
WorkspaceItem wsItem = null;
|
|
|
|
try {
|
|
|
|
Item item = storageHubClientService.uploadArchive(folderId, is, extractionFolderName);
|
|
|
|
wsItem = HLMapper.toWorkspaceItem(item);
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
logger.error("Error during upload archive", e);
|
|
|
|
throw new InternalErrorException(e.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
return wsItem;
|
|
|
|
}
|
|
|
|
|
2018-09-14 15:34:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-06-26 17:23:09 +02:00
|
|
|
|
|
|
|
|
2018-06-26 14:58:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createExternalUrl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public URLFileItem createExternalUrl(
|
|
|
|
String name, String description, String url, String destinationFolderId)
|
|
|
|
throws InsufficientPrivilegesException,
|
|
|
|
WorkspaceFolderNotFoundException, InternalErrorException,
|
|
|
|
ItemAlreadyExistException, WrongDestinationException, IOException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createExternalUrl(java.lang.String, java.lang.String, java.io.InputStream, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public URLFileItem createExternalUrl(
|
|
|
|
String name, String description, InputStream url,
|
|
|
|
String destinationfolderId)
|
|
|
|
throws InsufficientPrivilegesException, InternalErrorException,
|
|
|
|
ItemAlreadyExistException, WrongDestinationException,
|
|
|
|
WorkspaceFolderNotFoundException, IOException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#moveItem(java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceItem moveItem(String itemId, String destinationFolderId)
|
|
|
|
throws ItemNotFoundException, WrongDestinationException,
|
|
|
|
InsufficientPrivilegesException, InternalErrorException,
|
|
|
|
ItemAlreadyExistException, WorkspaceFolderNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#renameItem(java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void renameItem(String itemId, String newName)
|
|
|
|
throws ItemNotFoundException, InternalErrorException,
|
|
|
|
ItemAlreadyExistException, InsufficientPrivilegesException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#changeDescription(java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void changeDescription(String itemId, String newDescription)
|
|
|
|
throws ItemNotFoundException, InternalErrorException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getItemByPath(java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceItem getItemByPath(String path)
|
|
|
|
throws ItemNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#remove(java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void remove(String itemName, String folderId)
|
|
|
|
throws ItemNotFoundException, InternalErrorException,
|
|
|
|
InsufficientPrivilegesException, WrongItemTypeException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#copy(java.lang.String, java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceItem copy(
|
|
|
|
String itemId, String newName, String destinationFolderId)
|
|
|
|
throws ItemNotFoundException, WrongDestinationException,
|
|
|
|
InternalErrorException, ItemAlreadyExistException,
|
|
|
|
InsufficientPrivilegesException, WorkspaceFolderNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#copy(java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceItem copy(String itemId, String destinationFolderId)
|
|
|
|
throws ItemNotFoundException, WrongDestinationException,
|
|
|
|
InternalErrorException, ItemAlreadyExistException,
|
|
|
|
InsufficientPrivilegesException, WorkspaceFolderNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#searchByName(java.lang.String, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<WorkspaceItem> searchByName(String name, String folderId)
|
|
|
|
throws InternalErrorException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#searchByMimeType(java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<WorkspaceItem> searchByMimeType(String mimeType)
|
|
|
|
throws InternalErrorException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getFolderItems(org.gcube.common.storagehub.model.types.GenericItemType)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<WorkspaceItem> getFolderItems(GenericItemType type)
|
|
|
|
throws InternalErrorException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createSharedFolder(java.lang.String, java.lang.String, java.util.List, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceSharedFolder createSharedFolder(
|
|
|
|
String name, String description, List<String> users,
|
|
|
|
String destinationFolderId)
|
|
|
|
throws InternalErrorException, InsufficientPrivilegesException,
|
|
|
|
ItemAlreadyExistException, WrongDestinationException,
|
|
|
|
ItemNotFoundException, WorkspaceFolderNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createSharedFolder(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceSharedFolder createSharedFolder(
|
|
|
|
String name, String description, String groupId,
|
|
|
|
String destinationFolderId, String displayName, boolean isVREFolder)
|
|
|
|
throws InternalErrorException, InsufficientPrivilegesException,
|
|
|
|
ItemAlreadyExistException, WrongDestinationException,
|
|
|
|
ItemNotFoundException, WorkspaceFolderNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#shareFolder(java.util.List, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceSharedFolder shareFolder(
|
|
|
|
List<String> users, String destinationFolderId)
|
|
|
|
throws InternalErrorException, InsufficientPrivilegesException,
|
|
|
|
ItemAlreadyExistException, WrongDestinationException,
|
|
|
|
ItemNotFoundException, WorkspaceFolderNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#share(java.util.List, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceSharedFolder share(List<String> users, String itemId)
|
|
|
|
throws InternalErrorException, InsufficientPrivilegesException,
|
|
|
|
ItemAlreadyExistException, WrongDestinationException,
|
|
|
|
ItemNotFoundException, WorkspaceFolderNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createGcubeItem(java.lang.String, java.lang.String, java.util.List, java.lang.String, java.lang.String, java.util.Map, java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceItem createGcubeItem(
|
|
|
|
String name, String description, List<String> scopes, String creator,
|
|
|
|
String itemType, Map<String, String> properties,
|
|
|
|
String destinationFolderId)
|
|
|
|
throws InsufficientPrivilegesException,
|
|
|
|
WorkspaceFolderNotFoundException, InternalErrorException,
|
|
|
|
ItemAlreadyExistException, WrongDestinationException,
|
|
|
|
ItemNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#unshare(java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceItem unshare(String itemId)
|
|
|
|
throws InternalErrorException, ItemNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getTrash()
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceTrashItem getTrash()
|
|
|
|
throws InternalErrorException, ItemNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getMySpecialFolders()
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceFolder getMySpecialFolders()
|
|
|
|
throws InternalErrorException, ItemNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#searchByProperties(java.util.List)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<WorkspaceItem> searchByProperties(List<String> properties)
|
|
|
|
throws InternalErrorException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getVREFolderByScope(java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceSharedFolder getVREFolderByScope(String scope)
|
|
|
|
throws ItemNotFoundException, InternalErrorException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getDiskUsage()
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public long getDiskUsage()
|
|
|
|
throws InternalErrorException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getTotalItems()
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public int getTotalItems()
|
|
|
|
throws InternalErrorException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#removeItems(java.lang.String[])
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public Map<String, String> removeItems(String... id)
|
|
|
|
throws ItemNotFoundException, InternalErrorException,
|
|
|
|
InsufficientPrivilegesException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#createVREFolder(java.lang.String, java.lang.String, java.lang.String, org.gcube.portal.storagehubwrapper.shared.ACLType)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public WorkspaceVREFolder createVREFolder(
|
|
|
|
String scope, String description, String displayName, ACLType privilege)
|
|
|
|
throws InternalErrorException, InsufficientPrivilegesException,
|
|
|
|
ItemAlreadyExistException, WrongDestinationException,
|
|
|
|
ItemNotFoundException, WorkspaceFolderNotFoundException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getGroup(java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String getGroup(String groupId)
|
|
|
|
throws InternalErrorException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#isGroup(java.lang.String)
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean isGroup(String groupId)
|
|
|
|
throws InternalErrorException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#getPublicFolders()
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public List<WorkspaceItem> getPublicFolders()
|
|
|
|
throws InternalErrorException {
|
|
|
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|