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:
parent
6e9c1ca93d
commit
1068ba6ac1
|
@ -952,12 +952,14 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
if(fileDownloadEvent.getItemIdentifier()!=null){
|
if(fileDownloadEvent.getItemIdentifier()!=null){
|
||||||
|
|
||||||
|
// Add currentContextId parameter
|
||||||
|
String currentContextId = GCubeClientContext.getCurrentContextId();
|
||||||
|
|
||||||
if(fileDownloadEvent.getDownloadType().equals(DownloadType.SHOW)){
|
if(fileDownloadEvent.getDownloadType().equals(DownloadType.SHOW)){
|
||||||
if(fileDownloadEvent.getItemName()!= null){
|
if(fileDownloadEvent.getItemName()!= null){
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Add currentContextId parameter
|
|
||||||
String currentContextId = GCubeClientContext.getCurrentContextId();
|
|
||||||
//String currentUserId = GCubeClientContext.getCurrentUserId();
|
//String currentUserId = GCubeClientContext.getCurrentUserId();
|
||||||
String queryString = "id="+fileDownloadEvent.getItemIdentifier()+"&viewContent=true&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"="+currentContextId;
|
String queryString = "id="+fileDownloadEvent.getItemIdentifier()+"&viewContent=true&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"="+currentContextId;
|
||||||
if(fileDownloadEvent.getVersionId()!=null)
|
if(fileDownloadEvent.getVersionId()!=null)
|
||||||
|
@ -981,8 +983,6 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
||||||
|
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
// Add currentContextId parameter
|
|
||||||
String currentContextId = GCubeClientContext.getCurrentContextId();
|
|
||||||
//String currentUserId = GCubeClientContext.getCurrentUserId();
|
//String currentUserId = GCubeClientContext.getCurrentUserId();
|
||||||
String queryString = "id="+fileDownloadEvent.getItemIdentifier()+"&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"="+currentContextId;
|
String queryString = "id="+fileDownloadEvent.getItemIdentifier()+"&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"="+currentContextId;
|
||||||
if(fileDownloadEvent.getVersionId()!=null)
|
if(fileDownloadEvent.getVersionId()!=null)
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class FileModel extends BaseModelData implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Inits the default properties.
|
* Inits the default properties.
|
||||||
*/
|
*/
|
||||||
private void initDefaultProperties(){
|
protected void initDefaultProperties(){
|
||||||
setShortcutCategory(GXTCategorySmartFolder.SMF_UNKNOWN);
|
setShortcutCategory(GXTCategorySmartFolder.SMF_UNKNOWN);
|
||||||
setShareable(true);
|
setShareable(true);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,10 @@ public class FileModel extends BaseModelData implements Serializable {
|
||||||
* @return true, if is shareable
|
* @return true, if is shareable
|
||||||
*/
|
*/
|
||||||
public boolean isShareable() {
|
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
|
* @return true, if is shared
|
||||||
*/
|
*/
|
||||||
public boolean isShared(){
|
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
|
* @return true, if is directory
|
||||||
*/
|
*/
|
||||||
public boolean isDirectory(){
|
public boolean isDirectory(){
|
||||||
return (Boolean) get(ISDIRECTORY);
|
Object directory = get(ISDIRECTORY);
|
||||||
|
if(directory!=null)
|
||||||
|
return (Boolean) directory;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.gcube.portlets.user.workspace.client.model;
|
package org.gcube.portlets.user.workspace.client.model;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
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;
|
private static final long serialVersionUID = -607019966965449963L;
|
||||||
public static final String PATH = "path";
|
public static final String PATH = "path";
|
||||||
public static final String USER_VERSIONING = "user_versioning";
|
public static final String USER_VERSIONING = "user_versioning";
|
||||||
|
public static final String CREATED = "created";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new file model.
|
* Instantiates a new file model.
|
||||||
|
@ -33,12 +35,35 @@ public class FileVersionModel extends FileModel implements IsSerializable, Seria
|
||||||
* @param name the name
|
* @param name the name
|
||||||
* @param path the path
|
* @param path the path
|
||||||
* @param userFullName the user full name
|
* @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);
|
setIdentifier(identifier);
|
||||||
setName(name);
|
setName(name);
|
||||||
setPath(path);
|
setPath(path);
|
||||||
setUser(userFullName);
|
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) {
|
private void setUser(String userVersioning) {
|
||||||
set(USER_VERSIONING, userVersioning);
|
set(USER_VERSIONING, userVersioning);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,13 +81,10 @@ public class FileVersionModel extends FileModel implements IsSerializable, Seria
|
||||||
* @param path the new path
|
* @param path the new path
|
||||||
*/
|
*/
|
||||||
private void setPath(String path) {
|
private void setPath(String path) {
|
||||||
|
|
||||||
set(PATH, path);
|
set(PATH, path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the path.
|
* Gets the path.
|
||||||
*
|
*
|
||||||
|
|
|
@ -747,15 +747,7 @@ public interface GWTWorkspaceService extends RemoteService{
|
||||||
*/
|
*/
|
||||||
List<FileVersionModel> getVersionHistory(String fileIdentifier)
|
List<FileVersionModel> getVersionHistory(String fileIdentifier)
|
||||||
throws Exception;
|
throws Exception;
|
||||||
/**
|
|
||||||
* @param currentVersion
|
|
||||||
* @param selectedVersion
|
|
||||||
* @param operation
|
|
||||||
* @return
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
List<FileVersionModel> performOperationOnVersionedFile(
|
List<FileVersionModel> performOperationOnVersionedFile(
|
||||||
FileModel currentVersion, FileModel selectedVersion,
|
FileModel currentVersion, List<FileVersionModel> selectedVersion,
|
||||||
WorkspaceVersioningOperation operation)
|
WorkspaceVersioningOperation operation) throws Exception;
|
||||||
throws Exception;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -757,7 +757,7 @@ public interface GWTWorkspaceServiceAsync {
|
||||||
* @param callback the callback
|
* @param callback the callback
|
||||||
*/
|
*/
|
||||||
void performOperationOnVersionedFile(
|
void performOperationOnVersionedFile(
|
||||||
FileModel currentVersion, FileModel selectedVersion,
|
FileModel currentVersion, List<FileVersionModel> selectedVersion,
|
||||||
WorkspaceVersioningOperation operation,
|
WorkspaceVersioningOperation operation,
|
||||||
AsyncCallback<List<FileVersionModel>> callback);
|
AsyncCallback<List<FileVersionModel>> callback);
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
border: 8px solid #99C0E8;
|
border: 8px solid #99C0E8;
|
||||||
border-radius: 6px 6px 6px 6px;
|
border-radius: 6px 6px 6px 6px;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
line-height: 7px;
|
/* line-height: 7px; */
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
z-index: 1500;
|
z-index: 1500;
|
||||||
background-color: #FFFFFF;
|
background-color: #FFFFFF;
|
||||||
|
|
|
@ -78,13 +78,13 @@ public class DownloadServlet extends HttpServlet{
|
||||||
String contextID = req.getParameter(ConstantsExplorer.CURRENT_CONTEXT_ID);
|
String contextID = req.getParameter(ConstantsExplorer.CURRENT_CONTEXT_ID);
|
||||||
String versionID = req.getParameter(ConstantsExplorer.FILE_VERSION_ID);
|
String versionID = req.getParameter(ConstantsExplorer.FILE_VERSION_ID);
|
||||||
|
|
||||||
logger.debug("Input Params " +
|
logger.info("Download Params " +
|
||||||
"[id: "+itemId + ", " +
|
"[id: "+itemId + ", " +
|
||||||
"viewContent: "+viewContent+", " +
|
"viewContent: "+viewContent+", " +
|
||||||
ConstantsExplorer.VALIDATEITEM +": " +isValidItem+", " +
|
ConstantsExplorer.VALIDATEITEM +": " +isValidItem+", " +
|
||||||
"urlRedirectOnError:" +urlRedirectOnError+", " +
|
"urlRedirectOnError:" +urlRedirectOnError+", " +
|
||||||
"contextID: "+contextID+", " +
|
"contextID: "+contextID+", " +
|
||||||
"versioID: "+versionID+"]");
|
"versionID: "+versionID+"]");
|
||||||
|
|
||||||
if(itemId==null || itemId.isEmpty()){
|
if(itemId==null || itemId.isEmpty()){
|
||||||
sendError(resp,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Item id is null");
|
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;
|
Workspace wa = null;
|
||||||
try {
|
try {
|
||||||
//REMOVED BECAUSE IT DOES NOT WORK. MUST BE CHECK USERID AND CONTEXTID
|
//REMOVED BECAUSE IT DOES NOT WORK. MUST BE CHECK USERID AND CONTEXTID
|
||||||
|
|
|
@ -144,14 +144,14 @@ public class GWTWorkspaceBuilder {
|
||||||
return hashTestUser;
|
return hashTestUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To date.
|
* To date.
|
||||||
*
|
*
|
||||||
* @param calendar the calendar
|
* @param calendar the calendar
|
||||||
* @return the date
|
* @return the date
|
||||||
*/
|
*/
|
||||||
protected Date toDate(Calendar calendar)
|
public static Date toDate(Calendar calendar){
|
||||||
{
|
|
||||||
if (calendar == null) return new Date(0);
|
if (calendar == null) return new Date(0);
|
||||||
return calendar.getTime();
|
return calendar.getTime();
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ public class GWTWorkspaceBuilder {
|
||||||
* @param id the id
|
* @param id the id
|
||||||
* @param requestType the request type
|
* @param requestType the request type
|
||||||
* @param currentGroupId the current group id read from PortalContext
|
* @param currentGroupId the current group id read from PortalContext
|
||||||
* @param currUserId
|
* @param currUserId the curr user id
|
||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
protected String buildImageServiceUrl(String id, ImageRequestType requestType, String currentGroupId, String currUserId){
|
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 isInteralImage the is interal image
|
||||||
* @param fullDetails the full details
|
* @param fullDetails the full details
|
||||||
* @param currentGroupId the current group id
|
* @param currentGroupId the current group id
|
||||||
|
* @param currentUserId the current user id
|
||||||
* @return the GWT workspace item
|
* @return the GWT workspace item
|
||||||
* @throws InternalErrorException the internal error exception
|
* @throws InternalErrorException the internal error exception
|
||||||
*/
|
*/
|
||||||
|
@ -2245,7 +2246,7 @@ public class GWTWorkspaceBuilder {
|
||||||
List<FileVersionModel> listVersions = new ArrayList<FileVersionModel>(versions.size());
|
List<FileVersionModel> listVersions = new ArrayList<FileVersionModel>(versions.size());
|
||||||
for (WorkspaceVersion wsVersion : versions) {
|
for (WorkspaceVersion wsVersion : versions) {
|
||||||
String user = UserUtil.getUserFullName(wsVersion.getUser());
|
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);
|
listVersions.add(file);
|
||||||
}
|
}
|
||||||
return listVersions;
|
return listVersions;
|
||||||
|
|
|
@ -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)
|
* @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
|
@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");
|
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 {
|
try {
|
||||||
|
|
||||||
|
@ -3405,8 +3405,11 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
}
|
}
|
||||||
|
|
||||||
case RESTORE: {
|
case RESTORE: {
|
||||||
extFile.restoreVersion(olderVerison.getIdentifier());
|
for (FileVersionModel olderVerison : olderVersions) {
|
||||||
|
extFile.restoreVersion(olderVerison.getIdentifier());
|
||||||
|
}
|
||||||
return getVersionHistory(currentVersion.getIdentifier());
|
return getVersionHistory(currentVersion.getIdentifier());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case REFRESH: {
|
case REFRESH: {
|
||||||
|
@ -3414,8 +3417,10 @@ public class GWTWorkspaceServiceImpl extends RemoteServiceServlet implements GWT
|
||||||
}
|
}
|
||||||
|
|
||||||
case DELETE_PERMANENTLY: {
|
case DELETE_PERMANENTLY: {
|
||||||
extFile.removeVersion(olderVerison.getIdentifier());
|
for (FileVersionModel olderVerison : olderVersions) {
|
||||||
workspaceLogger.info("Version "+olderVerison.getIdentifier() +" of "+currentVersion.getName()+" removed");
|
extFile.removeVersion(olderVerison.getIdentifier());
|
||||||
|
workspaceLogger.info("Version "+olderVerison.getIdentifier() +" of "+currentVersion.getName()+" removed");
|
||||||
|
}
|
||||||
return getVersionHistory(currentVersion.getIdentifier());
|
return getVersionHistory(currentVersion.getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,15 @@ public class WsUtil {
|
||||||
public static Workspace getWorkspace(HttpServletRequest httpServletRequest, String contextID, GCubeUser user) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
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());
|
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);
|
logger.info("For ContextID: "+contextID +", read scope from Portal Context: "+currentScope);
|
||||||
PortalContextInfo info = getPortalContext(httpServletRequest, currentScope);
|
PortalContextInfo info = getPortalContext(httpServletRequest, currentScope);
|
||||||
logger.trace("PortalContextInfo: "+info);
|
logger.trace("PortalContextInfo: "+info);
|
||||||
|
|
Loading…
Reference in New Issue