diff --git a/.classpath b/.classpath index b19a0f5..171d5e4 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -30,5 +30,5 @@ - + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index afd5d47..c57a49e 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -2,7 +2,7 @@ - + diff --git a/pom.xml b/pom.xml index 3b6f52d..803fa96 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.gcube.portlets.user notifications war - 1.4.0-SNAPSHOT + 2.0.0-SNAPSHOT gCube Notifications Portlet @@ -23,7 +23,7 @@ 1.7 1.7 ${project.build.directory}/${project.build.finalName} - + 6.2.5 UTF-8 UTF-8 @@ -64,6 +64,7 @@ org.gcube.portlets.user gcube-widgets + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) org.gcube.portlets.widgets @@ -78,6 +79,7 @@ org.gcube.portal custom-portal-handler + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) provided @@ -98,9 +100,15 @@ org.gcube.applicationsupportlayer accesslogger + + org.gcube.dvos + usermanagement-core + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + com.liferay.portal portal-service + ${liferay.version} provided diff --git a/src/main/java/org/gcube/portlets/user/notifications/server/NotificationsServiceImpl.java b/src/main/java/org/gcube/portlets/user/notifications/server/NotificationsServiceImpl.java index 198cbd3..23b76fe 100644 --- a/src/main/java/org/gcube/portlets/user/notifications/server/NotificationsServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/notifications/server/NotificationsServiceImpl.java @@ -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 { diff --git a/src/main/webapp/WEB-INF/liferay-display.xml b/src/main/webapp/WEB-INF/liferay-display.xml index effc7a4..c2079c6 100644 --- a/src/main/webapp/WEB-INF/liferay-display.xml +++ b/src/main/webapp/WEB-INF/liferay-display.xml @@ -1,5 +1,5 @@ - + diff --git a/src/main/webapp/WEB-INF/liferay-plugin-package.properties b/src/main/webapp/WEB-INF/liferay-plugin-package.properties index 40cc54b..62b8b01 100644 --- a/src/main/webapp/WEB-INF/liferay-plugin-package.properties +++ b/src/main/webapp/WEB-INF/liferay-plugin-package.properties @@ -4,6 +4,6 @@ module-incremental-version=1 tags= short-description= change-log= -page-url=http://www.d4science.org -author=D4Science Org. +page-url=http://www.gcube.system.org +author=Massimiliano Assante licenses=EUPL \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/liferay-portlet.xml b/src/main/webapp/WEB-INF/liferay-portlet.xml index 552ef47..2c01fb5 100644 --- a/src/main/webapp/WEB-INF/liferay-portlet.xml +++ b/src/main/webapp/WEB-INF/liferay-portlet.xml @@ -1,5 +1,5 @@ - + diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index ee7748f..8abb7f5 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,8 +1,9 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + version="3.0"> +