removed cache for ASL Notifications Manager

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@128978 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-06-01 16:43:17 +00:00
parent b0090f0ef9
commit 7fec78a6b6
3 changed files with 33 additions and 36 deletions

View File

@ -28,7 +28,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/home/francesco-mangiacrapa/libraries/asm-5.0.3/lib/asm-5.0.3.jar"/>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -9,7 +9,10 @@ import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.gcube.application.framework.core.session.ASLSession;
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.workspace.WorkspaceItem;
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
import org.gcube.common.scope.impl.ScopeBean;
@ -40,11 +43,29 @@ public class NotificationsWorkspaceUploaderProducer {
* @param request the request
*/
public NotificationsWorkspaceUploaderProducer(ASLSession aslSession, HttpServletRequest request) {
this.notificationsMng = WsUtil.getNotificationManager(aslSession, request);
this.notificationsMng = getNotificationManager(aslSession, request);
this.aslSession = aslSession;
this.userId = aslSession.getUsername();
}
/**
* Gets the notification manager.
*
* @param session the session
* @param request the request
* @return the notification manager
*/
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);
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);
}catch (Exception e) {
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+session.getUsername(),e);
return null;
}
}
/**
* Gets the notifications mng.
*

View File

@ -37,9 +37,9 @@ 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_PORTLET_CLASS_ID = WorkspaceUploadServletStream.class.getName(); //IN DEV
// 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
//IN DEV
public static final String TEST_SCOPE = "/gcube/devsec";
public static String TEST_USER = "francesco.mangiacrapa";
public static String TEST_USER_FULL_NAME = "Test User";
@ -47,13 +47,13 @@ public class WsUtil {
protected static Logger logger = Logger.getLogger(WsUtil.class);
// public static boolean withoutPortal = false;
// public static boolean withoutPortal = false;
/**
* Checks if is within portal.
*
* @return true if you're running into the portal, false if in development
*/
* Checks if is within portal.
*
* @return true if you're running into the portal, false if in development
*/
public static boolean isWithinPortal() {
try {
UserLocalServiceUtil.getService();
@ -161,33 +161,10 @@ public class WsUtil {
}
/**
* Gets the notification manager.
*
* @param session the session
* @param request the request
* @return the notification manager
*/
public static NotificationsManager getNotificationManager(ASLSession session, HttpServletRequest request)
{
NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER);
if (notifMng == null) {
try{
logger.trace("Create new NotificationsManager for user: "+session.getUsername());
logger.trace("New ApplicationNotificationsManager with portlet class name: "+NOTIFICATION_PORTLET_CLASS_ID);
SocialNetworkingSite site = new SocialNetworkingSite(request);
SocialNetworkingUser curser = new SocialNetworkingUser(session.getUsername(), session.getUserEmailAddress(), session.getUserFullName(), session.getUserAvatarId());
notifMng = new ApplicationNotificationsManager(site, session.getScope(), curser, NOTIFICATION_PORTLET_CLASS_ID);
session.setAttribute(NOTIFICATION_MANAGER, notifMng);
}catch (Exception e) {
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+session.getUsername(),e);
}
}
return notifMng;
}
/**
* Gets the notification producer.
@ -266,7 +243,7 @@ public class WsUtil {
throw new Exception("Invalid uploader");
if(uploader.isErasable()){
// session.setAttribute(uploader.getIdentifier(), null);
// session.setAttribute(uploader.getIdentifier(), null);
session.removeAttribute(uploader.getIdentifier());
logger.info("Erased uploader: "+uploader.getIdentifier());
}
@ -309,7 +286,7 @@ public class WsUtil {
/*TODO REMOVE SESSION KEY FROM SESSION MUST BE MANAGED IN ANOTHER WAY IN ORDER TO AVOID THATH IT'S REMOVED FROM SESSION BEFORE THAT
* POLLING RETRIEVES STATUS, USE A FLAG REMOVED?*/
logger.debug("Set erasable uploader: "+uploader.getIdentifier() +" in session");
// uploader = null;
// uploader = null;
uploader.setErasable(true);
putWorkspaceUploaderInSession(httpSession, uploader);
return true;