added show VRE source when all updates is in mode infrastructure
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@92880 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3f32513834
commit
8ccca59096
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/news-feed-1.5.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/news-feed-1.5.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -31,5 +31,5 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/news-feed-1.5.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/news-feed-1.5.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/Users/massi/Documents/workspace/news-feed/target/news-feed-1.5.0-SNAPSHOT
|
||||
lastWarOutDir=/Users/massi/Documents/workspace/news-feed/target/news-feed-1.5.1-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>news-feed</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.5.0-SNAPSHOT</version>
|
||||
<version>1.5.1-SNAPSHOT</version>
|
||||
|
||||
<name>gCube News Feed Portlet</name>
|
||||
<description>
|
||||
|
@ -72,6 +72,10 @@
|
|||
<artifactId>aslcore</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>accesslogger</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslsocial</artifactId>
|
||||
|
|
|
@ -12,12 +12,9 @@ import org.jsonmaker.gwt.client.Jsonizer;
|
|||
|
||||
import com.google.gwt.core.client.EntryPoint;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.logical.shared.ResizeEvent;
|
||||
import com.google.gwt.event.logical.shared.ResizeHandler;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
|
||||
/**
|
||||
|
|
|
@ -92,8 +92,10 @@ 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 boolean showFeedTimelineSource = false;
|
||||
private boolean isInfrastructure = false;
|
||||
|
||||
private int delayMillis = 300000; //5 minutes by default (is read from a configuration file in the first async callback)
|
||||
|
||||
|
@ -152,11 +154,11 @@ public class NewsFeedPanel extends Composite {
|
|||
public void onSelectedUser(SelectedUserEvent event) {
|
||||
GWT.log("event...");
|
||||
Location.assign(GCubeSocialNetworking.USER_PROFILE_LINK+"?"+
|
||||
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
|
||||
Encoder.encode(event.getSelectedUser().getId()));
|
||||
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
|
||||
Encoder.encode(event.getSelectedUser().getId()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(SeeLikesEvent.TYPE, new SeeLikesEventHandler() {
|
||||
@Override
|
||||
public void onSeeLikes(SeeLikesEvent event) {
|
||||
|
@ -184,7 +186,7 @@ public class NewsFeedPanel extends Composite {
|
|||
doDeleteFeed(event.getToDelete());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
eventBus.addHandler(OpenFeedEvent.TYPE, new OpenFeedEventHandler() {
|
||||
@Override
|
||||
public void onOpenFeed(OpenFeedEvent event) {
|
||||
|
@ -225,7 +227,7 @@ public class NewsFeedPanel extends Composite {
|
|||
public void onSuccess(UserSettings result) {
|
||||
myUserInfo = result.getUserInfo();
|
||||
delayMillis = result.getRefreshingTimeInMillis();
|
||||
vreLabel = result.getChannelName();
|
||||
vreLabel = result.getVreLabel();
|
||||
if (result.getUserInfo().getUsername().equals("test.user")) {
|
||||
Window.alert("Your session has expired, please log out and login again");
|
||||
}
|
||||
|
@ -240,10 +242,13 @@ public class NewsFeedPanel extends Composite {
|
|||
currentFilter = FilterType.ALL_UPDATES;
|
||||
}
|
||||
//adjustments in the UI Depending on the scope
|
||||
if (result.isInfrastructure())
|
||||
if (result.isInfrastructure()) {
|
||||
filterPanelWrapper.setVisible(true);
|
||||
else
|
||||
mainPanel.addStyleName("framed");
|
||||
showFeedTimelineSource = result.isShowTimelineSourceLabel();
|
||||
isInfrastructure = true;
|
||||
}
|
||||
else
|
||||
mainPanel.addStyleName("framed");
|
||||
|
||||
}
|
||||
});
|
||||
|
@ -294,7 +299,7 @@ public class NewsFeedPanel extends Composite {
|
|||
newsPanel.setHeight("");
|
||||
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
||||
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
|
||||
newsPanel.add(new TweetTemplate(true, myUserInfo, result, eventBus));
|
||||
newsPanel.add(new TweetTemplate(true, true, myUserInfo, result, eventBus));
|
||||
}
|
||||
newsPanel.add(new Image(spacer));
|
||||
}
|
||||
|
@ -426,10 +431,16 @@ public class NewsFeedPanel extends Composite {
|
|||
newsPanel.clear();
|
||||
if (feeds != null) {
|
||||
if (feeds.size() == 0) {
|
||||
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>"+vreLabel+"s.</div>"));
|
||||
if (!isInfrastructure) {
|
||||
newsPanel.add(new HTML("<div class=\"nofeed-message\">" +
|
||||
"Sorry, looks like nobody shared anything yet. <br> " +
|
||||
"You may begin by sharing a news!</div>"));
|
||||
} else {
|
||||
newsPanel.add(new HTML("<div class=\"nofeed-message\">" +
|
||||
"Sorry, 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>"+vreLabel+"s.</div>"));
|
||||
}
|
||||
isFirstTweet = true;
|
||||
}
|
||||
else {
|
||||
|
@ -437,7 +448,7 @@ public class NewsFeedPanel extends Composite {
|
|||
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
||||
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
|
||||
for (EnhancedFeed feed : feeds) {
|
||||
newsPanel.add(new TweetTemplate(false, myUserInfo, feed, eventBus));
|
||||
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus));
|
||||
allUpdates.add(feed);
|
||||
}
|
||||
if (feeds.size() < 5) {
|
||||
|
@ -483,7 +494,7 @@ public class NewsFeedPanel extends Composite {
|
|||
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
||||
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
|
||||
for (EnhancedFeed feed : feeds)
|
||||
newsPanel.add(new TweetTemplate(false, myUserInfo, feed, eventBus));
|
||||
newsPanel.add(new TweetTemplate(false, false, myUserInfo, feed, eventBus));
|
||||
if (feeds.size() < 5) {
|
||||
newsPanel.add(new Image(spacer));
|
||||
}
|
||||
|
@ -522,7 +533,7 @@ public class NewsFeedPanel extends Composite {
|
|||
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
||||
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
|
||||
for (EnhancedFeed feed : feeds)
|
||||
newsPanel.add(new TweetTemplate(false, myUserInfo, feed, eventBus));
|
||||
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus));
|
||||
if (feeds.size() < 5) {
|
||||
newsPanel.add(new Image(spacer));
|
||||
}
|
||||
|
@ -561,7 +572,7 @@ public class NewsFeedPanel extends Composite {
|
|||
newsPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
||||
newsPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
|
||||
for (EnhancedFeed feed : feeds)
|
||||
newsPanel.add(new TweetTemplate(false, myUserInfo, feed, eventBus));
|
||||
newsPanel.add(new TweetTemplate(false, showFeedTimelineSource, myUserInfo, feed, eventBus));
|
||||
if (feeds.size() < 5) {
|
||||
newsPanel.add(new Image(spacer));
|
||||
}
|
||||
|
@ -614,7 +625,7 @@ public class NewsFeedPanel extends Composite {
|
|||
final UserSelectionDialog dlg = new UserSelectionDialog("People who set this as Favorite", eventBus);
|
||||
dlg.center();
|
||||
dlg.show();
|
||||
|
||||
|
||||
newsService.getAllLikesByFeed(feedId, new AsyncCallback<ArrayList<Like>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
|
@ -742,7 +753,7 @@ public class NewsFeedPanel extends Composite {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void doShowFeed(final TweetTemplate toShow) {
|
||||
String feedKey = toShow.getFeedKey();
|
||||
Window.Location.assign(Window.Location.getHref() + ((Window.Location.getHref().contains("?")) ? "&oid="+feedKey : "?oid="+feedKey));
|
||||
|
|
|
@ -37,8 +37,8 @@ public class FilterPanel extends Composite {
|
|||
this.service = newsService;
|
||||
//connectionsLink.setHTML("<a>Connections</a>");
|
||||
allUpdatesLink.setHTML("<a>All Updates</a>");
|
||||
favoritesLink.setHTML("<a>My Favorites</a>");
|
||||
onlyme.setHTML("<a>Only Me</a>");
|
||||
favoritesLink.setHTML("<a>Favorites</a>");
|
||||
onlyme.setHTML("<a>Your Posts</a>");
|
||||
//connectionsLink.getElement().getStyle().setCursor(Cursor.POINTER);
|
||||
allUpdatesLink.getElement().getStyle().setCursor(Cursor.POINTER);
|
||||
favoritesLink.getElement().getStyle().setCursor(Cursor.POINTER);
|
||||
|
|
|
@ -102,6 +102,8 @@ public class TweetTemplate extends Composite {
|
|||
@UiField
|
||||
HTML openImage;
|
||||
@UiField
|
||||
HTML vreSource;
|
||||
@UiField
|
||||
VerticalPanel previewPanel;
|
||||
@UiField
|
||||
Label messageSeparator;
|
||||
|
@ -113,10 +115,10 @@ public class TweetTemplate extends Composite {
|
|||
* @param displaySingle tells if you're displaying a single fedd or not
|
||||
* @param eventBus
|
||||
*/
|
||||
public TweetTemplate(boolean displaySingle, UserInfo myUserInfo, EnhancedFeed myFeed, HandlerManager eventBus) {
|
||||
public TweetTemplate(boolean displaySingle, boolean showTimelineSource, UserInfo myUserInfo, EnhancedFeed myFeed, HandlerManager eventBus) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.myUserInfo = myUserInfo;
|
||||
|
||||
this.vreSource.setVisible(false);
|
||||
this.myFeed = myFeed;
|
||||
isAppFeed = myFeed.getFeed().isApplicationFeed();
|
||||
Feed feed = myFeed.getFeed();
|
||||
|
@ -126,14 +128,14 @@ public class TweetTemplate extends Composite {
|
|||
this.eventBus = eventBus;
|
||||
this.isUsers = myFeed.isUsers();
|
||||
myComments = new ArrayList<SingleComment>();
|
||||
|
||||
|
||||
if (isUsers || myUserInfo.isAdmin()) {
|
||||
closeImage.setStyleName("closeImage");
|
||||
closeImage.setTitle(myUserInfo.isAdmin() ? "Delete (Administrator Mode)" : "delete");
|
||||
} else {
|
||||
closeImage.removeFromParent();
|
||||
}
|
||||
|
||||
|
||||
openImage.setStyleName("openImage");
|
||||
openImage.setTitle("Open this feed separately");
|
||||
//show if the user has already liked this
|
||||
|
@ -159,6 +161,13 @@ public class TweetTemplate extends Composite {
|
|||
+"?"+
|
||||
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
|
||||
Encoder.encode(feed.getEntityId())+"\">"+feed.getFullName()+"</a> " + feedText);
|
||||
|
||||
//show the vreid iff the info is present
|
||||
if (showTimelineSource && feed.getVreid() != null && feed.getVreid().compareTo("") != 0) {
|
||||
this.vreSource.setVisible(true);
|
||||
String vreName = feed.getVreid().substring(feed.getVreid().lastIndexOf("/")+1);
|
||||
vreSource.setHTML("<a class=\"link\" style=\"font-size: 10px; white-space: nowrap;\" href=\"/group/"+vreName.toLowerCase()+"\">[" +vreName + "]</a>");
|
||||
}
|
||||
}
|
||||
else {
|
||||
// messageSeparator.setVisible(false);
|
||||
|
@ -170,7 +179,7 @@ public class TweetTemplate extends Composite {
|
|||
closeImage.removeFromParent();
|
||||
try{
|
||||
String vreName = feed.getVreid().substring(feed.getVreid().lastIndexOf("/")+1);
|
||||
messageArea.setHTML("<a class=\"link\" href=\""+feed.getUri()+"\"> go App [" +vreName + "]</a>");
|
||||
messageArea.setHTML("<a class=\"link\" style=\"white-space: nowrap;\" href=\""+feed.getUri()+"\"> go App [" +vreName + "]</a>");
|
||||
}
|
||||
catch (Exception e) {}
|
||||
}
|
||||
|
@ -222,7 +231,7 @@ public class TweetTemplate extends Composite {
|
|||
* @param hidden
|
||||
*/
|
||||
public TweetTemplate(UserInfo myUserInfo, EnhancedFeed feed, HandlerManager eventBus, boolean hidden) {
|
||||
this(false, myUserInfo, feed, eventBus);
|
||||
this(false, false, myUserInfo, feed, eventBus);
|
||||
contentArea.getElement().getParentElement().getParentElement().setClassName("div-table-col content hidden");
|
||||
}
|
||||
|
||||
|
@ -250,22 +259,22 @@ public class TweetTemplate extends Composite {
|
|||
GWT.log("not belong to user");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@UiHandler("openImage")
|
||||
void onOpenFeedClick(ClickEvent e) {
|
||||
eventBus.fireEvent(new OpenFeedEvent(this));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@UiHandler("seeMore")
|
||||
void onSeeMoreClick(ClickEvent e) {
|
||||
contentArea.setHTML("<a class=\"link\"href=\""+GCubeSocialNetworking.USER_PROFILE_LINK+"?"+
|
||||
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
|
||||
Encoder.encode(myFeed.getFeed().getEntityId())+"\">"+
|
||||
myFeed.getFeed().getFullName()+"</a> " + myFeed.getFeed().getDescription());
|
||||
|
||||
Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID)+"="+
|
||||
Encoder.encode(myFeed.getFeed().getEntityId())+"\">"+
|
||||
myFeed.getFeed().getFullName()+"</a> " + myFeed.getFeed().getDescription());
|
||||
|
||||
seeMore.setHTML("");
|
||||
}
|
||||
|
||||
|
@ -325,7 +334,7 @@ public class TweetTemplate extends Composite {
|
|||
Window.alert("Could not load this component: " + reason.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -422,15 +431,15 @@ public class TweetTemplate extends Composite {
|
|||
public UserInfo getMyUserInfo() {
|
||||
return myUserInfo;
|
||||
}
|
||||
|
||||
|
||||
public String getMyFeedUserId() {
|
||||
return myFeed.getFeed().getEntityId();
|
||||
}
|
||||
|
||||
|
||||
public String getMyFeedText() {
|
||||
return myFeed.getFeed().getDescription();
|
||||
}
|
||||
|
||||
|
||||
public boolean isAppFeed() {
|
||||
return isAppFeed;
|
||||
}
|
||||
|
|
|
@ -16,20 +16,43 @@
|
|||
</div>
|
||||
<g:VerticalPanel ui:field="previewPanel"></g:VerticalPanel>
|
||||
<div class="tweet-actions">
|
||||
<g:HorizontalPanel>
|
||||
<g:HTML styleName="comment" ui:field="commentArea" />
|
||||
<g:Label styleName="tweet-separator">-</g:Label>
|
||||
<g:HTML styleName="like" ui:field="likeArea" />
|
||||
<g:Label ui:field="messageSeparator" styleName="tweet-separator">-</g:Label>
|
||||
<g:HTML styleName="message" ui:field="messageArea" />
|
||||
<g:HTML styleName="time" ui:field="timeArea" />
|
||||
<g:HTML ui:field="commentsNo"></g:HTML>
|
||||
<g:HTML ui:field="likesNo"></g:HTML>
|
||||
</g:HorizontalPanel>
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td align="left" style="vertical-align: top;">
|
||||
<g:HTML styleName="comment" ui:field="commentArea" />
|
||||
</td>
|
||||
<td align="left" style="vertical-align: top;">
|
||||
<g:Label styleName="tweet-separator">-</g:Label>
|
||||
</td>
|
||||
<td align="left" style="vertical-align: top;">
|
||||
<g:HTML styleName="like" ui:field="likeArea" />
|
||||
</td>
|
||||
<td align="left" style="vertical-align: top;">
|
||||
<g:Label ui:field="messageSeparator" styleName="tweet-separator">-</g:Label>
|
||||
</td>
|
||||
<td align="left" style="vertical-align: top;">
|
||||
<g:HTML styleName="message" ui:field="messageArea" />
|
||||
</td>
|
||||
<td align="left" style="vertical-align: top;">
|
||||
<g:HTML styleName="time" ui:field="timeArea" />
|
||||
</td>
|
||||
<td align="left" style="vertical-align: top;">
|
||||
<g:HTML ui:field="commentsNo"></g:HTML>
|
||||
</td>
|
||||
<td align="left" style="vertical-align: top;">
|
||||
<g:HTML ui:field="likesNo"></g:HTML>
|
||||
</td>
|
||||
<td align="right" style="width: 100%; vertical-align: top;">
|
||||
<g:HTML styleName="comment" ui:field="vreSource" ></g:HTML>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<g:VerticalPanel ui:field="commentsPanel"></g:VerticalPanel>
|
||||
</div>
|
||||
<div class="div-table-col close">
|
||||
<div class="div-table-col close">
|
||||
<g:HTML height="15px" ui:field="closeImage"></g:HTML>
|
||||
<g:HTML height="15px" ui:field="openImage"></g:HTML>
|
||||
</div>
|
||||
|
|
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# Defines the News Feed refreshing time in minutes
|
||||
REFRESH_TIME = 3
|
||||
CHANNEL_NAME = Virtual Research Environment
|
||||
VRE_LABEL = Virtual Research Environment
|
||||
SHOW_TIMELINE_SOURCE=false
|
Loading…
Reference in New Issue