fixed restore

Added GcubeItem

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@171643 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-09-24 14:18:06 +00:00
parent 4e2b311ade
commit 92d465ea8a
4 changed files with 98 additions and 44 deletions

View File

@ -8,6 +8,7 @@ import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
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.GenericItemContainer;
import org.gcube.common.storagehub.client.dsl.ItemContainer;
import org.gcube.common.storagehub.client.dsl.ListResolver;
import org.gcube.common.storagehub.client.dsl.StorageHubClient;
@ -439,10 +440,10 @@ public class StorageHubClientService {
Validate.notNull(itemId, "Bad invoking restore trash item the "+itemId+" is null");
FolderContainer container = shcClient.restoreThrashItem(itemId);
GenericItemContainer container = shcClient.restoreThrashItem(itemId);
if(container!=null){
FolderItem item = container.get();
Item item = container.get();
if(item!=null){
return item;
}else

View File

@ -11,6 +11,7 @@ import org.gcube.common.storagehub.model.Metadata;
import org.gcube.common.storagehub.model.items.AbstractFileItem;
import org.gcube.common.storagehub.model.items.ExternalURL;
import org.gcube.common.storagehub.model.items.FolderItem;
import org.gcube.common.storagehub.model.items.GCubeItem;
import org.gcube.common.storagehub.model.items.GenericFileItem;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.items.PDFFileItem;
@ -26,6 +27,7 @@ import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.AccountingEntry;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.FileItem;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.GcubeItem;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.ImageFile;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.PDFFile;
import org.gcube.common.storagehubwrapper.shared.tohl.impl.PropertyMap;
@ -96,16 +98,16 @@ public class HLMapper {
}
/**
* To property map.
*
* @param item the item
* @param metadata the metadata
* @return the property map
*/
public static PropertyMap toPropertyMap(Item item){
//ADDING (GCUBE) PROPERTIES
public static PropertyMap toPropertyMap(Metadata metadata){
PropertyMap pm = null;
Metadata metadata = item.getPropertyMap();
if(metadata!=null)
pm = new PropertyMap(metadata.getValues());
@ -117,6 +119,9 @@ public class HLMapper {
*
* @param <T> the generic type
* @param item the item
* @param withAccounting the with accounting
* @param withFileDetails the with file details
* @param withMapProperties the with map properties
* @return the t
*/
public static<T extends WorkspaceItem> T toWorkspaceItem(Item item, boolean withAccounting, boolean withFileDetails, boolean withMapProperties){
@ -213,11 +218,11 @@ public class HLMapper {
//ADDING (GCUBE) PROPERTIES
PropertyMap pm = null;
if(withMapProperties)
pm = toPropertyMap(item);
//TRASH //TODO
if(withMapProperties){
pm = toPropertyMap(item.getPropertyMap());
}
//CONVERTING TRASH ITEM
if(item.isTrashed()){
type = WorkspaceItemType.TRASH_ITEM;
TrashItem trashItem = (TrashItem) item; //??
@ -229,11 +234,28 @@ public class HLMapper {
theTrashItem.setDeletedFrom(trashItem.getDeletedFrom());
theTrashItem.setLenght(trashItem.getLenght());
theTrashItem.setMimeType(trashItem.getMimeType());
System.out.println(theTrashItem);
//theTrashItem.setFolder(trashItem.getFolder()); ??? NULL POINTER
theTrashItem.setFolder(trashItem.getFolder());
logger.trace("Wrapped TrashItem: "+theTrashItem);
}
if(item instanceof GCubeItem){
type = WorkspaceItemType.FILE_ITEM;
GCubeItem gcubeItem = (GCubeItem) item; //??
theItem = new GcubeItem();
GcubeItem theGcubeItem = (GcubeItem) theItem;
theGcubeItem.setFileItemType(FileItemType.GCUBE_ITEM);
theGcubeItem.setScopes(gcubeItem.getScopes());
theGcubeItem.setCreator(gcubeItem.getCreator());
theGcubeItem.setItemType(gcubeItem.getItemType());
theGcubeItem.setShared(gcubeItem.isShared());
PropertyMap property = toPropertyMap(gcubeItem.getProperty());
theGcubeItem.setProperty(property);
logger.trace("Wrapped GcubeItem: "+theGcubeItem);
}
System.out.println("The item: "+item);
System.out.println("The item id: "+item.getId());
theItem.setId(item.getId());
theItem.setName(itemName);
theItem.setPath(item.getPath());

View File

@ -0,0 +1,40 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.impl;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class GcubeItem extends FileItem implements org.gcube.common.storagehubwrapper.shared.tohl.items.GCubeItem {
/**
*
*/
private static final long serialVersionUID = -4523330832448380056L;
String[] scopes;
String creator;
String itemType;
String properties;
boolean shared;
PropertyMap property;
}

View File

@ -3,11 +3,8 @@
*/
package org.gcube.common.storagehubwrapper.shared.tohl.items;
import java.io.InputStream;
import java.util.List;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceSharedFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
/**
@ -16,46 +13,40 @@ import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorEx
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
*/
public interface GCubeItem extends FileItem {
public interface GCubeItem extends WorkspaceItem {
/**
* Gets the scopes.
*
* @return the scopes
* @throws InternalErrorException the internal error exception
*/
public List<String> getScopes() throws InternalErrorException;
public String[] getScopes();
/**
* Gets the item type.
*
* @return the item type
*/
public String getItemType();
/**
* Gets the creator.
*
* @return the creator
*/
public String getCreator();
/**
* Share.
*
* @param users the users
* @return the workspace shared folder
* @throws InternalErrorException the internal error exception
*/
public WorkspaceSharedFolder share(List<String> users) throws InternalErrorException;
/**
* Gets the data.
*
* @return the data
* @throws InternalErrorException the internal error exception
* @return the itemType
*/
public InputStream getData() throws InternalErrorException;
public String getItemType();
/**
* @return the properties
*/
public String getProperties();
/**
* @return the shared
*/
public boolean isShared();
/**
* @return the property
*/
public PropertyMap getProperty();
}