|
110 | 110 | import static jakarta.ws.rs.core.Response.Status.BAD_REQUEST; |
111 | 111 | import static jakarta.ws.rs.core.Response.Status.NOT_FOUND; |
112 | 112 | import static jakarta.ws.rs.core.Response.Status.FORBIDDEN; |
| 113 | +import java.math.BigDecimal; |
113 | 114 |
|
114 | 115 | @Path("datasets") |
115 | 116 | public class Datasets extends AbstractApiBean { |
@@ -3662,7 +3663,37 @@ public Response getFileStore(@Context ContainerRequestContext crc, @PathParam("i |
3662 | 3663 | return error(Response.Status.NOT_FOUND, "No such dataset"); |
3663 | 3664 | } |
3664 | 3665 |
|
3665 | | - return ok(JsonPrinter.jsonStorageDriver(dataset.getEffectiveStorageDriverId(), dataset)); |
| 3666 | + JsonObjectBuilder output = JsonPrinter.jsonStorageDriver(dataset.getEffectiveStorageDriverId(), dataset); |
| 3667 | + |
| 3668 | + // Add optional elements - storage size and file count limits, if present: |
| 3669 | + |
| 3670 | + Long storageSizeQuotaRemaining = null; |
| 3671 | + |
| 3672 | + if (systemConfig.isStorageQuotasEnforced()) { |
| 3673 | + UploadSessionQuotaLimit uploadSessionQuota = fileService.getUploadSessionQuotaLimit(dataset); |
| 3674 | + if (uploadSessionQuota != null) { |
| 3675 | + storageSizeQuotaRemaining = uploadSessionQuota.getRemainingQuotaInBytes(); |
| 3676 | + } |
| 3677 | + } |
| 3678 | + |
| 3679 | + Integer numberOfFilesRemaining = null; |
| 3680 | + |
| 3681 | + Integer effectiveFileCountLimit = dataset.getEffectiveDatasetFileCountLimit(); |
| 3682 | + |
| 3683 | + if (effectiveFileCountLimit != null) { |
| 3684 | + numberOfFilesRemaining = effectiveFileCountLimit - datasetService.getDataFileCountByOwner(dataset.getId()); |
| 3685 | + } |
| 3686 | + |
| 3687 | + if (storageSizeQuotaRemaining != null) { |
| 3688 | + output.add("storageQuotaRemaining", storageSizeQuotaRemaining); |
| 3689 | + } |
| 3690 | + |
| 3691 | + if (numberOfFilesRemaining != null) { |
| 3692 | + output.add("numberOfFilesRemaining", numberOfFilesRemaining); |
| 3693 | + } |
| 3694 | + |
| 3695 | + |
| 3696 | + return ok(output); |
3666 | 3697 | } |
3667 | 3698 |
|
3668 | 3699 | @PUT |
|
0 commit comments