git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@135164 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2016-12-01 13:15:12 +00:00
parent c1a735694f
commit a3e19f3afa
2 changed files with 11 additions and 13 deletions

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.widgets.workspaceuploader.server;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
@ -61,7 +62,7 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement
logger.info("returning uploader: "+uploader.getClientUploadKey() +" status: "+uploader.getUploadStatus() +", file: "+uploader.getFile().toString() +", progress: "+progress);
checkUploaderErasable(getThreadLocalRequest().getSession(), uploader);
checkUploaderErasable(this.getThreadLocalRequest(), uploader);
return uploader;
}
@ -73,7 +74,7 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement
* @param httpSession the http session
* @param uploader the uploader
*/
private void checkUploaderErasable(final HttpSession httpSession, final WorkspaceUploaderItem uploader){
private void checkUploaderErasable(final HttpServletRequest httpRequest, final WorkspaceUploaderItem uploader){
logger.trace("Checking Uploader erasable...");
if(uploader==null){
@ -81,13 +82,15 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement
return;
}
final HttpSession session = httpRequest.getSession();
new Thread(){
@Override
public void run() {
try {
logger.trace("Uploader: "+uploader.getClientUploadKey() +", is erasable?");
WsUtil.eraseWorkspaceUploaderInSession(getThreadLocalRequest(), uploader);
logger.trace("Uploader: "+uploader.getClientUploadKey() +", is erasable? "+uploader.isErasable());
WsUtil.eraseWorkspaceUploaderInSession(session, uploader);
}
catch (Exception e) {
logger.warn("Error during checkUploaderErasable: ", e);

View File

@ -7,7 +7,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
@ -75,7 +74,7 @@ public class WsUtil {
ScopeProvider.instance.set(scope);
return HomeLibrary.getUserWorkspace(username);
}
/**
* Gets the workspace.
*
@ -106,7 +105,7 @@ public class WsUtil {
*/
public static void putWorkspaceUploaderInSession(final HttpSession httpSession, WorkspaceUploaderItem uploader) throws Exception {
logger.trace("Put workspace uploader in session: "+uploader.getIdentifier() + ", STATUS: "+uploader.getUploadStatus());
if(uploader.getIdentifier()==null || uploader.getIdentifier().isEmpty())
throw new Exception("Invalid uploader");
@ -141,18 +140,14 @@ public class WsUtil {
* @param uploader the uploader
* @throws Exception the exception
*/
public static void eraseWorkspaceUploaderInSession(final HttpServletRequest request, WorkspaceUploaderItem uploader) throws Exception
public static void eraseWorkspaceUploaderInSession(final HttpSession httpSession, WorkspaceUploaderItem uploader) throws Exception
{
logger.trace("Erase WorkspaceUploader workspace uploader in session: "+uploader.getIdentifier() + ", erasable? "+uploader.isErasable());
if(uploader==null || uploader.getIdentifier()==null || uploader.getIdentifier().isEmpty())
throw new Exception("Invalid uploader");
HttpSession httpSession = request.getSession();
if(uploader.isErasable()){
// session.setAttribute(uploader.getIdentifier(), null);
httpSession.removeAttribute(uploader.getIdentifier());
logger.info("Erased uploader: "+uploader.getIdentifier());
}
@ -187,7 +182,7 @@ public class WsUtil {
* @throws Exception the exception
*/
public static boolean setErasableWorkspaceUploaderInSession(final HttpServletRequest request, String uploaderIdentifier) throws Exception {
HttpSession httpSession = request.getSession();
WorkspaceUploaderItem uploader = getWorkspaceUploaderInSession(request, uploaderIdentifier);