Enhancement on file versioning #7006
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@142810 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6aaa31fe2a
commit
6e9c1ca93d
|
@ -79,6 +79,7 @@ public class ConstantsExplorer {
|
|||
public static final String PASTEITEM = "Paste";
|
||||
public static final String MESSAGE_REFRESH_FOLDER = "Refresh Folder";
|
||||
public static final String MESSAGE_GET_INFO = "Get Info";
|
||||
public static final String FILE_VERSIONS = "Versions";
|
||||
public static final String MESSAGE_PUBLIC_LINK = "Get Public Link";
|
||||
public static final String MESSAGE_FOLDER_LINK = "Get Folder Link";
|
||||
public static final String MESSAGE_FOLDER_LINK_REMOVE = "Remove Folder Link";
|
||||
|
|
|
@ -39,7 +39,8 @@ public enum WorkspaceOperation {
|
|||
VRE_CHANGE_PERIMISSIONS("CHP", "CHP"),
|
||||
EDIT_PERMISSIONS("EDP", "EDP"), //EDIT PERMISSIONS
|
||||
FOLDER_LINK("FRL", "FRL"), //FOLDER LINK
|
||||
FOLDER_LINK_REMOVE("FPR","FPR"); //FOLDER LINK REMOVE
|
||||
FOLDER_LINK_REMOVE("FPR","FPR"),
|
||||
VERSIONING("VRN", "VRN"); //VERSIONING
|
||||
|
||||
|
||||
private String id; // ID CONTEXT MENU
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
package org.gcube.portlets.user.workspace.client.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
|
||||
/**
|
||||
* The Class FileVersionModel.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 20, 2017
|
||||
*/
|
||||
public class FileVersionModel extends FileModel implements IsSerializable, Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -607019966965449963L;
|
||||
public static final String PATH = "path";
|
||||
public static final String USER_VERSIONING = "user_versioning";
|
||||
|
||||
/**
|
||||
* Instantiates a new file model.
|
||||
*/
|
||||
public FileVersionModel(){
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new file model.
|
||||
*
|
||||
* @param identifier the identifier
|
||||
* @param name the name
|
||||
* @param path the path
|
||||
* @param userFullName the user full name
|
||||
*/
|
||||
public FileVersionModel(String identifier, String name, String path, String userFullName) {
|
||||
setIdentifier(identifier);
|
||||
setName(name);
|
||||
setPath(path);
|
||||
setUser(userFullName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user.
|
||||
*
|
||||
* @param userVersioning the new user
|
||||
*/
|
||||
private void setUser(String userVersioning) {
|
||||
set(USER_VERSIONING, userVersioning);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the path.
|
||||
*
|
||||
* @param path the new path
|
||||
*/
|
||||
private void setPath(String path) {
|
||||
|
||||
set(PATH, path);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the path.
|
||||
*
|
||||
* @return the path
|
||||
*/
|
||||
public String getPath(){
|
||||
return get(PATH);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the user.
|
||||
*
|
||||
* @return the user
|
||||
*/
|
||||
public String getUser(){
|
||||
return get(USER_VERSIONING);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
|
|||
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
|
||||
|
@ -744,7 +745,7 @@ public interface GWTWorkspaceService extends RemoteService{
|
|||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
List<FileModel> getVersionHistory(String fileIdentifier)
|
||||
List<FileVersionModel> getVersionHistory(String fileIdentifier)
|
||||
throws Exception;
|
||||
/**
|
||||
* @param currentVersion
|
||||
|
@ -753,7 +754,7 @@ public interface GWTWorkspaceService extends RemoteService{
|
|||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
List<FileModel> performOperationOnVersionedFile(
|
||||
List<FileVersionModel> performOperationOnVersionedFile(
|
||||
FileModel currentVersion, FileModel selectedVersion,
|
||||
WorkspaceVersioningOperation operation)
|
||||
throws Exception;
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
|
|||
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
|
||||
|
@ -736,12 +737,28 @@ public interface GWTWorkspaceServiceAsync {
|
|||
*/
|
||||
void getServletContextPath(String protocol, AsyncCallback<String> callback);
|
||||
|
||||
void getVersionHistory(
|
||||
String fileIdentifier, AsyncCallback<List<FileModel>> callback);
|
||||
|
||||
/**
|
||||
* Gets the version history.
|
||||
*
|
||||
* @param fileIdentifier the file identifier
|
||||
* @param callback the callback
|
||||
* @return the version history
|
||||
*/
|
||||
void getVersionHistory(
|
||||
String fileIdentifier, AsyncCallback<List<FileVersionModel>> callback);
|
||||
|
||||
/**
|
||||
* Perform operation on versioned file.
|
||||
*
|
||||
* @param currentVersion the current version
|
||||
* @param selectedVersion the selected version
|
||||
* @param operation the operation
|
||||
* @param callback the callback
|
||||
*/
|
||||
void performOperationOnVersionedFile(
|
||||
FileModel currentVersion, FileModel olderVersion,
|
||||
FileModel currentVersion, FileModel selectedVersion,
|
||||
WorkspaceVersioningOperation operation,
|
||||
AsyncCallback<List<FileModel>> callback);
|
||||
AsyncCallback<List<FileVersionModel>> callback);
|
||||
|
||||
}
|
||||
|
|
|
@ -32,11 +32,13 @@ import org.gcube.portlets.user.workspace.client.event.RenameItemEvent;
|
|||
import org.gcube.portlets.user.workspace.client.event.SendMessageEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.UnShareFolderEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.VRESettingPermissionEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.VersioningHistoryShowEvent;
|
||||
import org.gcube.portlets.user.workspace.client.event.WebDavUrlEvent;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
import org.gcube.portlets.user.workspace.client.resources.Resources;
|
||||
import org.gcube.portlets.user.workspace.client.util.FileModelUtils;
|
||||
import org.gcube.portlets.user.workspace.client.view.tree.CutCopyAndPaste.OperationType;
|
||||
import org.gcube.portlets.user.workspace.shared.WorkspaceVersioningOperation;
|
||||
|
||||
import com.extjs.gxt.ui.client.event.MenuEvent;
|
||||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||
|
@ -89,16 +91,10 @@ public class ContextMenuTree {
|
|||
|
||||
previewImage.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||
public void componentSelected(MenuEvent ce) {
|
||||
|
||||
// FileModel selected = treePanel.getSelectionModel().getSelectedItem();
|
||||
|
||||
FileModel selected = listSelectedItems.get(0);
|
||||
|
||||
if(selected!=null){
|
||||
eventBus.fireEvent(new ImagePreviewEvent(selected, ce.getClientX(), ce.getClientY()));
|
||||
}
|
||||
|
||||
//clearListSelectedItems();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -185,6 +181,23 @@ public class ContextMenuTree {
|
|||
contextMenu.add(mnGetInfo);
|
||||
|
||||
|
||||
MenuItem mnFileVersioning = new MenuItem();
|
||||
mnFileVersioning.setId(WorkspaceOperation.VERSIONING.getId());
|
||||
mnFileVersioning.setText(ConstantsExplorer.FILE_VERSIONS);
|
||||
mnFileVersioning.setIcon(Resources.getIconVersioning());
|
||||
|
||||
mnFileVersioning.addSelectionListener(new SelectionListener<MenuEvent>() {
|
||||
public void componentSelected(MenuEvent ce) {
|
||||
|
||||
for (FileModel sel : listSelectedItems) {
|
||||
eventBus.fireEvent(new VersioningHistoryShowEvent(WorkspaceVersioningOperation.SHOW, sel));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
contextMenu.add(mnFileVersioning);
|
||||
|
||||
|
||||
//SHARE LINK
|
||||
MenuItem mnGetLink = new MenuItem();
|
||||
mnGetLink.setId(WorkspaceOperation.SHARE_LINK.getId());
|
||||
|
@ -603,10 +616,8 @@ public class ContextMenuTree {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
contextMenu.add(upload);
|
||||
|
||||
|
||||
MenuItem uploadArchive = new MenuItem();
|
||||
uploadArchive.setId(WorkspaceOperation.UPLOAD_ARCHIVE.getId());
|
||||
uploadArchive.setText(ConstantsExplorer.MESSAGE_UPLOAD_ARCHIVE);
|
||||
|
@ -664,10 +675,8 @@ public class ContextMenuTree {
|
|||
});
|
||||
|
||||
contextMenu.add(changePermission);
|
||||
|
||||
contextMenu.add(new SeparatorMenuItem());
|
||||
|
||||
|
||||
MenuItem addAdministrator = new MenuItem();
|
||||
// addAdministrator.setId(WorkspaceOperation.ADD_ADMINISTRATOR.getId());
|
||||
addAdministrator.setText("Manage Administrator/s");
|
||||
|
@ -783,11 +792,6 @@ public class ContextMenuTree {
|
|||
contextMenu.getItemByItemId(WorkspaceOperation.UPLOAD_ARCHIVE.getId()).setVisible(false); //set invisible upload archive
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.ADD_URL.getId()).setVisible(false); //set invisible add url
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.REFRESH_FOLDER.getId()).setVisible(false); //set invisible refresh
|
||||
// contextMenu.getItemByItemId(WorkspaceOperation.SHARE.getId()).setVisible(false); //set invisible share
|
||||
// contextMenu.getItemByItemId(WorkspaceOperation.UNSHARE.getId()).setVisible(false); //set invisible unshare
|
||||
|
||||
|
||||
|
||||
contextMenu.showAt(posX, posY);
|
||||
}
|
||||
|
||||
|
@ -839,8 +843,9 @@ public class ContextMenuTree {
|
|||
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.VRE_CHANGE_PERIMISSIONS.getId()).setVisible(false); //VRE CHANGE PERMISSIONS
|
||||
|
||||
if(selectedItem.isShared()){ //SHARE LINK ON SHARED ITEM
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.VERSIONING.getId()).setVisible(false);
|
||||
|
||||
if(selectedItem.isShared()){ //SHARE LINK ON SHARED ITEM
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.SHARE_LINK.getId()).setVisible(true);
|
||||
}
|
||||
|
||||
|
@ -921,12 +926,15 @@ public class ContextMenuTree {
|
|||
case EXTERNAL_IMAGE:
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PREVIEW.getId()).setVisible(true);
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(true); //public link
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.VERSIONING.getId()).setVisible(true);
|
||||
break;
|
||||
case EXTERNAL_FILE:
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(true); //public link
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.VERSIONING.getId()).setVisible(true);
|
||||
break;
|
||||
case EXTERNAL_PDF_FILE:
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.PUBLIC_LINK.getId()).setVisible(true); //public link
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.VERSIONING.getId()).setVisible(true);
|
||||
break;
|
||||
case EXTERNAL_URL:
|
||||
contextMenu.getItemByItemId(WorkspaceOperation.LINK.getId()).setVisible(true);
|
||||
|
|
|
@ -20,6 +20,7 @@ import org.gcube.common.homelibary.model.items.gcube.DocumentMetadata;
|
|||
import org.gcube.common.homelibary.model.items.gcube.DocumentPartLink;
|
||||
import org.gcube.common.homelibary.model.items.type.NodeProperty;
|
||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||
import org.gcube.common.homelibary.model.versioning.WorkspaceVersion;
|
||||
import org.gcube.common.homelibrary.home.User;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.Properties;
|
||||
|
@ -61,6 +62,7 @@ import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
|
|||
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FolderGridModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||
|
@ -2233,16 +2235,18 @@ public class GWTWorkspaceBuilder {
|
|||
* @param versions the versions
|
||||
* @return the list
|
||||
*/
|
||||
public List<FileModel> toVersionHistory(List<String> versions){
|
||||
public List<FileVersionModel> toVersionHistory(List<WorkspaceVersion> versions){
|
||||
|
||||
if(versions==null){
|
||||
logger.error("Version history is null!!!");
|
||||
return new ArrayList<FileModel>();
|
||||
logger.warn("Version history is null!!!");
|
||||
return new ArrayList<FileVersionModel>();
|
||||
}
|
||||
|
||||
List<FileModel> listVersions = new ArrayList<FileModel>(versions.size());
|
||||
for (String id : versions) {
|
||||
listVersions.add(new FileModel(id, id, false));
|
||||
List<FileVersionModel> listVersions = new ArrayList<FileVersionModel>(versions.size());
|
||||
for (WorkspaceVersion wsVersion : versions) {
|
||||
String user = UserUtil.getUserFullName(wsVersion.getUser());
|
||||
FileVersionModel file = new FileVersionModel(wsVersion.getName(), wsVersion.getName(), wsVersion.getRemotePath(), user);
|
||||
listVersions.add(file);
|
||||
}
|
||||
return listVersions;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.apache.log4j.Logger;
|
|||
import org.gcube.common.encryption.StringEncrypter;
|
||||
import org.gcube.common.homelibary.model.items.type.FolderItemType;
|
||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||
import org.gcube.common.homelibary.model.versioning.WorkspaceVersion;
|
||||
import org.gcube.common.homelibrary.home.Home;
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
|
@ -49,6 +50,7 @@ import org.gcube.portlets.user.workspace.client.model.FileDetailsModel;
|
|||
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileTrashedModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FileVersionModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.FolderModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.InfoContactModel;
|
||||
import org.gcube.portlets.user.workspace.client.model.ScopeModel;
|
||||
|
@ -3340,7 +3342,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
* @throws Exception the exception
|
||||
*/
|
||||
@Override
|
||||
public List<FileModel> getVersionHistory(String fileIdentifier) throws Exception{
|
||||
public List<FileVersionModel> getVersionHistory(String fileIdentifier) throws Exception{
|
||||
|
||||
workspaceLogger.info("Get Version History "+fileIdentifier);
|
||||
|
||||
|
@ -3354,7 +3356,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
|
||||
if(fileHL instanceof ExternalFile){
|
||||
ExternalFile extFile = (ExternalFile) fileHL;
|
||||
List<String> versions = extFile.getVersionHistory();
|
||||
List<WorkspaceVersion> versions = extFile.getVersionHistory();
|
||||
GWTWorkspaceBuilder builder = getGWTWorkspaceBuilder();
|
||||
return builder.toVersionHistory(versions);
|
||||
}else
|
||||
|
@ -3376,7 +3378,7 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#performOperationOnVersionedFile(org.gcube.portlets.user.workspace.client.model.FileModel, org.gcube.portlets.user.workspace.client.model.FileModel, org.gcube.portlets.user.workspace.shared.WorkspaceVersioningOperation)
|
||||
*/
|
||||
@Override
|
||||
public List<FileModel> performOperationOnVersionedFile(FileModel currentVersion, FileModel olderVerison, WorkspaceVersioningOperation operation) throws Exception{
|
||||
public List<FileVersionModel> performOperationOnVersionedFile(FileModel currentVersion, FileModel olderVerison, WorkspaceVersioningOperation operation) throws Exception{
|
||||
|
||||
if(currentVersion == null || olderVerison==null)
|
||||
throw new Exception("File Versioned is null");
|
||||
|
|
Loading…
Reference in New Issue