Versioning #7006 first release
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@144060 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
1068ba6ac1
commit
3095ff46d2
|
@ -1,10 +1,7 @@
|
|||
package org.gcube.portlets.user.workspace.client.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
|
||||
/**
|
||||
* The Class FileVersionModel.
|
||||
|
@ -12,12 +9,13 @@ import com.google.gwt.user.client.rpc.IsSerializable;
|
|||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Feb 20, 2017
|
||||
*/
|
||||
public class FileVersionModel extends FileModel implements IsSerializable, Serializable {
|
||||
public class FileVersionModel extends FileModel {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -607019966965449963L;
|
||||
private static final long serialVersionUID = 4645522942385738974L;
|
||||
public static final String PATH = "path";
|
||||
public static final String USER_VERSIONING = "user_versioning";
|
||||
public static final String CREATED = "created";
|
||||
|
|
|
@ -139,7 +139,7 @@ public interface GWTWorkspaceService extends RemoteService{
|
|||
*
|
||||
* @param category the category
|
||||
* @return the smart folder results by category
|
||||
* @throws Exception
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
List<FileGridModel> getSmartFolderResultsByCategory(
|
||||
GXTCategorySmartFolder category) throws Exception;
|
||||
|
@ -738,16 +738,32 @@ public interface GWTWorkspaceService extends RemoteService{
|
|||
*
|
||||
* @param itemId the item id
|
||||
* @return the allow access
|
||||
* @throws SessionExpiredException the session expired exception
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
AllowAccess accessToFolderLink(String itemId) throws SessionExpiredException, Exception;
|
||||
|
||||
|
||||
/**
|
||||
* @param fileIdentifier
|
||||
* @return
|
||||
* @throws Exception
|
||||
* Perform operation on versioned file.
|
||||
*
|
||||
* @param fileId the file id
|
||||
* @param olderVersionIDs the older version i ds
|
||||
* @param operation the operation
|
||||
* @return the list
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
List<FileVersionModel> getVersionHistory(String fileIdentifier)
|
||||
throws Exception;
|
||||
List<FileVersionModel> performOperationOnVersionedFile(
|
||||
FileModel currentVersion, List<FileVersionModel> selectedVersion,
|
||||
String fileId, List<String> olderVersionIDs,
|
||||
WorkspaceVersioningOperation operation) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the version history.
|
||||
*
|
||||
* @param fileIdentifier the file identifier
|
||||
* @return the version history
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
List<FileVersionModel> getVersionHistory(String fileIdentifier) throws Exception;
|
||||
}
|
||||
|
|
|
@ -748,16 +748,8 @@ public interface GWTWorkspaceServiceAsync {
|
|||
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, List<FileVersionModel> selectedVersion,
|
||||
String fileId, List<String> olderVersionIds,
|
||||
WorkspaceVersioningOperation operation,
|
||||
AsyncCallback<List<FileVersionModel>> callback);
|
||||
|
||||
|
|
|
@ -3373,79 +3373,6 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @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<FileVersionModel> performOperationOnVersionedFile(FileModel currentVersion, List<FileVersionModel> olderVersions, WorkspaceVersioningOperation operation) throws Exception{
|
||||
|
||||
if(currentVersion == null || olderVersions==null || olderVersions.size()==0)
|
||||
throw new Exception("File Versioned is null");
|
||||
|
||||
workspaceLogger.info("Cuurent Version: "+currentVersion.getName()+", File Versioned "+olderVersions+ " perform operation: "+operation);
|
||||
|
||||
try {
|
||||
|
||||
Workspace workspace = getWorkspace();
|
||||
WorkspaceItem fileHL = workspace.getItem(currentVersion.getIdentifier());
|
||||
if(fileHL instanceof ExternalFile){
|
||||
ExternalFile extFile = (ExternalFile) fileHL;
|
||||
|
||||
switch (operation) {
|
||||
|
||||
case DOWNLOAD: {
|
||||
//IMPLEMENTED CLIENT-SIDE
|
||||
break;
|
||||
}
|
||||
|
||||
case EMPTY_OLDER_VERSIONS:{
|
||||
//TODO
|
||||
//extFile.(selectedVersion.getIdentifier());;
|
||||
}
|
||||
|
||||
case RESTORE: {
|
||||
for (FileVersionModel olderVerison : olderVersions) {
|
||||
extFile.restoreVersion(olderVerison.getIdentifier());
|
||||
}
|
||||
return getVersionHistory(currentVersion.getIdentifier());
|
||||
|
||||
}
|
||||
|
||||
case REFRESH: {
|
||||
return getVersionHistory(currentVersion.getIdentifier());
|
||||
}
|
||||
|
||||
case DELETE_PERMANENTLY: {
|
||||
for (FileVersionModel olderVerison : olderVersions) {
|
||||
extFile.removeVersion(olderVerison.getIdentifier());
|
||||
workspaceLogger.info("Version "+olderVerison.getIdentifier() +" of "+currentVersion.getName()+" removed");
|
||||
}
|
||||
return getVersionHistory(currentVersion.getIdentifier());
|
||||
}
|
||||
|
||||
default:{
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return getVersionHistory(currentVersion.getIdentifier());
|
||||
|
||||
}else
|
||||
throw new FileNotVersionedException("Selected file is not versioned");
|
||||
|
||||
}catch (Exception e) {
|
||||
|
||||
if (e instanceof FileNotVersionedException)
|
||||
throw new Exception(e.getMessage());
|
||||
workspaceLogger.error("Error in server during perform operation on versioning of: "+currentVersion.getName(), e);
|
||||
String error = ConstantsExplorer.SERVER_ERROR +" updating versioning of "+currentVersion.getName();
|
||||
throw new Exception(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#executeOperationOnTrash(java.util.List, org.gcube.portlets.user.workspace.shared.WorkspaceTrashOperation)
|
||||
*/
|
||||
|
@ -4085,4 +4012,82 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
|||
throw new Exception(error);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.user.workspace.client.rpc.GWTWorkspaceService#performOperationOnVersionedFile(java.lang.String, java.util.List, org.gcube.portlets.user.workspace.shared.WorkspaceVersioningOperation)
|
||||
*/
|
||||
@Override
|
||||
public List<FileVersionModel> performOperationOnVersionedFile(
|
||||
String fileId, List<String> olderVersionIDs,
|
||||
WorkspaceVersioningOperation operation) throws Exception {
|
||||
|
||||
if(fileId == null || olderVersionIDs==null || olderVersionIDs.size()==0)
|
||||
throw new Exception("File Versioned is null");
|
||||
|
||||
workspaceLogger.info("File Id: "+fileId+", Ids Version: "+olderVersionIDs+ " perform operation: "+operation);
|
||||
|
||||
try {
|
||||
|
||||
Workspace workspace = getWorkspace();
|
||||
WorkspaceItem fileHL = workspace.getItem(fileId);
|
||||
if(fileHL instanceof ExternalFile){
|
||||
ExternalFile extFile = (ExternalFile) fileHL;
|
||||
|
||||
switch (operation) {
|
||||
|
||||
case DOWNLOAD: {
|
||||
//IMPLEMENTED CLIENT-SIDE
|
||||
break;
|
||||
}
|
||||
|
||||
case DELETE_ALL_OLDER_VERSIONS:{
|
||||
//MUST BE OPTIMIZED HL-SIDE
|
||||
for (String olderVersionId : olderVersionIDs) {
|
||||
extFile.removeVersion(olderVersionId);
|
||||
workspaceLogger.info("Version "+olderVersionId +" of file id: "+fileId+" removed");
|
||||
}
|
||||
return getVersionHistory(fileId);
|
||||
}
|
||||
|
||||
case RESTORE: {
|
||||
for (String olderVersionId : olderVersionIDs) {
|
||||
extFile.restoreVersion(olderVersionId);
|
||||
workspaceLogger.info("Version "+olderVersionId +" of file id: "+fileId+" restored");
|
||||
}
|
||||
return getVersionHistory(fileId);
|
||||
|
||||
}
|
||||
|
||||
case REFRESH: {
|
||||
return getVersionHistory(fileId);
|
||||
}
|
||||
|
||||
case DELETE_PERMANENTLY: {
|
||||
for (String olderVersionId : olderVersionIDs) {
|
||||
extFile.removeVersion(olderVersionId);
|
||||
workspaceLogger.info("Version "+olderVersionId +" of file id: "+fileId+" removed");
|
||||
}
|
||||
return getVersionHistory(fileId);
|
||||
}
|
||||
|
||||
default:{
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return getVersionHistory(fileId);
|
||||
|
||||
}else
|
||||
throw new FileNotVersionedException("Selected file is not versioned");
|
||||
|
||||
}catch (Exception e) {
|
||||
|
||||
if (e instanceof FileNotVersionedException)
|
||||
throw new Exception(e.getMessage());
|
||||
workspaceLogger.error("Error in server during perform operation on versioning on file id: "+fileId, e);
|
||||
String error = ConstantsExplorer.SERVER_ERROR +" updating versioning of file id: "+fileId;
|
||||
throw new Exception(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ public enum WorkspaceVersioningOperation {
|
|||
RESTORE("Restore", "Restore the file to the selected version"),
|
||||
DOWNLOAD("Download", "Download the version of the selected file"),
|
||||
DELETE_PERMANENTLY("Delete Permanently", "Delete Permanently the version for the selected file"),
|
||||
EMPTY_OLDER_VERSIONS("Empty Old Versions", "Empty definitively all older versions of the file");
|
||||
DELETE_ALL_OLDER_VERSIONS("Delete all older versions", "Delete definitively all older versions of the file");
|
||||
|
||||
public String label;
|
||||
public String operationDescription;
|
||||
|
|
Loading…
Reference in New Issue