converted the trash item

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/storagehub-client-wrapper@171608 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-09-24 09:25:04 +00:00
parent 96b4b54ab0
commit 4e2b311ade
4 changed files with 62 additions and 23 deletions

View File

@ -15,6 +15,7 @@ import org.gcube.common.storagehub.model.items.GenericFileItem;
import org.gcube.common.storagehub.model.items.Item;
import org.gcube.common.storagehub.model.items.PDFFileItem;
import org.gcube.common.storagehub.model.items.SharedFolder;
import org.gcube.common.storagehub.model.items.TrashItem;
import org.gcube.common.storagehub.model.items.VreFolder;
import org.gcube.common.storagehub.model.items.nodes.Accounting;
import org.gcube.common.storagehub.model.items.nodes.Content;
@ -217,8 +218,21 @@ public class HLMapper {
//TRASH //TODO
if(theItem.isTrashed())
if(item.isTrashed()){
type = WorkspaceItemType.TRASH_ITEM;
TrashItem trashItem = (TrashItem) item; //??
theItem = new org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem();
org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem theTrashItem = (org.gcube.common.storagehubwrapper.shared.tohl.impl.TrashItem) theItem;
theTrashItem.setDeletedBy(trashItem.getDeletedBy());
theTrashItem.setDeletedTime(trashItem.getDeletedTime());
theTrashItem.setOriginalParentId(trashItem.getOriginalParentId());
theTrashItem.setDeletedFrom(trashItem.getDeletedFrom());
theTrashItem.setLenght(trashItem.getLenght());
theTrashItem.setMimeType(trashItem.getMimeType());
System.out.println(theTrashItem);
//theTrashItem.setFolder(trashItem.getFolder()); ??? NULL POINTER
}
theItem.setId(item.getId());
theItem.setName(itemName);

View File

@ -1,21 +1,20 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.trash;
package org.gcube.common.storagehubwrapper.shared.tohl;
import java.util.Calendar;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItemType;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
/**
* The Interface WorkspaceTrashItem.
* The Interface TrashedItem.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* Jun 15, 2018
* Sep 21, 2018
*/
public interface WorkspaceTrashItem extends WorkspaceFolder {
public interface TrashedItem extends WorkspaceItem {
/**
* Get original parent Id to restore the item.
@ -74,18 +73,4 @@ public interface WorkspaceTrashItem extends WorkspaceFolder {
*/
WorkspaceItemType getType();
/**
* Delete Permanently an item in the trash folder.
*
* @throws InternalErrorException the internal error exception
*/
void deletePermanently() throws InternalErrorException;
/**
* Restore an item in the trash folder.
*
* @throws InternalErrorException the internal error exception
*/
void restore() throws InternalErrorException;
}

View File

@ -0,0 +1,39 @@
/**
*
*/
package org.gcube.common.storagehubwrapper.shared.tohl.impl;
import java.util.Calendar;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.gcube.common.storagehubwrapper.shared.tohl.TrashedItem;
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
public class TrashItem extends WorkspaceItem implements TrashedItem{
/**
*
*/
private static final long serialVersionUID = -2070116308660673836L;
String name;
String deletedBy;
String originalParentId;
String deletedFrom;
Calendar deletedTime;
String mimeType;
long lenght;
boolean isFolder;
}

View File

@ -5,6 +5,7 @@ package org.gcube.common.storagehubwrapper.shared.tohl.trash;
import java.util.List;
import org.gcube.common.storagehubwrapper.shared.tohl.TrashedItem;
import org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceFolder;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.InternalErrorException;
import org.gcube.common.storagehubwrapper.shared.tohl.exceptions.ItemNotFoundException;
@ -60,7 +61,7 @@ public interface WorkspaceTrashFolder extends WorkspaceFolder {
* @deprecated use {@link #getChildren()} instead
*/
@Deprecated
public List<WorkspaceTrashItem> listTrashItems() throws InternalErrorException, ItemNotFoundException;
public List<TrashedItem> listTrashItems() throws InternalErrorException, ItemNotFoundException;
/**
* Get Trash Item by Id.
@ -71,7 +72,7 @@ public interface WorkspaceTrashFolder extends WorkspaceFolder {
* @deprecated use {@link org.gcube.portal.storagehubwrapper.server.tohl.homelibrary.home.workspace.Workspace#getItem(String itemId)} instead
*/
@Deprecated
public WorkspaceTrashItem getTrashItemById(String id) throws InternalErrorException;
public TrashedItem getTrashItemById(String id) throws InternalErrorException;