Fixed bug on currUserId. See #6275
Not it is passed as parameter git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/workspace-tree-widget@141320 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
163bb37c45
commit
3e267e603b
|
@ -944,7 +944,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
try {
|
||||
// Add currentContextId parameter
|
||||
String currentContextId = GCubeClientContext.getCurrentContextId();
|
||||
String queryString = "id="+fileDownloadEvent.getItemIdentifier()+"&viewContent=true&"+ConstantsExplorer.CONTEXT_ID+"="+currentContextId;
|
||||
String currentUserId = GCubeClientContext.getCurrentUserId();
|
||||
String queryString = "id="+fileDownloadEvent.getItemIdentifier()+"&viewContent=true&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"="+currentContextId+"&"+ConstantsExplorer.CURRENT_USER_ID+"="+currentUserId;
|
||||
new RequestBuilderWorkspaceValidateItem(RequestBuilder.GET, ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE, queryString, "_blank", downloadHandlerCallback);
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -966,7 +967,8 @@ public class AppControllerExplorer implements EventHandler, TreeAppControllerInt
|
|||
try {
|
||||
// Add currentContextId parameter
|
||||
String currentContextId = GCubeClientContext.getCurrentContextId();
|
||||
String queryString = "id="+fileDownloadEvent.getItemIdentifier()+"&"+ConstantsExplorer.CONTEXT_ID+"="+currentContextId;
|
||||
String currentUserId = GCubeClientContext.getCurrentUserId();
|
||||
String queryString = "id="+fileDownloadEvent.getItemIdentifier()+"&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"="+currentContextId+"&"+ConstantsExplorer.CURRENT_USER_ID+"="+currentUserId;
|
||||
new RequestBuilderWorkspaceValidateItem(RequestBuilder.GET,ConstantsExplorer.DOWNLOAD_WORKSPACE_SERVICE, queryString, "_self", downloadHandlerCallback);
|
||||
} catch (Exception e) {
|
||||
explorerPanel.getAsycTreePanel().unmask();
|
||||
|
|
|
@ -229,7 +229,8 @@ public static enum WS_UPLOAD_TYPE {File, Archive};
|
|||
//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 CURRENT_CONTEXT_ID = "contextID";
|
||||
public static final String CURRENT_USER_ID = "currUserId";
|
||||
public static final String REDIRECTONERROR = "redirectonerror";
|
||||
|
||||
//UPLOAD SERVLET PARAMETERS
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.workspace.server;
|
||||
|
||||
|
@ -24,7 +24,7 @@ import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @Jul 1, 2013
|
||||
*
|
||||
|
@ -47,59 +47,27 @@ public class DownloadPublicLinkServlet extends HttpServlet{
|
|||
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||||
|
||||
String smp = req.getParameter("smp");
|
||||
boolean viewContent = (req.getParameter("viewContent")==null)?false:req.getParameter("viewContent").equals("true");
|
||||
|
||||
boolean viewContent = req.getParameter("viewContent")==null?false:req.getParameter("viewContent").equals("true");
|
||||
|
||||
logger.trace("Input Params [smp: "+smp + ", viewContent: "+viewContent+"]");
|
||||
|
||||
|
||||
if(smp==null || smp.isEmpty()){
|
||||
sendError(resp,HttpServletResponse.SC_INTERNAL_SERVER_ERROR +": Item id is null");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
logger.trace("PUBLIC FILE DOWNLOAD REQUEST "+smp);
|
||||
|
||||
//COMMENTED 26/03/2013
|
||||
// String itemName = MimeTypeUtil.getNameWithExtension(item.getName(), mimeType);
|
||||
|
||||
// String contentDisposition = (viewContent)?"inline":"attachment";
|
||||
// //COMMENTED 26/03/2013
|
||||
//// resp.setHeader( "Content-Disposition", contentDisposition+"; filename=\"" + itemName + "\"" );
|
||||
// resp.setHeader( "Content-Disposition", contentDisposition+"; filename=\"" + item.getName() + "\"" );
|
||||
//
|
||||
// resp.setContentType(mimeType);
|
||||
//
|
||||
// resp.setContentLength((int) externalFile.getLength());
|
||||
//
|
||||
//
|
||||
// //MODIFIED 22-05-2013 CLOSE STREAM
|
||||
//// IOUtils.copy(externalFile.getData(), resp.getOutputStream());
|
||||
// is = externalFile.getData();
|
||||
// out = resp.getOutputStream();
|
||||
// IOUtils.copy(is, out);
|
||||
//
|
||||
// is.close();
|
||||
// out.close();
|
||||
|
||||
}
|
||||
|
||||
// protected void handleError(boolean urlRedirectOnError, HttpServletRequest req, HttpServletResponse resp, String itemId, String message) throws IOException{
|
||||
//
|
||||
// logger.warn("Handle error occurred: "+message);
|
||||
// if(urlRedirectOnError){
|
||||
// urlRedirect(req, resp, itemId);
|
||||
// }else
|
||||
// sendError(resp,message);
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
protected void sendError(HttpServletResponse response, String message) throws IOException
|
||||
{
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
HandlerResultMessage resultMessage = HandlerResultMessage.errorResult(message);
|
||||
response.getWriter().write(resultMessage.toString());
|
||||
response.flushBuffer();
|
||||
}
|
||||
|
||||
|
||||
public static String getRequestURL(HttpServletRequest req) {
|
||||
|
||||
String scheme = req.getScheme(); // http
|
||||
|
@ -114,86 +82,41 @@ public class DownloadPublicLinkServlet extends HttpServlet{
|
|||
StringBuffer url = new StringBuffer();
|
||||
url.append(scheme).append("://").append(serverName);
|
||||
|
||||
if ((serverPort != 80) && (serverPort != 443)) {
|
||||
if (serverPort != 80 && serverPort != 443) {
|
||||
url.append(":").append(serverPort);
|
||||
}
|
||||
|
||||
logger.trace("server: "+url);
|
||||
logger.trace("contextPath: "+contextPath);
|
||||
// logger.trace("servletPath: "+servletPath);
|
||||
// url.append(contextPath).append(servletPath);
|
||||
|
||||
|
||||
url.append(contextPath);
|
||||
|
||||
// if (pathInfo != null) {
|
||||
// url.append(pathInfo);
|
||||
// }
|
||||
// if (queryString != null) {
|
||||
// url.append("?").append(queryString);
|
||||
|
||||
// }
|
||||
|
||||
url.append(contextPath);
|
||||
PortalUrlGroupGatewayProperty p = new PortalUrlGroupGatewayProperty();
|
||||
|
||||
int lenght = p.getPath().length();
|
||||
|
||||
String groupgatewaypath = "/";
|
||||
|
||||
if(lenght>1){
|
||||
|
||||
String lastChar = p.getPath().substring(lenght-1, lenght-1);
|
||||
|
||||
groupgatewaypath+= lastChar.compareTo("/")!=0?p.getPath()+"/":p.getPath();
|
||||
}
|
||||
|
||||
url.append(groupgatewaypath);
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
InputStream is = null;
|
||||
|
||||
logger.trace("start");
|
||||
|
||||
// is = GCUBEStorage.getRemoteFile("/Home/test.user/Workspace3d660604-03ef-49eb-89c3-4c73f8a47914");
|
||||
|
||||
try{
|
||||
|
||||
|
||||
Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome("francesco.mangiacrapa").getWorkspace();
|
||||
//
|
||||
// ExternalFile f = (ExternalFile) ws.getItem("907ce8ef-5c0b-4601-83ac-215d1f432f6b");
|
||||
|
||||
WorkspaceItem wsItem = ws.getItem("907ce8ef-5c0b-4601-83ac-215d1f432f6b");
|
||||
|
||||
|
||||
logger.trace("metadata info recovered from HL: [ID: "+wsItem.getId() +", name: "+wsItem.getName()+"]");
|
||||
|
||||
|
||||
|
||||
|
||||
FileOutputStream out = new FileOutputStream(new File("/tmp/bla"));
|
||||
// byte[] buffer = new byte[1024];
|
||||
// int len;
|
||||
// while ((len = is.read(buffer)) != -1) {
|
||||
// out.write(buffer, 0, len);
|
||||
// }
|
||||
|
||||
logger.trace("cast as external file");
|
||||
ExternalFile f = (ExternalFile) wsItem;
|
||||
|
||||
is = f.getData();
|
||||
|
||||
IOUtils.copy(is, out);
|
||||
is.close();
|
||||
|
||||
out.close();
|
||||
|
||||
// logger.trace("Sleeping");
|
||||
// Thread.sleep(20000);
|
||||
// logger.trace("Alive");
|
||||
|
||||
logger.trace("end");
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -35,16 +35,19 @@ 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;
|
||||
import org.gcube.portlets.user.workspace.shared.HandlerResultMessage;
|
||||
import org.gcube.portlets.user.workspace.shared.SessionExpiredException;
|
||||
|
||||
|
||||
/**
|
||||
* The Class DownloadServlet.
|
||||
*
|
||||
* @author Federico De Faveri defaveri@isti.cnr.it
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Dec 21, 2016
|
||||
*/
|
||||
public class DownloadServlet extends HttpServlet{
|
||||
|
||||
|
@ -61,13 +64,17 @@ public class DownloadServlet extends HttpServlet{
|
|||
logger.trace("Workspace DownloadServlet ready.");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||
*/
|
||||
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
|
||||
|
||||
String itemId = req.getParameter("id");
|
||||
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);
|
||||
String contextID = req.getParameter(ConstantsExplorer.CURRENT_CONTEXT_ID);
|
||||
String userID = req.getParameter(ConstantsExplorer.CURRENT_USER_ID);
|
||||
|
||||
logger.debug("Input Params [id: "+itemId + ", viewContent: "+viewContent+", "+ConstantsExplorer.VALIDATEITEM +": " +isValidItem+", urlRedirectOnError:" +urlRedirectOnError+", contextID: "+contextID+"]");
|
||||
if(itemId==null || itemId.isEmpty()){
|
||||
|
@ -82,9 +89,7 @@ public class DownloadServlet extends HttpServlet{
|
|||
if(WsUtil.isSessionExpired(req))
|
||||
throw new SessionExpiredException();
|
||||
|
||||
String currentScope= PortalContext.getConfiguration().getCurrentScope(contextID);
|
||||
logger.info("For ContextID: "+contextID +", read scope from Portal Context: "+currentScope);
|
||||
wa = WsUtil.getWorkspace(req, currentScope);
|
||||
wa = WsUtil.getWorkspace(req, contextID, userID);
|
||||
} catch (Exception e) {
|
||||
|
||||
if (e instanceof SessionExpiredException){
|
||||
|
@ -423,10 +428,11 @@ public class DownloadServlet extends HttpServlet{
|
|||
}
|
||||
|
||||
/**
|
||||
* Method to manage HttpServletResponse content length also to big data
|
||||
* @param resp
|
||||
* @param length
|
||||
* @return
|
||||
* Method to manage HttpServletResponse content length also to big data.
|
||||
*
|
||||
* @param resp the resp
|
||||
* @param length the length
|
||||
* @return the http servlet response
|
||||
*/
|
||||
protected HttpServletResponse setContentLength(HttpServletResponse resp, long length){
|
||||
try{
|
||||
|
@ -440,6 +446,16 @@ public class DownloadServlet extends HttpServlet{
|
|||
return resp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle error.
|
||||
*
|
||||
* @param urlRedirectOnError the url redirect on error
|
||||
* @param req the req
|
||||
* @param resp the resp
|
||||
* @param itemId the item id
|
||||
* @param message the message
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
protected void handleError(boolean urlRedirectOnError, HttpServletRequest req, HttpServletResponse resp, String itemId, String message) throws IOException{
|
||||
|
||||
logger.warn("Handle error occurred: "+message);
|
||||
|
@ -451,6 +467,13 @@ public class DownloadServlet extends HttpServlet{
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Send error.
|
||||
*
|
||||
* @param response the response
|
||||
* @param message the message
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
protected void sendError(HttpServletResponse response, String message) throws IOException
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
|
||||
|
@ -465,6 +488,14 @@ public class DownloadServlet extends HttpServlet{
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send error for status.
|
||||
*
|
||||
* @param response the response
|
||||
* @param message the message
|
||||
* @param status the status
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
protected void sendErrorForStatus(HttpServletResponse response, String message, int status) throws IOException
|
||||
{
|
||||
response.setStatus(status);
|
||||
|
@ -478,6 +509,13 @@ public class DownloadServlet extends HttpServlet{
|
|||
response.flushBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send message.
|
||||
*
|
||||
* @param response the response
|
||||
* @param message the message
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
protected void sendMessage(HttpServletResponse response, String message) throws IOException
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_ACCEPTED);
|
||||
|
@ -486,6 +524,13 @@ public class DownloadServlet extends HttpServlet{
|
|||
response.flushBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send message resource available.
|
||||
*
|
||||
* @param response the response
|
||||
* @param message the message
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
protected void sendMessageResourceAvailable(HttpServletResponse response, String message) throws IOException
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_ACCEPTED);
|
||||
|
@ -494,6 +539,13 @@ public class DownloadServlet extends HttpServlet{
|
|||
response.flushBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send warn message.
|
||||
*
|
||||
* @param response the response
|
||||
* @param message the message
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
protected void sendWarnMessage(HttpServletResponse response, String message) throws IOException
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_ACCEPTED);
|
||||
|
@ -502,6 +554,14 @@ public class DownloadServlet extends HttpServlet{
|
|||
response.flushBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Url redirect.
|
||||
*
|
||||
* @param req the req
|
||||
* @param response the response
|
||||
* @param fakePath the fake path
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
protected void urlRedirect(HttpServletRequest req, HttpServletResponse response, String fakePath) throws IOException {
|
||||
|
||||
String requestUrl = getRequestURL(req) +fakePath;
|
||||
|
@ -511,6 +571,12 @@ public class DownloadServlet extends HttpServlet{
|
|||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request url.
|
||||
*
|
||||
* @param req the req
|
||||
* @return the request url
|
||||
*/
|
||||
public static String getRequestURL(HttpServletRequest req) {
|
||||
|
||||
String scheme = req.getScheme(); // http
|
||||
|
@ -531,78 +597,16 @@ public class DownloadServlet extends HttpServlet{
|
|||
|
||||
logger.trace("server: "+url);
|
||||
logger.trace("omitted contextPath: "+contextPath);
|
||||
// logger.trace("servletPath: "+servletPath);
|
||||
// url.append(contextPath).append(servletPath);
|
||||
|
||||
// if (pathInfo != null) {
|
||||
// url.append(pathInfo);
|
||||
// }
|
||||
// if (queryString != null) {
|
||||
// url.append("?").append(queryString);
|
||||
// }
|
||||
|
||||
PortalUrlGroupGatewayProperty p = new PortalUrlGroupGatewayProperty();
|
||||
|
||||
int lenght = p.getPath().length();
|
||||
|
||||
String groupgatewaypath = "/";
|
||||
|
||||
if(lenght>1){
|
||||
|
||||
String lastChar = p.getPath().substring(lenght-1, lenght-1);
|
||||
|
||||
groupgatewaypath+= lastChar.compareTo("/")!=0?p.getPath()+"/":p.getPath();
|
||||
}
|
||||
|
||||
url.append(groupgatewaypath);
|
||||
|
||||
return url.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
public static void main(String[] args) {
|
||||
|
||||
InputStream is = null;
|
||||
|
||||
logger.trace("start");
|
||||
|
||||
// is = GCUBEStorage.getRemoteFile("/Home/test.user/Workspace3d660604-03ef-49eb-89c3-4c73f8a47914");
|
||||
|
||||
try{
|
||||
|
||||
Workspace ws = HomeLibrary.getHomeManagerFactory().getHomeManager().getHome("francesco.mangiacrapa").getWorkspace();
|
||||
//
|
||||
// ExternalFile f = (ExternalFile) ws.getItem("907ce8ef-5c0b-4601-83ac-215d1f432f6b");
|
||||
|
||||
WorkspaceItem wsItem = ws.getItem("907ce8ef-5c0b-4601-83ac-215d1f432f6b");
|
||||
|
||||
|
||||
logger.trace("metadata info recovered from HL: [ID: "+wsItem.getId() +", name: "+wsItem.getName()+"]");
|
||||
|
||||
FileOutputStream out = new FileOutputStream(new File("/tmp/bla"));
|
||||
// byte[] buffer = new byte[1024];
|
||||
// int len;
|
||||
// while ((len = is.read(buffer)) != -1) {
|
||||
// out.write(buffer, 0, len);
|
||||
// }
|
||||
|
||||
logger.trace("cast as external file");
|
||||
ExternalFile f = (ExternalFile) wsItem;
|
||||
|
||||
is = f.getData();
|
||||
|
||||
IOUtils.copy(is, out);
|
||||
is.close();
|
||||
|
||||
out.close();
|
||||
|
||||
// logger.trace("Sleeping");
|
||||
// Thread.sleep(20000);
|
||||
// logger.trace("Alive");
|
||||
|
||||
logger.trace("end");
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
|
|
@ -259,7 +259,7 @@ public class GWTWorkspaceBuilder {
|
|||
sb.append(id);
|
||||
sb.append("&type=");
|
||||
sb.append(requestType.toString());
|
||||
sb.append("&"+ConstantsExplorer.CONTEXT_ID+"=");
|
||||
sb.append("&"+ConstantsExplorer.CURRENT_CONTEXT_ID+"=");
|
||||
sb.append(currentGroupId);
|
||||
sb.append("&random=");
|
||||
sb.append(UUID.randomUUID().toString());
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
|||
import org.gcube.common.homelibrary.home.workspace.exceptions.ItemNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.folder.items.Image;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
|
||||
import org.gcube.portlets.user.workspace.client.util.ImageRequestType;
|
||||
import org.gcube.portlets.user.workspace.server.util.WsUtil;
|
||||
|
@ -59,9 +58,10 @@ public class ImageServlet extends HttpServlet{
|
|||
|
||||
String imageId = req.getParameter("id");
|
||||
String imageType = req.getParameter("type");
|
||||
String contextID = req.getParameter(ConstantsExplorer.CONTEXT_ID);
|
||||
String contextID = req.getParameter(ConstantsExplorer.CURRENT_CONTEXT_ID);
|
||||
String currUserId = req.getParameter(ConstantsExplorer.CURRENT_USER_ID);
|
||||
|
||||
logger.info("request image id: "+imageId+", type: "+imageType +", "+ConstantsExplorer.CONTEXT_ID+ ": "+contextID);
|
||||
logger.info("request image id: "+imageId+", type: "+imageType +", "+ConstantsExplorer.CURRENT_CONTEXT_ID+ ": "+contextID);
|
||||
|
||||
ImageRequestType requestType = null;
|
||||
|
||||
|
@ -73,9 +73,7 @@ public class ImageServlet extends HttpServlet{
|
|||
|
||||
Workspace wa = null;
|
||||
try {
|
||||
String currentScope= PortalContext.getConfiguration().getCurrentScope(contextID);
|
||||
logger.info("For ContextID: "+contextID +", read scope from Portal Context: "+currentScope);
|
||||
wa = WsUtil.getWorkspace(req, currentScope);
|
||||
wa = WsUtil.getWorkspace(req, contextID, currUserId);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during workspace retrieving", e);
|
||||
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"Error during workspace retrieving");
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParame
|
|||
import org.gcube.portlets.user.workspace.server.resolver.UriResolverReaderParameterForResolverIndex.RESOLVER_TYPE;
|
||||
import org.gcube.portlets.user.workspace.server.util.resource.PropertySpecialFolderReader;
|
||||
import org.gcube.portlets.user.workspace.server.util.scope.ScopeUtilFilter;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
|
@ -147,25 +148,47 @@ public class WsUtil {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the workspace.
|
||||
*
|
||||
* @param httpServletRequest the http servlet request
|
||||
* @param useThisScope the use this scope
|
||||
* @param contextID the context 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(HttpServletRequest httpServletRequest, String useThisScope) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
||||
public static Workspace getWorkspace(HttpServletRequest httpServletRequest, String contextID, String currUserId) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException
|
||||
{
|
||||
logger.trace("Get Workspace");
|
||||
PortalContextInfo info = getPortalContext(httpServletRequest, useThisScope);
|
||||
String currentScope = PortalContext.getConfiguration().getCurrentScope(contextID);
|
||||
logger.info("For ContextID: "+contextID +", read scope from Portal Context: "+currentScope);
|
||||
PortalContextInfo info = getPortalContext(httpServletRequest, currentScope);
|
||||
logger.trace("PortalContextInfo: "+info);
|
||||
|
||||
ScopeProvider.instance.set(info.getCurrentScope());
|
||||
logger.trace("Scope provider instancied");
|
||||
|
||||
String username = null;
|
||||
try {
|
||||
GCubeUser gCubeUser = new LiferayUserManager().getUserById(Long.valueOf(currUserId));
|
||||
logger.debug("Gcube user read from liferay: "+gCubeUser);
|
||||
if(gCubeUser!=null && gCubeUser.getUsername()!=null)
|
||||
username = gCubeUser.getUsername();
|
||||
} catch (Exception e) {
|
||||
String error = "Error retrieving gCubeUser for: [userId= "
|
||||
+ currUserId + ", scope: " + currentScope + "]";
|
||||
logger.error(error, e);
|
||||
}
|
||||
|
||||
if(username==null || username.isEmpty())
|
||||
username = PortalContext.getConfiguration().getCurrentUser(httpServletRequest).getUsername();
|
||||
|
||||
//overriding username
|
||||
info.setUsername(username);
|
||||
|
||||
Workspace workspace = HomeLibrary.getUserWorkspace(info.getUsername());
|
||||
return workspace;
|
||||
|
||||
|
|
Loading…
Reference in New Issue