@Override
 public void renameFile(String userlogin, String docEntryUuid, String newName) {
   Account actor = accountService.findByLsUuid(userlogin);
   try {
     documentEntryService.renameDocumentEntry(actor, docEntryUuid, newName);
   } catch (BusinessException e) {
     logger.error("Can't rename document : " + docEntryUuid + " : " + e.getMessage());
   }
 }
 @Override
 public List<SignatureVo> getAllSignatures(UserVo userVo, DocumentVo documentVo) {
   Account actor = accountService.findByLsUuid(userVo.getLsUuid());
   try {
     DocumentEntry document = documentEntryService.findById(actor, documentVo.getIdentifier());
     return signatureTransformer.disassembleList(
         new ArrayList<Signature>(document.getDocument().getSignatures()));
   } catch (BusinessException e) {
     logger.error("Can't find document : " + documentVo.getIdentifier() + ": " + e.getMessage());
   }
   return null;
 }
  /* (non-Javadoc)
   * @see org.springframework.security.ui.rememberme.PersistentTokenRepository#removeUserTokens(java.lang.String)
   */
  public void removeUserTokens(String username) {
    List<Cookie> cookies = findByUserName(username);

    for (Cookie cookie : cookies) {
      try {
        delete(cookie);
      } catch (IllegalArgumentException e) {
        e.printStackTrace();
      } catch (BusinessException e) {
        e.printStackTrace();
      }
    }
  }
 @Override
 public MimeTypeStatus getMimeTypeStatus(String login, String uuid) {
   Account actor = accountService.findByLsUuid(login);
   if (actor != null) {
     DocumentEntry entry;
     try {
       entry = documentEntryService.findById(actor, uuid);
       return documentEntryService.getDocumentMimeTypeStatus(entry);
     } catch (BusinessException e) {
       logger.error("can't get document : " + e.getMessage());
     }
   }
   return null;
 }
 @Override
 public void updateFileProperties(
     String userlogin, String docEntryUuid, String newName, String comment) {
   Account actor = accountService.findByLsUuid(userlogin);
   if (comment == null) {
     comment = "";
   }
   try {
     documentEntryService.updateFileProperties(actor, docEntryUuid, newName, comment);
   } catch (BusinessException e) {
     logger.error(
         "Can't update file properties document : " + docEntryUuid + " : " + e.getMessage());
   }
 }
 @Override
 public boolean isSignedDocument(String userLsUuid, DocumentVo documentVo) {
   // Fix me : just write a finder
   boolean res = false;
   Account actor = accountService.findByLsUuid(userLsUuid);
   try {
     DocumentEntry document = documentEntryService.findById(actor, documentVo.getIdentifier());
     Set<Signature> signatures = document.getDocument().getSignatures();
     if (signatures != null && signatures.size() > 0) res = true;
   } catch (BusinessException e) {
     logger.error("Can't find document : " + documentVo.getIdentifier() + ": " + e.getMessage());
   }
   return res;
 }
 @Override
 public DocumentVo getDocument(String login, String uuid) {
   Account actor = accountService.findByLsUuid(login);
   if (actor != null) {
     DocumentEntry entry;
     try {
       entry = documentEntryService.findById(actor, uuid);
       return documentEntryTransformer.disassemble(entry);
     } catch (BusinessException e) {
       logger.error("can't get document : " + e.getMessage());
     }
   }
   return null;
 }
  /* (non-Javadoc)
   * @see org.springframework.security.ui.rememberme.PersistentTokenRepository#createNewToken(org.springframework.security.ui.rememberme.PersistentRememberMeToken)
   */
  public void createNewToken(PersistentRememberMeToken token) {
    Cookie cookie = new Cookie();

    Calendar calendar = GregorianCalendar.getInstance();
    calendar.setTime(token.getDate());

    cookie.setLastUse(calendar);
    cookie.setIdentifier(token.getSeries());
    cookie.setUserName(token.getUsername());
    cookie.setValue(token.getTokenValue());

    try {
      create(cookie);
    } catch (BusinessException e) {
      e.printStackTrace();
    }
  }
  /* (non-Javadoc)
   * @see org.springframework.security.ui.rememberme.PersistentTokenRepository#updateToken(java.lang.String, java.lang.String, java.util.Date)
   */
  public void updateToken(String series, String tokenValue, Date lastUsed) {
    Cookie cookie = findById(series);

    if (cookie != null) {
      cookie.setValue(tokenValue);

      Calendar calendar = GregorianCalendar.getInstance();
      calendar.setTime(lastUsed);
      cookie.setLastUse(calendar);

      try {
        update(cookie);
      } catch (BusinessException e) {
        e.printStackTrace();
      }
    }
  }
  @Override
  public SignatureVo getSignature(UserVo currentSigner, DocumentVo documentVo) {
    Account actor = accountService.findByLsUuid(currentSigner.getLsUuid());
    try {
      DocumentEntry document = documentEntryService.findById(actor, documentVo.getIdentifier());
      SignatureVo res = null;
      for (Signature signature : document.getDocument().getSignatures()) {
        if (signature.getSigner().equals(actor)) {
          res = signatureTransformer.disassemble(signature);
          break;
        }
      }
      return res;

    } catch (BusinessException e) {
      logger.error("Can't find document : " + documentVo.getIdentifier() + ": " + e.getMessage());
    }
    return null;
  }
  @Override
  public InputStream getDocumentThumbnail(String actorUuid, String docEntryUuid) {
    if (actorUuid == null) {
      logger.error("Can't find user with null parameter.");
      return null;
    }

    Account actor = accountService.findByLsUuid(actorUuid);
    if (actor == null) {
      logger.error("Can't find logged user.");
      return null;
    }

    try {
      return documentEntryService.getDocumentThumbnailStream(actor, docEntryUuid);
    } catch (BusinessException e) {
      logger.error("Can't get document thumbnail : " + docEntryUuid + " : " + e.getMessage());
    }
    return null;
  }