public String getUriToAttachment(String commentId, ICFile attachment, User user) {
    URIUtil uri = new URIUtil(IWMainApplication.getDefaultIWMainApplication().getMediaServletURI());

    uri.setParameter(
        MediaWritable.PRM_WRITABLE_CLASS,
        IWMainApplication.getEncryptedClassName(CommentAttachmentDownloader.class));
    uri.setParameter(ArticleCommentAttachmentStatisticsViewer.COMMENT_ID_PARAMETER, commentId);
    uri.setParameter(
        ArticleCommentAttachmentStatisticsViewer.COMMENT_ATTACHMENT_ID_PARAMETER,
        attachment.getPrimaryKey().toString());

    if (user != null) {
      uri.setParameter(LoginBusinessBean.PARAM_LOGIN_BY_UNIQUE_ID, user.getUniqueId());
      uri.setParameter(LoginBusinessBean.LoginStateParameter, LoginBusinessBean.LOGIN_EVENT_LOGIN);
    }

    return uri.getUri();
  }
 public String getUriForCommentLink(CommentsViewerProperties properties) {
   try {
     URIUtil uri = new URIUtil(WebContextFactory.get().getCurrentPage());
     uri.setParameter(CommentsViewer.AUTO_SHOW_COMMENTS, Boolean.TRUE.toString());
     return uri.getUri();
   } catch (Exception e) {
     LOGGER.log(Level.WARNING, "Error getting link for comment", e);
   }
   return null;
 }