Added INJECTED scope

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@134795 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-11-25 13:31:52 +00:00
parent 9cc5d57764
commit aaa9799db3
3 changed files with 73 additions and 27 deletions

View File

@ -3,6 +3,7 @@
*/
package org.gcube.portlets.user.workspace.client.util;
import org.gcube.portal.clientcontext.client.GCubeClientContext;
import org.gcube.portlets.user.workspace.client.AppControllerExplorer;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.event.SessionExpiredEvent;
@ -68,6 +69,7 @@ public class RequestBuilderWorkspaceValidateItem {
GWT.log("request builder for: "+urlRequest);
RequestBuilder requestBuilder = new RequestBuilder(method, urlRequest);
GCubeClientContext.injectContext(requestBuilder);
new InfoDisplayMessage("Download", "Requesting...", TIME_INFO_DISPLAY);
try {

View File

@ -35,6 +35,7 @@ import org.gcube.common.homelibrary.home.workspace.folder.items.ts.TimeSeries;
import org.gcube.common.homelibrary.util.Extensions;
import org.gcube.common.homelibrary.util.MimeTypeUtil;
import org.gcube.common.homelibrary.util.zip.ZipUtil;
import org.gcube.common.portal.PortalContext;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.server.property.PortalUrlGroupGatewayProperty;
import org.gcube.portlets.user.workspace.server.util.WsUtil;
@ -67,6 +68,7 @@ public class DownloadServlet extends HttpServlet{
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");
logger.trace("Input Params [id: "+itemId + ", viewContent: "+viewContent+", "+ConstantsExplorer.VALIDATEITEM +": " +isValidItem+", urlRedirectOnError:" +urlRedirectOnError+"]");
if(itemId==null || itemId.isEmpty()){
sendError(resp,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Item id is null");
@ -80,7 +82,10 @@ public class DownloadServlet extends HttpServlet{
if(WsUtil.isSessionExpired(req))
throw new SessionExpiredException();
wa = WsUtil.getWorkspace(req);
PortalContext pContext = PortalContext.getConfiguration();
String currentScope = pContext.getCurrentScope(req);
logger.info("INJECTED Scope "+currentScope);
wa = WsUtil.getWorkspace(req, currentScope);
} catch (Exception e) {
if (e instanceof SessionExpiredException){

View File

@ -96,6 +96,20 @@ public class WsUtil {
}
/**
* Gets the portal context.
*
* @param httpServletRequest the http servlet request
* @param overrideScope the override scope
* @return the portal context
*/
public static PortalContextInfo getPortalContext(HttpServletRequest httpServletRequest, String overrideScope){
PortalContextInfo info = getPortalContext(httpServletRequest);
info.setCurrentScope(overrideScope);
return info;
}
/**
* Checks if is session expired.
*
@ -134,6 +148,31 @@ public class WsUtil {
}
/**
* Gets the workspace.
*
* @param httpServletRequest the http servlet request
* @param useThisScope the use this scope
* @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(HttpServletRequest httpServletRequest, String useThisScope) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
{
logger.trace("Get Workspace");
PortalContextInfo info = getPortalContext(httpServletRequest, useThisScope);
logger.trace("PortalContextInfo: "+info);
ScopeProvider.instance.set(info.getCurrentScope());
logger.trace("Scope provider instancied");
Workspace workspace = HomeLibrary.getUserWorkspace(info.getUsername());
return workspace;
}
/**
* Gets the GWT workspace builder.
*