@Override
  public String getDestination(String objectId, HttpServletRequest req, HttpServletResponse res)
      throws Exception {
    MainSessionController mainSessionCtrl = util.getMainSessionController(req);
    String language = I18NHelper.defaultLanguage;
    if (mainSessionCtrl != null) {
      language = mainSessionCtrl.getFavoriteLanguage();
    }
    SimpleDocumentPK pk = new SimpleDocumentPK(objectId);
    if (StringUtil.isLong(objectId)) {
      pk.setOldSilverpeasId(Long.parseLong(objectId));
    }

    SimpleDocument attachment =
        AttachmentServiceProvider.getAttachmentService().searchDocumentById(pk, language);
    if (attachment == null) {
      return null;
    }
    String componentId = attachment.getInstanceId();
    String foreignId = attachment.getForeignId();

    if (isUserLogin(req) && isUserAllowed(req, componentId)) {
      boolean isAccessAuthorized = true;
      if (componentId.startsWith("kmelia")) {
        try {
          ComponentAuthorization security =
              (ComponentAuthorization) Class.forName(KMELIA_SECURITY_CLASS).newInstance();
          isAccessAuthorized = security.isAccessAuthorized(componentId, getUserId(req), foreignId);
        } catch (Exception e) {
          SilverTrace.error(
              "util",
              "GoToFile.doPost",
              "root.EX_CLASS_NOT_INITIALIZED",
              "org.silverpeas.components.kmelia.KmeliaAuthorization",
              e);
          return null;
        }
      }
      if (isAccessAuthorized) {
        res.setCharacterEncoding(CharEncoding.UTF_8);
        res.setContentType("text/html; charset=utf-8");
        String fileName = ClientBrowserUtil.rfc2047EncodeFilename(req, attachment.getFilename());
        res.setHeader("Content-Disposition", "inline; filename=\"" + fileName + "\"");
        return URLUtil.getFullApplicationURL(req) + encodeFilename(attachment.getAttachmentURL());
      }
    }
    return "ComponentId="
        + componentId
        + "&AttachmentId="
        + objectId
        + "&Mapping=File&ForeignId="
        + foreignId;
  }
 @Override
 public SimpleDocument searchDocumentById(
     final SimpleDocumentPK attachmentPK, final String lang) {
   SimpleDocument attachmentDetail = null;
   if (!ATTACHMENT_ID_DOESNT_EXISTS.equals(attachmentPK.getId())) {
     attachmentDetail = new SimpleDocument();
     attachmentDetail.setPK(attachmentPK);
     attachmentDetail.setOldSilverpeasId(Long.parseLong(attachmentPK.getId()));
     attachmentDetail.setAttachment(new SimpleAttachment());
     attachmentDetail.setFilename("originalFileName" + attachmentPK.getId());
   }
   return attachmentDetail;
 }