From 308fb4cc73aab6eebe8a5f099a632d5a09d67976 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Thu, 22 Dec 2016 09:26:36 +0000 Subject: [PATCH] Fixed hidden parameter for currUserId in client side See #6275 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@141357 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/uploader/DialogUpload.java | 5 ++-- .../server/WorkspaceUploadServletStream.java | 4 +++- .../workspaceuploader/server/util/WsUtil.java | 24 ------------------- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/DialogUpload.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/DialogUpload.java index 678bb61..e039af1 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/DialogUpload.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/DialogUpload.java @@ -94,8 +94,8 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo formPanel.setEncoding(FormPanel.ENCODING_MULTIPART); formPanel.setMethod(FormPanel.METHOD_POST); formPanel.setWidth("auto"); - - + + // Create a panel to hold all of the form widgets. panel = new VerticalPanel(); formPanel.setWidget(panel); @@ -105,6 +105,7 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo // Add hidden parameters panel.add(new Hidden(ConstantsWorkspaceUploader.CURR_GROUP_ID, GCubeClientContext.getCurrentContextId())); + panel.add(new Hidden(ConstantsWorkspaceUploader.CURR_USER_ID, GCubeClientContext.getCurrentUserId())); panel.add(new Hidden(ConstantsWorkspaceUploader.ID_FOLDER,parentId)); panel.add(new Hidden(ConstantsWorkspaceUploader.UPLOAD_TYPE,uploadType.toString())); diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServletStream.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServletStream.java index a5957bc..8884d6d 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServletStream.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServletStream.java @@ -252,7 +252,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet if (item.isFormField() && CURR_USER_ID.equals(item.getFieldName())){ currUserId = Streams.asString(item.openStream()); logger.debug("currUserId passed as parameter = " + currUserId); - logger.debug("currUserId into PortalContext scope= " + PortalContext.getConfiguration().getCurrentUser(request)); + logger.debug("currUserinto PortalContext = " + PortalContext.getConfiguration().getCurrentUser(request)); } //MUST BE THE LAST PARAMETER TRASMITTED @@ -513,6 +513,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet if (MimeTypeUtil.isZipContentType(uploadItem.getContentType())){ //UNZIP?? logger.debug("Unziping content"); + //THE WORKSPACE HAS BEEN INSTANCIED ABOVE workspaceUploader = WorkspaceUploaderMng.uploadArchive(currUserId, scopeGroupId, workspaceUploader, request, itemName, inputStream, destinationFolder, size); if(workspaceUploader==null) @@ -520,6 +521,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet sendMessage(response, workspaceUploader.getIdentifier()); } else{ + //THE WORKSPACE HAS BEEN INSTANCIED ABOVE workspaceUploader = WorkspaceUploaderMng.uploadFile(currUserId, scopeGroupId, request, workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size); if(workspaceUploader==null) diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/util/WsUtil.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/util/WsUtil.java index 21bacca..2ddb13c 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/util/WsUtil.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/util/WsUtil.java @@ -89,30 +89,6 @@ public class WsUtil { return HomeLibrary.getUserWorkspace(username); } - -// /** -// * Gets the workspace. -// * -// * @param username the username -// * @param scopeGroupId the scope group id -// * @param currUserId the curr user id -// * @return the workspace -// * @throws InternalErrorException the internal error exception -// * @throws HomeNotFoundException the home not found exception -// * @throws WorkspaceFolderNotFoundException the workspace folder not found exception -// */ -// public static Workspace getWorkspace(String username, String scopeGroupId, String currUserId) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException{ -// -// logger.trace("Get Workspace for user = " + username); -// PortalContext pContext = PortalContext.getConfiguration(); -// String scope = pContext.getCurrentScope(scopeGroupId); -// logger.trace("Client context scope: "+ scope + " username: "+username); -// -// ScopeProvider.instance.set(scope); -// return HomeLibrary.getUserWorkspace(username); -// } - - /** * Put workspace uploader in session. *