smart refresh implemented and tested, one corner case left
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@73068 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d8d339db27
commit
80bc8b119a
10
.classpath
10
.classpath
|
@ -20,16 +20,16 @@
|
||||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
|
|
||||||
<attributes>
|
|
||||||
<attribute name="owner.project.facets" value="java"/>
|
|
||||||
</attributes>
|
|
||||||
</classpathentry>
|
|
||||||
<classpathentry kind="output" path="target/news-feed-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
<classpathentry kind="output" path="target/news-feed-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#Thu Apr 04 16:40:07 CEST 2013
|
#Tue Apr 09 11:48:39 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
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -211,8 +211,8 @@
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>2.3.2</version>
|
<version>2.3.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.5</source>
|
<source>1.6</source>
|
||||||
<target>1.5</target>
|
<target>1.6</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<!-- SA Plugin -->
|
<!-- SA Plugin -->
|
||||||
|
|
|
@ -53,6 +53,8 @@ import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
import com.google.gwt.user.client.ui.Image;
|
import com.google.gwt.user.client.ui.Image;
|
||||||
import com.google.gwt.user.client.ui.SimplePanel;
|
import com.google.gwt.user.client.ui.SimplePanel;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
|
|
||||||
|
import edu.emory.mathcs.backport.java.util.Collections;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Massimiliano Assante, ISTI-CNR
|
* @author Massimiliano Assante, ISTI-CNR
|
||||||
|
@ -261,7 +263,11 @@ public class NewsFeedPanel extends Composite {
|
||||||
if (feeds != null && allUpdates.size() > 0) {
|
if (feeds != null && allUpdates.size() > 0) {
|
||||||
|
|
||||||
Date myLastUpdateTime = allUpdates.get(0).getFeed().getTime(); //this is the last update in the View
|
Date myLastUpdateTime = allUpdates.get(0).getFeed().getTime(); //this is the last update in the View
|
||||||
|
GWT.log("Last Mine: "+allUpdates.get(0).getFeed().getDescription());
|
||||||
|
|
||||||
|
GWT.log("Last Retr.: "+feeds.get(0).getFeed().getDescription());
|
||||||
|
|
||||||
|
|
||||||
tempCacheNewUpdates = new ArrayList<EnhancedFeed>(); //need to clear it everytime i check (in case someone deleted the updated in the meanwhile)
|
tempCacheNewUpdates = new ArrayList<EnhancedFeed>(); //need to clear it everytime i check (in case someone deleted the updated in the meanwhile)
|
||||||
|
|
||||||
//check if there are new updates (enter the while) and put them in a temporary cache for displaying on user click
|
//check if there are new updates (enter the while) and put them in a temporary cache for displaying on user click
|
||||||
|
@ -296,8 +302,13 @@ public class NewsFeedPanel extends Composite {
|
||||||
|
|
||||||
|
|
||||||
protected void doShowCachedNewUpdates() {
|
protected void doShowCachedNewUpdates() {
|
||||||
newUpdatesPanel.clear(); //remove the aler panel
|
newUpdatesPanel.clear(); //remove the alert panel
|
||||||
for (EnhancedFeed feed : tempCacheNewUpdates) {
|
newsFeedAlert = null; //reset the alert panel and other needed vars
|
||||||
|
currNewUpdatesNo = 0;
|
||||||
|
|
||||||
|
//need to put the in reverse order;
|
||||||
|
for (int i = tempCacheNewUpdates.size(); i > 0; i--) {
|
||||||
|
EnhancedFeed feed = tempCacheNewUpdates.get(i-1);
|
||||||
final TweetTemplate tt = new TweetTemplate(myUserInfo, feed, eventBus, true);
|
final TweetTemplate tt = new TweetTemplate(myUserInfo, feed, eventBus, true);
|
||||||
newsPanel.insert(tt, 0); //insert in the view
|
newsPanel.insert(tt, 0); //insert in the view
|
||||||
allUpdates.add(0, feed); //insert in the model
|
allUpdates.add(0, feed); //insert in the model
|
||||||
|
@ -311,6 +322,41 @@ public class NewsFeedPanel extends Composite {
|
||||||
t.schedule(100);
|
t.schedule(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* used when addin directly a feed from the UI (IPC)
|
||||||
|
* @param userid
|
||||||
|
* @param fullName
|
||||||
|
* @param thumbURL
|
||||||
|
* @param description
|
||||||
|
*/
|
||||||
|
public void addJustAddedFeed(ClientFeed cFeed) {
|
||||||
|
Feed feed = new Feed(cFeed.getKey(), FeedType.SHARE, cFeed.getUserid(), cFeed.getTime(), "", cFeed.getUri(), cFeed.getLinkUrlThumbnail(),
|
||||||
|
cFeed.getDescription(), PrivacyLevel.CONNECTION, cFeed.getFullName(),
|
||||||
|
cFeed.getEmail(), cFeed.getThumbnailURL(), cFeed.getLinkTitle(), cFeed.getLinkDescription(), cFeed.getLinkHost());
|
||||||
|
EnhancedFeed toAdd = new EnhancedFeed(feed, false, true); //false cuz he could not have liked this yet and true because is the current user's
|
||||||
|
|
||||||
|
final TweetTemplate tt = new TweetTemplate(myUserInfo, toAdd, eventBus, true);
|
||||||
|
if (isFirstTweet) {
|
||||||
|
newsPanel.clear();
|
||||||
|
newsPanel.add(new Image(spacer));
|
||||||
|
isFirstTweet = false;
|
||||||
|
}
|
||||||
|
newsPanel.insert(tt, 0);
|
||||||
|
Timer t = new Timer() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
tt.setcontentAreaStyle("visible");
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
t.schedule(500);
|
||||||
|
|
||||||
|
//insert it also in the model so that the user who created it do not get notified about this new update
|
||||||
|
allUpdates.add(0, toAdd); //insert in the model
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All Updates
|
* All Updates
|
||||||
|
@ -481,41 +527,7 @@ public class NewsFeedPanel extends Composite {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* used when addin directly a feed from the UI (IPC)
|
|
||||||
* @param userid
|
|
||||||
* @param fullName
|
|
||||||
* @param thumbURL
|
|
||||||
* @param description
|
|
||||||
*/
|
|
||||||
public void addJustAddedFeed(ClientFeed cFeed) {
|
|
||||||
Feed feed = new Feed(cFeed.getKey(), FeedType.SHARE, cFeed.getUserid(), null, "", cFeed.getUri(), cFeed.getLinkUrlThumbnail(),
|
|
||||||
cFeed.getDescription(), PrivacyLevel.CONNECTION, cFeed.getFullName(),
|
|
||||||
cFeed.getEmail(), cFeed.getThumbnailURL(), cFeed.getLinkTitle(), cFeed.getLinkDescription(), cFeed.getLinkHost());
|
|
||||||
EnhancedFeed toAdd = new EnhancedFeed(feed, false, true); //false cuz he could not have liked this yet and true because is the current user's
|
|
||||||
|
|
||||||
final TweetTemplate tt = new TweetTemplate(myUserInfo, toAdd, eventBus, true);
|
|
||||||
if (isFirstTweet) {
|
|
||||||
newsPanel.clear();
|
|
||||||
newsPanel.add(new Image(spacer));
|
|
||||||
isFirstTweet = false;
|
|
||||||
}
|
|
||||||
newsPanel.insert(tt, 0);
|
|
||||||
Timer t = new Timer() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
tt.setcontentAreaStyle("visible");
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
t.schedule(500);
|
|
||||||
|
|
||||||
|
|
||||||
//insert it also in the model so that the user who created it do not get notified about this new update
|
|
||||||
allUpdates.add(0, toAdd); //insert in the model
|
|
||||||
}
|
|
||||||
|
|
||||||
private void showLoader() {
|
private void showLoader() {
|
||||||
newsPanel.clear();
|
newsPanel.clear();
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final String SESSION_ADMIN_ATTR = "SESSION_ADMIN_ATTR";
|
private static final String SESSION_ADMIN_ATTR = "SESSION_ADMIN_ATTR";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -245,7 +245,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
ArrayList<Feed> toMerge = new ArrayList<Feed>();
|
ArrayList<Feed> toMerge = new ArrayList<Feed>();
|
||||||
HashMap<String, Feed> feedsMap = new HashMap<String, Feed>();
|
HashMap<String, Feed> feedsMap = new HashMap<String, Feed>();
|
||||||
|
|
||||||
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE("/gcube/devsec/devVRE", 15);
|
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE("/gcube/devsec/devVRE", 5);
|
||||||
for (Feed feed : OrganizationFeeds) {
|
for (Feed feed : OrganizationFeeds) {
|
||||||
feedsMap.put(feed.getKey(), feed);
|
feedsMap.put(feed.getKey(), feed);
|
||||||
}
|
}
|
||||||
|
@ -473,7 +473,7 @@ 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 userInfo = 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());
|
UserSettings toReturn = new UserSettings(userInfo, getFeedsRefreshTimeInMillis());
|
||||||
setUserSettingsInSession(toReturn);
|
setUserSettingsInSession(toReturn);
|
||||||
|
@ -638,37 +638,39 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
* @return the refreshingTime in milliseconds
|
* @return the refreshingTime in milliseconds
|
||||||
*/
|
*/
|
||||||
private int getFeedsRefreshTimeInMillis() {
|
private int getFeedsRefreshTimeInMillis() {
|
||||||
//return 20000; //for testing
|
if (withinPortal) {
|
||||||
_log.info("Trying to read custom REFRESH_TIME");
|
_log.info("Trying to read custom REFRESH_TIME");
|
||||||
|
Properties props = new Properties();
|
||||||
|
int toReturn = 0;
|
||||||
|
int minutes = 0;
|
||||||
|
String propertyfile = "";
|
||||||
|
try {
|
||||||
|
ServletContext servletContext = getServletContext();
|
||||||
|
String contextPath = servletContext.getRealPath(File.separator);
|
||||||
|
propertyfile = contextPath + "conf" + File.separator + "settings.properties";
|
||||||
|
File propsFile = new File(propertyfile);
|
||||||
|
FileInputStream fis = new FileInputStream(propsFile);
|
||||||
|
props.load( fis);
|
||||||
|
|
||||||
Properties props = new Properties();
|
minutes = Integer.parseInt(props.getProperty("REFRESH_TIME"));
|
||||||
int toReturn = 0;
|
toReturn = minutes*60*1000;
|
||||||
int minutes = 0;
|
}
|
||||||
String propertyfile = "";
|
//catch exception in case properties file does not exist
|
||||||
try {
|
catch(IOException e) {
|
||||||
ServletContext servletContext = getServletContext();
|
toReturn = 300000; //5 minutes
|
||||||
String contextPath = servletContext.getRealPath(File.separator);
|
_log.error("settings.properties file not found under " + propertyfile +", returning 5 minutes");
|
||||||
propertyfile = contextPath + "conf" + File.separator + "settings.properties";
|
return toReturn;
|
||||||
File propsFile = new File(propertyfile);
|
}
|
||||||
FileInputStream fis = new FileInputStream(propsFile);
|
//catch exception in case the property value isNot a Number
|
||||||
props.load( fis);
|
catch (ClassCastException ex) {
|
||||||
|
toReturn = 300000; //5 minutes
|
||||||
minutes = Integer.parseInt(props.getProperty("REFRESH_TIME"));
|
_log.error("REFRESH_TIME must be a number (in minutes) returning 5 minutes");
|
||||||
toReturn = minutes*60*1000;
|
return toReturn;
|
||||||
}
|
}
|
||||||
//catch exception in case properties file does not exist
|
_log.debug("Returning REFRESH_TIME in millis: " + toReturn + ", (" + minutes + " minutes)");
|
||||||
catch(IOException e) {
|
|
||||||
toReturn = 300000; //5 minutes
|
|
||||||
_log.error("settings.properties file not found under " + propertyfile +", returning 5 minutes");
|
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
//catch exception in case the property value isNot a Number
|
else
|
||||||
catch (ClassCastException ex) {
|
return 15000; //15 secs for testing
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue