added refreshing time in prop file
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@72932 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
76dd55c325
commit
ae51ecbc94
|
@ -6,7 +6,6 @@
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="src" path="target/generated-sources/gwt"/>
|
|
||||||
<classpathentry including="**/*.java" kind="src" output="src/main/webapp/WEB-INF/classes" path="src/main/resources"/>
|
<classpathentry including="**/*.java" kind="src" output="src/main/webapp/WEB-INF/classes" path="src/main/resources"/>
|
||||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
<attributes>
|
<attributes>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#Tue Apr 02 16:01:09 CEST 2013
|
#Thu Apr 04 16:40:07 CEST 2013
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<faceted-project>
|
<faceted-project>
|
||||||
<fixed facet="wst.jsdt.web"/>
|
<fixed facet="wst.jsdt.web"/>
|
||||||
<installed facet="jst.web" version="2.3"/>
|
|
||||||
<installed facet="wst.jsdt.web" version="1.0"/>
|
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||||
|
<installed facet="jst.web" version="2.5"/>
|
||||||
<installed facet="java" version="1.6"/>
|
<installed facet="java" version="1.6"/>
|
||||||
</faceted-project>
|
</faceted-project>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.gcube.portal.databook.shared.Comment;
|
||||||
import org.gcube.portal.databook.shared.Like;
|
import org.gcube.portal.databook.shared.Like;
|
||||||
import org.gcube.portal.databook.shared.UserInfo;
|
import org.gcube.portal.databook.shared.UserInfo;
|
||||||
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
|
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
|
||||||
|
import org.gcube.portlets.user.newsfeed.shared.UserSettings;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.RemoteService;
|
import com.google.gwt.user.client.rpc.RemoteService;
|
||||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
|
@ -37,5 +38,5 @@ public interface NewsService extends RemoteService {
|
||||||
|
|
||||||
ArrayList<Comment> getAllCommentsByFeed(String feedid);
|
ArrayList<Comment> getAllCommentsByFeed(String feedid);
|
||||||
|
|
||||||
UserInfo getUserInfo();
|
UserSettings getUserSettings();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.gcube.portal.databook.shared.Comment;
|
||||||
import org.gcube.portal.databook.shared.Like;
|
import org.gcube.portal.databook.shared.Like;
|
||||||
import org.gcube.portal.databook.shared.UserInfo;
|
import org.gcube.portal.databook.shared.UserInfo;
|
||||||
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
|
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
|
||||||
|
import org.gcube.portlets.user.newsfeed.shared.UserSettings;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
|
@ -27,7 +28,7 @@ public interface NewsServiceAsync {
|
||||||
|
|
||||||
void getOnlyMyUserFeeds(AsyncCallback<ArrayList<EnhancedFeed>> callback);
|
void getOnlyMyUserFeeds(AsyncCallback<ArrayList<EnhancedFeed>> callback);
|
||||||
|
|
||||||
void getUserInfo(AsyncCallback<UserInfo> callback);
|
void getUserSettings(AsyncCallback<UserSettings> callback);
|
||||||
|
|
||||||
void comment(String feedid, String text, String feedOwnerId,
|
void comment(String feedid, String text, String feedOwnerId,
|
||||||
AsyncCallback<Comment> callback);
|
AsyncCallback<Comment> callback);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.gcube.portlets.user.newsfeed.client.templates.FilterPanel;
|
||||||
import org.gcube.portlets.user.newsfeed.client.templates.SingleComment;
|
import org.gcube.portlets.user.newsfeed.client.templates.SingleComment;
|
||||||
import org.gcube.portlets.user.newsfeed.client.templates.TweetTemplate;
|
import org.gcube.portlets.user.newsfeed.client.templates.TweetTemplate;
|
||||||
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
|
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
|
||||||
|
import org.gcube.portlets.user.newsfeed.shared.UserSettings;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.core.client.RunAsyncCallback;
|
import com.google.gwt.core.client.RunAsyncCallback;
|
||||||
|
@ -73,13 +74,12 @@ public class NewsFeedPanel extends Composite {
|
||||||
public static final String COMMENT_LABEL = "Reply";
|
public static final String COMMENT_LABEL = "Reply";
|
||||||
public static final String MESSAGE_LABEL = "Message";
|
public static final String MESSAGE_LABEL = "Message";
|
||||||
|
|
||||||
public static final int delayMillis = 300000; //5 minutes
|
private int delayMillis = 300000; //5 minutes by default
|
||||||
|
|
||||||
private boolean isFirstTweet = false;
|
private boolean isFirstTweet = false;
|
||||||
|
|
||||||
private Image loadingImage;
|
private Image loadingImage;
|
||||||
private UserInfo myUserInfo;
|
private UserInfo myUserInfo;
|
||||||
|
|
||||||
private FilterType currentFilter;
|
private FilterType currentFilter;
|
||||||
private Timer feedsTimer;
|
private Timer feedsTimer;
|
||||||
/**
|
/**
|
||||||
|
@ -176,15 +176,16 @@ public class NewsFeedPanel extends Composite {
|
||||||
loadingImage = new Image(loading);
|
loadingImage = new Image(loading);
|
||||||
newsPanel.add(loadingImage);
|
newsPanel.add(loadingImage);
|
||||||
|
|
||||||
newsService.getUserInfo(new AsyncCallback<UserInfo>() {
|
newsService.getUserSettings(new AsyncCallback<UserSettings>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(UserInfo result) {
|
public void onSuccess(UserSettings result) {
|
||||||
myUserInfo = result;
|
myUserInfo = result.getUserInfo();
|
||||||
if (result.getUsername().equals("test.user")) {
|
delayMillis = result.getRefreshingTimeInMillis();
|
||||||
|
if (result.getUserInfo().getUsername().equals("test.user")) {
|
||||||
Window.alert("Your session has expired, please log out and login again");
|
Window.alert("Your session has expired, please log out and login again");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -438,7 +439,7 @@ public class NewsFeedPanel extends Composite {
|
||||||
newsPanel.clear();
|
newsPanel.clear();
|
||||||
newsPanel.add(new HTML("<div class=\"nofeed-message\">" +
|
newsPanel.add(new HTML("<div class=\"nofeed-message\">" +
|
||||||
"Ops! There were problems while retrieving your feeds!. <br> " +
|
"Ops! There were problems while retrieving your feeds!. <br> " +
|
||||||
"Looks like we are not able to communicate with the infrastructure, (or your session expired)<br> please try again in a short while or refresh the page.</div>"));
|
"Looks like we are not able to communicate with the infrastructure,<br> (or your session expired)<br> please try again in a short while or refresh the page.</div>"));
|
||||||
stopTimer();
|
stopTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.gcube.portal.databook.shared.UserInfo;
|
||||||
import org.gcube.portlets.user.newsfeed.client.FilterType;
|
import org.gcube.portlets.user.newsfeed.client.FilterType;
|
||||||
import org.gcube.portlets.user.newsfeed.client.NewsServiceAsync;
|
import org.gcube.portlets.user.newsfeed.client.NewsServiceAsync;
|
||||||
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;
|
import org.gcube.portlets.user.newsfeed.client.panels.NewsFeedPanel;
|
||||||
|
import org.gcube.portlets.user.newsfeed.shared.UserSettings;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.dom.client.Style.Cursor;
|
import com.google.gwt.dom.client.Style.Cursor;
|
||||||
|
@ -87,15 +88,15 @@ public class FilterPanel extends Composite {
|
||||||
onlyme.removeStyleName("filter-selected");
|
onlyme.removeStyleName("filter-selected");
|
||||||
favoritesLink.setStyleName("filter-selected");
|
favoritesLink.setStyleName("filter-selected");
|
||||||
caller.setCurrentFilter(FilterType.LIKEDFEEDS);
|
caller.setCurrentFilter(FilterType.LIKEDFEEDS);
|
||||||
service.getUserInfo(new AsyncCallback<UserInfo>() {
|
service.getUserSettings(new AsyncCallback<UserSettings>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
Window.alert(ERROR_MESSAGE);
|
Window.alert(ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(UserInfo result) {
|
public void onSuccess(UserSettings result) {
|
||||||
if (result.getUsername().equals("test.user")) {
|
if (result.getUserInfo().getUsername().equals("test.user")) {
|
||||||
Window.alert(SESSION_EXPIRED);
|
Window.alert(SESSION_EXPIRED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -110,15 +111,15 @@ public class FilterPanel extends Composite {
|
||||||
favoritesLink.removeStyleName("filter-selected");
|
favoritesLink.removeStyleName("filter-selected");
|
||||||
allUpdatesLink.setStyleName("filter-selected");
|
allUpdatesLink.setStyleName("filter-selected");
|
||||||
caller.setCurrentFilter(FilterType.ALL_UPDATES);
|
caller.setCurrentFilter(FilterType.ALL_UPDATES);
|
||||||
service.getUserInfo(new AsyncCallback<UserInfo>() {
|
service.getUserSettings(new AsyncCallback<UserSettings>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
Window.alert(ERROR_MESSAGE);
|
Window.alert(ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(UserInfo result) {
|
public void onSuccess(UserSettings result) {
|
||||||
if (result.getUsername().equals("test.user")) {
|
if (result.getUserInfo().getUsername().equals("test.user")) {
|
||||||
Window.alert(SESSION_EXPIRED);
|
Window.alert(SESSION_EXPIRED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -133,15 +134,15 @@ public class FilterPanel extends Composite {
|
||||||
favoritesLink.removeStyleName("filter-selected");
|
favoritesLink.removeStyleName("filter-selected");
|
||||||
onlyme.setStyleName("filter-selected");
|
onlyme.setStyleName("filter-selected");
|
||||||
caller.setCurrentFilter(FilterType.MINE);
|
caller.setCurrentFilter(FilterType.MINE);
|
||||||
service.getUserInfo(new AsyncCallback<UserInfo>() {
|
service.getUserSettings(new AsyncCallback<UserSettings>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
Window.alert(ERROR_MESSAGE);
|
Window.alert(ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(UserInfo result) {
|
public void onSuccess(UserSettings result) {
|
||||||
if (result.getUsername().equals("test.user")) {
|
if (result.getUserInfo().getUsername().equals("test.user")) {
|
||||||
Window.alert(SESSION_EXPIRED);
|
Window.alert(SESSION_EXPIRED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
package org.gcube.portlets.user.newsfeed.server;
|
package org.gcube.portlets.user.newsfeed.server;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
|
@ -26,6 +30,7 @@ import org.gcube.portal.databook.shared.ex.FeedTypeNotFoundException;
|
||||||
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
|
import org.gcube.portal.databook.shared.ex.PrivacyLevelTypeNotFoundException;
|
||||||
import org.gcube.portlets.user.newsfeed.client.NewsService;
|
import org.gcube.portlets.user.newsfeed.client.NewsService;
|
||||||
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
|
import org.gcube.portlets.user.newsfeed.shared.EnhancedFeed;
|
||||||
|
import org.gcube.portlets.user.newsfeed.shared.UserSettings;
|
||||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
|
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
|
||||||
|
|
||||||
|
@ -63,13 +68,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
|
|
||||||
private final static int MAX_FEEDS_NO = 20;
|
private final static int MAX_FEEDS_NO = 20;
|
||||||
|
|
||||||
|
|
||||||
//this is the cache for the user portraitsId that change among portals, the cache avoids to continuosly ask the LR DB the portraitID;
|
|
||||||
private HashMap<String, Long> portraitIdCache;
|
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
store = new DBCassandraAstyanaxImpl();
|
store = new DBCassandraAstyanaxImpl();
|
||||||
portraitIdCache = new HashMap<String, Long>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
@ -106,9 +106,11 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
else {
|
else {
|
||||||
//in case the portal is restarted and you have the social home open it will get test.user (no callback to set session info)
|
//in case the portal is restarted and you have the social home open it will get test.user (no callback to set session info)
|
||||||
//this check just return nothing if that happens
|
//this check just return nothing if that happens
|
||||||
if (userName.compareTo("test.user") == 0)
|
if (userName.compareTo("test.user") == 0) {
|
||||||
|
_log.debug("Found " + userName + " returning nothing");
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
_log.info("****** retrieving feeds for user: " + userName);
|
_log.info("****** retrieving feeds for user: " + userName);
|
||||||
User currUser = OrganizationsUtil.validateUser(userName);
|
User currUser = OrganizationsUtil.validateUser(userName);
|
||||||
|
|
||||||
|
@ -218,8 +220,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -280,7 +282,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
}
|
}
|
||||||
return enhanceFeeds(userFeeds);
|
return enhanceFeeds(userFeeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<EnhancedFeed> getOnlyLikedFeeds() {
|
public ArrayList<EnhancedFeed> getOnlyLikedFeeds() {
|
||||||
String userName = getASLSession().getUsername();
|
String userName = getASLSession().getUsername();
|
||||||
|
@ -297,7 +299,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
@Override
|
@Override
|
||||||
public boolean like(String feedid, String feedText, String feedOwnerId) {
|
public boolean like(String feedid, String feedText, String feedOwnerId) {
|
||||||
boolean likeCommitResult = false;
|
boolean likeCommitResult = false;
|
||||||
UserInfo user = getUserInfo();
|
UserInfo user = getUserSettings().getUserInfo();
|
||||||
Like toLike = new Like(UUID.randomUUID().toString(), user.getUsername(),
|
Like toLike = new Like(UUID.randomUUID().toString(), user.getUsername(),
|
||||||
new Date(), feedid, user.getFullName(), user.getAvatarId());
|
new Date(), feedid, user.getFullName(), user.getAvatarId());
|
||||||
try {
|
try {
|
||||||
|
@ -311,8 +313,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
if (likeCommitResult) {
|
if (likeCommitResult) {
|
||||||
//if the user who liked this post is not the user who posted it notify the poster user (Feed owner)
|
//if the user who liked this post is not the user who posted it notify the poster user (Feed owner)
|
||||||
if (! user.getUsername().equals(feedOwnerId)) {
|
if (! user.getUsername().equals(feedOwnerId)) {
|
||||||
NotificationsManager nm = new ApplicationNotificationsManager(getASLSession());
|
NotificationsManager nm = new ApplicationNotificationsManager(getASLSession());
|
||||||
boolean nResult = nm.notifyLikedFeed(feedOwnerId, feedid, escapeHtml(feedText));
|
boolean nResult = nm.notifyLikedFeed(feedOwnerId, feedid, escapeHtml(feedText));
|
||||||
_log.trace("Like Notification added? " + nResult);
|
_log.trace("Like Notification added? " + nResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +329,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
public Comment comment(String feedid, String commentText, String feedOwnerId) {
|
public Comment comment(String feedid, String commentText, String feedOwnerId) {
|
||||||
boolean commentCommitResult = false;
|
boolean commentCommitResult = false;
|
||||||
_log.trace("Trying to add this comment " + commentText);
|
_log.trace("Trying to add this comment " + commentText);
|
||||||
UserInfo user = getUserInfo();
|
UserInfo user = getUserSettings().getUserInfo();
|
||||||
Comment comment = new Comment(UUID.randomUUID().toString(), user.getUsername(),
|
Comment comment = new Comment(UUID.randomUUID().toString(), user.getUsername(),
|
||||||
new Date(), feedid, escapeHtml(commentText), user.getFullName(), user.getAvatarId());
|
new Date(), feedid, escapeHtml(commentText), user.getFullName(), user.getAvatarId());
|
||||||
try {
|
try {
|
||||||
|
@ -348,7 +350,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
}
|
}
|
||||||
//if there are other users who liked this post they get notified too, asynchronously with this thread
|
//if there are other users who liked this post they get notified too, asynchronously with this thread
|
||||||
Thread thread = new Thread(new NotificationsThread(commentText, nm, getAllLikesByFeed(feedid)));
|
Thread thread = new Thread(new NotificationsThread(commentText, nm, getAllLikesByFeed(feedid)));
|
||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
return comment;
|
return comment;
|
||||||
}
|
}
|
||||||
|
@ -368,10 +370,10 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
//sort the Feeds
|
//sort the Feeds
|
||||||
Collections.sort(toEnhance, Collections.reverseOrder());
|
Collections.sort(toEnhance, Collections.reverseOrder());
|
||||||
ArrayList<String> likedFeeds = (ArrayList<String>) store.getAllLikedFeedIdsByUser(getASLSession().getUsername());
|
ArrayList<String> likedFeeds = (ArrayList<String>) store.getAllLikedFeedIdsByUser(getASLSession().getUsername());
|
||||||
// System.out.println("Liked Feed for " + username);
|
// System.out.println("Liked Feed for " + username);
|
||||||
// for (String liked : likedFeeds) {
|
// for (String liked : likedFeeds) {
|
||||||
// System.out.println(liked);
|
// System.out.println(liked);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
for (Feed feed : toEnhance) {
|
for (Feed feed : toEnhance) {
|
||||||
feed.setDescription(replaceAmpersand(feed.getDescription()));
|
feed.setDescription(replaceAmpersand(feed.getDescription()));
|
||||||
|
@ -435,25 +437,20 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
StringBuilder thumbnailURL = new StringBuilder("/image/user_male_portrait?img_id=");
|
StringBuilder thumbnailURL = new StringBuilder("/image/user_male_portrait?img_id=");
|
||||||
// if (portraitIdCache.containsKey(screenName))
|
User user = null;
|
||||||
// return thumbnailURL.append(portraitIdCache.get(screenName)).toString();
|
try {
|
||||||
// else {
|
user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), screenName);
|
||||||
User user = null;
|
} catch (PortalException e) {
|
||||||
try {
|
e.printStackTrace();
|
||||||
user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), screenName);
|
} catch (SystemException e) {
|
||||||
// portraitIdCache.put(screenName, user.getPortraitId());
|
e.printStackTrace();
|
||||||
} catch (PortalException e) {
|
}
|
||||||
e.printStackTrace();
|
return thumbnailURL.append(user.getPortraitId()).toString();
|
||||||
} catch (SystemException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return thumbnailURL.append(user.getPortraitId()).toString();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserInfo getUserInfo() {
|
public UserSettings getUserSettings() {
|
||||||
if (getUserFromSession() != null)
|
if (getUserFromSession() != null)
|
||||||
return getUserFromSession();
|
return getUserFromSession();
|
||||||
try {
|
try {
|
||||||
|
@ -469,19 +466,22 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
email = user.getEmailAddress();
|
email = user.getEmailAddress();
|
||||||
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
|
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
|
||||||
String accountURL = themeDisplay.getURLMyAccount().toString();
|
String accountURL = themeDisplay.getURLMyAccount().toString();
|
||||||
UserInfo toReturn = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, false, null);
|
|
||||||
|
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, false, null);
|
||||||
|
UserSettings toReturn = new UserSettings(userInfo, getFeedsRefreshTimeInMillis());
|
||||||
setUserInSession(toReturn);
|
setUserInSession(toReturn);
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_log.info("Returning test USER");
|
_log.info("Returning test USER");
|
||||||
return new UserInfo(getASLSession().getUsername(), fullName, thumbnailURL, email, "fakeAccountUrl", true, false, null);
|
UserInfo user = new UserInfo(getASLSession().getUsername(), fullName, thumbnailURL, email, "fakeAccountUrl", true, false, null);
|
||||||
|
return new UserSettings(user, getFeedsRefreshTimeInMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return new UserInfo();
|
return new UserSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -525,11 +525,11 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserInfo getUserFromSession() {
|
private UserSettings getUserFromSession() {
|
||||||
return (UserInfo) getASLSession().getAttribute(UserInfo.USER_INFO_ATTR);
|
return (UserSettings) getASLSession().getAttribute(UserInfo.USER_INFO_ATTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUserInSession(UserInfo user) {
|
private void setUserInSession(UserSettings user) {
|
||||||
getASLSession().setAttribute(UserInfo.USER_INFO_ATTR, user);
|
getASLSession().setAttribute(UserInfo.USER_INFO_ATTR, user);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -558,7 +558,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comment editComment(Comment toEdit) {
|
public Comment editComment(Comment toEdit) {
|
||||||
UserInfo user = getUserInfo();
|
UserInfo user = getUserSettings().getUserInfo();
|
||||||
Comment edited = new Comment(toEdit.getKey(), toEdit.getUserid(),
|
Comment edited = new Comment(toEdit.getKey(), toEdit.getUserid(),
|
||||||
new Date(), toEdit.getFeedid(), escapeHtml(toEdit.getText()), user.getFullName(), user.getAvatarId());
|
new Date(), toEdit.getFeedid(), escapeHtml(toEdit.getText()), user.getFullName(), user.getAvatarId());
|
||||||
try {
|
try {
|
||||||
|
@ -626,4 +626,36 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* read from the property the refreshing time
|
||||||
|
* @return the refreshingTime in milliseconds
|
||||||
|
*/
|
||||||
|
private int getFeedsRefreshTimeInMillis() {
|
||||||
|
Properties props = new Properties();
|
||||||
|
int toReturn = 0;
|
||||||
|
int minutes = 0;
|
||||||
|
try {
|
||||||
|
String propertyfile = this.getThreadLocalRequest().getServletPath()+"conf/settings.properties";
|
||||||
|
File propsFile = new File(propertyfile);
|
||||||
|
FileInputStream fis = new FileInputStream(propsFile);
|
||||||
|
props.load( fis);
|
||||||
|
|
||||||
|
minutes = Integer.parseInt(props.getProperty("REFRESH_TIME"));
|
||||||
|
toReturn = minutes*60*1000;
|
||||||
|
}
|
||||||
|
//catch exception in case properties file does not exist
|
||||||
|
catch(IOException e) {
|
||||||
|
toReturn = 300000; //5 minutes
|
||||||
|
_log.error("settings.properties file not found under conf dir, returning 5 minutes");
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
//catch exception in case the property value isNot a Number
|
||||||
|
catch (ClassCastException ex) {
|
||||||
|
toReturn = 300000; //5 minutes
|
||||||
|
_log.error("REFRESH_TIME must be a number (in minutes) returning 5 minutes");
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
_log.debug("Returning REFRESH_TIME in millis: " + toReturn + " minutes: " + minutes);
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package org.gcube.portlets.user.newsfeed.shared;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.gcube.portal.databook.shared.UserInfo;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class UserSettings implements Serializable {
|
||||||
|
private UserInfo userInfo;
|
||||||
|
private int refreshingTimeInMillis;
|
||||||
|
public UserSettings() {
|
||||||
|
super();
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
public UserSettings(UserInfo userInfo, int refreshingTimeInMillis) {
|
||||||
|
super();
|
||||||
|
this.userInfo = userInfo;
|
||||||
|
this.refreshingTimeInMillis = refreshingTimeInMillis;
|
||||||
|
}
|
||||||
|
public UserInfo getUserInfo() {
|
||||||
|
return userInfo;
|
||||||
|
}
|
||||||
|
public void setUserInfo(UserInfo userInfo) {
|
||||||
|
this.userInfo = userInfo;
|
||||||
|
}
|
||||||
|
public int getRefreshingTimeInMillis() {
|
||||||
|
return refreshingTimeInMillis;
|
||||||
|
}
|
||||||
|
public void setRefreshingTimeInMillis(int refreshingTimeInMillis) {
|
||||||
|
this.refreshingTimeInMillis = refreshingTimeInMillis;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "UserSettings [userInfo=" + userInfo
|
||||||
|
+ ", refreshingTimeInMillis=" + refreshingTimeInMillis + "]";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Defines the News Feed refreshing time in minutes
|
||||||
|
REFRESH_TIME = 5
|
Loading…
Reference in New Issue