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:
Francesco Mangiacrapa 2016-11-25 14:09:57 +00:00
parent aaa9799db3
commit 6e9a534c05
3 changed files with 19 additions and 15 deletions

View File

@ -225,9 +225,10 @@ public static enum WS_UPLOAD_TYPE {File, Archive};
*/ */
public enum ViewSwitchType {Tree, SmartFolder, Messages}; 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 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 VALIDATEITEM = "validateitem";
public static final String CONTEXT_ID = "contextID";
public static final String REDIRECTONERROR = "redirectonerror"; public static final String REDIRECTONERROR = "redirectonerror";
//UPLOAD SERVLET PARAMETERS //UPLOAD SERVLET PARAMETERS

View File

@ -32,7 +32,7 @@ public class RequestBuilderWorkspaceValidateItem {
*/ */
protected static final int TIME_INFO_DISPLAY = 1500; //milliseconds protected static final int TIME_INFO_DISPLAY = 1500; //milliseconds
private AsyncCallback<WindowOpenParameter> callback; private AsyncCallback<WindowOpenParameter> callback;
private String parameters; private String httpQueryString;
/** /**
* *
@ -49,7 +49,7 @@ public class RequestBuilderWorkspaceValidateItem {
final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", targetWindow, ""); final NewBrowserWindow newBrowserWindow = NewBrowserWindow.open("", targetWindow, "");
this.parameters = params; this.httpQueryString = params;
if(servletName==null) if(servletName==null)
return; return;
@ -59,17 +59,21 @@ public class RequestBuilderWorkspaceValidateItem {
if(!servletName.contains("/")) if(!servletName.contains("/"))
servletName+="/"+servletName; servletName+="/"+servletName;
if(parameters==null) if(httpQueryString==null)
parameters = ConstantsExplorer.VALIDATEITEM+"=true"; httpQueryString = ConstantsExplorer.VALIDATEITEM+"=true";
else 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); GWT.log("request builder for: "+urlRequest);
RequestBuilder requestBuilder = new RequestBuilder(method, urlRequest); RequestBuilder requestBuilder = new RequestBuilder(method, urlRequest);
GCubeClientContext.injectContext(requestBuilder); //requestBuilder = GCubeClientContext.injectContext(requestBuilder);
new InfoDisplayMessage("Download", "Requesting...", TIME_INFO_DISPLAY); new InfoDisplayMessage("Download", "Requesting...", TIME_INFO_DISPLAY);
try { try {
@ -95,7 +99,7 @@ public class RequestBuilderWorkspaceValidateItem {
}else { //OK STATUS }else { //OK STATUS
if(callback!=null) if(callback!=null)
callback.onSuccess(new WindowOpenParameter(targetWindow, "", params, true, newBrowserWindow)); callback.onSuccess(new WindowOpenParameter(targetWindow, "", httpQueryString, true, newBrowserWindow));
} }
} }

View File

@ -67,24 +67,23 @@ public class DownloadServlet extends HttpServlet{
boolean viewContent = req.getParameter("viewContent")==null?false:req.getParameter("viewContent").equals("true"); 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 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"); boolean urlRedirectOnError = req.getParameter(ConstantsExplorer.REDIRECTONERROR)==null?false:req.getParameter(ConstantsExplorer.REDIRECTONERROR).equals("true");
String contextID = req.getParameter(ConstantsExplorer.CONTEXT_ID);
logger.debug("Input Params [id: "+itemId + ", viewContent: "+viewContent+", "+ConstantsExplorer.VALIDATEITEM +": " +isValidItem+", urlRedirectOnError:" +urlRedirectOnError+", contextID: "+contextID+"]");
logger.trace("Input Params [id: "+itemId + ", viewContent: "+viewContent+", "+ConstantsExplorer.VALIDATEITEM +": " +isValidItem+", urlRedirectOnError:" +urlRedirectOnError+"]");
if(itemId==null || itemId.isEmpty()){ if(itemId==null || itemId.isEmpty()){
sendError(resp,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Item id is null"); sendError(resp,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Item id is null");
return; return;
} }
logger.trace("FILE DOWNLOAD REQUEST "+itemId); logger.debug("FILE DOWNLOAD REQUEST "+itemId);
Workspace wa = null; Workspace wa = null;
try { try {
//ADDED 13-01-2014 SESSION VALIDATION //ADDED 13-01-2014 SESSION VALIDATION
if(WsUtil.isSessionExpired(req)) if(WsUtil.isSessionExpired(req))
throw new SessionExpiredException(); throw new SessionExpiredException();
PortalContext pContext = PortalContext.getConfiguration(); String currentScope= PortalContext.getConfiguration().getCurrentScope(contextID);
String currentScope = pContext.getCurrentScope(req); logger.info("For ContextID: "+contextID +", read scope from Portal Context: "+currentScope);
logger.info("INJECTED Scope "+currentScope);
wa = WsUtil.getWorkspace(req, currentScope); wa = WsUtil.getWorkspace(req, currentScope);
} catch (Exception e) { } catch (Exception e) {