Enhancement on file versioning #7006

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@144024 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-02-21 17:24:44 +00:00
parent 6e9c1ca93d
commit 1068ba6ac1
10 changed files with 75 additions and 39 deletions

View File

@ -952,12 +952,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
if(fileDownloadEvent.getItemIdentifier()!=null){
// Add currentContextId parameter
String currentContextId = GCubeClientContext.getCurrentContextId();
if(fileDownloadEvent.getDownloadType().equals(DownloadType.SHOW)){
if(fileDownloadEvent.getItemName()!= null){
try {
// Add currentContextId parameter
String currentContextId = GCubeClientContext.getCurrentContextId();
//String currentUserId = GCubeClientContext.getCurrentUserId();
String queryString = "id="+fileDownloadEvent.getItemIdentifier()+"&viewContent=true&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"="+currentContextId;
if(fileDownloadEvent.getVersionId()!=null)
@ -981,8 +983,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
else {
try {
// Add currentContextId parameter
String currentContextId = GCubeClientContext.getCurrentContextId();
//String currentUserId = GCubeClientContext.getCurrentUserId();
String queryString = "id="+fileDownloadEvent.getItemIdentifier()+"&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"="+currentContextId;
if(fileDownloadEvent.getVersionId()!=null)

View File

@ -93,7 +93,7 @@ public class FileModel extends BaseModelData implements Serializable {
/**
* Inits the default properties.
*/
private void initDefaultProperties(){
protected void initDefaultProperties(){
setShortcutCategory(GXTCategorySmartFolder.SMF_UNKNOWN);
setShareable(true);
}
@ -132,7 +132,10 @@ public class FileModel extends BaseModelData implements Serializable {
* @return true, if is shareable
*/
public boolean isShareable() {
return (Boolean) get(ConstantsExplorer.ISSHAREABLE);
Object sharable = get(ConstantsExplorer.ISSHAREABLE);
if(sharable!=null)
return (Boolean) sharable;
return false;
}
/**
@ -246,7 +249,10 @@ public class FileModel extends BaseModelData implements Serializable {
* @return true, if is shared
*/
public boolean isShared(){
return (Boolean) get(ISSHARED);
Object shared = get(ISSHARED);
if(shared!=null)
return (Boolean) shared;
return false;
}
/**
@ -423,7 +429,10 @@ public class FileModel extends BaseModelData implements Serializable {
* @return true, if is directory
*/
public boolean isDirectory(){
return (Boolean) get(ISDIRECTORY);
Object directory = get(ISDIRECTORY);
if(directory!=null)
return (Boolean) directory;
return false;
}
/* (non-Javadoc)

View File

@ -1,6 +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;
@ -19,6 +20,7 @@ public class FileVersionModel extends FileModel implements IsSerializable, Seria
private static final long serialVersionUID = -607019966965449963L;
public static final String PATH = "path";
public static final String USER_VERSIONING = "user_versioning";
public static final String CREATED = "created";
/**
* Instantiates a new file model.
@ -33,12 +35,35 @@ public class FileVersionModel extends FileModel implements IsSerializable, Seria
* @param name the name
* @param path the path
* @param userFullName the user full name
* @param created the created
*/
public FileVersionModel(String identifier, String name, String path, String userFullName) {
public FileVersionModel(String identifier, String name, String path, String userFullName, Date created) {
setIdentifier(identifier);
setName(name);
setPath(path);
setUser(userFullName);
setCreated(created);
super.initDefaultProperties();
}
/**
* Sets the created.
*
* @param created2 the new created
*/
private void setCreated(Date created2) {
set(CREATED, created2);
}
/**
* Gets the created.
*
* @return the created
*/
public Date getCreated(){
return (Date) get(CREATED);
}
/**
@ -48,7 +73,6 @@ public class FileVersionModel extends FileModel implements IsSerializable, Seria
*/
private void setUser(String userVersioning) {
set(USER_VERSIONING, userVersioning);
}
/**
@ -57,13 +81,10 @@ public class FileVersionModel extends FileModel implements IsSerializable, Seria
* @param path the new path
*/
private void setPath(String path) {
set(PATH, path);
}
/**
* Gets the path.
*

View File

@ -747,15 +747,7 @@ public interface GWTWorkspaceService extends RemoteService{
*/
List<FileVersionModel> getVersionHistory(String fileIdentifier)
throws Exception;
/**
* @param currentVersion
* @param selectedVersion
* @param operation
* @return
* @throws Exception
*/
List<FileVersionModel> performOperationOnVersionedFile(
FileModel currentVersion, FileModel selectedVersion,
WorkspaceVersioningOperation operation)
throws Exception;
FileModel currentVersion, List<FileVersionModel> selectedVersion,
WorkspaceVersioningOperation operation) throws Exception;
}

View File

@ -757,7 +757,7 @@ public interface GWTWorkspaceServiceAsync {
* @param callback the callback
*/
void performOperationOnVersionedFile(
FileModel currentVersion, FileModel selectedVersion,
FileModel currentVersion, List<FileVersionModel> selectedVersion,
WorkspaceVersioningOperation operation,
AsyncCallback<List<FileVersionModel>> callback);

View File

@ -4,7 +4,7 @@
border: 8px solid #99C0E8;
border-radius: 6px 6px 6px 6px;
box-shadow: none;
line-height: 7px;
/* line-height: 7px; */
opacity: 1;
z-index: 1500;
background-color: #FFFFFF;

View File

@ -78,13 +78,13 @@ public class DownloadServlet extends HttpServlet{
String contextID = req.getParameter(ConstantsExplorer.CURRENT_CONTEXT_ID);
String versionID = req.getParameter(ConstantsExplorer.FILE_VERSION_ID);
logger.debug("Input Params " +
logger.info("Download Params " +
"[id: "+itemId + ", " +
"viewContent: "+viewContent+", " +
ConstantsExplorer.VALIDATEITEM +": " +isValidItem+", " +
"urlRedirectOnError:" +urlRedirectOnError+", " +
"contextID: "+contextID+", " +
"versioID: "+versionID+"]");
"versionID: "+versionID+"]");
if(itemId==null || itemId.isEmpty()){
sendError(resp,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Item id is null");
@ -92,7 +92,7 @@ public class DownloadServlet extends HttpServlet{
}
logger.debug("FILE DOWNLOAD REQUEST "+itemId);
logger.debug("DOWNLOAD REQUEST FOR ITEM ID: "+itemId);
Workspace wa = null;
try {
//REMOVED BECAUSE IT DOES NOT WORK. MUST BE CHECK USERID AND CONTEXTID

View File

@ -144,14 +144,14 @@ public class GWTWorkspaceBuilder {
return hashTestUser;
}
/**
* To date.
*
* @param calendar the calendar
* @return the date
*/
protected Date toDate(Calendar calendar)
{
public static Date toDate(Calendar calendar){
if (calendar == null) return new Date(0);
return calendar.getTime();
@ -262,7 +262,7 @@ public class GWTWorkspaceBuilder {
* @param id the id
* @param requestType the request type
* @param currentGroupId the current group id read from PortalContext
* @param currUserId
* @param currUserId the curr user id
* @return the string
*/
protected String buildImageServiceUrl(String id, ImageRequestType requestType, String currentGroupId, String currUserId){
@ -288,6 +288,7 @@ public class GWTWorkspaceBuilder {
* @param isInteralImage the is interal image
* @param fullDetails the full details
* @param currentGroupId the current group id
* @param currentUserId the current user id
* @return the GWT workspace item
* @throws InternalErrorException the internal error exception
*/
@ -2245,7 +2246,7 @@ public class GWTWorkspaceBuilder {
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);
FileVersionModel file = new FileVersionModel(wsVersion.getName(), wsVersion.getName(), wsVersion.getRemotePath(), user, toDate(wsVersion.getCreated()));
listVersions.add(file);
}
return listVersions;

View File

@ -3378,12 +3378,12 @@ 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<FileVersionModel> performOperationOnVersionedFile(FileModel currentVersion, FileModel olderVerison, WorkspaceVersioningOperation operation) throws Exception{
public List<FileVersionModel> performOperationOnVersionedFile(FileModel currentVersion, List<FileVersionModel> olderVersions, WorkspaceVersioningOperation operation) throws Exception{
if(currentVersion == null || olderVerison==null)
if(currentVersion == null || olderVersions==null || olderVersions.size()==0)
throw new Exception("File Versioned is null");
workspaceLogger.info("Cuurent Version: "+currentVersion.getName()+", File Versioned "+olderVerison.getName()+ " perform operation: "+operation);
workspaceLogger.info("Cuurent Version: "+currentVersion.getName()+", File Versioned "+olderVersions+ " perform operation: "+operation);
try {
@ -3405,8 +3405,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
case RESTORE: {
extFile.restoreVersion(olderVerison.getIdentifier());
for (FileVersionModel olderVerison : olderVersions) {
extFile.restoreVersion(olderVerison.getIdentifier());
}
return getVersionHistory(currentVersion.getIdentifier());
}
case REFRESH: {
@ -3414,8 +3417,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
}
case DELETE_PERMANENTLY: {
extFile.removeVersion(olderVerison.getIdentifier());
workspaceLogger.info("Version "+olderVerison.getIdentifier() +" of "+currentVersion.getName()+" removed");
for (FileVersionModel olderVerison : olderVersions) {
extFile.removeVersion(olderVerison.getIdentifier());
workspaceLogger.info("Version "+olderVerison.getIdentifier() +" of "+currentVersion.getName()+" removed");
}
return getVersionHistory(currentVersion.getIdentifier());
}

View File

@ -160,7 +160,15 @@ public class WsUtil {
public static Workspace getWorkspace(HttpServletRequest httpServletRequest, String contextID, GCubeUser user) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
{
logger.info("Get workspace using contextID: "+contextID +", current user: "+user.getUsername());
String currentScope = PortalContext.getConfiguration().getCurrentScope(contextID);
String currentScope;
if(isWithinPortal())
currentScope = PortalContext.getConfiguration().getCurrentScope(contextID);
else{
currentScope = PortalContext.getConfiguration().getCurrentScope(httpServletRequest);
logger.warn("STARTING IN TEST MODE!!!! USING SCOPE: "+currentScope);
}
logger.info("For ContextID: "+contextID +", read scope from Portal Context: "+currentScope);
PortalContextInfo info = getPortalContext(httpServletRequest, currentScope);
logger.trace("PortalContextInfo: "+info);