From 96006bba758f9653d1d0d03e78bc3918daebfa66 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Wed, 6 Apr 2016 14:35:20 +0000 Subject: [PATCH] updated to liferay 62 git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@126812 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 4 +- .settings/org.eclipse.wst.common.component | 9 ++ ...se.wst.common.project.facet.core.prefs.xml | 7 + ....eclipse.wst.common.project.facet.core.xml | 3 +- log.txt | 0 pom.xml | 56 +++++-- .../newsfeed/client/panels/NewsFeedPanel.java | 16 +- .../client/ui/AddCommentTemplate.java | 2 +- .../newsfeed/client/ui/SingleComment.java | 14 +- .../newsfeed/client/ui/SingleComment.ui.xml | 2 +- .../newsfeed/client/ui/TweetTemplate.java | 15 +- .../user/newsfeed/server/NewsServiceImpl.java | 142 ++++++++---------- .../portlets/user/newsfeed/server/Utils.java | 76 +++------- .../server/portlet/NewsFeedPortlet.java | 4 + src/main/webapp/NewsFeed.css | 72 +++------ src/main/webapp/WEB-INF/liferay-display.xml | 3 +- src/main/webapp/WEB-INF/liferay-portlet.xml | 2 +- src/main/webapp/WEB-INF/web.xml | 6 +- 18 files changed, 208 insertions(+), 225 deletions(-) create mode 100644 .settings/org.eclipse.wst.common.project.facet.core.prefs.xml create mode 100644 log.txt diff --git a/.classpath b/.classpath index 866643f..d1cf11c 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -31,5 +31,5 @@ - + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 7d33a49..c340b01 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,6 +4,15 @@ + + uses + + + uses + + + uses + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml new file mode 100644 index 0000000..cc81385 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index afd5d47..664cfd0 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -2,7 +2,8 @@ - + + diff --git a/log.txt b/log.txt new file mode 100644 index 0000000..e69de29 diff --git a/pom.xml b/pom.xml index af9d3d1..24b7cc1 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.gcube.portlets.user news-feed war - 1.13.1-SNAPSHOT + 2.0.0-SNAPSHOT gCube News Feed Portlet @@ -32,7 +32,7 @@ 1.7 1.7 ${project.build.directory}/${project.build.finalName} - + 6.2.5 UTF-8 UTF-8 @@ -48,12 +48,6 @@ - - xerces - xercesImpl - 2.9.1 - provided - com.google.gwt gwt-user @@ -100,7 +94,7 @@ org.gcube.portlets.widgets session-checker - [0.2.0-SNAPSHOT, 1.0.0-SNAPSHOT) + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) org.gcube.portlets.widgets @@ -120,7 +114,7 @@ org.gcube.portlets.widgets image-previewer-widget - 1.0.0-SNAPSHOT + [1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT) org.gcube.common @@ -146,22 +140,31 @@ org.gcube.portlets.user gcube-widgets + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) compile org.gcube.portal custom-portal-handler + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) provided + + org.gcube.common.portal + portal-manager + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + provided + + + org.gcube.dvos + usermanagement-core + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + org.gcube.core common-scope-maps compile - - org.gcube.dvos - usermanagement-core - com.google gwt-jsonmaker @@ -183,6 +186,25 @@ com.liferay.portal portal-service + ${liferay.version} + provided + + + com.liferay.portal + util-bridges + ${liferay.version} + provided + + + com.liferay.portal + util-taglib + ${liferay.version} + provided + + + com.liferay.portal + util-java + ${liferay.version} provided @@ -190,6 +212,12 @@ portlet-api provided + + javax.servlet + javax.servlet-api + 3.0.1 + provided + org.slf4j slf4j-log4j12 diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/panels/NewsFeedPanel.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/panels/NewsFeedPanel.java index bc6d3f6..3d079df 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/client/panels/NewsFeedPanel.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/panels/NewsFeedPanel.java @@ -6,6 +6,7 @@ import java.util.HashSet; import net.eliasbalasis.tibcopagebus4gwt.client.PageBusAdapterException; +import org.gcube.common.portal.GCubePortalConstants; import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portal.databook.client.util.Encoder; import org.gcube.portal.databook.shared.Attachment; @@ -17,6 +18,7 @@ import org.gcube.portal.databook.shared.FeedType; import org.gcube.portal.databook.shared.Like; import org.gcube.portal.databook.shared.PrivacyLevel; import org.gcube.portal.databook.shared.UserInfo; +import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper; import org.gcube.portlets.user.newsfeed.client.FilterType; import org.gcube.portlets.user.newsfeed.client.NewsFeed; import org.gcube.portlets.user.newsfeed.client.NewsService; @@ -202,8 +204,8 @@ public class NewsFeedPanel extends Composite { eventBus.addHandler(SelectedUserEvent.TYPE, new SelectedUserEventHandler() { @Override public void onSelectedUser(SelectedUserEvent event) { - GWT.log("event..."); - Location.assign(GCubeSocialNetworking.USER_PROFILE_LINK+"?"+ + final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; + Location.assign(profilePageURL+"?"+ Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+ Encoder.encode(event.getSelectedUser().getId())); } @@ -331,8 +333,8 @@ public class NewsFeedPanel extends Composite { showFeedTimelineSource = result.isShowTimelineSourceLabel(); isInfrastructure = true; } - else - mainPanel.addStyleName("framed"); +// else +// mainPanel.addStyleName("framed"); } }); @@ -414,8 +416,8 @@ public class NewsFeedPanel extends Composite { @Override public void onSuccess(EnhancedFeed result) { if (result.getFeed().getType() == FeedType.DISABLED) { - - String usrLink = ""+result.getFeed().getFullName()+ " "; @@ -772,7 +774,7 @@ public class NewsFeedPanel extends Composite { } else { newsPanel.add(new HTML("
" + "Sorry, looks like we've got nothing for you at the moment.
" + - "You may begin by joining some of the available " + + "You may begin by joining some of the available " + "
"+vreLabel+"s.
")); } isFirstTweet = true; diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/AddCommentTemplate.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/AddCommentTemplate.java index a25737b..259e883 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/AddCommentTemplate.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/AddCommentTemplate.java @@ -90,7 +90,7 @@ public class AddCommentTemplate extends Composite { mainPanel.removeStyleName("comment-hidden"); mainPanel.setStyleName("single-comment"); commentTextArea.addStyleName("comment-dark-color"); - submitButton.setText("Save"); + submitButton.setText("Edit"); } /** Used by AddCommentTemplate to instantiate SuperPosedTextArea */ diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/SingleComment.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/SingleComment.java index 47b647e..f6c8481 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/SingleComment.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/SingleComment.java @@ -1,8 +1,11 @@ package org.gcube.portlets.user.newsfeed.client.ui; +import org.gcube.common.portal.GCubePortalConstants; +import org.gcube.common.portal.PortalContext; import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portal.databook.client.util.Encoder; import org.gcube.portal.databook.shared.Comment; +import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper; import org.gcube.portlets.user.newsfeed.client.event.DeleteCommentEvent; import com.google.gwt.core.client.GWT; @@ -14,6 +17,7 @@ import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Event; +import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; @@ -85,8 +89,9 @@ public class SingleComment extends Composite { commentToShow = commentToShow.substring(0, TEXT_TO_SHOW_LENGHT) + "..."; seeMore.setHTML(" See More "); } - - commentText.setHTML(""+toShow.getFullName()+ " " + commentToShow); @@ -110,8 +115,9 @@ public class SingleComment extends Composite { commentToShow = commentToShow.replaceAll("<","<").replaceAll(">",">"); commentToShow = commentToShow.replaceAll("&","&"); - - commentText.setHTML(""+ myComment.getFullName()+" " + commentToShow); diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/SingleComment.ui.xml b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/SingleComment.ui.xml index f3c0e4d..83f2e44 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/SingleComment.ui.xml +++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/SingleComment.ui.xml @@ -11,7 +11,7 @@ + width="36px" height="36px" /> diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/TweetTemplate.java b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/TweetTemplate.java index 7ddc47c..cd097af 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/TweetTemplate.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/client/ui/TweetTemplate.java @@ -7,6 +7,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import org.gcube.common.portal.GCubePortalConstants; import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portal.databook.client.util.Encoder; import org.gcube.portal.databook.shared.Attachment; @@ -14,6 +15,7 @@ import org.gcube.portal.databook.shared.Comment; import org.gcube.portal.databook.shared.EnhancedFeed; import org.gcube.portal.databook.shared.Feed; import org.gcube.portal.databook.shared.UserInfo; +import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper; import org.gcube.portlets.user.newsfeed.client.event.AddLikeEvent; import org.gcube.portlets.user.newsfeed.client.event.DeleteFeedEvent; import org.gcube.portlets.user.newsfeed.client.event.OpenFeedEvent; @@ -37,6 +39,7 @@ import com.google.gwt.uibinder.client.UiField; import com.google.gwt.uibinder.client.UiHandler; import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.Window; +import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTMLPanel; @@ -301,10 +304,12 @@ public class TweetTemplate extends Composite { //replace the < & and > feedText = feedText.replaceAll("<","<").replaceAll(">",">"); feedText = feedText.replaceAll("&","&"); - + + final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; + if (! isAppFeed) { // sharePostArea.setHTML("" + NewsFeedPanel.SHARE_FWD_LABEL + ""); - contentArea.setHTML(""+feed.getFullName()+" " + feedText); @@ -441,7 +446,11 @@ public class TweetTemplate extends Composite { //replace the < & and > feedText = feedText.replaceAll("<","<").replaceAll(">",">"); feedText = feedText.replaceAll("&","&"); - contentArea.setHTML(""+ myFeed.getFeed().getFullName()+" " + feedText); diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java index 66137b4..8f36293 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/server/NewsServiceImpl.java @@ -21,10 +21,12 @@ 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.common.portal.GCubePortalConstants; +import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.impl.ScopeBean; import org.gcube.common.scope.impl.ScopeBean.Type; -import org.gcube.portal.custom.communitymanager.OrganizationsUtil; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; +import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl; import org.gcube.portal.databook.server.DatabookStore; import org.gcube.portal.databook.shared.Attachment; @@ -43,6 +45,7 @@ import org.gcube.portal.notifications.bean.GenericItemBean; import org.gcube.portal.notifications.thread.CommentNotificationsThread; import org.gcube.portal.notifications.thread.LikeNotificationsThread; import org.gcube.portal.notifications.thread.MentionNotificationsThread; +import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper; import org.gcube.portlets.user.newsfeed.client.NewsService; import org.gcube.portlets.user.newsfeed.shared.MoreFeedsBean; import org.gcube.portlets.user.newsfeed.shared.NewsConstants; @@ -51,21 +54,22 @@ import org.gcube.portlets.user.newsfeed.shared.UserSettings; import org.gcube.portlets.widgets.pickitem.shared.ItemBean; import org.gcube.socialnetworking.social_data_search_client.ElasticSearchClientImpl; import org.gcube.vomanagement.usermanagement.GroupManager; -import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager; +import org.gcube.vomanagement.usermanagement.UserManager; +import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; +import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault; +import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; +import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager; +import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; +import org.gcube.vomanagement.usermanagement.model.GCubeGroup; +import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; -import com.liferay.portal.kernel.util.WebKeys; -import com.liferay.portal.model.Organization; -import com.liferay.portal.model.Role; -import com.liferay.portal.model.User; -import com.liferay.portal.model.UserModel; -import com.liferay.portal.service.OrganizationLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil; -import com.liferay.portal.theme.ThemeDisplay; /** * The server side implementation of the RPC service. @@ -74,10 +78,7 @@ import com.liferay.portal.theme.ThemeDisplay; public class NewsServiceImpl extends RemoteServiceServlet implements NewsService { private static final Logger _log = LoggerFactory.getLogger(NewsServiceImpl.class); - /** - * - */ - private static final String ADMIN_ROLE = "Administrator"; + private static final String VRE_LABEL = "VRE_LABEL"; private static final String SHOW_TIMELINE_SOURCE = "SHOW_TIMELINE_SOURCE"; private static final String REFRESH_TIME = "REFRESH_TIME"; @@ -139,7 +140,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService */ public String getDevelopmentUser() { String user = NewsConstants.TEST_USER; - // user = "costantino.perciante"; +// user = "costantino.perciante"; return user; } /** @@ -179,18 +180,24 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService } if (username.compareTo(NewsConstants.TEST_USER) != 0 && !isDevelopment) { - 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(); - String accountURL = ""; + UserManager um = new LiferayUserManager(); + GCubeUser user = um.getUserByUsername(username); + + thumbnailURL = user.getUserAvatarURL(); + fullName = user.getFullname(); + email = user.getEmail(); + final String profilePageURL = + GCubePortalConstants.PREFIX_GROUP_URL + + PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest())+ + GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; + String accountURL = profilePageURL; + try { - ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY); - accountURL = themeDisplay.getURLMyAccount().toString(); + accountURL = ""; }catch (NullPointerException e) { e.printStackTrace(); } - UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, isAdmin(), null); + UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmail(), accountURL, true, isAdmin(), null); CustomConfiguration config = getUserConfiguration(); UserSettings toReturn = new UserSettings(userInfo, config.getRefreshTime(), session.getScopeName(), config.getVreLabel(), isInfrastructureScope(), config.isShowTimelineSource()); setUserSettingsInSession(toReturn); @@ -243,18 +250,20 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService return null; } - _log.info("****** retrieving feeds for user: " + userName); - User currUser = OrganizationsUtil.validateUser(userName); + _log.info("****** retrieving posts for user: " + userName); + UserManager um = new LiferayUserManager(); + GCubeUser currUser = um.getUserByUsername(userName); /** * this handles the case where the portlet is deployed outside of VREs (regular) */ if (isInfrastructureScope()) { + _log.info("****** risInfrastructureScope() = true"); //VRE Feeds GroupManager gm = new LiferayGroupManager(); - for (Organization org : currUser.getOrganizations()) { - if (gm.isVRE(org.getOrganizationId()+"")) { - String vreid = gm.getScope(""+org.getOrganizationId()); //get the scope - _log.trace("Reading feeds for VRE: " + vreid); + for (GCubeGroup group : gm.listGroupsByUser(currUser.getUserId())) { + if (gm.isVRE(group.getGroupId())) { + String vreid = gm.getInfrastructureScope(group.getGroupId()); //get the scope + _log.info("Reading feeds for VRE: " + vreid); ArrayList OrganizationFeeds = (ArrayList) store.getRecentFeedsByVRE(vreid, feedsNoPerCategory); for (Feed feed : OrganizationFeeds) { feedsMap.put(feed.getKey(), feed); @@ -328,16 +337,18 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService } String lowerCaseHashtag = hashtag.toLowerCase(); + /** * this handles the case where the portlet is deployed outside of VREs (regular) */ if (isInfrastructureScope()) { - User currUser = OrganizationsUtil.validateUser(userName); + UserManager um = new LiferayUserManager(); + GCubeUser currUser = um.getUserByUsername(userName); //VRE Feeds - for (Organization org : currUser.getOrganizations()) { - GroupManager gm = new LiferayGroupManager(); - if (gm.isVRE(org.getOrganizationId()+"")) { - String vreid = gm.getScope(""+org.getOrganizationId()); //get the scope + GroupManager gm = new LiferayGroupManager(); + for (GCubeGroup group : gm.listGroupsByUser(currUser.getUserId())) { + if (gm.isVRE(group.getGroupId())) { + String vreid = gm.getInfrastructureScope(group.getGroupId()); //get the scope ArrayList feeds = (ArrayList) store.getVREFeedsByHashtag(vreid, lowerCaseHashtag); for (Feed feed : feeds) { feedsMap.put(feed.getKey(), feed); @@ -410,11 +421,13 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService Set vres = new HashSet(); if (isInfrastructureScope()) { - User currUser = OrganizationsUtil.validateUser(userName); - for (Organization org : currUser.getOrganizations()) { - GroupManager gm = new LiferayGroupManager(); - if (gm.isVRE(org.getOrganizationId()+"")) { - String vreid = gm.getScope(""+org.getOrganizationId()); //get the scope + UserManager um = new LiferayUserManager(); + GCubeUser currUser = um.getUserByUsername(userName); + //VRE Feeds + GroupManager gm = new LiferayGroupManager(); + for (GCubeGroup group : gm.listGroupsByUser(currUser.getUserId())) { + if (gm.isVRE(group.getGroupId())) { + String vreid = gm.getInfrastructureScope(group.getGroupId()); //get the scope vres.add(vreid); } } @@ -701,7 +714,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService ArrayList mentionedUsers = null; if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) { mentionedUsers = getSelectedUserIds(mentionedUserFullNamesList); - escapedCommentText = Utils.convertMentionPeopleAnchorHTML(escapedCommentText, mentionedUsers); + escapedCommentText = Utils.convertMentionPeopleAnchorHTML(escapedCommentText, mentionedUsers, getThreadLocalRequest()); } Comment comment = new Comment(UUID.randomUUID().toString(), user.getUsername(), @@ -857,20 +870,13 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService if (! isWithinPortal()) { return ""; } - StringBuilder thumbnailURL = new StringBuilder("/image/user_male_portrait?img_id="); - User user = null; + String thumbnailURL = ""; try { - user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), screenName); - } - catch (com.liferay.portal.NoSuchUserException ex) { - return null; - } - catch (PortalException e) { - e.printStackTrace(); - } catch (SystemException e) { + thumbnailURL = new LiferayUserManager().getUserByUsername(screenName).getUserAvatarURL(); + } catch (UserManagementSystemException | UserRetrievalFault e) { e.printStackTrace(); } - return thumbnailURL.append(user.getPortraitId()).toString(); + return thumbnailURL; } @Override @@ -992,7 +998,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService if (fullNames == null) return new ArrayList(); else { - ArrayList allUsers = Utils.getOrganizationUsers("/"+OrganizationsUtil.getRootOrganizationName(), getASLSession().getUsername(), isWithinPortal()); + ArrayList allUsers = Utils.getOrganizationUsers("/"+PortalContext.getConfiguration().getInfrastructureName(), getASLSession().getUsername(), isWithinPortal()); ArrayList toReturn = new ArrayList(); for (String fullName : fullNames) for (ItemBean puser : allUsers) { @@ -1014,40 +1020,16 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService private boolean isAdmin() throws PortalException, SystemException { if (! isWithinPortal()) return false; - try { - User currUser = OrganizationsUtil.validateUser(getASLSession().getUsername()); - List organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount()); - Organization rootOrganization = null; - for (Organization organization : organizations) { - if (organization.getName().equals(OrganizationsUtil.getRootOrganizationName() ) ) { - rootOrganization = organization; - break; - } - } - - _log.trace("root: " + rootOrganization.getName() ); - return (hasRole(ADMIN_ROLE, rootOrganization.getName(), currUser)); + GCubeUser curUser = new LiferayUserManager().getUserByUsername(getASLSession().getUsername()); + return new LiferayRoleManager().isAdmin(curUser.getUserId()); } - catch (NullPointerException e) { - _log.error("Cannot find root organziation, please check gcube-data.properties file in $CATALINA_HOME/conf folder"); + catch (Exception e) { + _log.error("Could not check if the user is an Administrator, returning false"); return false; } } - /** - * - * @param rolename - * @param organizationName - * @param user - * @return - * @throws SystemException - */ - private boolean hasRole(String rolename, String organizationName, User user) throws SystemException { - for (Role role : user.getRoles()) - if (role.getName().compareTo(rolename) == 0 ) - return true; - return false; - } + /** * utilty method that convert a URL in a text into a clickable link into the browser * diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/server/Utils.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/Utils.java index 27d93fa..c03dd37 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/server/Utils.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/server/Utils.java @@ -7,21 +7,26 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.servlet.http.HttpServletRequest; + import org.apache.commons.codec.binary.Base64; +import org.gcube.common.portal.GCubePortalConstants; +import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.impl.ScopeBean; import org.gcube.common.scope.impl.ScopeBean.Type; -import org.gcube.portal.custom.communitymanager.OrganizationsUtil; import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portlets.widgets.pickitem.shared.ItemBean; import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.UserManager; -import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager; -import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager; -import org.gcube.vomanagement.usermanagement.model.UserModel; +import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; +import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; +import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.liferay.portal.service.UserLocalServiceUtil; +import com.liferay.portal.kernel.exception.PortalException; +import com.liferay.portal.kernel.exception.SystemException; +import com.liferay.portal.kernel.management.PortalManager; public class Utils { private static final Logger _log = LoggerFactory.getLogger(Utils.class); @@ -38,7 +43,7 @@ public class Utils { UserManager um = new LiferayUserManager(); GroupManager gm = new LiferayGroupManager(); ScopeBean sb = new ScopeBean(scope); - List users = null; + List users = null; if (sb.is(Type.INFRASTRUCTURE)) users = um.listUsersByGroup(gm.getRootVO().getGroupId()); @@ -52,12 +57,9 @@ public class Utils { _log.error("Error, you must be in SCOPE VRE OR INFRASTURCTURE, you are in VO SCOPE returning no users"); return portalUsers; } - for (UserModel user : users) { - if (user.getScreenName().compareTo("test.user") != 0 && user.getScreenName().compareTo(currUser) != 0) { //skip test.user & current user - String thumbnailURL = ""; - com.liferay.portal.model.UserModel lifeUser = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), user.getScreenName()); - thumbnailURL = "/image/user_male_portrait?img_id="+lifeUser.getPortraitId(); - portalUsers.add(new ItemBean(user.getUserId(), user.getScreenName(), user.getFullname(), thumbnailURL)); + for (GCubeUser user : users) { + if (user.getUsername().compareTo("test.user") != 0 && user.getUsername().compareTo(currUser) != 0) { //skip test.user & current user + portalUsers.add(new ItemBean(user.getUserId()+"", user.getUsername(), user.getFullname(), user.getUserAvatarURL())); } } } @@ -152,9 +154,15 @@ public class Utils { * @param taggedPeople * @return */ - protected static String convertMentionPeopleAnchorHTML(String escapedFeedText, ArrayList taggedPeople) { + protected static String convertMentionPeopleAnchorHTML(String escapedFeedText, ArrayList taggedPeople, HttpServletRequest request) { + String userProfilePageURL = ""; + try { + userProfilePageURL = PortalContext.getConfiguration().getSiteLandingPagePath(request)+GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; + } catch (PortalException | SystemException e) { + e.printStackTrace(); + } for (ItemBean tagged : taggedPeople) { - String taggedHTML = ""+tagged.getAlternativeName()+" "; @@ -180,43 +188,5 @@ public class Utils { } return null; } - - /** -// * -// * @param vreid -// * @param hashtag -// * @return the feed map for the client containing occurrences of the hashtag -// * @throws PrivacyLevelTypeNotFoundException -// * @throws FeedTypeNotFoundException -// * @throws FeedIDNotFoundException -// * @throws ColumnNameNotFoundException -// */ -// private HashMap getFeedsMap(String vreid, String hashtag) throws PrivacyLevelTypeNotFoundException, FeedTypeNotFoundException, FeedIDNotFoundException, ColumnNameNotFoundException { -// if (hashtag.length() < 2) -// throw new IllegalArgumentException("Hashtag length myst be greater than 1"); -// else { -// HashMap feedsMap = new HashMap(); -// String upperCase = hashtag; -// String lowerCase = hashtag; -// -// char afterHashtag = hashtag.charAt(1); -// if (Character.isUpperCase(afterHashtag)) { -// upperCase = hashtag; -// lowerCase =hashtag.substring(0,1)+Character.toLowerCase(afterHashtag)+hashtag.substring(2); -// } else { -// upperCase =hashtag.substring(0,1)+Character.toUpperCase(afterHashtag)+hashtag.substring(2); -// lowerCase = hashtag; -// } -// -// ArrayList lowerCaseFeeds = (ArrayList) store.getVREFeedsByHashtag(vreid, lowerCase); -// for (Feed feed : lowerCaseFeeds) { -// feedsMap.put(feed.getKey(), feed); -// } -// ArrayList upperCaseFeeds = (ArrayList) store.getVREFeedsByHashtag(vreid, upperCase); -// for (Feed feed : upperCaseFeeds) { -// feedsMap.put(feed.getKey(), feed); -// } -// return feedsMap; -// } -// } + } diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/server/portlet/NewsFeedPortlet.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/portlet/NewsFeedPortlet.java index ffed0ef..e25b84b 100644 --- a/src/main/java/org/gcube/portlets/user/newsfeed/server/portlet/NewsFeedPortlet.java +++ b/src/main/java/org/gcube/portlets/user/newsfeed/server/portlet/NewsFeedPortlet.java @@ -11,11 +11,15 @@ import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class NewsFeedPortlet extends GenericPortlet { + private static final Logger _log = LoggerFactory.getLogger(NewsFeedPortlet.class); public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { response.setContentType("text/html"); ScopeHelper.setContext(request); + _log.debug("NewsFeedPortlet context set"); PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/NewsFeed_view.jsp"); dispatcher.include(request, response); } diff --git a/src/main/webapp/NewsFeed.css b/src/main/webapp/NewsFeed.css index fa357b7..a96eeb4 100644 --- a/src/main/webapp/NewsFeed.css +++ b/src/main/webapp/NewsFeed.css @@ -1,4 +1,4 @@ -@import url(http://fonts.googleapis.com/css?family=Architects+Daughter); +@import url(https://fonts.googleapis.com/css?family=Architects+Daughter); table { border-collapse: separate !important; @@ -46,7 +46,7 @@ table { /* this is very important when usere paste long links*/ } -.post-comment { +div#comment-inputContainer textarea.post-comment { padding: 4px 2px; color: #999; background-color: transparent; @@ -60,6 +60,17 @@ table { margin-left: 5px; width: 430px; min-height: 30px; + border-radius: 5px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; +} + +div#comment-inputContainer textarea.post-comment.comment-dark-color { + color: #333; + background-color: transparent; + transition: background .25s ease-in-out; + -moz-transition: background .25s ease-in-out; + -webkit-transition: background .25s ease-in-out; } .highlightedUser { @@ -67,17 +78,6 @@ table { } /* DIV trick ends here */ -.framed { - margin: 0 0 10px; - padding: 10px; - margin: 0 5px; - background: #FFF; - border-radius: 6px !important; - -moz-border-radius: 6px !important; - -webkit-border-radius: 6px !important; - border: 1px solid #DBDBDB; -} - .new-feeds-container { position: relative; } @@ -249,17 +249,12 @@ table { line-height: 14px; } -.member-photo { +img.member-photo { display: block; padding: 2px; border: 1px solid #E6E6E6; } -.commentsPanel { - width: 410px !important; - padding-left: 5px; -} - .comment-hidden { opacity: 0; } @@ -276,7 +271,7 @@ table { .commentsPanel { width: 99%; - margin-top: 4px; + margin: 4px 0 0 4px; } .more-comment { @@ -289,14 +284,14 @@ table { border-bottom-width: 1px; } -.single-comment { +div>table.single-comment { background-color: #EFF3F5; border-bottom-color: #FFF; border-bottom-style: solid; border-bottom-width: 1px; border-left: 2px solid #DDD; padding-left: 3px; - width: 494px; + width: 495px; } .comment-bgcolor { @@ -398,11 +393,6 @@ a.seemore, a.seemore:visited { color: #3B5998; } -a.seemore:hover { - opacity: 0.8; - text-decoration: underline; -} - a.person-link { font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 16x; @@ -418,11 +408,6 @@ a.person-link, a.person-link:visited { color: #3B5998; } -a.person-link:hover { - opacity: 0.8; - font-size: 16x; - text-decoration: underline; -} .tweet-content { font-family: 'Helvetica Neue', Arial, sans-serif; @@ -468,12 +453,6 @@ a.person-link:hover { background: url("images/star_blue.png") no-repeat left; } -.tweet-actions .likes-number:hover, .show-comments-number:hover { - opacity: 0.8; - cursor: pointer; - cursor: hand; -} - .tweet-actions .comments-number, .show-comments-number { color: #3B5998; width: 20px; @@ -491,12 +470,7 @@ a.person-link:hover { cursor: hand; } -.tweet-actions div a:hover { - opacity: 0.8; - text-decoration: underline; -} - -a.link, a.link:active, a.link:visited { +div.tweet-content a.link, div.tweet-content a.link:active, div.tweet-content a.link:visited, div.user-comment a.link, div.user-comment a.link:active, div.user-comment a.link:visited { font-family: 'Lucida Grande', Verdana, 'Bitstream Vera Sans', Arial, sans-serif; font-size: 12px; @@ -592,12 +566,4 @@ a.link:hover { transition: background .45s ease-in-out; -moz-transition: background .45s ease-in-out; -webkit-transition: background .45s ease-in-out; -} - -.comment-dark-color { - color: #333; - background-color: transparent; - transition: background .25s ease-in-out; - -moz-transition: background .25s ease-in-out; - -webkit-transition: background .25s ease-in-out; -} +} \ No newline at end of file diff --git a/src/main/webapp/WEB-INF/liferay-display.xml b/src/main/webapp/WEB-INF/liferay-display.xml index e90e2e7..ff6aaa3 100644 --- a/src/main/webapp/WEB-INF/liferay-display.xml +++ b/src/main/webapp/WEB-INF/liferay-display.xml @@ -1,6 +1,5 @@ - - + diff --git a/src/main/webapp/WEB-INF/liferay-portlet.xml b/src/main/webapp/WEB-INF/liferay-portlet.xml index 903f230..282346b 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 c5b48ee..4f93f03 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,8 +1,8 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + version="3.0">