diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java index 6a6df3d..04a522d 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/ConstantsExplorer.java @@ -225,9 +225,10 @@ public static enum WS_UPLOAD_TYPE {File, Archive}; */ public enum ViewSwitchType {Tree, SmartFolder, Messages}; - //SERLVET ERROR + //SERLVET PARAMETERS public static final String ERROR_ITEM_DOES_NOT_EXIST = "Item does not exist. It may have been deleted by another user"; public static final String VALIDATEITEM = "validateitem"; + public static final String CONTEXT_ID = "contextID"; public static final String REDIRECTONERROR = "redirectonerror"; //UPLOAD SERVLET PARAMETERS diff --git a/src/main/java/org/gcube/portlets/user/workspace/client/util/RequestBuilderWorkspaceValidateItem.java b/src/main/java/org/gcube/portlets/user/workspace/client/util/RequestBuilderWorkspaceValidateItem.java index f08793f..4f023af 100644 --- a/src/main/java/org/gcube/portlets/user/workspace/client/util/RequestBuilderWorkspaceValidateItem.java +++ b/src/main/java/org/gcube/portlets/user/workspace/client/util/RequestBuilderWorkspaceValidateItem.java @@ -32,7 +32,7 @@ public class RequestBuilderWorkspaceValidateItem { */ protected static final int TIME_INFO_DISPLAY = 1500; //milliseconds private AsyncCallback callback; - private String parameters; + private String httpQueryString; /** * @@ -49,7 +49,7 @@ public class RequestBuilderWorkspaceValidateItem { final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", targetWindow, ""); - this.parameters = params; + this.httpQueryString = params; if(servletName==null) return; @@ -59,17 +59,21 @@ public class RequestBuilderWorkspaceValidateItem { if(!servletName.contains("/")) servletName+="/"+servletName; - if(parameters==null) - parameters = ConstantsExplorer.VALIDATEITEM+"=true"; + if(httpQueryString==null) + httpQueryString = ConstantsExplorer.VALIDATEITEM+"=true"; else - parameters +="&"+ConstantsExplorer.VALIDATEITEM+"=true"; + httpQueryString +="&"+ConstantsExplorer.VALIDATEITEM+"=true"; - String urlRequest = servletName+"?"+parameters; + // Add hidden parameters + String currentContextId = GCubeClientContext.getCurrentContextId(); + httpQueryString+="&"+ConstantsExplorer.CONTEXT_ID+"="+currentContextId; + + String urlRequest = servletName+"?"+httpQueryString; GWT.log("request builder for: "+urlRequest); RequestBuilder requestBuilder = new RequestBuilder(method, urlRequest); - GCubeClientContext.injectContext(requestBuilder); + //requestBuilder = GCubeClientContext.injectContext(requestBuilder); new InfoDisplayMessage("Download", "Requesting...", TIME_INFO_DISPLAY); try { @@ -95,7 +99,7 @@ public class RequestBuilderWorkspaceValidateItem { }else { //OK STATUS if(callback!=null) - callback.onSuccess(new WindowOpenParameter(targetWindow, "", params, true, newBrowserWindow)); + callback.onSuccess(new WindowOpenParameter(targetWindow, "", httpQueryString, true, newBrowserWindow)); } } 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 c82a792..68d7f1a 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 @@ -67,24 +67,23 @@ public class DownloadServlet extends HttpServlet{ boolean viewContent = req.getParameter("viewContent")==null?false:req.getParameter("viewContent").equals("true"); boolean isValidItem = req.getParameter(ConstantsExplorer.VALIDATEITEM)==null?false:req.getParameter(ConstantsExplorer.VALIDATEITEM).equals("true"); boolean urlRedirectOnError = req.getParameter(ConstantsExplorer.REDIRECTONERROR)==null?false:req.getParameter(ConstantsExplorer.REDIRECTONERROR).equals("true"); + String contextID = req.getParameter(ConstantsExplorer.CONTEXT_ID); - - logger.trace("Input Params [id: "+itemId + ", viewContent: "+viewContent+", "+ConstantsExplorer.VALIDATEITEM +": " +isValidItem+", urlRedirectOnError:" +urlRedirectOnError+"]"); + logger.debug("Input Params [id: "+itemId + ", viewContent: "+viewContent+", "+ConstantsExplorer.VALIDATEITEM +": " +isValidItem+", urlRedirectOnError:" +urlRedirectOnError+", contextID: "+contextID+"]"); if(itemId==null || itemId.isEmpty()){ sendError(resp,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Item id is null"); return; } - logger.trace("FILE DOWNLOAD REQUEST "+itemId); + logger.debug("FILE DOWNLOAD REQUEST "+itemId); Workspace wa = null; try { //ADDED 13-01-2014 SESSION VALIDATION if(WsUtil.isSessionExpired(req)) throw new SessionExpiredException(); - PortalContext pContext = PortalContext.getConfiguration(); - String currentScope = pContext.getCurrentScope(req); - logger.info("INJECTED Scope "+currentScope); + String currentScope= PortalContext.getConfiguration().getCurrentScope(contextID); + logger.info("For ContextID: "+contextID +", read scope from Portal Context: "+currentScope); wa = WsUtil.getWorkspace(req, currentScope); } catch (Exception e) {