コード例 #1
0
  @Override
  public Long getUserAvailableSize(UserVo userVo) throws BusinessException {
    Account account = accountService.findByLsUuid(userVo.getLsUuid());

    return Math.min(
        documentEntryService.getAvailableSize(account),
        documentEntryService.getUserMaxFileSize(account));
  }
コード例 #2
0
 @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;
 }
コード例 #3
0
 @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());
   }
 }
コード例 #4
0
 private DisplayableAccountOccupationEntryVo getAccountStats(User user) throws BusinessException {
   Long userAvailableQuota = documentEntryService.getAvailableSize(user);
   Long userTotalQuota = documentEntryService.getTotalSize(user);
   Long userUsedSize = 0L;
   for (Entry entry : user.getEntries()) {
     if (entry.getEntryType().equals(EntryType.DOCUMENT)) {
       userUsedSize += ((DocumentEntry) entry).getSize();
     }
   }
   DisplayableAccountOccupationEntryVo accountOccupation =
       new DisplayableAccountOccupationEntryVo(
           user.getFirstName(),
           user.getLastName(),
           user.getMail(),
           user.getAccountType(),
           userAvailableQuota,
           userTotalQuota,
           userUsedSize);
   return accountOccupation;
 }
コード例 #5
0
 @Override
 public DocumentVo insertFile(InputStream in, String fileName, UserVo owner)
     throws BusinessException {
   logger.debug("insert files for document entries");
   Account actor = accountService.findByLsUuid(owner.getLsUuid());
   fileName = fileName.replace("\\", "_");
   fileName = fileName.replace(":", "_");
   DocumentEntry createDocumentEntry =
       documentEntryService.createDocumentEntry(actor, in, fileName);
   return documentEntryTransformer.disassemble(createDocumentEntry);
 }
コード例 #6
0
 @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;
 }
コード例 #7
0
 @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;
 }
コード例 #8
0
 @Override
 public void insertSignatureFile(
     InputStream file,
     long size,
     String fileName,
     UserVo ownerVo,
     DocumentVo documentVo,
     X509Certificate signerCertificate)
     throws BusinessException {
   Account actor = accountService.findByLsUuid(ownerVo.getLsUuid());
   DocumentEntry documentEntry = documentEntryService.findById(actor, documentVo.getIdentifier());
   signatureService.createSignature(
       actor, documentEntry.getDocument(), file, size, fileName, signerCertificate);
 }
コード例 #9
0
  @Override
  public DocumentVo updateDocumentContent(
      String currentFileUUID,
      InputStream file,
      long size,
      String fileName,
      UserVo ownerVo,
      String friendlySize)
      throws BusinessException {
    Account actor = accountService.findByLsUuid(ownerVo.getLsUuid());

    DocumentEntry originalEntry = documentEntryService.findById(actor, currentFileUUID);
    String originalFileName = originalEntry.getName();

    DocumentEntry documentEntry =
        documentEntryService.updateDocumentEntry(actor, currentFileUUID, file, size, fileName);
    if (documentEntry.isShared()) {
      // send email, file has been replaced ....
      entryService.sendSharedUpdateDocNotification(documentEntry, friendlySize, originalFileName);
    }

    return documentEntryTransformer.disassemble(documentEntry);
  }
コード例 #10
0
 @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());
   }
 }
コード例 #11
0
  @Override
  public boolean documentHasThumbnail(String actorUuid, String docEntryUuid) {
    if (actorUuid == null) {
      logger.error("Can't find user with null parameter.");
      return false;
    }

    Account actor = accountService.findByLsUuid(actorUuid);
    if (actor == null) {
      logger.error("Can't find logged user.");
      return false;
    }
    return documentEntryService.documentHasThumbnail(actor, docEntryUuid);
  }
コード例 #12
0
 @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;
 }
