private boolean addAttachment(CommentsViewerProperties properties, Comment comment) {
    if (ListUtil.isEmpty(properties.getUploadedFiles())) {
      return true;
    }

    try {
      ICFileHome fileHome = getFileHome();
      for (String uploadedFile : properties.getUploadedFiles()) {
        if (!uploadedFile.startsWith(CoreConstants.WEBDAV_SERVLET_URI)) {
          uploadedFile =
              new StringBuilder(CoreConstants.WEBDAV_SERVLET_URI).append(uploadedFile).toString();
        }

        ICFile file = fileHome.create();

        file.setName(
            URLEncoder.encode(
                uploadedFile.substring(uploadedFile.lastIndexOf(CoreConstants.SLASH) + 1),
                CoreConstants.ENCODING_UTF8));
        file.setFileUri(URLEncoder.encode(uploadedFile, CoreConstants.ENCODING_UTF8));

        file.store();

        comment.addAttachment(file);
      }
      comment.store();
      return true;
    } catch (Exception e) {
      LOGGER.log(Level.WARNING, "Unable to add attachments: " + properties.getUploadedFiles(), e);
    }
    return false;
  }
  public Object addComment(CommentsViewerProperties properties) {
    if (properties == null || properties.getEntryId() == null) {
      LOGGER.warning("Properties are not provided or entry ID is unknown: " + properties);
      return null;
    }

    try {
      boolean hasFullRightsForComments = hasFullRightsForComments(properties.getIdentifier());

      CommentHome commentHome = getCommentHome();
      Comment comment = commentHome.create();

      comment.setEntryId(properties.getEntryId());
      comment.setCommentHolder(String.valueOf(properties.getIdentifier()));

      boolean hasReplyToId =
          properties.getReplyForComment() == null
              ? false
              : properties.getReplyForComment() < 0 ? false : true;
      boolean privateComment = hasReplyToId || !hasFullRightsForComments;
      comment.setPrivateComment(privateComment);
      comment.setReplyForCommentId(properties.getReplyForComment());
      comment.setAnnouncedToPublic(hasFullRightsForComments && !privateComment);

      User author = getLoggedInUser();
      if (author != null) {
        comment.setAuthorId(Integer.valueOf(author.getId()));
      }
      comment.store();

      addAttachment(properties, comment);

      return comment.getPrimaryKey();
    } catch (Exception e) {
      LOGGER.log(Level.WARNING, "Error creating " + Comment.class, e);
    }

    return null;
  }
 protected String getLinkForRecipient(String recipient, CommentsViewerProperties properties) {
   return properties.getCommentsPageUrl();
 }