frame the mainpanel if in VRE
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/news-feed@73154 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e1d2c1e23f
commit
64de50b635
|
@ -29,8 +29,6 @@ import org.gcube.portlets.user.newsfeed.client.event.SeeLikesEvent;
|
||||||
import org.gcube.portlets.user.newsfeed.client.event.SeeLikesEventHandler;
|
import org.gcube.portlets.user.newsfeed.client.event.SeeLikesEventHandler;
|
||||||
import org.gcube.portlets.user.newsfeed.client.event.ShowNewUpdatesEvent;
|
import org.gcube.portlets.user.newsfeed.client.event.ShowNewUpdatesEvent;
|
||||||
import org.gcube.portlets.user.newsfeed.client.event.ShowNewUpdatesEventHandler;
|
import org.gcube.portlets.user.newsfeed.client.event.ShowNewUpdatesEventHandler;
|
||||||
import org.gcube.portlets.user.newsfeed.client.event.StopTimerEvent;
|
|
||||||
import org.gcube.portlets.user.newsfeed.client.event.StopTimerEventHandler;
|
|
||||||
import org.gcube.portlets.user.newsfeed.client.panels.dialog.LikesDialog;
|
import org.gcube.portlets.user.newsfeed.client.panels.dialog.LikesDialog;
|
||||||
import org.gcube.portlets.user.newsfeed.client.templates.FilterPanel;
|
import org.gcube.portlets.user.newsfeed.client.templates.FilterPanel;
|
||||||
import org.gcube.portlets.user.newsfeed.client.templates.NewFeedsAvailable;
|
import org.gcube.portlets.user.newsfeed.client.templates.NewFeedsAvailable;
|
||||||
|
@ -54,8 +52,6 @@ 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
|
||||||
|
@ -73,7 +69,7 @@ public class NewsFeedPanel extends Composite {
|
||||||
private HorizontalPanel filterPanel = new HorizontalPanel();
|
private HorizontalPanel filterPanel = new HorizontalPanel();
|
||||||
private SimplePanel newUpdatesPanel = new SimplePanel();
|
private SimplePanel newUpdatesPanel = new SimplePanel();
|
||||||
private VerticalPanel newsPanel = new VerticalPanel();
|
private VerticalPanel newsPanel = new VerticalPanel();
|
||||||
|
|
||||||
private NewFeedsAvailable newsFeedAlert;
|
private NewFeedsAvailable newsFeedAlert;
|
||||||
|
|
||||||
private static final String warning = GWT.getModuleBaseURL() + "../images/warning_blue.png";
|
private static final String warning = GWT.getModuleBaseURL() + "../images/warning_blue.png";
|
||||||
|
@ -86,7 +82,7 @@ public class NewsFeedPanel extends Composite {
|
||||||
public static final String MESSAGE_LABEL = "Message";
|
public static final String MESSAGE_LABEL = "Message";
|
||||||
|
|
||||||
private int delayMillis = 300000; //5 minutes by default (is read from a configuration file in the first async callback)
|
private int delayMillis = 300000; //5 minutes by default (is read from a configuration file in the first async callback)
|
||||||
|
|
||||||
private int currNewUpdatesNo = 0;
|
private int currNewUpdatesNo = 0;
|
||||||
|
|
||||||
private boolean isFirstTweet = false;
|
private boolean isFirstTweet = false;
|
||||||
|
@ -104,7 +100,7 @@ public class NewsFeedPanel extends Composite {
|
||||||
* events binder
|
* events binder
|
||||||
*/
|
*/
|
||||||
private void bind() {
|
private void bind() {
|
||||||
|
|
||||||
eventBus.addHandler(ShowNewUpdatesEvent.TYPE, new ShowNewUpdatesEventHandler() {
|
eventBus.addHandler(ShowNewUpdatesEvent.TYPE, new ShowNewUpdatesEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onShowNewUpdatesClick(ShowNewUpdatesEvent event) {
|
public void onShowNewUpdatesClick(ShowNewUpdatesEvent event) {
|
||||||
|
@ -113,21 +109,9 @@ public class NewsFeedPanel extends Composite {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
eventBus.addHandler(StopTimerEvent.TYPE, new StopTimerEventHandler() {
|
|
||||||
@Override
|
|
||||||
public void onStopTimer(StopTimerEvent event) {
|
|
||||||
GWT.log("Stop timer");
|
|
||||||
if (event.isRestart())
|
|
||||||
resetTimer();
|
|
||||||
else
|
|
||||||
stopTimer();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
eventBus.addHandler(AddLikeEvent.TYPE, new AddLikeEventHandler() {
|
eventBus.addHandler(AddLikeEvent.TYPE, new AddLikeEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onAddLike(AddLikeEvent event) {
|
public void onAddLike(AddLikeEvent event) {
|
||||||
resetTimer();
|
|
||||||
doAddLike( event.getOwner(), event.getFeedId());
|
doAddLike( event.getOwner(), event.getFeedId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -135,7 +119,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
eventBus.addHandler(AddCommentEvent.TYPE, new AddCommentEventHandler() {
|
eventBus.addHandler(AddCommentEvent.TYPE, new AddCommentEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onAddComment(AddCommentEvent event) {
|
public void onAddComment(AddCommentEvent event) {
|
||||||
resetTimer();
|
|
||||||
doAddComment(event.getOwner(), event.getText());
|
doAddComment(event.getOwner(), event.getText());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -143,7 +126,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
eventBus.addHandler(EditCommentEvent.TYPE, new EditCommentEventHandler() {
|
eventBus.addHandler(EditCommentEvent.TYPE, new EditCommentEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onEditComment(EditCommentEvent event) {
|
public void onEditComment(EditCommentEvent event) {
|
||||||
resetTimer();
|
|
||||||
doEditComment(event.getOwner(), event.getCommentInstance());
|
doEditComment(event.getOwner(), event.getCommentInstance());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -152,7 +134,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
eventBus.addHandler(SeeLikesEvent.TYPE, new SeeLikesEventHandler() {
|
eventBus.addHandler(SeeLikesEvent.TYPE, new SeeLikesEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onSeeLikes(SeeLikesEvent event) {
|
public void onSeeLikes(SeeLikesEvent event) {
|
||||||
resetTimer();
|
|
||||||
doShowLikes(event.getFeedId());
|
doShowLikes(event.getFeedId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -160,7 +141,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
eventBus.addHandler(SeeCommentsEvent.TYPE, new SeeCommentsEventHandler() {
|
eventBus.addHandler(SeeCommentsEvent.TYPE, new SeeCommentsEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onSeeComments(SeeCommentsEvent event) {
|
public void onSeeComments(SeeCommentsEvent event) {
|
||||||
resetTimer();
|
|
||||||
doShowComments(event.getOwner(), event.isCommentForm2Add());
|
doShowComments(event.getOwner(), event.isCommentForm2Add());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -168,7 +148,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
eventBus.addHandler(DeleteCommentEvent.TYPE, new DeleteCommentEventHandler() {
|
eventBus.addHandler(DeleteCommentEvent.TYPE, new DeleteCommentEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onDeleteComment(DeleteCommentEvent event) {
|
public void onDeleteComment(DeleteCommentEvent event) {
|
||||||
resetTimer();
|
|
||||||
doDeleteComment(event.getOwner(), event.getCommentId());
|
doDeleteComment(event.getOwner(), event.getCommentId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -176,7 +155,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
eventBus.addHandler(DeleteFeedEvent.TYPE, new DeleteFeedEventHandler() {
|
eventBus.addHandler(DeleteFeedEvent.TYPE, new DeleteFeedEventHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onDeleteFeed(DeleteFeedEvent event) {
|
public void onDeleteFeed(DeleteFeedEvent event) {
|
||||||
resetTimer();
|
|
||||||
doDeleteFeed(event.getToDelete());
|
doDeleteFeed(event.getToDelete());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -189,7 +167,9 @@ public class NewsFeedPanel extends Composite {
|
||||||
*/
|
*/
|
||||||
public NewsFeedPanel() {
|
public NewsFeedPanel() {
|
||||||
bind();
|
bind();
|
||||||
|
mainPanel.setWidth("600px");
|
||||||
mainPanel.add(filterPanel);
|
mainPanel.add(filterPanel);
|
||||||
|
filterPanel.setVisible(false);
|
||||||
mainPanel.add(newUpdatesPanel);
|
mainPanel.add(newUpdatesPanel);
|
||||||
mainPanel.add(newsPanel);
|
mainPanel.add(newsPanel);
|
||||||
|
|
||||||
|
@ -211,7 +191,7 @@ public class NewsFeedPanel extends Composite {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(UserSettings result) {
|
public void onSuccess(UserSettings result) {
|
||||||
myUserInfo = result.getUserInfo();
|
myUserInfo = result.getUserInfo();
|
||||||
delayMillis = result.getRefreshingTimeInMillis();
|
delayMillis = result.getRefreshingTimeInMillis();
|
||||||
if (result.getUserInfo().getUsername().equals("test.user")) {
|
if (result.getUserInfo().getUsername().equals("test.user")) {
|
||||||
Window.alert("Your session has expired, please log out and login again");
|
Window.alert("Your session has expired, please log out and login again");
|
||||||
}
|
}
|
||||||
|
@ -219,6 +199,12 @@ public class NewsFeedPanel extends Composite {
|
||||||
showAllUpdatesFeeds();
|
showAllUpdatesFeeds();
|
||||||
currentFilter = FilterType.ALL_UPDATES;
|
currentFilter = FilterType.ALL_UPDATES;
|
||||||
}
|
}
|
||||||
|
//adjustments in the UI Depending on the scope
|
||||||
|
if (result.isInfrastructure())
|
||||||
|
filterPanel.setVisible(true);
|
||||||
|
else
|
||||||
|
mainPanel.addStyleName("framed");
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -231,13 +217,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
feedsTimer.scheduleRepeating(delayMillis);
|
feedsTimer.scheduleRepeating(delayMillis);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetTimer() {
|
|
||||||
feedsTimer.cancel();
|
|
||||||
feedsTimer.scheduleRepeating(delayMillis);
|
|
||||||
}
|
|
||||||
private void stopTimer() {
|
|
||||||
feedsTimer.cancel();
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -265,20 +244,20 @@ public class NewsFeedPanel extends Composite {
|
||||||
|
|
||||||
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 Mine: "+allUpdates.get(0).getFeed().getDescription());
|
||||||
|
|
||||||
GWT.log("Last Retr.: "+feeds.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
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < feeds.size() && feeds.get(i).getFeed().getTime().after(myLastUpdateTime)) {
|
while (i < feeds.size() && feeds.get(i).getFeed().getTime().after(myLastUpdateTime)) {
|
||||||
tempCacheNewUpdates.add(feeds.get(i));
|
tempCacheNewUpdates.add(feeds.get(i));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* currNewUpdatesNo keeps the number of updates to be added on user clicks,
|
/* currNewUpdatesNo keeps the number of updates to be added on user clicks,
|
||||||
* i keeps the total number as it arrives,
|
* i keeps the total number as it arrives,
|
||||||
* if they differ you got to refresh the updates to show the new number
|
* if they differ you got to refresh the updates to show the new number
|
||||||
|
@ -308,7 +287,7 @@ public class NewsFeedPanel extends Composite {
|
||||||
newUpdatesPanel.clear(); //remove the alert panel
|
newUpdatesPanel.clear(); //remove the alert panel
|
||||||
newsFeedAlert = null; //reset the alert panel and other needed vars
|
newsFeedAlert = null; //reset the alert panel and other needed vars
|
||||||
currNewUpdatesNo = 0;
|
currNewUpdatesNo = 0;
|
||||||
|
|
||||||
//need to put them in reverse order;
|
//need to put them in reverse order;
|
||||||
for (int i = tempCacheNewUpdates.size(); i > 0; i--) {
|
for (int i = tempCacheNewUpdates.size(); i > 0; i--) {
|
||||||
EnhancedFeed feed = tempCacheNewUpdates.get(i-1);
|
EnhancedFeed feed = tempCacheNewUpdates.get(i-1);
|
||||||
|
@ -328,7 +307,7 @@ public class NewsFeedPanel extends Composite {
|
||||||
String currTitle = Document.get().getTitle();
|
String currTitle = Document.get().getTitle();
|
||||||
Document.get().setTitle(currTitle.startsWith("(") ? currTitle.substring(4) : currTitle);
|
Document.get().setTitle(currTitle.startsWith("(") ? currTitle.substring(4) : currTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* used when addin directly a feed from the UI (IPC)
|
* used when addin directly a feed from the UI (IPC)
|
||||||
* @param userid
|
* @param userid
|
||||||
|
@ -359,7 +338,7 @@ public class NewsFeedPanel extends Composite {
|
||||||
};
|
};
|
||||||
|
|
||||||
t.schedule(500);
|
t.schedule(500);
|
||||||
|
|
||||||
//insert it also in the model so that the user who created it do not get notified about this new update
|
//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
|
allUpdates.add(0, toAdd); //insert in the model
|
||||||
}
|
}
|
||||||
|
@ -369,7 +348,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
*/
|
*/
|
||||||
public void showAllUpdatesFeeds() {
|
public void showAllUpdatesFeeds() {
|
||||||
showLoader();
|
showLoader();
|
||||||
resetTimer();
|
|
||||||
newsService.getAllUpdateUserFeeds(new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
newsService.getAllUpdateUserFeeds(new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
||||||
|
@ -416,7 +394,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
*/
|
*/
|
||||||
public void showOnlyConnectionsFeeds() {
|
public void showOnlyConnectionsFeeds() {
|
||||||
showLoader();
|
showLoader();
|
||||||
resetTimer();
|
|
||||||
newsService.getOnlyConnectionsUserFeeds(new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
newsService.getOnlyConnectionsUserFeeds(new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
||||||
|
@ -457,7 +434,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
*/
|
*/
|
||||||
public void showOnlyMyFeeds() {
|
public void showOnlyMyFeeds() {
|
||||||
showLoader();
|
showLoader();
|
||||||
resetTimer();
|
|
||||||
newsService.getOnlyMyUserFeeds(new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
newsService.getOnlyMyUserFeeds(new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
||||||
|
@ -497,7 +473,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
*/
|
*/
|
||||||
public void showOnlyLikedFeeds() {
|
public void showOnlyLikedFeeds() {
|
||||||
showLoader();
|
showLoader();
|
||||||
resetTimer();
|
|
||||||
newsService.getOnlyLikedFeeds(new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
newsService.getOnlyLikedFeeds(new AsyncCallback<ArrayList<EnhancedFeed>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
public void onSuccess(ArrayList<EnhancedFeed> feeds) {
|
||||||
|
@ -549,7 +524,6 @@ public class NewsFeedPanel extends Composite {
|
||||||
newsPanel.add(new HTML("<div class=\"nofeed-message\">" +
|
newsPanel.add(new HTML("<div class=\"nofeed-message\">" +
|
||||||
"Ops! There were problems while retrieving your feeds!. <br> " +
|
"Ops! There were problems while retrieving your feeds!. <br> " +
|
||||||
"Looks like we are not able to communicate with the infrastructure,<br> (or your session expired)<br> please try again in a short while or refresh the page.</div>"));
|
"Looks like we are not able to communicate with the infrastructure,<br> (or your session expired)<br> please try again in a short while or refresh the page.</div>"));
|
||||||
stopTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doAddLike(final TweetTemplate owner, final String feedId) {
|
private void doAddLike(final TweetTemplate owner, final String feedId) {
|
||||||
|
|
|
@ -94,14 +94,61 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
_log.warn("USER IS NULL setting testing user and Running OUTSIDE PORTAL");
|
_log.warn("USER IS NULL setting testing user and Running OUTSIDE PORTAL");
|
||||||
user = "test.user";
|
//user = "test.user";
|
||||||
//user = "massimiliano.assante";
|
user = "massimiliano.assante";
|
||||||
|
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
withinPortal = true;
|
withinPortal = true;
|
||||||
}
|
}
|
||||||
return SessionManager.getInstance().getASLSession(sessionID, user);
|
return SessionManager.getInstance().getASLSession(sessionID, user);
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* this is the first method called by the web app
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public UserSettings getUserSettings() {
|
||||||
|
if (getUserSettingsFromSession() != null)
|
||||||
|
return getUserSettingsFromSession();
|
||||||
|
try {
|
||||||
|
ASLSession session = getASLSession();
|
||||||
|
String username = session.getUsername();
|
||||||
|
String email = username+"@isti.cnr.it";
|
||||||
|
String fullName = username+" FULL";
|
||||||
|
String thumbnailURL = "images/Avatar_default.png";
|
||||||
|
|
||||||
|
if (withinPortal) {
|
||||||
|
UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
|
||||||
|
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
|
||||||
|
fullName = user.getFirstName() + " " + user.getLastName();
|
||||||
|
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(), session.getScopeName(), 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return new UserSettings();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the scope is the whole infrastructure.
|
||||||
|
* @return <code>true</code> if it is, <code>false</code> otherwise.
|
||||||
|
*/
|
||||||
|
private boolean isInfrastructureScope() {
|
||||||
|
return getASLSession().getScope().isInfrastructure();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<EnhancedFeed> getAllUpdateUserFeeds() {
|
public ArrayList<EnhancedFeed> getAllUpdateUserFeeds() {
|
||||||
|
@ -122,37 +169,50 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
|
|
||||||
_log.info("****** retrieving feeds for user: " + userName);
|
_log.info("****** retrieving feeds for user: " + userName);
|
||||||
User currUser = OrganizationsUtil.validateUser(userName);
|
User currUser = OrganizationsUtil.validateUser(userName);
|
||||||
|
/**
|
||||||
//VRE Feeds
|
* this handles the case where the portlet is deployed outside of VREs (regular)
|
||||||
for (Organization org : currUser.getOrganizations()) {
|
*/
|
||||||
GroupManager gm = new LiferayGroupManager();
|
if (isInfrastructureScope()) {
|
||||||
if (gm.isVRE(org.getOrganizationId()+"")) {
|
//VRE Feeds
|
||||||
String vreid = gm.getScope(""+org.getOrganizationId()); //get the scope
|
for (Organization org : currUser.getOrganizations()) {
|
||||||
_log.trace("Reading feeds for VRE: " + vreid);
|
GroupManager gm = new LiferayGroupManager();
|
||||||
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE(vreid, 10);
|
if (gm.isVRE(org.getOrganizationId()+"")) {
|
||||||
for (Feed feed : OrganizationFeeds) {
|
String vreid = gm.getScope(""+org.getOrganizationId()); //get the scope
|
||||||
feedsMap.put(feed.getKey(), feed);
|
_log.trace("Reading feeds for VRE: " + vreid);
|
||||||
|
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE(vreid, 10);
|
||||||
|
for (Feed feed : OrganizationFeeds) {
|
||||||
|
feedsMap.put(feed.getKey(), feed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
//User Own Feeds
|
||||||
//User Own Feeds
|
ArrayList<Feed> userFeeds = (ArrayList<Feed>) store.getRecentFeedsByUser(userName, 10);
|
||||||
ArrayList<Feed> userFeeds = (ArrayList<Feed>) store.getRecentFeedsByUser(userName, 10);
|
for (Feed feed : userFeeds) {
|
||||||
for (Feed feed : userFeeds) {
|
feedsMap.put(feed.getKey(), feed);
|
||||||
feedsMap.put(feed.getKey(), feed);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//UserFriends Feeds
|
//UserFriends Feeds
|
||||||
ArrayList<String> userFriendsIds = (ArrayList<String>)store.getFriends(userName);
|
ArrayList<String> userFriendsIds = (ArrayList<String>)store.getFriends(userName);
|
||||||
for (String userid : userFriendsIds) {
|
for (String userid : userFriendsIds) {
|
||||||
for (Feed feed : store.getRecentFeedsByUser(userid, 10)) {
|
for (Feed feed : store.getRecentFeedsByUser(userid, 10)) {
|
||||||
|
feedsMap.put(feed.getKey(), feed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Portal Feeds
|
||||||
|
ArrayList<Feed> portalFeeds = (ArrayList<Feed>) store.getAllPortalPrivacyLevelFeeds();
|
||||||
|
for (Feed feed : portalFeeds) {
|
||||||
feedsMap.put(feed.getKey(), feed);
|
feedsMap.put(feed.getKey(), feed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//else must be in a VRE scope
|
||||||
//Portal Feeds
|
else {
|
||||||
ArrayList<Feed> portalFeeds = (ArrayList<Feed>) store.getAllPortalPrivacyLevelFeeds();
|
String vreid = getASLSession().getScopeName();
|
||||||
for (Feed feed : portalFeeds) {
|
_log.trace("News Feed in VRE, Reading feeds for VRE: " + vreid);
|
||||||
feedsMap.put(feed.getKey(), feed);
|
ArrayList<Feed> OrganizationFeeds = (ArrayList<Feed>) store.getRecentFeedsByVRE(vreid, 30);
|
||||||
|
for (Feed feed : OrganizationFeeds) {
|
||||||
|
feedsMap.put(feed.getKey(), feed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String key: feedsMap.keySet()) {
|
for (String key: feedsMap.keySet()) {
|
||||||
|
@ -377,7 +437,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
}
|
}
|
||||||
return edited;
|
return edited;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String replaceAmpersand(String toReplace) {
|
private String replaceAmpersand(String toReplace) {
|
||||||
String toReturn = toReplace.replaceAll("&", "&");
|
String toReturn = toReplace.replaceAll("&", "&");
|
||||||
return toReturn;
|
return toReturn;
|
||||||
|
@ -472,40 +532,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserSettings getUserSettings() {
|
|
||||||
if (getUserSettingsFromSession() != null)
|
|
||||||
return getUserSettingsFromSession();
|
|
||||||
try {
|
|
||||||
String username = getASLSession().getUsername();
|
|
||||||
String email = username+"@isti.cnr.it";
|
|
||||||
String fullName = username+" FULL";
|
|
||||||
String thumbnailURL = "images/Avatar_default.png";
|
|
||||||
|
|
||||||
if (withinPortal) {
|
|
||||||
UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
|
|
||||||
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
|
|
||||||
fullName = user.getFirstName() + " " + user.getLastName();
|
|
||||||
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);
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return new UserSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<Like> getAllLikesByFeed(String feedid) {
|
public ArrayList<Like> getAllLikesByFeed(String feedid) {
|
||||||
|
@ -578,7 +605,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
return html.replaceAll("&", "&").replaceAll("<", "<")
|
return html.replaceAll("&", "&").replaceAll("<", "<")
|
||||||
.replaceAll(">", ">");
|
.replaceAll(">", ">");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return true if the user is a portal administrator or not
|
* @return true if the user is a portal administrator or not
|
||||||
|
@ -704,6 +731,6 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return 30000; //30 secs for testing
|
return 60000; //60 secs for testing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,14 +8,18 @@ import org.gcube.portal.databook.shared.UserInfo;
|
||||||
public class UserSettings implements Serializable {
|
public class UserSettings implements Serializable {
|
||||||
private UserInfo userInfo;
|
private UserInfo userInfo;
|
||||||
private int refreshingTimeInMillis;
|
private int refreshingTimeInMillis;
|
||||||
public UserSettings() {
|
private String currentScope;
|
||||||
|
boolean isInfrastructure;
|
||||||
|
public UserSettings() {
|
||||||
super();
|
super();
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
}
|
||||||
public UserSettings(UserInfo userInfo, int refreshingTimeInMillis) {
|
public UserSettings(UserInfo userInfo, int refreshingTimeInMillis,
|
||||||
|
String currentScope, boolean isInfrastructure) {
|
||||||
super();
|
super();
|
||||||
this.userInfo = userInfo;
|
this.userInfo = userInfo;
|
||||||
this.refreshingTimeInMillis = refreshingTimeInMillis;
|
this.refreshingTimeInMillis = refreshingTimeInMillis;
|
||||||
|
this.currentScope = currentScope;
|
||||||
|
this.isInfrastructure = isInfrastructure;
|
||||||
}
|
}
|
||||||
public UserInfo getUserInfo() {
|
public UserInfo getUserInfo() {
|
||||||
return userInfo;
|
return userInfo;
|
||||||
|
@ -29,9 +33,24 @@ public class UserSettings implements Serializable {
|
||||||
public void setRefreshingTimeInMillis(int refreshingTimeInMillis) {
|
public void setRefreshingTimeInMillis(int refreshingTimeInMillis) {
|
||||||
this.refreshingTimeInMillis = refreshingTimeInMillis;
|
this.refreshingTimeInMillis = refreshingTimeInMillis;
|
||||||
}
|
}
|
||||||
|
public String getCurrentScope() {
|
||||||
|
return currentScope;
|
||||||
|
}
|
||||||
|
public void setCurrentScope(String currentScope) {
|
||||||
|
this.currentScope = currentScope;
|
||||||
|
}
|
||||||
|
public boolean isInfrastructure() {
|
||||||
|
return isInfrastructure;
|
||||||
|
}
|
||||||
|
public void setInfrastructure(boolean isInfrastructure) {
|
||||||
|
this.isInfrastructure = isInfrastructure;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "UserSettings [userInfo=" + userInfo
|
return "UserSettings [userInfo=" + userInfo
|
||||||
+ ", refreshingTimeInMillis=" + refreshingTimeInMillis + "]";
|
+ ", refreshingTimeInMillis=" + refreshingTimeInMillis
|
||||||
|
+ ", currentScope=" + currentScope + ", isInfrastructure="
|
||||||
|
+ isInfrastructure + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,20 @@ table {
|
||||||
border-spacing: 0;
|
border-spacing: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.framed {
|
||||||
|
margin: 0 0 10px;
|
||||||
|
padding: 10px;
|
||||||
|
margin: 0px 5px;
|
||||||
|
|
||||||
|
background: #FFF url(images/vre_bg_gray.png) repeat-x left bottom;
|
||||||
|
|
||||||
|
border-radius: 6px !important;
|
||||||
|
-moz-border-radius: 6px !important;
|
||||||
|
-webkit-border-radius: 6px !important;
|
||||||
|
|
||||||
|
border: 1px solid #DBDBDB;
|
||||||
|
}
|
||||||
|
|
||||||
.new-feeds-container {
|
.new-feeds-container {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
Loading…
Reference in New Issue