Added support for messages reply via email
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/notifications-common-library@119768 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
28c94379d4
commit
b05daeb5b2
4
.project
4
.project
|
@ -16,12 +16,12 @@
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
disabled=06target
|
||||||
|
eclipse.preferences.version=1
|
2
pom.xml
2
pom.xml
|
@ -17,7 +17,7 @@
|
||||||
<description>
|
<description>
|
||||||
gCube Notifications Common Library is a common library containing shared code for Notification of social events to users.
|
gCube Notifications Common Library is a common library containing shared code for Notification of social events to users.
|
||||||
</description>
|
</description>
|
||||||
<name>invites-common-library</name>
|
<name>notifications-common-library</name>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</connection>
|
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</connection>
|
||||||
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</developerConnection>
|
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</developerConnection>
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package org.gcube.portal.notifications.thread;
|
package org.gcube.portal.notifications.thread;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||||
|
import org.gcube.portal.notifications.bean.GenericItemBean;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -17,15 +20,15 @@ public class MessageNotificationsThread implements Runnable {
|
||||||
private String messageText;
|
private String messageText;
|
||||||
private String messageId;
|
private String messageId;
|
||||||
private String subjectText;
|
private String subjectText;
|
||||||
private List<String> recipientIds;
|
private List<GenericItemBean> recipients;
|
||||||
private NotificationsManager nm;
|
private NotificationsManager nm;
|
||||||
|
|
||||||
public MessageNotificationsThread(List<String> recipientIds, String postId, String subjectText, String messageText, NotificationsManager nm) {
|
public MessageNotificationsThread(List<GenericItemBean> recipients, String postId, String subjectText, String messageText, NotificationsManager nm) {
|
||||||
super();
|
super();
|
||||||
this.messageId = postId;
|
this.messageId = postId;
|
||||||
this.messageText = messageText;
|
this.messageText = messageText;
|
||||||
this.subjectText = subjectText;
|
this.subjectText = subjectText;
|
||||||
this.recipientIds = recipientIds;
|
this.recipients = recipients;
|
||||||
this.nm = nm;
|
this.nm = nm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +36,14 @@ public class MessageNotificationsThread implements Runnable {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
String checkedText = escapeHtmlAndTransformNewlines(messageText);
|
String checkedText = escapeHtmlAndTransformNewlines(messageText);
|
||||||
for (String userIdToNotify : recipientIds) {
|
for (GenericItemBean userToNotify : recipients) {
|
||||||
if (nm.notifyMessageReceived(userIdToNotify, messageId, subjectText, checkedText))
|
String userIdToNotify = userToNotify.getName();
|
||||||
|
List<GenericItemBean> temp = new ArrayList<GenericItemBean>(recipients.size());
|
||||||
|
temp = copy(recipients);
|
||||||
|
temp.remove(userToNotify);
|
||||||
|
String[] otherRecipientsFullNames = getFullNamesOnly(temp);
|
||||||
|
|
||||||
|
if (nm.notifyMessageReceived(userIdToNotify, messageId, subjectText, checkedText, otherRecipientsFullNames))
|
||||||
_log.trace("Sending message notifications to: " + userIdToNotify + " OK");
|
_log.trace("Sending message notifications to: " + userIdToNotify + " OK");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -42,6 +51,23 @@ public class MessageNotificationsThread implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String[] getFullNamesOnly(List<GenericItemBean> toCopy) {
|
||||||
|
String[] toReturn = new String[toCopy.size()];
|
||||||
|
int i = 0;
|
||||||
|
for (GenericItemBean item : toCopy) {
|
||||||
|
toReturn[i] = item.getAlternativeName();
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<GenericItemBean> copy(List<GenericItemBean> toCopy) {
|
||||||
|
List<GenericItemBean> toReturn = new ArrayList<GenericItemBean>();
|
||||||
|
for (GenericItemBean genericItemBean : toCopy) {
|
||||||
|
toReturn.add(genericItemBean);
|
||||||
|
}
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Escape an html string. Escaping data received from the client helps to
|
* Escape an html string. Escaping data received from the client helps to
|
||||||
* prevent cross-site script vulnerabilities.
|
* prevent cross-site script vulnerabilities.
|
||||||
|
|
Loading…
Reference in New Issue