diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java index 6062f13..39194fb 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java @@ -503,8 +503,8 @@ public interface GWTWorkspaceService extends RemoteService { * @throws Exception * the exception */ - TrashOperationContent executeOperationOnTrash(List listTrashItemIds, WorkspaceTrashOperation operation) - throws Exception; + TrashOperationContent executeOperationOnTrash(List listTrashItemIds, List destinationFolderIds, + WorkspaceTrashOperation operation) throws Exception; /** diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java index 20cfb21..1d87aae 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java @@ -29,6 +29,7 @@ import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField; import com.google.gwt.user.client.rpc.AsyncCallback; +// TODO: Auto-generated Javadoc /** * The Interface GWTWorkspaceServiceAsync. * @@ -39,36 +40,34 @@ public interface GWTWorkspaceServiceAsync { /** * Gets the user workspace size. * - * @param callback - * the callback + * @param callback the callback + * @return the user workspace size */ void getUserWorkspaceSize(AsyncCallback callback); /** * Gets the root for tree. * - * @param callback - * the callback + * @param callback the callback + * @return the root for tree */ void getRootForTree(AsyncCallback callback); /** * Gets the folder children. * - * @param folder - * the folder - * @param callback - * the callback + * @param folder the folder + * @param callback the callback + * @return the folder children */ void getFolderChildren(FolderModel folder, AsyncCallback> callback); /** * Gets the folder children for file grid. * - * @param folder - * the folder - * @param callback - * the callback + * @param folder the folder + * @param callback the callback + * @return the folder children for file grid */ void getFolderChildrenForFileGrid(FileModel folder, AsyncCallback> callback); @@ -113,22 +112,19 @@ public interface GWTWorkspaceServiceAsync { /** * Gets the children sub tree to root by identifier. * - * @param itemIdentifier - * the item identifier - * @param callback - * the callback + * @param itemIdentifier the item identifier + * @param callback the callback + * @return the children sub tree to root by identifier */ void getChildrenSubTreeToRootByIdentifier(String itemIdentifier, AsyncCallback> callback); /** * Gets the items by search name. * - * @param text - * the text - * @param folderId - * the folder id - * @param callback - * the callback + * @param text the text + * @param folderId the folder id + * @param callback the callback + * @return the items by search name */ void getItemsBySearchName(String text, String folderId, AsyncCallback> callback); @@ -178,31 +174,25 @@ public interface GWTWorkspaceServiceAsync { // void getAllSmartFolders(AsyncCallback> callback); /** - * Gets the image by id. - * - * @param identifier - * the identifier - * @param isInteralImage - * the is interal image - * @param fullDetails - * the full details - * @param callback - * the callback - */ + * Gets the image by id. + * + * @param identifier the identifier + * @param isInteralImage the is interal image + * @param fullDetails the full details + * @param callback the callback + * @return the image by id + */ void getImageById(String identifier, boolean isInteralImage, boolean fullDetails, AsyncCallback callback); /** * Gets the url by id. * - * @param identifier - * the identifier - * @param isInternalUrl - * the is internal url - * @param fullDetails - * the full details - * @param callback - * the callback + * @param identifier the identifier + * @param isInternalUrl the is internal url + * @param fullDetails the full details + * @param callback the callback + * @return the url by id */ void getUrlById(String identifier, boolean isInternalUrl, boolean fullDetails, AsyncCallback callback); @@ -257,15 +247,13 @@ public interface GWTWorkspaceServiceAsync { // void getAllScope(AsyncCallback> callback); /** - * Gets the list parents by item identifier. - * - * @param itemIdentifier - * the item identifier - * @param includeItemAsParent - * the include item as parent - * @param callback - * the callback - */ + * Gets the list parents by item identifier. + * + * @param itemIdentifier the item identifier + * @param includeItemAsParent the include item as parent + * @param callback the callback + * @return the list parents by item identifier + */ void getListParentsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent, AsyncCallback> callback); @@ -284,10 +272,9 @@ public interface GWTWorkspaceServiceAsync { /** * Gets the item creation date by id. * - * @param itemId - * the item id - * @param asyncCallback - * the async callback + * @param itemId the item id + * @param asyncCallback the async callback + * @return the item creation date by id */ void getItemCreationDateById(String itemId, AsyncCallback asyncCallback); @@ -314,96 +301,84 @@ public interface GWTWorkspaceServiceAsync { /** * Gets the parent by item id. * - * @param identifier - * the identifier - * @param asyncCallback - * the async callback + * @param identifier the identifier + * @param asyncCallback the async callback + * @return the parent by item id */ void getParentByItemId(String identifier, AsyncCallback asyncCallback); /** * Gets the accounting readers. * - * @param identifier - * the identifier - * @param callback - * the callback + * @param identifier the identifier + * @param callback the callback + * @return the accounting readers */ void getAccountingReaders(String identifier, AsyncCallback> callback); /** * Gets the accounting history. * - * @param identifier - * the identifier - * @param callback - * the callback + * @param identifier the identifier + * @param callback the callback + * @return the accounting history */ void getAccountingHistory(String identifier, AsyncCallback> callback); /** * Gets the item for file grid. * - * @param itemId - * the item id - * @param callback - * the callback + * @param itemId the item id + * @param callback the callback + * @return the item for file grid */ void getItemForFileGrid(String itemId, AsyncCallback callback); /** * Gets the item for file tree. * - * @param itemId - * the item id - * @param asyncCallback - * the async callback + * @param itemId the item id + * @param asyncCallback the async callback + * @return the item for file tree */ void getItemForFileTree(String itemId, AsyncCallback asyncCallback); /** * Gets the folder children for file grid by id. * - * @param folderId - * the folder id - * @param callback - * the callback + * @param folderId the folder id + * @param callback the callback + * @return the folder children for file grid by id */ void getFolderChildrenForFileGridById(String folderId, AsyncCallback> callback); /** * Gets the short url. * - * @param longUrl - * the long url - * @param callback - * the callback + * @param longUrl the long url + * @param callback the callback + * @return the short url */ void getShortUrl(String longUrl, AsyncCallback callback); /** * Gets the public link for file item id. * - * @param itemId - * the item id - * @param shortenUrl - * the shorten url - * @param callback - * the callback + * @param itemId the item id + * @param shortenUrl the shorten url + * @param callback the callback + * @return the public link for file item id */ void getPublicLinkForFileItemId(String itemId, boolean shortenUrl, AsyncCallback callback); /** * Gets the public link for file item id to version. * - * @param itemId - * the item id - * @param version - * the version - * @param shortenUrl - * the shorten url - * @param callback - * the callback + * @param itemId the item id + * @param version the version + * @param shortenUrl the shorten url + * @param callback the callback + * @return the public link for file item id to version */ void getPublicLinkForFileItemIdToVersion(String itemId, String version, boolean shortenUrl, AsyncCallback callback); @@ -453,18 +428,17 @@ public interface GWTWorkspaceServiceAsync { /** * Gets the my login. * - * @param currentPortletUrl - * the current portlet url - * @param callback - * the callback + * @param currentPortletUrl the current portlet url + * @param callback the callback + * @return the my login */ void getMyLogin(String currentPortletUrl, AsyncCallback callback); /** * Gets the trash content. * - * @param callback - * the callback + * @param callback the callback + * @return the trash content */ void getTrashContent(AsyncCallback> callback); @@ -478,42 +452,40 @@ public interface GWTWorkspaceServiceAsync { */ void updateTrashContent(WorkspaceTrashOperation operation, AsyncCallback callback); + /** * Execute operation on trash. * - * @param listTrashItemIds - * the list trash item ids - * @param operation - * the operation - * @param callback - * the callback + * @param listTrashItemIds the list trash item ids + * @param destinationFolderIds the destination folder ids + * @param operation the operation + * @param callback the callback */ - void executeOperationOnTrash(List listTrashItemIds, WorkspaceTrashOperation operation, + void executeOperationOnTrash(List listTrashItemIds, List destinationFolderIds, WorkspaceTrashOperation operation, AsyncCallback callback); /** * Gets the user workspace total items. * - * @param callback - * the callback + * @param callback the callback + * @return the user workspace total items */ void getUserWorkspaceTotalItems(AsyncCallback callback); /** * Gets the user workspace quote. * - * @param callback - * the callback + * @param callback the callback + * @return the user workspace quote */ void getUserWorkspaceQuote(AsyncCallback callback); /** * Gets the item description by id. * - * @param identifier - * the identifier - * @param callback - * the callback + * @param identifier the identifier + * @param callback the callback + * @return the item description by id */ void getItemDescriptionById(String identifier, AsyncCallback callback); @@ -530,10 +502,9 @@ public interface GWTWorkspaceServiceAsync { /** * Gets the HTML gcube item properties. * - * @param itemId - * the item id - * @param callback - * the callback + * @param itemId the item id + * @param callback the callback + * @return the HTML gcube item properties */ void getHTMLGcubeItemProperties(String itemId, AsyncCallback callback); @@ -552,8 +523,8 @@ public interface GWTWorkspaceServiceAsync { /** * Gets the my first name. * - * @param callback - * the callback + * @param callback the callback + * @return the my first name */ void getMyFirstName(AsyncCallback callback); @@ -573,20 +544,18 @@ public interface GWTWorkspaceServiceAsync { /** * Gets the servlet context path. * - * @param protocol - * the protocol - * @param callback - * the callback + * @param protocol the protocol + * @param callback the callback + * @return the servlet context path */ void getServletContextPath(String protocol, AsyncCallback callback); /** * Gets the version history. * - * @param fileIdentifier - * the file identifier - * @param callback - * the callback + * @param fileIdentifier the file identifier + * @param callback the callback + * @return the version history */ void getVersionHistory(String fileIdentifier, AsyncCallback> callback); @@ -608,12 +577,10 @@ public interface GWTWorkspaceServiceAsync { /** * Gets the images for folder. * - * @param folderId - * the folder id - * @param currentImageId - * the current image id - * @param asyncCallback - * the async callback + * @param folderId the folder id + * @param currentImageId the current image id + * @param asyncCallback the async callback + * @return the images for folder */ void getImagesForFolder(String folderId, String currentImageId, AsyncCallback> asyncCallback); @@ -621,8 +588,8 @@ public interface GWTWorkspaceServiceAsync { /** * Gets the list of vr es for logged user. * - * @param callback - * the callback + * @param callback the callback + * @return the list of VR es for logged user */ void getListOfVREsForLoggedUser(AsyncCallback> callback); @@ -639,10 +606,9 @@ public interface GWTWorkspaceServiceAsync { /** * Gets the link for send to switch board. * - * @param itemId - * the item id - * @param callback - * the callback + * @param itemId the item id + * @param callback the callback + * @return the link for send to switch board */ void getLinkForSendToSwitchBoard(String itemId, AsyncCallback callback); diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index b94dbf4..0236413 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -86,6 +86,7 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.liferay.portal.service.UserLocalServiceUtil; @@ -944,7 +945,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT * the exception */ @Override - public TrashOperationContent executeOperationOnTrash(List listTrashItemIds, + public TrashOperationContent executeOperationOnTrash(List listTrashItemIds, List destinationFolderIds, WorkspaceTrashOperation operation) throws Exception { workspaceLogger.info("Get TrashContent, operation: " + operation); @@ -997,12 +998,20 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT case RESTORE: { boolean restored = false; + int index = 0; for (String trashItemId : listTrashItemIds) { try { org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem trashedItem = workspace .getItem(trashItemId); if (trashedItem != null && trashedItem.isTrashed()) { - workspace.restoreThrashItem(trashedItem.getId()); + String destFolderId = null; + try { + destFolderId = destinationFolderIds!=null && destinationFolderIds.get(index)!=null?destinationFolderIds.get(index):null; + }catch (IndexOutOfBoundsException e) { + workspaceLogger.debug("No destination folder Id at index: "+index); + } + workspaceLogger.info("Trying to restore the item id: "+trashedItem.getId()+", in the folder id: "+destFolderId); + workspace.restoreThrashItem(trashedItem.getId(), destFolderId); listUpdatedTrashIds.add(trashItemId); restored = true; } @@ -1013,6 +1022,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT fakeFile.setIdentifier(trashItemId); listContentError.add(fakeFile); } + index++; } String label = listTrashItemIds.size() > 1 ? "items" : "item"; diff --git a/src/main/java/org/gcube/portlets/user/workspace/shared/TrashOperationContent.java b/src/main/java/org/gcube/portlets/user/workspace/shared/TrashOperationContent.java index 2bd6fca..c696999 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/shared/TrashOperationContent.java +++ b/src/main/java/org/gcube/portlets/user/workspace/shared/TrashOperationContent.java @@ -5,56 +5,108 @@ package org.gcube.portlets.user.workspace.shared; import java.util.List; + +// TODO: Auto-generated Javadoc /** - * @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it - * Feb 17, 2014 + * The Class TrashOperationContent. * + * @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy) + * May 18, 2020 */ public class TrashOperationContent extends TrashContent{ - private static final long serialVersionUID = 3089944053784656200L; + /** + * + */ + private static final long serialVersionUID = -7825694364945907231L; private List listTrashIds; + private List listDestinationFolderIds; private WorkspaceTrashOperation operation; + /** + * Instantiates a new trash operation content. + */ public TrashOperationContent() { } + /** + * Instantiates a new trash operation content. + * + * @param operation the operation + * @param listTrashIds the list trash ids + */ public TrashOperationContent(WorkspaceTrashOperation operation, List listTrashIds) { this.listTrashIds = listTrashIds; this.operation = operation; } + + /** + * Instantiates a new trash operation content. + * + * @param listTrashIds the list trash ids + * @param listDestinationFolderIds the list destination folder ids + * @param operation the operation + */ + public TrashOperationContent(List listTrashIds, List listDestinationFolderIds, + WorkspaceTrashOperation operation) { + super(); + this.listTrashIds = listTrashIds; + this.listDestinationFolderIds = listDestinationFolderIds; + this.operation = operation; + } + /** + * Sets the list trash ids. + * + * @param listTrashIds the new list trash ids + */ public void setListTrashIds(List listTrashIds) { this.listTrashIds = listTrashIds; } + /** + * Gets the operation. + * + * @return the operation + */ public WorkspaceTrashOperation getOperation() { return operation; } + /** + * Sets the operation. + * + * @param operation the new operation + */ public void setOperation(WorkspaceTrashOperation operation) { this.operation = operation; } + /** + * Gets the list trash ids. + * + * @return the list trash ids + */ public List getListTrashIds() { return listTrashIds; } + /** + * Gets the list destination folder ids. + * + * @return the list destination folder ids + */ + public List getListDestinationFolderIds() { + return listDestinationFolderIds; + } + @Override public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("TrashOperationContent [listTrashIds="); - builder.append(listTrashIds); - builder.append(", operation="); - builder.append(operation); - builder.append(", trashContent="); - builder.append(trashContent); - builder.append(", listErrors="); - builder.append(listErrors); - builder.append("]"); - return builder.toString(); + return "TrashOperationContent [listTrashIds=" + listTrashIds + ", listDestinationFolderIds=" + + listDestinationFolderIds + ", operation=" + operation + "]"; } + }