|
|
|
@ -46,6 +46,7 @@ import org.gcube.portal.notifications.thread.CommentNotificationsThread;
|
|
|
|
|
import org.gcube.portal.notifications.thread.LikeNotificationsThread;
|
|
|
|
|
import org.gcube.portal.notifications.thread.MentionNotificationsThread;
|
|
|
|
|
import org.gcube.portlets.user.newsfeed.client.NewsService;
|
|
|
|
|
import org.gcube.portlets.user.newsfeed.shared.MentionedDTO;
|
|
|
|
|
import org.gcube.portlets.user.newsfeed.shared.MoreFeedsBean;
|
|
|
|
|
import org.gcube.portlets.user.newsfeed.shared.NewsConstants;
|
|
|
|
|
import org.gcube.portlets.user.newsfeed.shared.OperationResult;
|
|
|
|
@ -55,6 +56,7 @@ import org.gcube.social_networking.socialutillibrary.Utils;
|
|
|
|
|
import org.gcube.socialnetworking.social_data_search_client.ElasticSearchClient;
|
|
|
|
|
import org.gcube.socialnetworking.social_data_search_client.ElasticSearchClientImpl;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.RoleManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
|
|
|
|
import org.gcube.vomanagement.usermanagement.exception.TeamRetrievalFault;
|
|
|
|
@ -605,7 +607,7 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|
|
|
|
* @param feedOwnerId the username of the user who created the post that was commented
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public OperationResult comment(String feedid, String commentText, HashSet<String> mentionedUserFullNames, String feedOwnerId, boolean isAppFeed) {
|
|
|
|
|
public OperationResult comment(String feedid, String commentText, HashSet<MentionedDTO> mentionedItemsSet, String feedOwnerId, boolean isAppFeed) {
|
|
|
|
|
boolean commentCommitResult = false;
|
|
|
|
|
_log.trace("Trying to add this comment " + commentText);
|
|
|
|
|
UserInfo user = getUserSettings().getUserInfo();
|
|
|
|
@ -622,12 +624,12 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|
|
|
|
escapedCommentText = Utils.convertHashtagsAnchorHTML(escapedCommentText, hashtags);
|
|
|
|
|
|
|
|
|
|
//copy the set into a list
|
|
|
|
|
ArrayList<String> mentionedUserFullNamesList = new ArrayList<String>();
|
|
|
|
|
mentionedUserFullNamesList.addAll(mentionedUserFullNames);
|
|
|
|
|
ArrayList<MentionedDTO> mentionedItems = new ArrayList<MentionedDTO>();
|
|
|
|
|
mentionedItems.addAll(mentionedItemsSet);
|
|
|
|
|
|
|
|
|
|
ArrayList<ItemBean> mentionedUsers = null;
|
|
|
|
|
if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) {
|
|
|
|
|
mentionedUsers = getSelectedUserIds(mentionedUserFullNamesList);
|
|
|
|
|
if (mentionedItemsSet != null && ! mentionedItemsSet.isEmpty()) {
|
|
|
|
|
mentionedUsers = getMentionsBean(mentionedItems);
|
|
|
|
|
escapedCommentText = Utils.convertMentionPeopleAnchorHTML(escapedCommentText, mentionedUsers, getThreadLocalRequest());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1029,29 +1031,33 @@ public class NewsServiceImpl extends RemoteServiceServlet implements NewsService
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @return the screennames of the addressee (user logins e.g. pino.pini)
|
|
|
|
|
* @param mentions
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public ArrayList<ItemBean> getSelectedUserIds(ArrayList<String> fullNames) {
|
|
|
|
|
if (fullNames == null)
|
|
|
|
|
return new ArrayList<ItemBean>();
|
|
|
|
|
else {
|
|
|
|
|
PortalContext pContext = PortalContext.getConfiguration();
|
|
|
|
|
String userName = pContext.getCurrentUser(getThreadLocalRequest()).getUsername();
|
|
|
|
|
String context = pContext.getCurrentScope(getThreadLocalRequest());
|
|
|
|
|
ArrayList<ItemBean> allUsers = Utils.getDisplayableItemBeans(context, userName, isWithinPortal());
|
|
|
|
|
ArrayList<ItemBean> toReturn = new ArrayList<ItemBean>();
|
|
|
|
|
for (String fullName : fullNames)
|
|
|
|
|
for (ItemBean puser : allUsers) {
|
|
|
|
|
if (puser.getAlternativeName().compareTo(fullName) == 0) {
|
|
|
|
|
toReturn.add(puser);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private ArrayList<ItemBean> getMentionsBean(ArrayList<MentionedDTO> mentions) {
|
|
|
|
|
ArrayList<ItemBean> toReturn = new ArrayList<ItemBean>();
|
|
|
|
|
if (mentions == null)
|
|
|
|
|
return toReturn;
|
|
|
|
|
UserManager um = new LiferayUserManager();
|
|
|
|
|
RoleManager rm = new LiferayRoleManager();
|
|
|
|
|
try {
|
|
|
|
|
for (MentionedDTO mentioned : mentions) {
|
|
|
|
|
if (mentioned.getType().equalsIgnoreCase("user")) {
|
|
|
|
|
long userId = Long.parseLong(mentioned.id);
|
|
|
|
|
GCubeUser user = um.getUserById(userId);
|
|
|
|
|
toReturn.add(new ItemBean(user.getUserId()+"", user.getUsername(), user.getFullname(), user.getUserAvatarURL()));
|
|
|
|
|
}
|
|
|
|
|
else { //is a team
|
|
|
|
|
long teamId = Long.parseLong(mentioned.id);
|
|
|
|
|
GCubeTeam gCubeTeam = rm.getTeam(teamId);
|
|
|
|
|
toReturn.add(new ItemBean(gCubeTeam.getTeamId()+"", gCubeTeam.getTeamName()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
_log.error("getMentionsBean Error: ", e);
|
|
|
|
|
}
|
|
|
|
|
return toReturn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* tell if the user is a portal administrator or not
|
|
|
|
|
* @param username
|
|
|
|
|