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
This commit is contained in:
Massimiliano Assante 2016-04-06 14:35:20 +00:00
parent 5fcef05c31
commit 96006bba75
18 changed files with 208 additions and 225 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/news-feed-1.13.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/news-feed-2.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -31,5 +31,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/news-feed-1.13.1-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/news-feed-2.0.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -4,6 +4,15 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<dependent-module archiveName="session-checker-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/session-checker/session-checker">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="pickitem-widget-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickitem-widget/pickitem-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="gcube-widgets-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="news-feed"/>
</wb-module>

View File

@ -0,0 +1,7 @@
<root>
<facet id="jst.jaxrs">
<node name="libprov">
<attribute name="provider-id" value="jaxrs-no-op-library-provider"/>
</node>
</facet>
</root>

View File

@ -2,7 +2,8 @@
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="jst.web" version="2.5"/>
<installed facet="java" version="1.7"/>
<installed facet="liferay.portlet" version="6.0"/>
<installed facet="jst.jaxrs" version="2.0"/>
<installed facet="jst.web" version="3.0"/>
</faceted-project>

0
log.txt Normal file
View File

56
pom.xml
View File

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>news-feed</artifactId>
<packaging>war</packaging>
<version>1.13.1-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<name>gCube News Feed Portlet</name>
<description>
@ -32,7 +32,7 @@
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<liferay.version>6.2.5</liferay.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
@ -48,12 +48,6 @@
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
@ -100,7 +94,7 @@
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>session-checker</artifactId>
<version>[0.2.0-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
@ -120,7 +114,7 @@
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>image-previewer-widget</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>[1.1.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
@ -146,22 +140,31 @@
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-scope-maps</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
</dependency>
<dependency>
<groupId>com.google</groupId>
<artifactId>gwt-jsonmaker</artifactId>
@ -183,6 +186,25 @@
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-bridges</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-taglib</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-java</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -190,6 +212,12 @@
<artifactId>portlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>

View File

@ -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 = "<a class=\"link\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK+"?"+
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
String usrLink = "<a class=\"link\" href=\""+profilePageURL+"?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(result.getFeed().getEntityId())+"\">"+result.getFeed().getFullName()+
"</a> ";
@ -772,7 +774,7 @@ public class NewsFeedPanel extends Composite {
} else {
newsPanel.add(new HTML("<div class=\"nofeed-message\">" +
"Sorry, looks like we've got nothing for you at the moment. <br> " +
"You may begin by <a class=\"vrelink\" href=\"/group/data-e-infrastructure-gateway/join-new/\"><span class=\"important\">joining</span></a> some of the available " +
"You may begin by joining some of the available " +
"<br>"+vreLabel+"s.</div>"));
}
isFirstTweet = true;

View File

@ -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 */

View File

@ -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("<a class=\"seemore\"> See More </a>");
}
commentText.setHTML("<a class=\"link\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK+"?"+
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
commentText.setHTML("<a class=\"link\" href=\"" + profilePageURL + "?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(toShow.getUserid())+"\">"+toShow.getFullName()+
"</a> " + commentToShow);
@ -110,8 +115,9 @@ public class SingleComment extends Composite {
commentToShow = commentToShow.replaceAll("&lt;","<").replaceAll("&gt;",">");
commentToShow = commentToShow.replaceAll("&amp;","&");
commentText.setHTML("<a class=\"link\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK+"?"+
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
commentText.setHTML("<a class=\"link\" href=\"" + profilePageURL + "?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(myComment.getUserid())+"\">"+
myComment.getFullName()+"</a> " + commentToShow);

View File

@ -11,7 +11,7 @@
<tr>
<td width="30px" align="middle">
<g:Image styleName="member-photo" url="" ui:field="avatarImage"
width="30px" height="30px" />
width="36px" height="36px" />
<m:AvatarReplacement4Comments visible="false"
ui:field="avatarReplacement"></m:AvatarReplacement4Comments>
</td>

View File

@ -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("&lt;","<").replaceAll("&gt;",">");
feedText = feedText.replaceAll("&amp;","&");
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
if (! isAppFeed) {
// sharePostArea.setHTML("<a>" + NewsFeedPanel.SHARE_FWD_LABEL + "</a>");
contentArea.setHTML("<a class=\"link\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK
contentArea.setHTML("<a class=\"link\" href=\""+profilePageURL
+"?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(feed.getEntityId())+"\">"+feed.getFullName()+"</a> " + feedText);
@ -441,7 +446,11 @@ public class TweetTemplate extends Composite {
//replace the < & and >
feedText = feedText.replaceAll("&lt;","<").replaceAll("&gt;",">");
feedText = feedText.replaceAll("&amp;","&");
contentArea.setHTML("<a class=\"link\"href=\""+GCubeSocialNetworking.USER_PROFILE_LINK+"?"+
final String profilePageURL = GCubePortalConstants.PREFIX_GROUP_URL + ClientScopeHelper.extractOrgFriendlyURL(Location.getHref()) +GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
contentArea.setHTML("<a class=\"link\"href=\"" + profilePageURL + "?"+
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
Encoder.encode(myFeed.getFeed().getEntityId())+"\">"+
myFeed.getFeed().getFullName()+"</a> " + feedText);

View File

@ -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<Feed> OrganizationFeeds = (ArrayList<Feed>) 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<Feed> feeds = (ArrayList<Feed>) 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<String> vres = new HashSet<String>();
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<ItemBean> 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<ItemBean>();
else {
ArrayList<ItemBean> allUsers = Utils.getOrganizationUsers("/"+OrganizationsUtil.getRootOrganizationName(), getASLSession().getUsername(), isWithinPortal());
ArrayList<ItemBean> allUsers = Utils.getOrganizationUsers("/"+PortalContext.getConfiguration().getInfrastructureName(), getASLSession().getUsername(), isWithinPortal());
ArrayList<ItemBean> toReturn = new ArrayList<ItemBean>();
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<Organization> 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
*

View File

@ -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<UserModel> users = null;
List<GCubeUser> 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<ItemBean> taggedPeople) {
protected static String convertMentionPeopleAnchorHTML(String escapedFeedText, ArrayList<ItemBean> 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 = "<a class=\"link\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK
String taggedHTML = "<a class=\"link\" href=\""+userProfilePageURL
+"?"+
new String(Base64.encodeBase64(GCubeSocialNetworking.USER_PROFILE_OID.getBytes()))+"="+
new String(Base64.encodeBase64(tagged.getName().getBytes()))+"\">"+tagged.getAlternativeName()+"</a> ";
@ -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<String, Feed> 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<String, Feed> feedsMap = new HashMap<String, Feed>();
// 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<Feed> lowerCaseFeeds = (ArrayList<Feed>) store.getVREFeedsByHashtag(vreid, lowerCase);
// for (Feed feed : lowerCaseFeeds) {
// feedsMap.put(feed.getKey(), feed);
// }
// ArrayList<Feed> upperCaseFeeds = (ArrayList<Feed>) store.getVREFeedsByHashtag(vreid, upperCase);
// for (Feed feed : upperCaseFeeds) {
// feedsMap.put(feed.getKey(), feed);
// }
// return feedsMap;
// }
// }
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -1,6 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.0.0//EN" "http://www.liferay.com/dtd/liferay-display_6_0_0.dtd">
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.2.0//EN" "http://www.liferay.com/dtd/liferay-display_6_2_0.dtd">
<display>
<category name="gCube Social Apps">
<portlet id="NewsFeed" />

View File

@ -1,5 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 5.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_0_0.dtd">
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_2_0.dtd">
<liferay-portlet-app>
<portlet>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<!-- Servlets -->
<servlet>