Fix for Bug #1303 notification of posts do not handle multi tabs
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@124605 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fe2150c2f4
commit
2e1e2042ea
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/share-updates-1.9.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/share-updates-1.9.2-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/share-updates-1.9.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/share-updates-1.9.2-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
<dependent-module archiveName="pickitem-widget-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickitem-widget/pickitem-widget">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
|
||||
<property name="context-root" value="share-updates"/>
|
||||
</wb-module>
|
||||
|
|
9
pom.xml
9
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>share-updates</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.9.1-SNAPSHOT</version>
|
||||
<version>1.9.2-SNAPSHOT</version>
|
||||
<name>gCube Share Updates Portlet</name>
|
||||
<description>
|
||||
gCube Share Updates for exchanging updates with other users of VREs.
|
||||
|
@ -58,11 +58,16 @@
|
|||
<artifactId>gwt-servlet</artifactId>
|
||||
<version>${gwtVersion}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.gwt</groupId>
|
||||
<artifactId>gwt-dev</artifactId>
|
||||
<version>${gwtVersion}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.gwtbootstrap</groupId>
|
||||
<artifactId>gwt-bootstrap</artifactId>
|
||||
<version>2.3.2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
|
|
|
@ -19,9 +19,9 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
|||
@RemoteServiceRelativePath("shareupdateServlet")
|
||||
public interface ShareUpdateService extends RemoteService {
|
||||
|
||||
ClientFeed sharePostWithLinkPreview(String feedText, FeedType type, PrivacyLevel pLevel, String vreName, LinkPreview preview, String urlThumbnail, ArrayList<String> mentionedUsers, boolean notifyGroup);
|
||||
ClientFeed sharePostWithLinkPreview(String feedText, FeedType type, PrivacyLevel pLevel, Long vreOrgId, LinkPreview preview, String urlThumbnail, ArrayList<String> mentionedUsers, boolean notifyGroup);
|
||||
|
||||
ClientFeed sharePostWithAttachments(String feedText, FeedType type, PrivacyLevel pLevel, String vreName,ArrayList<UploadedFile> uploadedFiles, ArrayList<String> mentionedUsers, boolean notifyGroup, boolean saveCopyWokspace);
|
||||
ClientFeed sharePostWithAttachments(String feedText, FeedType type, PrivacyLevel pLevel, Long vreOrgId,ArrayList<UploadedFile> uploadedFiles, ArrayList<String> mentionedUsers, boolean notifyGroup, boolean saveCopyWokspace);
|
||||
|
||||
UserSettings getUserSettings();
|
||||
|
||||
|
|
|
@ -29,12 +29,12 @@ public interface ShareUpdateServiceAsync {
|
|||
void getHashtags(AsyncCallback<ArrayList<ItemBean>> callback);
|
||||
|
||||
void sharePostWithLinkPreview(String feedText, FeedType type,
|
||||
PrivacyLevel pLevel, String vreName, LinkPreview preview,
|
||||
PrivacyLevel pLevel, Long vreOrgId, LinkPreview preview,
|
||||
String urlThumbnail, ArrayList<String> mentionedUsers, boolean notifyGroup,
|
||||
AsyncCallback<ClientFeed> callback);
|
||||
|
||||
void sharePostWithAttachments(String feedText, FeedType type,
|
||||
PrivacyLevel pLevel, String vreName,
|
||||
PrivacyLevel pLevel, Long vreOrgId,
|
||||
ArrayList<UploadedFile> uploadedFiles,
|
||||
ArrayList<String> mentionedUsers, boolean notifyGroup,
|
||||
boolean saveCopyWokspace, AsyncCallback<ClientFeed> callback);
|
||||
|
|
|
@ -432,8 +432,9 @@ public class ShareUpdateForm extends Composite {
|
|||
|
||||
LinkPreview preview2Share = new LinkPreview(linkTitle, linkDescription, linkUrl, linkHost, null);
|
||||
|
||||
Long vreOrgId = Long.parseLong(vreId);
|
||||
// share post (it could contain a link preview)
|
||||
shareupdateService.sharePostWithLinkPreview(toShareText, FeedType.TWEET, getPrivacyLevel(), vreId, preview2Share, linkUrlThumbnail, mentionedUsers, notifyGroup, new AsyncCallback<ClientFeed>() {
|
||||
shareupdateService.sharePostWithLinkPreview(toShareText, FeedType.TWEET, getPrivacyLevel(), vreOrgId, preview2Share, linkUrlThumbnail, mentionedUsers, notifyGroup, new AsyncCallback<ClientFeed>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
submitButton.setEnabled(true);
|
||||
|
@ -490,9 +491,9 @@ public class ShareUpdateForm extends Composite {
|
|||
file.getFormat()));
|
||||
|
||||
}
|
||||
|
||||
Long vreOrgId = Long.parseLong(vreId);
|
||||
// share the post
|
||||
shareupdateService.sharePostWithAttachments(toShareText, FeedType.TWEET, getPrivacyLevel(), vreId, uploadedFiles, mentionedUsers, notifyGroup, saveInWorkspaceCheckbox.getValue(), new AsyncCallback<ClientFeed>() {
|
||||
shareupdateService.sharePostWithAttachments(toShareText, FeedType.TWEET, getPrivacyLevel(), vreOrgId, uploadedFiles, mentionedUsers, notifyGroup, saveInWorkspaceCheckbox.getValue(), new AsyncCallback<ClientFeed>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ClientFeed feed) {
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.gcube.application.framework.core.session.ASLSession;
|
|||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.storage.UriResolverReaderParameter;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
|
@ -147,10 +147,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
*/
|
||||
@Override
|
||||
public ClientFeed sharePostWithLinkPreview(String postText, FeedType feedType, PrivacyLevel pLevel,
|
||||
String vreId, LinkPreview preview, String urlThumbnail, ArrayList<String> mentionedUserFullNames, boolean notifyGroup) {
|
||||
Long vreOrgId, LinkPreview preview, String urlThumbnail, ArrayList<String> mentionedUserFullNames, boolean notifyGroup) {
|
||||
|
||||
|
||||
_log.debug("Writing a new post with text " + postText);
|
||||
// escape text
|
||||
String escapedFeedText = TextTransfromUtils.escapeHtmlAndTransformUrl(postText);
|
||||
|
||||
|
@ -198,8 +196,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
|
||||
//get the VRE scope if single channel post
|
||||
String vreScope2Set = "";
|
||||
if (pLevel == PrivacyLevel.SINGLE_VRE && vreId != null && vreId.compareTo("") != 0) {
|
||||
vreScope2Set = (withinPortal) ? getScopeByOrganizationId(vreId) : session.getScope();
|
||||
if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null) {
|
||||
vreScope2Set = (withinPortal) ? getScopeByOrganizationId(vreOrgId) : session.getScope();
|
||||
}
|
||||
|
||||
// build the feed to share (and save on cassandra)
|
||||
|
@ -213,8 +211,9 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
//need to put the feed into VRES Timeline too
|
||||
if (pLevel == PrivacyLevel.VRES) {
|
||||
_log.trace("PrivacyLevel was set to VRES attempting to write onto User's VRES Timelines");
|
||||
for (GroupModel vre : getUserVREs(username)) {
|
||||
String vreScope = getScopeByOrganizationId(vre.getGroupId());
|
||||
for (GroupModel vre : getUserVREs(username)) {
|
||||
Long orgId = Long.parseLong(vre.getGroupId());
|
||||
String vreScope = getScopeByOrganizationId(orgId);
|
||||
_log.trace("Attempting to write onto " + vreScope);
|
||||
try {
|
||||
store.saveFeedToVRETimeline(toShare.getKey(), vreScope);
|
||||
|
@ -227,7 +226,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
}
|
||||
//share on a single VRE Timeline
|
||||
//receives a VreId(groupId) get the scope from the groupId
|
||||
else if (pLevel == PrivacyLevel.SINGLE_VRE && vreId != null && vreId.compareTo("") != 0) {
|
||||
else if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null) {
|
||||
_log.trace("Attempting to write onto " + vreScope2Set);
|
||||
try {
|
||||
store.saveFeedToVRETimeline(toShare.getKey(), vreScope2Set);
|
||||
|
@ -247,15 +246,21 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
|
||||
|
||||
//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, hashtags));
|
||||
if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null && notifyGroup) {
|
||||
NotificationsManager nm = new ApplicationNotificationsManager(
|
||||
vreScope2Set,
|
||||
new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL),
|
||||
NEWS_FEED_PORTLET_CLASSNAME);
|
||||
Thread thread = new Thread(new PostNotificationsThread(toShare.getKey(), escapedFeedText, ""+vreOrgId, nm, hashtags));
|
||||
thread.start();
|
||||
|
||||
}
|
||||
//send the notification to the mentioned users
|
||||
if (mentionedUsers != null && mentionedUsers.size() > 0) {
|
||||
NotificationsManager nm = new ApplicationNotificationsManager(session);
|
||||
NotificationsManager nm = new ApplicationNotificationsManager(
|
||||
vreScope2Set,
|
||||
new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL),
|
||||
NEWS_FEED_PORTLET_CLASSNAME);
|
||||
ArrayList<GenericItemBean> toPass = new ArrayList<GenericItemBean>();
|
||||
for (ItemBean u : mentionedUsers) {
|
||||
toPass.add(new GenericItemBean(u.getId(), u.getName(), u.getAlternativeName(), u.getThumbnailURL()));
|
||||
|
@ -267,18 +272,14 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
return cf;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Share a post with at least one attachment.
|
||||
*/
|
||||
@Override
|
||||
public ClientFeed sharePostWithAttachments(String feedText, FeedType feedType,
|
||||
PrivacyLevel pLevel, String vreId, ArrayList<UploadedFile> uploadedFiles,
|
||||
PrivacyLevel pLevel, Long vreOrgId, ArrayList<UploadedFile> uploadedFiles,
|
||||
ArrayList<String> mentionedUserFullNames, boolean notifyGroup, boolean saveCopyWokspace) {
|
||||
|
||||
_log.debug("Incoming text is " + feedText);
|
||||
|
||||
// escape text
|
||||
String escapedFeedText = TextTransfromUtils.escapeHtmlAndTransformUrl(feedText);
|
||||
|
||||
|
@ -380,8 +381,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
|
||||
//get the VRE scope if single channel post
|
||||
String vreScope2Set = "";
|
||||
if (pLevel == PrivacyLevel.SINGLE_VRE && vreId != null && vreId.compareTo("") != 0) {
|
||||
vreScope2Set = (withinPortal) ? getScopeByOrganizationId(vreId) : session.getScope();
|
||||
if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null ) {
|
||||
vreScope2Set = (withinPortal) ? getScopeByOrganizationId(vreOrgId) : session.getScope();
|
||||
}
|
||||
|
||||
Feed toShare = null;
|
||||
|
@ -417,8 +418,9 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
//need to put the feed into VRES Timeline too
|
||||
if (pLevel == PrivacyLevel.VRES) {
|
||||
_log.trace("PrivacyLevel was set to VRES attempting to write onto User's VRES Timelines");
|
||||
for (GroupModel vre : getUserVREs(username)) {
|
||||
String vreScope = getScopeByOrganizationId(vre.getGroupId());
|
||||
for (GroupModel vre : getUserVREs(username)) {
|
||||
Long orgId = Long.parseLong(vre.getGroupId());
|
||||
String vreScope = getScopeByOrganizationId(orgId);
|
||||
_log.trace("Attempting to write onto " + vreScope);
|
||||
try {
|
||||
store.saveFeedToVRETimeline(toShare.getKey(), vreScope);
|
||||
|
@ -430,7 +432,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
|
||||
} //share on a single VRE Timeline
|
||||
//receives a VreId(groupId) get the scope from the groupId
|
||||
else if (pLevel == PrivacyLevel.SINGLE_VRE && vreId != null && vreId.compareTo("") != 0) {
|
||||
else if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null) {
|
||||
_log.trace("Attempting to write onto " + vreScope2Set);
|
||||
try {
|
||||
store.saveFeedToVRETimeline(toShare.getKey(), vreScope2Set);
|
||||
|
@ -450,15 +452,21 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
|
||||
|
||||
//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(), textToPost, ""+session.getGroupId(), nm, hashtags));
|
||||
if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null && notifyGroup) {
|
||||
NotificationsManager nm = new ApplicationNotificationsManager(
|
||||
vreScope2Set,
|
||||
new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL),
|
||||
NEWS_FEED_PORTLET_CLASSNAME);
|
||||
Thread thread = new Thread(new PostNotificationsThread(toShare.getKey(), textToPost, ""+vreOrgId, nm, hashtags));
|
||||
thread.start();
|
||||
|
||||
}
|
||||
//send the notification to the mentioned users
|
||||
if (mentionedUsers != null && mentionedUsers.size() > 0) {
|
||||
NotificationsManager nm = new ApplicationNotificationsManager(session);
|
||||
NotificationsManager nm = new ApplicationNotificationsManager(
|
||||
vreScope2Set,
|
||||
new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL),
|
||||
NEWS_FEED_PORTLET_CLASSNAME);
|
||||
ArrayList<GenericItemBean> toPass = new ArrayList<GenericItemBean>();
|
||||
for (ItemBean u : mentionedUsers) {
|
||||
toPass.add(new GenericItemBean(u.getId(), u.getName(), u.getAlternativeName(), u.getThumbnailURL()));
|
||||
|
@ -781,12 +789,12 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
return toReturn;
|
||||
}
|
||||
|
||||
private String getScopeByOrganizationId(String vreid) {
|
||||
private String getScopeByOrganizationId(Long vreOrgId) {
|
||||
GroupManager gm = new LiferayGroupManager();
|
||||
try {
|
||||
return gm.getScope(vreid);
|
||||
return gm.getScope(vreOrgId+"");
|
||||
} catch (Exception e) {
|
||||
_log.error("Could not find a scope for this VREid: " + vreid);
|
||||
_log.error("Could not find a scope for this vreOrgId: " + vreOrgId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue