Пример #1
0
 /**
  * @param commentId
  * @param userId - request owner
  * @throws BetException
  */
 @Override
 public void deleteComment(Long commentId, Long userId) throws BetException {
   Comment c = getCommentById(commentId);
   checkUpdateRights(c, userId);
   c.setStatus(Comment.STATUS_DELETED);
   c = em.merge(c);
 }
Пример #2
0
 @Override
 public void updateComment(Long commentId, Long ownerId, String newMessage) throws BetException {
   Comment c = getCommentById(commentId);
   checkUpdateRights(c, ownerId);
   c.setMessage(newMessage);
   c = em.merge(c);
 }
Пример #3
0
 // TODO: change this metod for admin
 private void checkUpdateRights(Comment c, Long reqOwnerId) throws BetException {
   if (c == null) {
     throw new BetException("comment is not specified");
   }
   if (reqOwnerId == null) {
     throw new BetException("request owner is not specified");
   }
   if (!c.getUserId().equals(reqOwnerId)) {
     throw new BetException("Access denied");
   }
 }
Пример #4
0
 @Override
 public List<SimpleComment> getSimpleBetComments(Long betId, Long ownerId) throws BetException {
   List<SimpleComment> sbList = new ArrayList();
   List<Comment> list = getBetComments(betId, ownerId);
   for (Comment c : list) {
     sbList.add(
         new SimpleComment(
             c.getMessage(),
             userMan.getVkIdByUserId(c.getUserId()),
             c.getBetId(),
             c.getCreationDate() == null ? null : c.getCreationDate().getTime(),
             c.getId()));
   }
   return sbList;
 }