private void createBusinessCheck(UploadRequestUrl requestUrl, DocumentEntry document) throws BusinessException { UploadRequest request = requestUrl.getUploadRequest(); if (!request.getStatus().equals(UploadRequestStatus.STATUS_ENABLED)) { throw new BusinessException( BusinessErrorCode.UPLOAD_REQUEST_READONLY_MODE, "The current upload request url is in read only mode : " + requestUrl.getUuid()); } if (request.getMaxFileSize() != null) { if (document.getSize() > request.getMaxFileSize()) { throw new BusinessException( BusinessErrorCode.UPLOAD_REQUEST_FILE_TOO_LARGE, "You already have reached the uploaded file limit."); } } if (request.getMaxFileCount() != null) { // already reach the limit if (request.getUploadRequestEntries().size() >= request.getMaxFileCount()) { throw new BusinessException( BusinessErrorCode.UPLOAD_REQUEST_TOO_MANY_FILES, "You already have reached the uploaded file limit."); } } if (request.getMaxDepositSize() != null) { long totalSize = 0; for (UploadRequestEntry entry : request.getUploadRequestEntries()) { totalSize += entry.getSize(); } totalSize += document.getSize(); if (totalSize >= request.getMaxDepositSize()) { throw new BusinessException( BusinessErrorCode.UPLOAD_REQUEST_TOTAL_DEPOSIT_SIZE_TOO_LARGE, "You already have reached the limit of your quota."); } } }