Integrated with #19058

task/19600
Francesco Mangiacrapa 4 years ago
parent e0198673f1
commit 1bac6d28a2

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

@ -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<String> callback);
/**
* Gets the root for tree.
*
* @param callback
* the callback
* @param callback the callback
* @return the root for tree
*/
void getRootForTree(AsyncCallback<FolderModel> 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<List<FileModel>> 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<List<FileGridModel>> 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<ArrayList<SubTree>> 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<List<FileGridModel>> callback);
@ -178,31 +174,25 @@ public interface GWTWorkspaceServiceAsync {
// void getAllSmartFolders(AsyncCallback<List<SmartFolderModel>> 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<GWTWorkspaceItem> 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<GWTWorkspaceItem> callback);
@ -257,15 +247,13 @@ public interface GWTWorkspaceServiceAsync {
// void getAllScope(AsyncCallback<List<ScopeModel>> 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<List<FileModel>> 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<Date> 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<FileModel> 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<List<GxtAccountingField>> 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<List<GxtAccountingField>> 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<FileGridModel> 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<FileModel> 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<List<FileGridModel>> 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<String> 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<PublicLink> 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<PublicLink> 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<UserBean> callback);
/**
* Gets the trash content.
*
* @param callback
* the callback
* @param callback the callback
* @return the trash content
*/
void getTrashContent(AsyncCallback<List<FileTrashedModel>> callback);
@ -478,42 +452,40 @@ public interface GWTWorkspaceServiceAsync {
*/
void updateTrashContent(WorkspaceTrashOperation operation, AsyncCallback<TrashContent> 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<String> listTrashItemIds, WorkspaceTrashOperation operation,
void executeOperationOnTrash(List<String> listTrashItemIds, List<String> destinationFolderIds, WorkspaceTrashOperation operation,
AsyncCallback<TrashOperationContent> callback);
/**
* Gets the user workspace total items.
*
* @param callback
* the callback
* @param callback the callback
* @return the user workspace total items
*/
void getUserWorkspaceTotalItems(AsyncCallback<Long> callback);
/**
* Gets the user workspace quote.
*
* @param callback
* the callback
* @param callback the callback
* @return the user workspace quote
*/
void getUserWorkspaceQuote(AsyncCallback<WorkspaceUserQuote> 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<String> 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<String> 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<String> 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<String> 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<List<FileVersionModel>> 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<List<GWTWorkspaceItem>> 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<List<GcubeVRE>> 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<String> callback);

@ -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<String> listTrashItemIds,
public TrashOperationContent executeOperationOnTrash(List<String> listTrashItemIds, List<String> 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";

@ -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<String> listTrashIds;
private List<String> 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<String> 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<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) {
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<String> getListTrashIds() {
return listTrashIds;
}
/**
* Gets the list destination folder ids.
*
* @return the list destination folder ids
*/
public List<String> 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 + "]";
}
}

Loading…
Cancel
Save