Added context ID as parameter to DownoloadServlet
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@134799 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
aaa9799db3
commit
6e9a534c05
|
@ -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
|
||||
|
|
|
@ -32,7 +32,7 @@ public class RequestBuilderWorkspaceValidateItem {
|
|||
*/
|
||||
protected static final int TIME_INFO_DISPLAY = 1500; //milliseconds
|
||||
private AsyncCallback<WindowOpenParameter> 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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
||||
|
|
Loading…
Reference in New Issue