コード例 #13
0
 @Override
 public void deleteUploadRequestEntry(
     String uploadRequestUrlUuid, String password, String entryUuid) throws BusinessException {
   UploadRequestUrl requestUrl = find(uploadRequestUrlUuid, password);
   deleteBusinessCheck(requestUrl);
   Set<UploadRequestEntry> entries = requestUrl.getUploadRequest().getUploadRequestEntries();
   UploadRequestEntry found = null;
   for (UploadRequestEntry entry : entries) {
     if (entry.getUuid().equals(entryUuid)) {
       found = entry;
       break;
     }
   }
   if (found != null) {
     String documentEntryUuid = null;
     if (found.getDocumentEntry() != null) {
       documentEntryUuid = found.getDocumentEntry().getUuid();
     }
     found.setDocumentEntry(null);
     found = uploadRequestEntryBusinessService.update(found);
     if (documentEntryUuid != null) {
       // TODO: HOOK : Extract owner for upload request URL
       // Actor should be used instead of owner
       Account owner = requestUrl.getUploadRequest().getOwner();
       // Store the file into the owner account.
       DocumentEntry documentEntry = documentEntryService.findById(owner, documentEntryUuid);
       documentEntryService.deleteDocumentEntry(owner, documentEntry);
     }
     uploadRequestEntryBusinessService.delete(found);
   } else {
     throw new BusinessException(
         BusinessErrorCode.FORBIDDEN,
         "You do not have the right to delete a file into upload request : "
             + uploadRequestUrlUuid);
   }
 }
コード例 #14
0
  @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;
  }
コード例 #15
0
  @Override
  public boolean isSignedDocumentByCurrentUser(UserVo currentSigner, DocumentVo documentVo)
      throws BusinessException {

    Account actor = accountService.findByLsUuid(currentSigner.getLsUuid());
    DocumentEntry doc = documentEntryService.findById(actor, documentVo.getIdentifier());
    Set<Signature> signatures = doc.getDocument().getSignatures();

    boolean res = false;

    for (Signature signature : signatures) {
      if (signature.getSigner().equals(actor)) {
        res = true;
        break;
      }
    }

    return res;
  }
コード例 #16
0
  @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;
  }
コード例 #17
0
 @Override
 public UploadRequestEntry createUploadRequestEntry(
     String uploadRequestUrlUuid, InputStream fi, String fileName, String password)
     throws BusinessException {
   // Retrieve upload request URL
   UploadRequestUrl requestUrl = find(uploadRequestUrlUuid, password);
   // HOOK : Extract owner for upload request URL
   Account owner = requestUrl.getUploadRequest().getOwner();
   // Store the file into the owner account.
   DocumentEntry document = documentEntryService.createDocumentEntry(owner, fi, fileName);
   createBusinessCheck(requestUrl, document);
   Account actor = accountRepository.getUploadRequestSystemAccount();
   // Create the link between the document and the upload request URL.
   UploadRequestEntry uploadRequestEntry =
       new UploadRequestEntry(document, requestUrl.getUploadRequest());
   UploadRequestEntry requestEntry = uploadRequestEntryBusinessService.create(uploadRequestEntry);
   MailContainerWithRecipient mail =
       mailBuildingService.buildAckUploadRequest(
           (User) requestUrl.getUploadRequest().getOwner(), requestUrl, requestEntry);
   notifierService.sendNotification(mail);
   return requestEntry;
 }
コード例 #18
0
 @Override
 public InputStream retrieveFileStream(DocumentVo doc, String lsUid) throws BusinessException {
   Account actor = accountService.findByLsUuid(lsUid);
   return documentEntryService.getDocumentStream(actor, doc.getIdentifier());
 }
コード例 #19
0
 @Override
 public Long getGlobalQuota(UserVo userVo) throws BusinessException {
   Account actor = accountService.findByLsUuid(userVo.getLsUuid());
   return documentEntryService.getGlobalQuota(actor);
 }
コード例 #20
0
 @Override
 public boolean isUserQuotaActive(UserVo userVo) throws BusinessException {
   Account actor = accountService.findByLsUuid(userVo.getLsUuid());
   return documentEntryService.isUserQuotaActive(actor);
 }
コード例 #21
0
 @Override
 public boolean isEnciphermentActive(UserVo userVo) {
   Account actor = accountService.findByLsUuid(userVo.getLsUuid());
   return documentEntryService.isEnciphermentActive(actor);
 }
コード例 #22
0
 @Override
 public Long getUserTotalQuota(UserVo userVo) throws BusinessException {
   Account account = accountService.findByLsUuid(userVo.getLsUuid());
   return documentEntryService.getTotalSize(account);
 }