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;
  }