+
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/server/CustomConfiguration.java b/src/main/java/org/gcube/portlets/user/newsfeed/server/CustomConfiguration.java
new file mode 100644
index 0000000..f124c7e
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/newsfeed/server/CustomConfiguration.java
@@ -0,0 +1,51 @@
+package org.gcube.portlets.user.newsfeed.server;
+/**
+ * custom class to read propety file once
+ * @author massi
+ *
+ */
+public class CustomConfiguration {
+ private int refreshTime;
+ private String vreLabel;
+ private boolean showTimelineSource;
+
+ public CustomConfiguration(int refreshTime, String vreLabel,
+ boolean showTimelineSource) {
+ super();
+ this.refreshTime = refreshTime;
+ this.vreLabel = vreLabel;
+ this.showTimelineSource = showTimelineSource;
+ }
+
+ public int getRefreshTime() {
+ return refreshTime;
+ }
+
+ public void setRefreshTime(int refreshTime) {
+ this.refreshTime = refreshTime;
+ }
+
+ public String getVreLabel() {
+ return vreLabel;
+ }
+
+ public void setVreLabel(String vreLabel) {
+ this.vreLabel = vreLabel;
+ }
+
+ public boolean isShowTimelineSource() {
+ return showTimelineSource;
+ }
+
+ public void setShowTimelineSource(boolean showTimelineSource) {
+ this.showTimelineSource = showTimelineSource;
+ }
+
+ @Override
+ public String toString() {
+ return "CustomConfiguration [refreshTime=" + refreshTime
+ + ", vreLabel=" + vreLabel + ", showTimelineSource="
+ + showTimelineSource + "]";
+ }
+
+}
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 b4141b1..e5c2372 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
@@ -64,16 +64,15 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
*
*/
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";
+
private static final String SESSION_ADMIN_ATTR = "SESSION_ADMIN_ATTR";
-
+ private static final String USER_SETTINGS_ATTR = "USER_SETTINGS_ATTR";
/**
*
*/
- private static final String USER_SETTINGS_ATTR = "USER_SETTINGS_ATTR";
-
private DatabookStore store;
private boolean withinPortal = false;
@@ -98,8 +97,8 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
if (user == null) {
_log.warn("USER IS NULL setting testing user and Running OUTSIDE PORTAL");
user = "test.user";
-// user = "massimiliano.assante";
-// SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube");
+ user = "massimiliano.assante";
+ SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devVRE/testvrefolder2");
}
else {
withinPortal = true;
@@ -129,14 +128,16 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
String accountURL = themeDisplay.getURLMyAccount().toString();
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, isAdmin(), null);
- UserSettings toReturn = new UserSettings(userInfo, getFeedsRefreshTimeInMillis(), session.getScopeName(), getVRELabel(), isInfrastructureScope());
+ CustomConfiguration config = getUserConfiguration();
+ UserSettings toReturn = new UserSettings(userInfo, config.getRefreshTime(), session.getScopeName(), config.getVreLabel(), isInfrastructureScope(), config.isShowTimelineSource());
setUserSettingsInSession(toReturn);
return toReturn;
}
else {
_log.info("Returning test USER");
+ CustomConfiguration config = getUserConfiguration();
UserInfo user = new UserInfo(getASLSession().getUsername(), fullName, thumbnailURL, email, "fakeAccountUrl", true, false, null);
- return new UserSettings(user, getFeedsRefreshTimeInMillis(), session.getScopeName(), getVRELabel(), isInfrastructureScope());
+ return new UserSettings(user, config.getRefreshTime(), session.getScopeName(), config.getVreLabel(), isInfrastructureScope(), config.isShowTimelineSource());
}
} catch (Exception e) {
@@ -733,73 +734,55 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
}
/**
- * read from the property the name of the label to use for VREs/Channels
- * @return the refreshingTime in milliseconds
+ * read from the property file in /conf the refreshing time and other configurations needed
+ * @return CustomConfiguration
*/
- private String getVRELabel() {
- String toReturn = "Area";
- if (withinPortal) {
- _log.info("Trying to read custom VRE Label");
- Properties props = new Properties();
- String propertyfile = "";
+ private CustomConfiguration getUserConfiguration() {
+ CustomConfiguration toReturn = null;
+ _log.info("Trying to read custom config fr News Feed (REFRESH_TIME, VRE Label and show timeline source)");
+ Properties props = new Properties();
+ int minutes = 0;
+ String label = "";
+ boolean showTimelineSource = true;
+
+ 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);
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);
-
- toReturn = (String) props.getProperty("CHANNEL_NAME");
-
- }
- //catch exception in case properties file does not exist
- catch(IOException e) {
- toReturn = "Area";
- _log.error("settings.properties file not found under " + propertyfile +", returning Area");
- return toReturn;
- }
- }
- return toReturn;
- }
- /**
- * read from the property the refreshing time
- * @return the refreshingTime in milliseconds
- */
- private int getFeedsRefreshTimeInMillis() {
- 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);
-
- 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;
+ minutes = Integer.parseInt(props.getProperty(REFRESH_TIME));
+ minutes = minutes*60*1000;
}
//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;
+ minutes = 300000; //5 minutes
+ _log.error(REFRESH_TIME + " must be a number (in minutes) returning 5 minutes");
}
- _log.debug("Returning REFRESH_TIME in millis: " + toReturn + ", (" + minutes + " minutes)");
- return toReturn;
+ //the vre label
+ label = props.getProperty(VRE_LABEL);
+ try {
+ showTimelineSource = Boolean.parseBoolean(props.getProperty(SHOW_TIMELINE_SOURCE));
+
+ }
+ //catch exception in case the property value isNot true or false
+ catch (ClassCastException ex) {
+ showTimelineSource = true;
+ _log.error(showTimelineSource + " must be true or false, returning true");
+ }
+
}
- else
- return 60000; //60 secs for testing
+ //catch exception in case properties file does not exist
+ catch(IOException e) {
+ minutes = 300000; //5 minutes
+ _log.error("settings.properties file not found under " + propertyfile +", returning 5 minutes");
+ }
+
+ _log.debug("Read Configuration from property file: " + toReturn);
+ return new CustomConfiguration(minutes, label, showTimelineSource);
+
}
}
diff --git a/src/main/java/org/gcube/portlets/user/newsfeed/shared/UserSettings.java b/src/main/java/org/gcube/portlets/user/newsfeed/shared/UserSettings.java
index 13e80ab..3003ba7 100644
--- a/src/main/java/org/gcube/portlets/user/newsfeed/shared/UserSettings.java
+++ b/src/main/java/org/gcube/portlets/user/newsfeed/shared/UserSettings.java
@@ -9,22 +9,40 @@ public class UserSettings implements Serializable {
private UserInfo userInfo;
private int refreshingTimeInMillis;
private String currentScope;
- private String channelName;
+ //indicate the
+ private String vreLabel;
+ //indicate whether the webapp is running at infrasturcture level
boolean isInfrastructure;
+ //indicate whether to indicate the feed timeline source or not (From whicn VRE/Channel this feed come from)
+ boolean showTimelineSourceLabel;
public UserSettings() {
super();
}
+
public UserSettings(UserInfo userInfo, int refreshingTimeInMillis,
- String currentScope, String channelName, boolean isInfrastructure) {
+ String currentScope, String vreLabel, boolean isInfrastructure,
+ boolean showTimelineSourceLabel) {
super();
this.userInfo = userInfo;
this.refreshingTimeInMillis = refreshingTimeInMillis;
this.currentScope = currentScope;
- this.channelName = channelName;
+ this.vreLabel = vreLabel;
this.isInfrastructure = isInfrastructure;
+ this.showTimelineSourceLabel = showTimelineSourceLabel;
}
+
+ public boolean isShowTimelineSourceLabel() {
+ return showTimelineSourceLabel;
+ }
+
+
+ public void setShowTimelineSourceLabel(boolean showTimelineSourceLabel) {
+ this.showTimelineSourceLabel = showTimelineSourceLabel;
+ }
+
+
public UserInfo getUserInfo() {
return userInfo;
}
@@ -50,20 +68,23 @@ public class UserSettings implements Serializable {
this.isInfrastructure = isInfrastructure;
}
- public String getChannelName() {
- return channelName;
+ public String getVreLabel() {
+ return vreLabel;
}
- public void setChannelName(String channelName) {
- this.channelName = channelName;
+ public void setVreLabel(String channelName) {
+ this.vreLabel = channelName;
}
@Override
public String toString() {
return "UserSettings [userInfo=" + userInfo
+ ", refreshingTimeInMillis=" + refreshingTimeInMillis
- + ", currentScope=" + currentScope + ", isInfrastructure="
- + isInfrastructure + "]";
+ + ", currentScope=" + currentScope + ", vreLabel=" + vreLabel
+ + ", isInfrastructure=" + isInfrastructure
+ + ", showTimelineSourceLabel=" + showTimelineSourceLabel + "]";
}
+
+
}
diff --git a/src/main/webapp/conf/settings.properties b/src/main/webapp/conf/settings.properties
index d8ee383..3e9cb8b 100644
--- a/src/main/webapp/conf/settings.properties
+++ b/src/main/webapp/conf/settings.properties
@@ -1,3 +1,4 @@
# Defines the News Feed refreshing time in minutes
REFRESH_TIME = 3
-CHANNEL_NAME = Virtual Research Environment
\ No newline at end of file
+VRE_LABEL = Virtual Research Environment
+SHOW_TIMELINE_SOURCE=false
\ No newline at end of file