Added configuration file for VRE Labels<

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@91516 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-02-13 09:17:48 +00:00
parent 039db2c23e
commit 379c6bcee3
10 changed files with 75 additions and 24 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/news-feed-1.4.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/news-feed-1.5.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -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="output" path="target/news-feed-1.4.1-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/news-feed-1.5.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -1,5 +1,5 @@
eclipse.preferences.version=1
jarsExcludedFromWebInfLib=
lastWarOutDir=/Users/massi/Documents/workspace/news-feed/target/news-feed-1.4.1-SNAPSHOT
lastWarOutDir=/Users/massi/Documents/workspace/news-feed/target/news-feed-1.5.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

View File

@ -1,13 +1,12 @@
#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
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -3,5 +3,5 @@
<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.6"/>
<installed facet="java" version="1.7"/>
</faceted-project>

View File

@ -1,4 +1,9 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets.user.NewsFeed.1-5-0"
date="2014-02-13">
<Change>Moved to Java7</Change>
<Change>Added configuration file for VRE Labels</Change>
</Changeset>
<Changeset component="org.gcube.portlets.user.NewsFeed.1-4-0"
date="2013-10-21">
<Change>Moved to GWT 2.5.1</Change>

10
pom.xml
View File

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>news-feed</artifactId>
<packaging>war</packaging>
<version>1.4.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
<name>gCube News Feed Portlet</name>
<description>
@ -29,8 +29,8 @@
<gwtVersion>2.5.1</gwtVersion>
<distroDirectory>distro</distroDirectory>
<!-- GWT needs at least java 1.6 -->
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -209,8 +209,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<!-- SA Plugin -->

View File

@ -92,6 +92,8 @@ public class NewsFeedPanel extends Composite {
public static final String LIKED_LABEL = "Favorited";
public static final String COMMENT_LABEL = "Reply";
public static final String MESSAGE_LABEL = "Message";
private String vreLabel;
private int delayMillis = 300000; //5 minutes by default (is read from a configuration file in the first async callback)
@ -222,7 +224,8 @@ public class NewsFeedPanel extends Composite {
@Override
public void onSuccess(UserSettings result) {
myUserInfo = result.getUserInfo();
delayMillis = result.getRefreshingTimeInMillis();
delayMillis = result.getRefreshingTimeInMillis();
vreLabel = result.getChannelName();
if (result.getUserInfo().getUsername().equals("test.user")) {
Window.alert("Your session has expired, please log out and login again");
}
@ -426,7 +429,7 @@ public class NewsFeedPanel extends Composite {
newsPanel.add(new HTML("<div class=\"nofeed-message\">" +
"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 " +
"<br>Virtual Research Environments.</div>"));
"<br>"+vreLabel+"s.</div>"));
isFirstTweet = true;
}
else {

View File

@ -129,14 +129,14 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
String accountURL = themeDisplay.getURLMyAccount().toString();
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, false, null);
UserSettings toReturn = new UserSettings(userInfo, getFeedsRefreshTimeInMillis(), session.getScopeName(), isInfrastructureScope());
UserSettings toReturn = new UserSettings(userInfo, getFeedsRefreshTimeInMillis(), session.getScopeName(), getVRELabel(), isInfrastructureScope());
setUserSettingsInSession(toReturn);
return toReturn;
}
else {
_log.info("Returning test USER");
UserInfo user = new UserInfo(getASLSession().getUsername(), fullName, thumbnailURL, email, "fakeAccountUrl", true, false, null);
return new UserSettings(user, getFeedsRefreshTimeInMillis(), session.getScopeName(), isInfrastructureScope());
return new UserSettings(user, getFeedsRefreshTimeInMillis(), session.getScopeName(), getVRELabel(), isInfrastructureScope());
}
} catch (Exception e) {
@ -732,6 +732,36 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
return sb.toString();
}
/**
* read from the property the name of the label to use for VREs/Channels
* @return the refreshingTime in milliseconds
*/
private String getVRELabel() {
String toReturn = "Area";
if (withinPortal) {
_log.info("Trying to read custom VRE Label");
Properties props = new Properties();
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);
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

View File

@ -9,18 +9,22 @@ public class UserSettings implements Serializable {
private UserInfo userInfo;
private int refreshingTimeInMillis;
private String currentScope;
private String channelName;
boolean isInfrastructure;
public UserSettings() {
super();
}
public UserSettings(UserInfo userInfo, int refreshingTimeInMillis,
String currentScope, boolean isInfrastructure) {
String currentScope, String channelName, boolean isInfrastructure) {
super();
this.userInfo = userInfo;
this.refreshingTimeInMillis = refreshingTimeInMillis;
this.currentScope = currentScope;
this.channelName = channelName;
this.isInfrastructure = isInfrastructure;
}
public UserInfo getUserInfo() {
return userInfo;
}
@ -45,6 +49,15 @@ public class UserSettings implements Serializable {
public void setInfrastructure(boolean isInfrastructure) {
this.isInfrastructure = isInfrastructure;
}
public String getChannelName() {
return channelName;
}
public void setChannelName(String channelName) {
this.channelName = channelName;
}
@Override
public String toString() {
return "UserSettings [userInfo=" + userInfo

View File

@ -1,2 +1,3 @@
# Defines the News Feed refreshing time in minutes
REFRESH_TIME = 3
REFRESH_TIME = 3
CHANNEL_NAME = Virtual Research Environment