Postnotification thread added
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/notifications-common-library@121951 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
b05daeb5b2
commit
4716fc9a86
|
@ -0,0 +1,48 @@
|
|||
package org.gcube.portal.notifications.thread;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 List<String> hashtags;
|
||||
private NotificationsManager nm;
|
||||
|
||||
public PostNotificationsThread(String postId, String postText, String groupId, NotificationsManager nm, List<String> hashtags) {
|
||||
super();
|
||||
this.postId = postId;
|
||||
this.postText = postText;
|
||||
this.groupId = groupId;
|
||||
this.hashtags = hashtags;
|
||||
this.nm = nm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
UserManager um = new LiferayUserManager();
|
||||
String[] hashtagsToPass = hashtags.toArray(new String[hashtags.size()]);
|
||||
try {
|
||||
for (UserModel user : um.listUsersByGroup(groupId)) {
|
||||
boolean result = nm.notifyPost(user.getScreenName(), postId, postText, hashtagsToPass);
|
||||
_log.trace("Sending Notification for post alert to: " + user.getScreenName() + " result?"+ result);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue