Search in sources :

Example 1 with CommentReplyMessage

use of org.eclipse.vorto.repository.notification.message.CommentReplyMessage in project vorto by eclipse.

the class DefaultCommentService method notifyAllCommentAuthors.

private void notifyAllCommentAuthors(Comment comment, ModelInfo model) {
    Set<String> recipients = new HashSet<>();
    recipients.add(model.getAuthor());
    List<Comment> existingComments = this.commentRepository.findByModelId(comment.getModelId());
    for (Comment c : existingComments) {
        recipients.add(c.getAuthor());
    }
    recipients.stream().filter(recipient -> !User.USER_ANONYMOUS.equalsIgnoreCase(recipient)).forEach(recipient -> {
        User user = accountService.getUser(recipient);
        if (user != null) {
            notificationService.sendNotification(new CommentReplyMessage(user, model, comment.getContent()));
        }
    });
}
Also used : DoesNotExistException(org.eclipse.vorto.repository.services.exceptions.DoesNotExistException) Date(java.util.Date) ModelNotFoundException(org.eclipse.vorto.repository.core.ModelNotFoundException) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) ICommentService(org.eclipse.vorto.repository.comment.ICommentService) User(org.eclipse.vorto.repository.domain.User) ModelId(org.eclipse.vorto.model.ModelId) IModelRepository(org.eclipse.vorto.repository.core.IModelRepository) ModelInfo(org.eclipse.vorto.repository.core.ModelInfo) NamespaceService(org.eclipse.vorto.repository.services.NamespaceService) HashSet(java.util.HashSet) CommentReplyMessage(org.eclipse.vorto.repository.notification.message.CommentReplyMessage) List(java.util.List) PathNotFoundException(javax.jcr.PathNotFoundException) ModelRepositoryFactory(org.eclipse.vorto.repository.core.impl.ModelRepositoryFactory) Service(org.springframework.stereotype.Service) Optional(java.util.Optional) INotificationService(org.eclipse.vorto.repository.notification.INotificationService) DefaultUserAccountService(org.eclipse.vorto.repository.account.impl.DefaultUserAccountService) Comment(org.eclipse.vorto.repository.domain.Comment) IModelRepositoryFactory(org.eclipse.vorto.repository.core.IModelRepositoryFactory) Comment(org.eclipse.vorto.repository.domain.Comment) User(org.eclipse.vorto.repository.domain.User) CommentReplyMessage(org.eclipse.vorto.repository.notification.message.CommentReplyMessage) HashSet(java.util.HashSet)

Aggregations

Date (java.util.Date)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 PathNotFoundException (javax.jcr.PathNotFoundException)1 ModelId (org.eclipse.vorto.model.ModelId)1 DefaultUserAccountService (org.eclipse.vorto.repository.account.impl.DefaultUserAccountService)1 ICommentService (org.eclipse.vorto.repository.comment.ICommentService)1 IModelRepository (org.eclipse.vorto.repository.core.IModelRepository)1 IModelRepositoryFactory (org.eclipse.vorto.repository.core.IModelRepositoryFactory)1 ModelInfo (org.eclipse.vorto.repository.core.ModelInfo)1 ModelNotFoundException (org.eclipse.vorto.repository.core.ModelNotFoundException)1 ModelRepositoryFactory (org.eclipse.vorto.repository.core.impl.ModelRepositoryFactory)1 Comment (org.eclipse.vorto.repository.domain.Comment)1 User (org.eclipse.vorto.repository.domain.User)1 INotificationService (org.eclipse.vorto.repository.notification.INotificationService)1 CommentReplyMessage (org.eclipse.vorto.repository.notification.message.CommentReplyMessage)1 NamespaceService (org.eclipse.vorto.repository.services.NamespaceService)1 DoesNotExistException (org.eclipse.vorto.repository.services.exceptions.DoesNotExistException)1