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"/>
|
||||
</attributes>
|
||||
</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">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</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"/>
|
||||
</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
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -211,8 +211,8 @@
|
|||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</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.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.Collections;
|
||||
/**
|
||||
*
|
||||
* @author Massimiliano Assante, ISTI-CNR
|
||||
|
@ -261,7 +263,11 @@ public class NewsFeedPanel extends Composite {
|
|||
if (feeds != null && allUpdates.size() > 0) {
|
||||
|
||||
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)
|
||||
|
||||
//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() {
|
||||
newUpdatesPanel.clear(); //remove the aler panel
|
||||
for (EnhancedFeed feed : tempCacheNewUpdates) {
|
||||
newUpdatesPanel.clear(); //remove the alert panel
|
||||
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);
|
||||
newsPanel.insert(tt, 0); //insert in the view
|
||||
allUpdates.add(0, feed); //insert in the model
|
||||
|
@ -311,6 +322,41 @@ public class NewsFeedPanel extends Composite {
|
|||
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
|
||||
|
@ -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() {
|
||||
newsPanel.clear();
|
||||
|
|
|
@ -63,7 +63,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
*
|
||||
*/
|
||||
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>();
|
||||
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) {
|
||||
feedsMap.put(feed.getKey(), feed);
|
||||
}
|
||||
|
@ -473,7 +473,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
email = user.getEmailAddress();
|
||||
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
|
||||
String accountURL = themeDisplay.getURLMyAccount().toString();
|
||||
|
||||
|
||||
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, false, null);
|
||||
UserSettings toReturn = new UserSettings(userInfo, getFeedsRefreshTimeInMillis());
|
||||
setUserSettingsInSession(toReturn);
|
||||
|
@ -638,37 +638,39 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|||
* @return the refreshingTime in milliseconds
|
||||
*/
|
||||
private int getFeedsRefreshTimeInMillis() {
|
||||
//return 20000; //for testing
|
||||
_log.info("Trying to read custom REFRESH_TIME");
|
||||
if (withinPortal) {
|
||||
_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();
|
||||
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);
|
||||
|
||||
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 " + propertyfile +", returning 5 minutes");
|
||||
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 " + propertyfile +", 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;
|
||||
}
|
||||
//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;
|
||||
else
|
||||
return 15000; //15 secs for testing
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue