added possibility to alert the users of a VRE when posting in to a VRE

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@92658 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-03-04 23:38:20 +00:00
parent 538ff34f7f
commit c4d45a8d89
9 changed files with 103 additions and 35 deletions

View File

@ -114,6 +114,10 @@
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>accesslogger</artifactId>
</dependency>
<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>pdf-renderer</artifactId>

View File

@ -17,7 +17,7 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
*/
@RemoteServiceRelativePath("shareupdateServlet")
public interface ShareUpdateService extends RemoteService {
ClientFeed share(String feedText, FeedType type, PrivacyLevel pLevel, String vreName, LinkPreview preview, String urlThumbnail, ArrayList<String> mentionedUsers, String fileName, String FilePathOnServer);
ClientFeed share(String feedText, FeedType type, PrivacyLevel pLevel, String vreName, LinkPreview preview, String urlThumbnail, ArrayList<String> mentionedUsers, String fileName, String FilePathOnServer, boolean notifyGroup);
UserSettings getUserSettings();

View File

@ -18,7 +18,8 @@ public interface ShareUpdateServiceAsync {
void share(String feedText, FeedType type, PrivacyLevel pLevel,
String vreName, LinkPreview preview, String urlThumbnail,
ArrayList<String> mentionedUsers, String fileName,
String FilePathOnServer, AsyncCallback<ClientFeed> callback);
String FilePathOnServer, boolean notifyGroup,
AsyncCallback<ClientFeed> callback);
void checkLink(String linkToCheck, AsyncCallback<LinkPreview> callback);

View File

@ -22,7 +22,6 @@ import org.jsonmaker.gwt.client.Jsonizer;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Document;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.VerticalAlign;
import com.google.gwt.dom.client.Style.Visibility;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@ -58,11 +57,15 @@ public class ShareUpdateForm extends Composite {
.create(ShareUpdateService.class);
final PageBusAdapter pageBusAdapter = new PageBusAdapter();
// the label for all Vres/channels
private final static String ALL_VRES = "Share with: your Virtual Research Environments";
protected final static String SHARE_UPDATE_TEXT = "Share an update or paste a link, use “@” to mention someone";
protected final static String ERROR_UPDATE_TEXT = "Looks like empty to me!";
public final static String NO_TEXT_FILE_SHARE = "_N0_73X7_SH4R3_";
private final static String LISTBOX_LEVEL = " - ";
public static final String loading = GWT.getModuleBaseURL() + "../images/avatarLoader.gif";
public static final String avatar_default = GWT.getModuleBaseURL() + "../images/Avatar_default.png";
public static final String attach = GWT.getModuleBaseURL() + "../images/attach.png";
@ -106,7 +109,11 @@ public class ShareUpdateForm extends Composite {
@UiField SuperPosedTextArea shareTextArea;
@UiField ListBox privacyLevel = new ListBox(false);
@UiField
ListBox privacyLevel = new ListBox(false);
@UiField
ListBox notifyListbox = new ListBox(false);
private UserInfo myUserInfo;
@ -149,23 +156,25 @@ public class ShareUpdateForm extends Composite {
avatarImage.setUrl(myUserInfo.getAvatarId());
String singleVREName = "";
if (myUserInfo.getOwnVREs().size() > 1) {
privacyLevel.addItem("My VREs", PrivacyLevel.VRES.toString());
privacyLevel.addItem(ALL_VRES, PrivacyLevel.VRES.toString());
for (String vreId : myUserInfo.getOwnVREs().keySet())
privacyLevel.addItem(LISTBOX_LEVEL + myUserInfo.getOwnVREs().get(vreId), vreId);
privacyLevel.addItem(LISTBOX_LEVEL + "Share with: " + myUserInfo.getOwnVREs().get(vreId), vreId);
}
else if (myUserInfo.getOwnVREs().size() == 1)
for (String vreId : myUserInfo.getOwnVREs().keySet()) {
singleVREName = myUserInfo.getOwnVREs().get(vreId);
privacyLevel.addItem(LISTBOX_LEVEL + singleVREName, vreId);
privacyLevel.addItem(LISTBOX_LEVEL + "Share with: " + singleVREName, vreId);
}
//privacyLevel.addItem("My Connections", PrivacyLevel.CONNECTION.toString());
if (myUserInfo.isAdmin() && userSettings.isInfrastructure())
privacyLevel.addItem("Anyone", PrivacyLevel.PORTAL.toString());
privacyLevel.addItem("Share with: Everyone", PrivacyLevel.PORTAL.toString());
//change css if deployed in VRE scope
if (!userSettings.isInfrastructure()) {
mainPanel.addStyleName("framed");
Document.get().getElementById("staticPrivacyLevel").setInnerText(singleVREName);
notifyListbox.addItem("Share with: " + singleVREName);
notifyListbox.addItem("Share with: " + singleVREName+" + Notification to members");
notifyListbox.setVisible(true);
}
else
privacyLevel.setVisible(true);
@ -270,8 +279,8 @@ public class ShareUpdateForm extends Composite {
}
}
LinkPreview preview2Share = new LinkPreview(linkTitle, linkDescription, linkUrl, linkHost, null);
shareupdateService.share(toShare, FeedType.TWEET, getPrivacyLevel(), vreId, preview2Share, linkUrlThumbnail, mentionedUsers, fileName, filePath, new AsyncCallback<ClientFeed>() {
boolean notifyGroup = notifyListbox.getSelectedIndex() > 0;
shareupdateService.share(toShare, FeedType.TWEET, getPrivacyLevel(), vreId, preview2Share, linkUrlThumbnail, mentionedUsers, fileName, filePath, notifyGroup, new AsyncCallback<ClientFeed>() {
public void onFailure(Throwable caught) {
submitButton.setEnabled(true);
shareTextArea.setEnabled(true);

View File

@ -1,6 +1,7 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:m="urn:import:org.gcube.portlets.user.shareupdates.client.view" xmlns:j="urn:import:org.gcube.portlets.widgets.fileupload.client.view">
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:m="urn:import:org.gcube.portlets.user.shareupdates.client.view"
xmlns:j="urn:import:org.gcube.portlets.widgets.fileupload.client.view">
<g:HTMLPanel ui:field="mainPanel">
<table class="shareContainer">
<tr>
@ -18,7 +19,8 @@
</div>
</div>
<div id="inputContainer">
<m:SuperPosedTextArea styleName="postTextArea" ui:field="shareTextArea" />
<m:SuperPosedTextArea styleName="postTextArea"
ui:field="shareTextArea" />
</div>
</div>
</td>
@ -28,20 +30,22 @@
<m:Placeholder ui:field="preview"></m:Placeholder>
<table class="toolsContainer">
<tr>
<td valign="middle" width="50%">
<td valign="middle" width="60px;">
</td>
<td valign="middle" width="372px">
<div style="text-align: left; padding-top: 2px; color: #777;">
privacy level:
<g:ListBox styleName="wizardListbox" ui:field="privacyLevel"
visible="false" />
<span id="staticPrivacyLevel"></span>
<g:ListBox styleName="wizardListbox" ui:field="notifyListbox"
visible="false" />
</div>
</td>
<td valign="middle"></td>
<td valign="middle">
<div class="buttonDiv">
<g:HTML ui:field="attachButton" styleName="gwt-Button"/>
<g:Button ui:field="submitButton" styleName="shareButton" width="90px" text="Share" />
<div class="buttonDiv">
<g:HTML ui:field="attachButton" styleName="gwt-Button" />
<g:Button ui:field="submitButton" styleName="shareButton"
width="90px" text="Share" />
</div>
</td>
</tr>

View File

@ -0,0 +1,43 @@
package org.gcube.portlets.user.shareupdates.server;
import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.UserModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Massimiliano Assante ISTI-CNR
*
*/
public class PostNotificationsThread implements Runnable {
private static Logger _log = LoggerFactory.getLogger(PostNotificationsThread.class);
private String postText;
private String postId;
private String groupId;
private NotificationsManager nm;
public PostNotificationsThread(String postId, String postText, String groupId, NotificationsManager nm) {
super();
this.postId = postId;
this.postText = postText;
this.groupId = groupId;
this.nm = nm;
}
@Override
public void run() {
UserManager um = new LiferayUserManager();
try {
for (UserModel user : um.listUsersByGroup(groupId)) {
boolean result = nm.notifyPost(user.getScreenName(), postId, postText);
_log.trace("Sending Notification for post alert to: " + user.getScreenName() + " result?"+ result);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -99,6 +99,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
private static final String STORAGE_OWNER = "gCubeSocialFramework";
public static final String UPLOAD_DIR = "/social-framework-uploads";
private static final String NEWS_FEED_PORTLET_CLASSNAME = "org.gcube.portlets.user.newsfeed.server.NewsServiceImpl";
/**
*
*/
@ -133,8 +134,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
if (user == null) {
_log.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL");
user = "test.user";
// user = "massimiliano.assante";
// SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
user = "massimiliano.assante";
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
withinPortal = false;
}
else {
@ -148,7 +149,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
*
*/
public ClientFeed share(String postText, FeedType feedType, PrivacyLevel pLevel,
String vreId, LinkPreview preview, String urlThumbnail, ArrayList<String> mentionedUserFullNames,String fileName, String filePathOnServer) {
String vreId, LinkPreview preview, String urlThumbnail, ArrayList<String> mentionedUserFullNames,String fileName, String filePathOnServer, boolean notifyGroup) {
String escapedFeedText = escapeHtml(postText);
@ -230,9 +231,16 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
ClientFeed cf = new ClientFeed(toShare.getKey(), toShare.getType().toString(), username, feedDate, toShare.getUri(),
replaceAmpersand(toShare.getDescription()), fullName, email, thumbnailURL, toShare.getLinkTitle(), toShare.getLinkDescription(),
toShare.getUriThumbnail(), toShare.getLinkHost());
//send the notification to the mentioned users
//send the notification about this posts to everyone in the group if notifyGroup is true
if (pLevel == PrivacyLevel.SINGLE_VRE && vreId != null && vreId.compareTo("") != 0 && notifyGroup) {
NotificationsManager nm = new ApplicationNotificationsManager(session, NEWS_FEED_PORTLET_CLASSNAME);
Thread thread = new Thread(new PostNotificationsThread(toShare.getKey(), escapedFeedText, ""+session.getGroupId(), nm));
thread.start();
}
//send the notification to the mentioned users
if (mentionedUsers != null && mentionedUsers.size() > 0) {
NotificationsManager nm = new ApplicationNotificationsManager(session);
Thread thread = new Thread(new MentionNotificationsThread(toShare.getKey(), escapedFeedText, nm, mentionedUsers));

View File

@ -13,7 +13,7 @@
name="net.eliasbalasis.tibcopagebus4gwt.testsubscriber.TestSubscriber" />
<!-- To Comment out -->
<set-property name="user.agent" value="safari,gecko1_8,ie9" />
<!-- <set-property name="user.agent" value="safari,gecko1_8,ie9" /> -->
<!-- Other module inherits -->

View File

@ -244,22 +244,21 @@ a.link:hover {
}
.wizardListbox {
height: 19px;
width: 110px;
height: 25px;
width: 372px;
background: #F2F2F2 url(images/white-grad.png) repeat-x scroll left top;
border-color: #BBB;
color: #464646;
font-size: 10px;
color: #444;
font-size: 12px;
border-width: 1px;
border-style: solid;
cursor: pointer;
cursor: hand;
padding-bottom: 3px;
margin-left: 6px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
}
.error {
color: #FFF;
background-color: pink;