@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); } }
@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; }