Added method deleteItem
Updated pom at 0-2-0 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@171465 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
4ae1b0f025
commit
3fa88ee8d3
|
@ -1,4 +1,8 @@
|
|||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.common.storagehubwrapper.0-2-0"
|
||||
date="2018-06-20">
|
||||
<Change>[Task #12059] added delete item</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.common.storagehubwrapper.0-1-0"
|
||||
date="2018-06-20">
|
||||
<Change>[Task #12059] first release</Change>
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-wrapper</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
<name>storagehub-client-wrapper</name>
|
||||
<description>This is a wrapper of storagehub-client library. It allows to interact with storagehub in a simplified way by exposing several utilities. Moreover, It exposes object as defined in (the old) HL interfaces</description>
|
||||
<scm>
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.gcube.common.scope.api.ScopeProvider;
|
|||
import org.gcube.common.storagehub.client.dsl.FileContainer;
|
||||
import org.gcube.common.storagehub.client.dsl.FolderContainer;
|
||||
import org.gcube.common.storagehub.client.dsl.ItemContainer;
|
||||
import org.gcube.common.storagehub.client.dsl.ListResolver;
|
||||
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
|
||||
import org.gcube.common.storagehub.client.plugins.AbstractPlugin;
|
||||
import org.gcube.common.storagehub.client.proxies.ItemManagerClient;
|
||||
|
@ -129,8 +130,12 @@ public class StorageHubClientService {
|
|||
*/
|
||||
public List<? extends Item> getParents(String itemId) {
|
||||
setContextProviders(scope, authorizationToken);
|
||||
List<? extends Item> toReturn = shcClient.open(itemId).asItem().getAnchestors();
|
||||
return toReturn;
|
||||
ListResolver toReturn = shcClient.open(itemId).asItem().getAnchestors();
|
||||
if(toReturn==null || toReturn.getItems()==null){
|
||||
logger.warn("Parent List of item id "+itemId+" is null");
|
||||
return null;
|
||||
}
|
||||
return toReturn.getItems();
|
||||
}
|
||||
|
||||
//TODO MAP OF SHARED ROOT ID
|
||||
|
@ -141,7 +146,7 @@ public class StorageHubClientService {
|
|||
*
|
||||
* @param itemId the item id
|
||||
* @return the id shared folder
|
||||
* @throws Exception
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public String getIdSharedFolder(String itemId) throws Exception {
|
||||
setContextProviders(scope, authorizationToken);
|
||||
|
@ -154,22 +159,33 @@ public class StorageHubClientService {
|
|||
*
|
||||
* @param itemId the item id
|
||||
* @return the root shared folder
|
||||
* @throws Exception
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public FolderItem getRootSharedFolder(String itemId) throws Exception {
|
||||
setContextProviders(scope, authorizationToken);
|
||||
return getRootSharedFolder(shcClient.open(itemId).asItem());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the root shared folder.
|
||||
*
|
||||
* @param itemContainer the item container
|
||||
* @return the root shared folder
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public FolderItem getRootSharedFolder(ItemContainer<Item> itemContainer) throws Exception {
|
||||
setContextProviders(scope, authorizationToken);
|
||||
|
||||
ItemContainer<Item> item = shcClient.open(itemId).asItem();
|
||||
FolderContainer rootSharedFolder = null;
|
||||
if(item.get().isShared()){
|
||||
rootSharedFolder = item.getRootSharedFolder();
|
||||
Item item = itemContainer.get();
|
||||
if(item.isShared()){
|
||||
rootSharedFolder = itemContainer.getRootSharedFolder();
|
||||
}else
|
||||
throw new Exception("The item with id: "+itemId +" is not shared");
|
||||
throw new Exception("The item with id: "+item.getId() +" is not shared");
|
||||
|
||||
Validate.notNull(rootSharedFolder, "The root shared folder with id "+itemId+" does not exist");
|
||||
Validate.notNull(rootSharedFolder, "The root shared folder with children id "+item.getId()+" does not exist");
|
||||
return rootSharedFolder.get();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -332,6 +348,22 @@ public class StorageHubClientService {
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Delete item by id.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public void deleteItemById(String itemId) throws Exception{
|
||||
|
||||
Validate.notNull(itemId, "Bad invoking operation the "+itemId+" is null");
|
||||
|
||||
shcClient.open(itemId).asItem().delete();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
|
|
|
@ -60,6 +60,8 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
|||
|
||||
|
||||
/**
|
||||
* Checks if is with accounting.
|
||||
*
|
||||
* @return the withAccounting
|
||||
*/
|
||||
public boolean isWithAccounting() {
|
||||
|
@ -69,6 +71,8 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
|||
|
||||
|
||||
/**
|
||||
* Checks if is with file details.
|
||||
*
|
||||
* @return the withFileDetails
|
||||
*/
|
||||
public boolean isWithFileDetails() {
|
||||
|
@ -78,6 +82,8 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
|||
|
||||
|
||||
/**
|
||||
* Checks if is with map properties.
|
||||
*
|
||||
* @return the withMapProperties
|
||||
*/
|
||||
public boolean isWithMapProperties() {
|
||||
|
@ -151,9 +157,6 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
|||
* 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) {
|
||||
|
@ -201,7 +204,7 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
|||
}
|
||||
|
||||
/**
|
||||
* Builds the WorkspaceStorageHubClientService
|
||||
* Builds the WorkspaceStorageHubClientService.
|
||||
*
|
||||
* @return the workspace storage hub client service
|
||||
*/
|
||||
|
@ -441,6 +444,48 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -498,17 +543,6 @@ public final class WorkspaceStorageHubClientService implements Workspace{
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#removeItem(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void removeItem(String itemId)
|
||||
throws ItemNotFoundException, InternalErrorException,
|
||||
InsufficientPrivilegesException {
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portal.storagehubwrapper.shared.Workspace#moveItem(java.lang.String, java.lang.String)
|
||||
|
|
|
@ -188,6 +188,36 @@ public interface Workspace{
|
|||
public List<WorkspaceItem> find(String name, String folderId) throws InternalErrorException, ItemNotFoundException, WrongItemTypeException;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -247,14 +277,17 @@ public interface Workspace{
|
|||
*/
|
||||
public URLFileItem createExternalUrl(String name, String description, InputStream url, String destinationfolderId) throws InsufficientPrivilegesException, InternalErrorException, ItemAlreadyExistException, WrongDestinationException, WorkspaceFolderNotFoundException, IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Remove an item.
|
||||
* @param itemId the item to remove.
|
||||
* @throws ItemNotFoundException if the item has not been found.
|
||||
* @throws InternalErrorException if an internal error occurs.
|
||||
* @throws InsufficientPrivilegesException if the user don't have sufficient privileges to perform this operation.
|
||||
* Delete item.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @throws ItemNotFoundException the item not found exception
|
||||
* @throws InternalErrorException the internal error exception
|
||||
* @throws InsufficientPrivilegesException the insufficient privileges exception
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public void removeItem(String itemId) throws ItemNotFoundException, InternalErrorException, InsufficientPrivilegesException;
|
||||
public void deleteItem(String itemId) throws ItemNotFoundException, InternalErrorException, InsufficientPrivilegesException, Exception;
|
||||
|
||||
/**
|
||||
* Move a workspaceItem to a specified destination.
|
||||
|
|
Loading…
Reference in New Issue