@Override public Long getUserAvailableSize(UserVo userVo) throws BusinessException { Account account = accountService.findByLsUuid(userVo.getLsUuid()); return Math.min( documentEntryService.getAvailableSize(account), documentEntryService.getUserMaxFileSize(account)); }
@Override public DocumentVo decryptDocument(DocumentVo docVo, UserVo userVo, String password) throws BusinessException { Account actor = accountService.findByLsUuid(userVo.getLsUuid()); DocumentEntry documentEntry = enciphermentService.decryptDocument(actor, docVo.getIdentifier(), actor, password); return documentEntryTransformer.disassemble(documentEntry); }
@Override public void removeDocument(UserVo actorVo, DocumentVo document) throws BusinessException { Account actor = accountService.findByLsUuid(actorVo.getLsUuid()); if (actor != null) { entryService.deleteAllShareEntriesWithDocumentEntry(actor, document.getIdentifier()); } else { throw new BusinessException(BusinessErrorCode.USER_NOT_FOUND, "The user couldn't be found"); } }
@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); }
@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; }
@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); }
@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; }
@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 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); }
@Override public Long getGlobalQuota(UserVo userVo) throws BusinessException { Account actor = accountService.findByLsUuid(userVo.getLsUuid()); return documentEntryService.getGlobalQuota(actor); }
@Override public boolean isUserQuotaActive(UserVo userVo) throws BusinessException { Account actor = accountService.findByLsUuid(userVo.getLsUuid()); return documentEntryService.isUserQuotaActive(actor); }
@Override public boolean isEnciphermentActive(UserVo userVo) { Account actor = accountService.findByLsUuid(userVo.getLsUuid()); return documentEntryService.isEnciphermentActive(actor); }
@Override public Long getUserTotalQuota(UserVo userVo) throws BusinessException { Account account = accountService.findByLsUuid(userVo.getLsUuid()); return documentEntryService.getTotalSize(account); }
@Override public InputStream retrieveFileStream(DocumentVo doc, UserVo actorVo) throws BusinessException { return retrieveFileStream(doc, actorVo.getLsUuid()); }