Integrated with #19058

This commit is contained in:
Francesco Mangiacrapa 2020-05-18 18:11:28 +02:00
parent e0198673f1
commit 1bac6d28a2
4 changed files with 189 additions and 161 deletions

View File

@ -503,8 +503,8 @@ public interface GWTWorkspaceService extends RemoteService {
* @throws Exception * @throws Exception
* the exception * the exception
*/ */
TrashOperationContent executeOperationOnTrash(List<String> listTrashItemIds, WorkspaceTrashOperation operation) TrashOperationContent executeOperationOnTrash(List<String> listTrashItemIds, List<String> destinationFolderIds,
throws Exception; WorkspaceTrashOperation operation) throws Exception;
/** /**

View File

@ -29,6 +29,7 @@ import org.gcube.portlets.user.workspace.shared.accounting.GxtAccountingField;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
// TODO: Auto-generated Javadoc
/** /**
* The Interface GWTWorkspaceServiceAsync. * The Interface GWTWorkspaceServiceAsync.
* *
@ -39,36 +40,34 @@ public interface GWTWorkspaceServiceAsync {
/** /**
* Gets the user workspace size. * Gets the user workspace size.
* *
* @param callback * @param callback the callback
* the callback * @return the user workspace size
*/ */
void getUserWorkspaceSize(AsyncCallback<String> callback); void getUserWorkspaceSize(AsyncCallback<String> callback);
/** /**
* Gets the root for tree. * Gets the root for tree.
* *
* @param callback * @param callback the callback
* the callback * @return the root for tree
*/ */
void getRootForTree(AsyncCallback<FolderModel> callback); void getRootForTree(AsyncCallback<FolderModel> callback);
/** /**
* Gets the folder children. * Gets the folder children.
* *
* @param folder * @param folder the folder
* the folder * @param callback the callback
* @param callback * @return the folder children
* the callback
*/ */
void getFolderChildren(FolderModel folder, AsyncCallback<List<FileModel>> callback); void getFolderChildren(FolderModel folder, AsyncCallback<List<FileModel>> callback);
/** /**
* Gets the folder children for file grid. * Gets the folder children for file grid.
* *
* @param folder * @param folder the folder
* the folder * @param callback the callback
* @param callback * @return the folder children for file grid
* the callback
*/ */
void getFolderChildrenForFileGrid(FileModel folder, AsyncCallback<List<FileGridModel>> callback); void getFolderChildrenForFileGrid(FileModel folder, AsyncCallback<List<FileGridModel>> callback);
@ -113,22 +112,19 @@ public interface GWTWorkspaceServiceAsync {
/** /**
* Gets the children sub tree to root by identifier. * Gets the children sub tree to root by identifier.
* *
* @param itemIdentifier * @param itemIdentifier the item identifier
* the item identifier * @param callback the callback
* @param callback * @return the children sub tree to root by identifier
* the callback
*/ */
void getChildrenSubTreeToRootByIdentifier(String itemIdentifier, AsyncCallback<ArrayList<SubTree>> callback); void getChildrenSubTreeToRootByIdentifier(String itemIdentifier, AsyncCallback<ArrayList<SubTree>> callback);
/** /**
* Gets the items by search name. * Gets the items by search name.
* *
* @param text * @param text the text
* the text * @param folderId the folder id
* @param folderId * @param callback the callback
* the folder id * @return the items by search name
* @param callback
* the callback
*/ */
void getItemsBySearchName(String text, String folderId, AsyncCallback<List<FileGridModel>> callback); void getItemsBySearchName(String text, String folderId, AsyncCallback<List<FileGridModel>> callback);
@ -178,31 +174,25 @@ public interface GWTWorkspaceServiceAsync {
// void getAllSmartFolders(AsyncCallback<List<SmartFolderModel>> callback); // void getAllSmartFolders(AsyncCallback<List<SmartFolderModel>> callback);
/** /**
* Gets the image by id. * Gets the image by id.
* *
* @param identifier * @param identifier the identifier
* the identifier * @param isInteralImage the is interal image
* @param isInteralImage * @param fullDetails the full details
* the is interal image * @param callback the callback
* @param fullDetails * @return the image by id
* the full details */
* @param callback
* the callback
*/
void getImageById(String identifier, boolean isInteralImage, boolean fullDetails, void getImageById(String identifier, boolean isInteralImage, boolean fullDetails,
AsyncCallback<GWTWorkspaceItem> callback); AsyncCallback<GWTWorkspaceItem> callback);
/** /**
* Gets the url by id. * Gets the url by id.
* *
* @param identifier * @param identifier the identifier
* the identifier * @param isInternalUrl the is internal url
* @param isInternalUrl * @param fullDetails the full details
* the is internal url * @param callback the callback
* @param fullDetails * @return the url by id
* the full details
* @param callback
* the callback
*/ */
void getUrlById(String identifier, boolean isInternalUrl, boolean fullDetails, void getUrlById(String identifier, boolean isInternalUrl, boolean fullDetails,
AsyncCallback<GWTWorkspaceItem> callback); AsyncCallback<GWTWorkspaceItem> callback);
@ -257,15 +247,13 @@ public interface GWTWorkspaceServiceAsync {
// void getAllScope(AsyncCallback<List<ScopeModel>> callback); // void getAllScope(AsyncCallback<List<ScopeModel>> callback);
/** /**
* Gets the list parents by item identifier. * Gets the list parents by item identifier.
* *
* @param itemIdentifier * @param itemIdentifier the item identifier
* the item identifier * @param includeItemAsParent the include item as parent
* @param includeItemAsParent * @param callback the callback
* the include item as parent * @return the list parents by item identifier
* @param callback */
* the callback
*/
void getListParentsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent, void getListParentsByItemIdentifier(String itemIdentifier, boolean includeItemAsParent,
AsyncCallback<List<FileModel>> callback); AsyncCallback<List<FileModel>> callback);
@ -284,10 +272,9 @@ public interface GWTWorkspaceServiceAsync {
/** /**
* Gets the item creation date by id. * Gets the item creation date by id.
* *
* @param itemId * @param itemId the item id
* the item id * @param asyncCallback the async callback
* @param asyncCallback * @return the item creation date by id
* the async callback
*/ */
void getItemCreationDateById(String itemId, AsyncCallback<Date> asyncCallback); void getItemCreationDateById(String itemId, AsyncCallback<Date> asyncCallback);
@ -314,96 +301,84 @@ public interface GWTWorkspaceServiceAsync {
/** /**
* Gets the parent by item id. * Gets the parent by item id.
* *
* @param identifier * @param identifier the identifier
* the identifier * @param asyncCallback the async callback
* @param asyncCallback * @return the parent by item id
* the async callback
*/ */
void getParentByItemId(String identifier, AsyncCallback<FileModel> asyncCallback); void getParentByItemId(String identifier, AsyncCallback<FileModel> asyncCallback);
/** /**
* Gets the accounting readers. * Gets the accounting readers.
* *
* @param identifier * @param identifier the identifier
* the identifier * @param callback the callback
* @param callback * @return the accounting readers
* the callback
*/ */
void getAccountingReaders(String identifier, AsyncCallback<List<GxtAccountingField>> callback); void getAccountingReaders(String identifier, AsyncCallback<List<GxtAccountingField>> callback);
/** /**
* Gets the accounting history. * Gets the accounting history.
* *
* @param identifier * @param identifier the identifier
* the identifier * @param callback the callback
* @param callback * @return the accounting history
* the callback
*/ */
void getAccountingHistory(String identifier, AsyncCallback<List<GxtAccountingField>> callback); void getAccountingHistory(String identifier, AsyncCallback<List<GxtAccountingField>> callback);
/** /**
* Gets the item for file grid. * Gets the item for file grid.
* *
* @param itemId * @param itemId the item id
* the item id * @param callback the callback
* @param callback * @return the item for file grid
* the callback
*/ */
void getItemForFileGrid(String itemId, AsyncCallback<FileGridModel> callback); void getItemForFileGrid(String itemId, AsyncCallback<FileGridModel> callback);
/** /**
* Gets the item for file tree. * Gets the item for file tree.
* *
* @param itemId * @param itemId the item id
* the item id * @param asyncCallback the async callback
* @param asyncCallback * @return the item for file tree
* the async callback
*/ */
void getItemForFileTree(String itemId, AsyncCallback<FileModel> asyncCallback); void getItemForFileTree(String itemId, AsyncCallback<FileModel> asyncCallback);
/** /**
* Gets the folder children for file grid by id. * Gets the folder children for file grid by id.
* *
* @param folderId * @param folderId the folder id
* the folder id * @param callback the callback
* @param callback * @return the folder children for file grid by id
* the callback
*/ */
void getFolderChildrenForFileGridById(String folderId, AsyncCallback<List<FileGridModel>> callback); void getFolderChildrenForFileGridById(String folderId, AsyncCallback<List<FileGridModel>> callback);
/** /**
* Gets the short url. * Gets the short url.
* *
* @param longUrl * @param longUrl the long url
* the long url * @param callback the callback
* @param callback * @return the short url
* the callback
*/ */
void getShortUrl(String longUrl, AsyncCallback<String> callback); void getShortUrl(String longUrl, AsyncCallback<String> callback);
/** /**
* Gets the public link for file item id. * Gets the public link for file item id.
* *
* @param itemId * @param itemId the item id
* the item id * @param shortenUrl the shorten url
* @param shortenUrl * @param callback the callback
* the shorten url * @return the public link for file item id
* @param callback
* the callback
*/ */
void getPublicLinkForFileItemId(String itemId, boolean shortenUrl, AsyncCallback<PublicLink> callback); void getPublicLinkForFileItemId(String itemId, boolean shortenUrl, AsyncCallback<PublicLink> callback);
/** /**
* Gets the public link for file item id to version. * Gets the public link for file item id to version.
* *
* @param itemId * @param itemId the item id
* the item id * @param version the version
* @param version * @param shortenUrl the shorten url
* the version * @param callback the callback
* @param shortenUrl * @return the public link for file item id to version
* the shorten url
* @param callback
* the callback
*/ */
void getPublicLinkForFileItemIdToVersion(String itemId, String version, boolean shortenUrl, void getPublicLinkForFileItemIdToVersion(String itemId, String version, boolean shortenUrl,
AsyncCallback<PublicLink> callback); AsyncCallback<PublicLink> callback);
@ -453,18 +428,17 @@ public interface GWTWorkspaceServiceAsync {
/** /**
* Gets the my login. * Gets the my login.
* *
* @param currentPortletUrl * @param currentPortletUrl the current portlet url
* the current portlet url * @param callback the callback
* @param callback * @return the my login
* the callback
*/ */
void getMyLogin(String currentPortletUrl, AsyncCallback<UserBean> callback); void getMyLogin(String currentPortletUrl, AsyncCallback<UserBean> callback);
/** /**
* Gets the trash content. * Gets the trash content.
* *
* @param callback * @param callback the callback
* the callback * @return the trash content
*/ */
void getTrashContent(AsyncCallback<List<FileTrashedModel>> callback); void getTrashContent(AsyncCallback<List<FileTrashedModel>> callback);
@ -478,42 +452,40 @@ public interface GWTWorkspaceServiceAsync {
*/ */
void updateTrashContent(WorkspaceTrashOperation operation, AsyncCallback<TrashContent> callback); void updateTrashContent(WorkspaceTrashOperation operation, AsyncCallback<TrashContent> callback);
/** /**
* Execute operation on trash. * Execute operation on trash.
* *
* @param listTrashItemIds * @param listTrashItemIds the list trash item ids
* the list trash item ids * @param destinationFolderIds the destination folder ids
* @param operation * @param operation the operation
* the operation * @param callback the callback
* @param callback
* the callback
*/ */
void executeOperationOnTrash(List<String> listTrashItemIds, WorkspaceTrashOperation operation, void executeOperationOnTrash(List<String> listTrashItemIds, List<String> destinationFolderIds, WorkspaceTrashOperation operation,
AsyncCallback<TrashOperationContent> callback); AsyncCallback<TrashOperationContent> callback);
/** /**
* Gets the user workspace total items. * Gets the user workspace total items.
* *
* @param callback * @param callback the callback
* the callback * @return the user workspace total items
*/ */
void getUserWorkspaceTotalItems(AsyncCallback<Long> callback); void getUserWorkspaceTotalItems(AsyncCallback<Long> callback);
/** /**
* Gets the user workspace quote. * Gets the user workspace quote.
* *
* @param callback * @param callback the callback
* the callback * @return the user workspace quote
*/ */
void getUserWorkspaceQuote(AsyncCallback<WorkspaceUserQuote> callback); void getUserWorkspaceQuote(AsyncCallback<WorkspaceUserQuote> callback);
/** /**
* Gets the item description by id. * Gets the item description by id.
* *
* @param identifier * @param identifier the identifier
* the identifier * @param callback the callback
* @param callback * @return the item description by id
* the callback
*/ */
void getItemDescriptionById(String identifier, AsyncCallback<String> callback); void getItemDescriptionById(String identifier, AsyncCallback<String> callback);
@ -530,10 +502,9 @@ public interface GWTWorkspaceServiceAsync {
/** /**
* Gets the HTML gcube item properties. * Gets the HTML gcube item properties.
* *
* @param itemId * @param itemId the item id
* the item id * @param callback the callback
* @param callback * @return the HTML gcube item properties
* the callback
*/ */
void getHTMLGcubeItemProperties(String itemId, AsyncCallback<String> callback); void getHTMLGcubeItemProperties(String itemId, AsyncCallback<String> callback);
@ -552,8 +523,8 @@ public interface GWTWorkspaceServiceAsync {
/** /**
* Gets the my first name. * Gets the my first name.
* *
* @param callback * @param callback the callback
* the callback * @return the my first name
*/ */
void getMyFirstName(AsyncCallback<String> callback); void getMyFirstName(AsyncCallback<String> callback);
@ -573,20 +544,18 @@ public interface GWTWorkspaceServiceAsync {
/** /**
* Gets the servlet context path. * Gets the servlet context path.
* *
* @param protocol * @param protocol the protocol
* the protocol * @param callback the callback
* @param callback * @return the servlet context path
* the callback
*/ */
void getServletContextPath(String protocol, AsyncCallback<String> callback); void getServletContextPath(String protocol, AsyncCallback<String> callback);
/** /**
* Gets the version history. * Gets the version history.
* *
* @param fileIdentifier * @param fileIdentifier the file identifier
* the file identifier * @param callback the callback
* @param callback * @return the version history
* the callback
*/ */
void getVersionHistory(String fileIdentifier, AsyncCallback<List<FileVersionModel>> callback); void getVersionHistory(String fileIdentifier, AsyncCallback<List<FileVersionModel>> callback);
@ -608,12 +577,10 @@ public interface GWTWorkspaceServiceAsync {
/** /**
* Gets the images for folder. * Gets the images for folder.
* *
* @param folderId * @param folderId the folder id
* the folder id * @param currentImageId the current image id
* @param currentImageId * @param asyncCallback the async callback
* the current image id * @return the images for folder
* @param asyncCallback
* the async callback
*/ */
void getImagesForFolder(String folderId, String currentImageId, void getImagesForFolder(String folderId, String currentImageId,
AsyncCallback<List<GWTWorkspaceItem>> asyncCallback); AsyncCallback<List<GWTWorkspaceItem>> asyncCallback);
@ -621,8 +588,8 @@ public interface GWTWorkspaceServiceAsync {
/** /**
* Gets the list of vr es for logged user. * Gets the list of vr es for logged user.
* *
* @param callback * @param callback the callback
* the callback * @return the list of VR es for logged user
*/ */
void getListOfVREsForLoggedUser(AsyncCallback<List<GcubeVRE>> callback); void getListOfVREsForLoggedUser(AsyncCallback<List<GcubeVRE>> callback);
@ -639,10 +606,9 @@ public interface GWTWorkspaceServiceAsync {
/** /**
* Gets the link for send to switch board. * Gets the link for send to switch board.
* *
* @param itemId * @param itemId the item id
* the item id * @param callback the callback
* @param callback * @return the link for send to switch board
* the callback
*/ */
void getLinkForSendToSwitchBoard(String itemId, AsyncCallback<String> callback); void getLinkForSendToSwitchBoard(String itemId, AsyncCallback<String> callback);

View File

@ -86,6 +86,7 @@ import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.service.UserLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil;
@ -944,7 +945,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
* the exception * the exception
*/ */
@Override @Override
public TrashOperationContent executeOperationOnTrash(List<String> listTrashItemIds, public TrashOperationContent executeOperationOnTrash(List<String> listTrashItemIds, List<String> destinationFolderIds,
WorkspaceTrashOperation operation) throws Exception { WorkspaceTrashOperation operation) throws Exception {
workspaceLogger.info("Get TrashContent, operation: " + operation); workspaceLogger.info("Get TrashContent, operation: " + operation);
@ -997,12 +998,20 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
case RESTORE: { case RESTORE: {
boolean restored = false; boolean restored = false;
int index = 0;
for (String trashItemId : listTrashItemIds) { for (String trashItemId : listTrashItemIds) {
try { try {
org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem trashedItem = workspace org.gcube.common.storagehubwrapper.shared.tohl.WorkspaceItem trashedItem = workspace
.getItem(trashItemId); .getItem(trashItemId);
if (trashedItem != null && trashedItem.isTrashed()) { 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); listUpdatedTrashIds.add(trashItemId);
restored = true; restored = true;
} }
@ -1013,6 +1022,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
fakeFile.setIdentifier(trashItemId); fakeFile.setIdentifier(trashItemId);
listContentError.add(fakeFile); listContentError.add(fakeFile);
} }
index++;
} }
String label = listTrashItemIds.size() > 1 ? "items" : "item"; String label = listTrashItemIds.size() > 1 ? "items" : "item";

View File

@ -5,56 +5,108 @@ package org.gcube.portlets.user.workspace.shared;
import java.util.List; import java.util.List;
// TODO: Auto-generated Javadoc
/** /**
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it * The Class TrashOperationContent.
* Feb 17, 2014
* *
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* May 18, 2020
*/ */
public class TrashOperationContent extends TrashContent{ public class TrashOperationContent extends TrashContent{
private static final long serialVersionUID = 3089944053784656200L;
/**
*
*/
private static final long serialVersionUID = -7825694364945907231L;
private List<String> listTrashIds; private List<String> listTrashIds;
private List<String> listDestinationFolderIds;
private WorkspaceTrashOperation operation; private WorkspaceTrashOperation operation;
/**
* Instantiates a new trash operation content.
*/
public TrashOperationContent() { public TrashOperationContent() {
} }
/**
* Instantiates a new trash operation content.
*
* @param operation the operation
* @param listTrashIds the list trash ids
*/
public TrashOperationContent(WorkspaceTrashOperation operation, List<String> listTrashIds) { public TrashOperationContent(WorkspaceTrashOperation operation, List<String> listTrashIds) {
this.listTrashIds = listTrashIds; this.listTrashIds = listTrashIds;
this.operation = operation; 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<String> listTrashIds, List<String> 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<String> listTrashIds) { public void setListTrashIds(List<String> listTrashIds) {
this.listTrashIds = listTrashIds; this.listTrashIds = listTrashIds;
} }
/**
* Gets the operation.
*
* @return the operation
*/
public WorkspaceTrashOperation getOperation() { public WorkspaceTrashOperation getOperation() {
return operation; return operation;
} }
/**
* Sets the operation.
*
* @param operation the new operation
*/
public void setOperation(WorkspaceTrashOperation operation) { public void setOperation(WorkspaceTrashOperation operation) {
this.operation = operation; this.operation = operation;
} }
/**
* Gets the list trash ids.
*
* @return the list trash ids
*/
public List<String> getListTrashIds() { public List<String> getListTrashIds() {
return listTrashIds; return listTrashIds;
} }
/**
* Gets the list destination folder ids.
*
* @return the list destination folder ids
*/
public List<String> getListDestinationFolderIds() {
return listDestinationFolderIds;
}
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); return "TrashOperationContent [listTrashIds=" + listTrashIds + ", listDestinationFolderIds="
builder.append("TrashOperationContent [listTrashIds="); + listDestinationFolderIds + ", operation=" + operation + "]";
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();
} }
} }