Fixed issue on getServerName()
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@130367 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3dd5bd1016
commit
627f65af26
|
@ -34,6 +34,7 @@ import org.gcube.common.homelibrary.util.Extensions;
|
|||
import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploader;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploaderProducer;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.shared.HandlerResultMessage;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
||||
|
@ -375,6 +376,9 @@ public class WorkspaceUploadServlet extends HttpServlet {
|
|||
*/
|
||||
public static void notifyUploadInSharedFolder(final HttpServletRequest request, final HttpSession httpSession, final Workspace workspace, final String itemId, final String destinationFolderId, final boolean isOverwrite){
|
||||
|
||||
boolean requestIsNull = request==null;
|
||||
logger.trace("[2] HttpServletRequest is: null? "+requestIsNull+", URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||
final NotificationsWorkspaceUploaderProducer np = new NotificationsWorkspaceUploaderProducer(httpSession,request);
|
||||
new Thread(){
|
||||
public void run() {
|
||||
WorkspaceItem sourceItem;
|
||||
|
@ -382,7 +386,8 @@ public class WorkspaceUploadServlet extends HttpServlet {
|
|||
sourceItem = workspace.getItem(itemId);
|
||||
String sourceSharedId = sourceItem.getIdSharedFolder();
|
||||
WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId);
|
||||
NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(request, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
||||
logger.trace("[3] HttpServletRequest is: URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||
NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(np, request, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error in notifyUploadInSharedFolder", e);
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ import org.gcube.common.homelibrary.util.MimeTypeUtil;
|
|||
import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploader;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploaderProducer;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.upload.AbstractUploadProgressListener;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.upload.MemoryUploadListener;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.upload.UploadCanceledException;
|
||||
|
@ -162,6 +163,8 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
|
||||
System.out.println("POST on UploadServlet");
|
||||
logger.info("POST on UploadServlet");
|
||||
boolean requestIsNull = request==null;
|
||||
logger.trace("[1] HttpServletRequest is: null? "+requestIsNull+", URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||
|
||||
if (!ServletFileUpload.isMultipartContent(request)) {
|
||||
logger.error("ERROR: multipart request not found");
|
||||
|
@ -639,6 +642,8 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
*/
|
||||
public static void notifyUploadInSharedFolder(final HttpServletRequest request, final HttpSession httpSession, final Workspace workspace, final String itemId, final String destinationFolderId, final boolean isOverwrite){
|
||||
|
||||
logger.trace("[2] HttpServletRequest is: URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||
final NotificationsWorkspaceUploaderProducer np = new NotificationsWorkspaceUploaderProducer(httpSession,request);
|
||||
new Thread(){
|
||||
public void run() {
|
||||
WorkspaceItem sourceItem;
|
||||
|
@ -646,7 +651,8 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
sourceItem = workspace.getItem(itemId);
|
||||
String sourceSharedId = sourceItem.getIdSharedFolder();
|
||||
WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId);
|
||||
NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(request, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
||||
logger.trace("[3] HttpServletRequest is: URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||
NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(np, request, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error in notifyUploadInSharedFolder", e);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class NotificationsWorkspaceUploader {
|
|||
* @param sourceSharedId
|
||||
* @param folderDestinationItem
|
||||
*/
|
||||
public static void checkSendNotifyChangedItemToShare(HttpServletRequest request, HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) {
|
||||
public static void checkSendNotifyChangedItemToShare(NotificationsWorkspaceUploaderProducer np, HttpServletRequest request, HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) {
|
||||
|
||||
logger.trace("checkSendNotifyAddItemToShare");
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class NotificationsWorkspaceUploader {
|
|||
|
||||
WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder());
|
||||
|
||||
NotificationsWorkspaceUploaderProducer np = new NotificationsWorkspaceUploaderProducer(WsUtil.getAslSession(httpSession),request);
|
||||
logger.trace("[4] HttpServletRequest is: URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||
|
||||
if(destinationSharedFolder instanceof WorkspaceSharedFolder){
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ package org.gcube.portlets.widgets.workspaceuploader.server.notification;
|
|||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
|
@ -37,27 +38,33 @@ public class NotificationsWorkspaceUploaderProducer {
|
|||
protected String userId;
|
||||
|
||||
/**
|
||||
* Instantiates a new notifications producer.
|
||||
* Instantiates a new notifications workspace uploader producer.
|
||||
*
|
||||
* @param httpSession the http session
|
||||
* @param aslSession the asl session
|
||||
* @param request the request
|
||||
*/
|
||||
public NotificationsWorkspaceUploaderProducer(ASLSession aslSession, HttpServletRequest request) {
|
||||
this.notificationsMng = getNotificationManager(aslSession, request);
|
||||
this.aslSession = aslSession;
|
||||
public NotificationsWorkspaceUploaderProducer(HttpSession httpSession, HttpServletRequest request) {
|
||||
this.aslSession = WsUtil.getAslSession(httpSession);
|
||||
this.notificationsMng = getNotificationManager(httpSession, aslSession, request);
|
||||
this.userId = aslSession.getUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the notification manager.
|
||||
*
|
||||
* @param httpSession the http session
|
||||
* @param session the session
|
||||
* @param request the request
|
||||
* @return the notification manager
|
||||
*/
|
||||
public NotificationsManager getNotificationManager(ASLSession session, HttpServletRequest request) {
|
||||
/*public NotificationsManager getNotificationManager(ASLSession session, HttpServletRequest request) {
|
||||
try{
|
||||
logger.trace("Create new NotificationsManager for user: "+session.getUsername());
|
||||
logger.trace("New ApplicationNotificationsManager with portlet class name: "+WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
|
||||
boolean isRequestNull = request==null;
|
||||
// logger.info("The request is null? "+isRequestNull +", request URL: "+request.getRequestURL());
|
||||
logger.info("The request is null? "+isRequestNull);
|
||||
SocialNetworkingSite site = new SocialNetworkingSite(request);
|
||||
SocialNetworkingUser curser = new SocialNetworkingUser(session.getUsername(), session.getUserEmailAddress(), session.getUserFullName(), session.getUserAvatarId());
|
||||
return new ApplicationNotificationsManager(site, session.getScope(), curser, WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
|
||||
|
@ -65,6 +72,42 @@ public class NotificationsWorkspaceUploaderProducer {
|
|||
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+session.getUsername(),e);
|
||||
return null;
|
||||
}
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Gets the notification manager.
|
||||
*
|
||||
* @param session the session
|
||||
* @param request the request
|
||||
* @return the notification manager
|
||||
*/
|
||||
public NotificationsManager getNotificationManager(HttpSession httpSession, ASLSession session, HttpServletRequest request)
|
||||
{
|
||||
|
||||
NotificationsManager notifMng = (NotificationsManager) httpSession.getAttribute(WsUtil.NOTIFICATION_MANAGER_UPLOADER);
|
||||
|
||||
if (notifMng == null) {
|
||||
try{
|
||||
logger.trace("Create new NotificationsManager for user: "+session.getUsername());
|
||||
logger.trace("New ApplicationNotificationsManager with portlet class name: "+WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
|
||||
logger.info("Request URI: "+request.getRequestURI());
|
||||
SocialNetworkingSite site = new SocialNetworkingSite(request);
|
||||
SocialNetworkingUser curser = new SocialNetworkingUser(session.getUsername(), session.getUserEmailAddress(), session.getUserFullName(), session.getUserAvatarId());
|
||||
notifMng = new ApplicationNotificationsManager(site, session.getScope(), curser, WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
|
||||
httpSession.setAttribute(WsUtil.NOTIFICATION_MANAGER_UPLOADER, notifMng);
|
||||
}catch (Exception e) {
|
||||
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+session.getUsername(),e);
|
||||
}
|
||||
}
|
||||
|
||||
return notifMng;
|
||||
/*logger.trace("Create new NotificationsManager for user: "+session.getUsername());
|
||||
logger.trace("New ApplicationNotificationsManager with portlet class name: "+WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
|
||||
boolean requestIsNull = request==null;
|
||||
logger.info("[5] HttpServletRequest is: null? "+requestIsNull+", URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||
SocialNetworkingSite site = new SocialNetworkingSite(request);
|
||||
SocialNetworkingUser curser = new SocialNetworkingUser(session.getUsername(), session.getUserEmailAddress(), session.getUserFullName(), session.getUserAvatarId());
|
||||
return new ApplicationNotificationsManager(site, session.getScope(), curser, WsUtil.NOTIFICATION_PORTLET_CLASS_ID);*/
|
||||
}
|
||||
/**
|
||||
* Gets the notifications mng.
|
||||
|
|
|
@ -3,16 +3,11 @@
|
|||
*/
|
||||
package org.gcube.portlets.widgets.workspaceuploader.server.util;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
|
@ -20,7 +15,6 @@ import org.gcube.common.homelibrary.home.workspace.Workspace;
|
|||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploaderProducer;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
||||
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
|
@ -35,8 +29,8 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
|||
public class WsUtil {
|
||||
|
||||
public static final String USERNAME_ATTRIBUTE = ScopeHelper.USERNAME_ATTRIBUTE;
|
||||
public static final String NOTIFICATION_MANAGER = "WORKSPACE_UPLOADER_NOTIFICATION_MANAGER";
|
||||
public static final String NOTIFICATION_PRODUCER = "WORKSPACE_UPLOADER_NOTIFICATION_PRODUCER";
|
||||
public static final String NOTIFICATION_MANAGER_UPLOADER = "WS_UPLOADER_NOTIFICATION_MANAGER";
|
||||
// public static final String NOTIFICATION_PRODUCER = "WORKSPACE_UPLOADER_NOTIFICATION_PRODUCER";
|
||||
// public static final String NOTIFICATION_PORTLET_CLASS_ID = WorkspaceUploadServletStream.class.getName(); //IN DEV
|
||||
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl";
|
||||
//IN DEV
|
||||
|
@ -137,8 +131,6 @@ public class WsUtil {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the workspace.
|
||||
*
|
||||
|
@ -160,32 +152,27 @@ public class WsUtil {
|
|||
return HomeLibrary.getUserWorkspace(session.getUsername());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the notification producer.
|
||||
*
|
||||
* @param session the session
|
||||
* @param request the request
|
||||
* @return the notification producer
|
||||
*/
|
||||
public static NotificationsWorkspaceUploaderProducer getNotificationProducer(ASLSession session, HttpServletRequest request)
|
||||
{
|
||||
|
||||
NotificationsWorkspaceUploaderProducer notifProducer = (NotificationsWorkspaceUploaderProducer) session.getAttribute(NOTIFICATION_PRODUCER);
|
||||
|
||||
if (notifProducer == null) {
|
||||
logger.trace("Create new Notification Producer for user: "+session.getUsername());
|
||||
notifProducer = new NotificationsWorkspaceUploaderProducer(session, request);
|
||||
session.setAttribute(NOTIFICATION_PRODUCER, notifProducer);
|
||||
}
|
||||
|
||||
return notifProducer;
|
||||
}
|
||||
//
|
||||
// /**
|
||||
// * Gets the notification producer.
|
||||
// *
|
||||
// * @param session the session
|
||||
// * @param request the request
|
||||
// * @return the notification producer
|
||||
// */
|
||||
// public static NotificationsWorkspaceUploaderProducer getNotificationProducer(ASLSession session, HttpServletRequest request)
|
||||
// {
|
||||
//
|
||||
// NotificationsWorkspaceUploaderProducer notifProducer = (NotificationsWorkspaceUploaderProducer) session.getAttribute(NOTIFICATION_PRODUCER);
|
||||
//
|
||||
// if (notifProducer == null) {
|
||||
// logger.trace("Create new Notification Producer for user: "+session.getUsername());
|
||||
// notifProducer = new NotificationsWorkspaceUploaderProducer(session, request);
|
||||
// session.setAttribute(NOTIFICATION_PRODUCER, notifProducer);
|
||||
// }
|
||||
//
|
||||
// return notifProducer;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Put workspace uploader in session.
|
||||
|
|
Loading…
Reference in New Issue