diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java index 7b33e36..96dc891 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/AppControllerExplorer.java @@ -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) diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java index 90ae142..79d34e2 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileModel.java @@ -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) diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileVersionModel.java b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileVersionModel.java index 10b20b7..4c2ab52 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/model/FileVersionModel.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/model/FileVersionModel.java @@ -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. * diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java index 081fd10..11d524b 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceService.java @@ -747,15 +747,7 @@ public interface GWTWorkspaceService extends RemoteService{ */ List getVersionHistory(String fileIdentifier) throws Exception; - /** - * @param currentVersion - * @param selectedVersion - * @param operation - * @return - * @throws Exception - */ List performOperationOnVersionedFile( - FileModel currentVersion, FileModel selectedVersion, - WorkspaceVersioningOperation operation) - throws Exception; + FileModel currentVersion, List selectedVersion, + WorkspaceVersioningOperation operation) throws Exception; } diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java index cb0a976..062e014 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/rpc/GWTWorkspaceServiceAsync.java @@ -757,7 +757,7 @@ public interface GWTWorkspaceServiceAsync { * @param callback the callback */ void performOperationOnVersionedFile( - FileModel currentVersion, FileModel selectedVersion, + FileModel currentVersion, List selectedVersion, WorkspaceVersioningOperation operation, AsyncCallback> callback); diff --git a/src/main/java/org/gcube/portlets/user/workspace/public/workspacetree.css b/src/main/java/org/gcube/portlets/user/workspace/public/workspacetree.css index 520c7ce..853801a 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/public/workspacetree.css +++ b/src/main/java/org/gcube/portlets/user/workspace/public/workspacetree.css @@ -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; diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/DownloadServlet.java b/src/main/java/org/gcube/portlets/user/workspace/server/DownloadServlet.java index 16ceb4d..b4b7c1f 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/DownloadServlet.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/DownloadServlet.java @@ -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 diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java index 74feb79..cbe368b 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceBuilder.java @@ -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 listVersions = new ArrayList(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; diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java index 2f7ad55..1cb3f64 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/GWTWorkspaceServiceImpl.java @@ -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 performOperationOnVersionedFile(FileModel currentVersion, FileModel olderVerison, WorkspaceVersioningOperation operation) throws Exception{ + public List performOperationOnVersionedFile(FileModel currentVersion, List 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()); } diff --git a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java index 7a26d37..f82ef5f 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java +++ b/src/main/java/org/gcube/portlets/user/workspace/server/util/WsUtil.java @@ -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);