diff --git a/src/main/java/org/gcube/common/storagehubwrapper/server/converter/HLMapper.java b/src/main/java/org/gcube/common/storagehubwrapper/server/converter/HLMapper.java index 1244a70..f5ccd24 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/server/converter/HLMapper.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/server/converter/HLMapper.java @@ -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); diff --git a/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/trash/WorkspaceTrashItem.java b/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/TrashedItem.java similarity index 67% rename from src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/trash/WorkspaceTrashItem.java rename to src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/TrashedItem.java index b87819e..3ae023c 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/trash/WorkspaceTrashItem.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/TrashedItem.java @@ -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; - } \ No newline at end of file diff --git a/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/impl/TrashItem.java b/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/impl/TrashItem.java new file mode 100644 index 0000000..5cd4b30 --- /dev/null +++ b/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/impl/TrashItem.java @@ -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; + +} diff --git a/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/trash/WorkspaceTrashFolder.java b/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/trash/WorkspaceTrashFolder.java index 058d1e3..32792d5 100644 --- a/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/trash/WorkspaceTrashFolder.java +++ b/src/main/java/org/gcube/common/storagehubwrapper/shared/tohl/trash/WorkspaceTrashFolder.java @@ -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 listTrashItems() throws InternalErrorException, ItemNotFoundException; + public List 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;