|
|
|
@ -17,7 +17,6 @@ import javax.servlet.ServletContext;
|
|
|
|
|
|
|
|
|
|
import org.gcube.application.framework.core.session.ASLSession;
|
|
|
|
|
import org.gcube.application.framework.core.session.SessionManager;
|
|
|
|
|
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
|
|
|
|
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|
|
|
|
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
|
|
|
|
import org.gcube.portal.databook.server.DatabookStore;
|
|
|
|
@ -28,14 +27,13 @@ import org.gcube.portal.databook.shared.UserInfo;
|
|
|
|
|
import org.gcube.portlets.user.notifications.client.NotificationsService;
|
|
|
|
|
import org.gcube.portlets.user.notifications.shared.NotificationConstants;
|
|
|
|
|
import org.gcube.portlets.user.notifications.shared.NotificationPreference;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
|
|
|
|
import com.liferay.portal.kernel.util.WebKeys;
|
|
|
|
|
import com.liferay.portal.model.UserModel;
|
|
|
|
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
|
|
|
|
import com.liferay.portal.theme.ThemeDisplay;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The server side implementation of the RPC service.
|
|
|
|
@ -51,10 +49,6 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
|
|
|
|
|
* The store interface
|
|
|
|
|
*/
|
|
|
|
|
private DatabookStore store;
|
|
|
|
|
/**
|
|
|
|
|
* used for debugging in eclipse
|
|
|
|
|
*/
|
|
|
|
|
private boolean withinPortal = false;
|
|
|
|
|
/**
|
|
|
|
|
* connect to cassandra at startup
|
|
|
|
|
*/
|
|
|
|
@ -76,14 +70,23 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
|
|
|
|
|
if (user == null) {
|
|
|
|
|
user = getDevelopmentUser();
|
|
|
|
|
_log.warn("USER IS NULL setting "+user+" and Running OUTSIDE PORTAL");
|
|
|
|
|
withinPortal = false;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
withinPortal = true;
|
|
|
|
|
}
|
|
|
|
|
System.out.println("SessionID = " + sessionID);
|
|
|
|
|
_log.debug("SessionID = " + sessionID);
|
|
|
|
|
return SessionManager.getInstance().getASLSession(sessionID, user);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return true if you're running into the portal, false if in development
|
|
|
|
|
*/
|
|
|
|
|
private boolean isWithinPortal() {
|
|
|
|
|
try {
|
|
|
|
|
UserLocalServiceUtil.getService();
|
|
|
|
|
return true;
|
|
|
|
|
} catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) {
|
|
|
|
|
_log.trace("Development Mode ON");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* set the user in development mode
|
|
|
|
|
* @return
|
|
|
|
@ -100,14 +103,14 @@ public class NotificationsServiceImpl extends RemoteServiceServlet implements No
|
|
|
|
|
String fullName = username+" FULL";
|
|
|
|
|
String thumbnailURL = "images/Avatar_default.png";
|
|
|
|
|
|
|
|
|
|
if (withinPortal) {
|
|
|
|
|
UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
|
|
|
|
|
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
|
|
|
|
|
fullName = user.getFirstName() + " " + user.getLastName();
|
|
|
|
|
email = user.getEmailAddress();
|
|
|
|
|
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
|
|
|
|
|
String accountURL = themeDisplay.getURLMyAccount().toString();
|
|
|
|
|
UserInfo toReturn = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, false, null);
|
|
|
|
|
if (isWithinPortal()) {
|
|
|
|
|
GCubeUser user = new LiferayUserManager().getUserByUsername(username);
|
|
|
|
|
|
|
|
|
|
thumbnailURL = user.getUserAvatarURL();
|
|
|
|
|
fullName = user.getFullname();
|
|
|
|
|
email = user.getEmail();
|
|
|
|
|
String accountURL = "TODO";//TODO:
|
|
|
|
|
UserInfo toReturn = new UserInfo(username, fullName, thumbnailURL, email, accountURL, true, false, null);
|
|
|
|
|
return toReturn;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|