packer (WIP)
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
import p.packer.messages.assets.AssetFamilyCatalog;
|
||||
|
||||
public record PackerPackSummaryAssetDTO(
|
||||
int assetId,
|
||||
String assetName,
|
||||
AssetFamilyCatalog assetFamily,
|
||||
int minArtifactCount,
|
||||
int maxArtifactCount,
|
||||
long lastModified) {
|
||||
|
||||
public PackerPackSummaryAssetDTO {
|
||||
if (assetId < 0) {
|
||||
throw new IllegalArgumentException("assetId must not be negative");
|
||||
}
|
||||
assetName = java.util.Objects.requireNonNull(assetName, "assetName").trim();
|
||||
assetFamily = java.util.Objects.requireNonNullElse(assetFamily, AssetFamilyCatalog.UNKNOWN);
|
||||
if (assetName.isBlank()) {
|
||||
throw new IllegalArgumentException("assetName must not be blank");
|
||||
}
|
||||
if (minArtifactCount < 0) {
|
||||
throw new IllegalArgumentException("minArtifactCount must not be negative");
|
||||
}
|
||||
if (maxArtifactCount < 0) {
|
||||
throw new IllegalArgumentException("maxArtifactCount must not be negative");
|
||||
}
|
||||
if (minArtifactCount > maxArtifactCount) {
|
||||
throw new IllegalArgumentException("minArtifactCount must not be greater than maxArtifactCount");
|
||||
}
|
||||
if (lastModified < 0L) {
|
||||
throw new IllegalArgumentException("lastModified must not be negative");
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-12
@@ -1,22 +1,16 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PackerPackSummaryDTO(
|
||||
int includedRegisteredAssetCount,
|
||||
int outsideBuildSetAssetCount,
|
||||
String canonicalArtifactName) {
|
||||
int totalIncludedAssetCount,
|
||||
List<PackerPackSummaryAssetDTO> assets) {
|
||||
|
||||
public PackerPackSummaryDTO {
|
||||
if (includedRegisteredAssetCount < 0) {
|
||||
throw new IllegalArgumentException("includedRegisteredAssetCount must not be negative");
|
||||
}
|
||||
if (outsideBuildSetAssetCount < 0) {
|
||||
throw new IllegalArgumentException("outsideBuildSetAssetCount must not be negative");
|
||||
}
|
||||
canonicalArtifactName = Objects.requireNonNull(canonicalArtifactName, "canonicalArtifactName").trim();
|
||||
if (canonicalArtifactName.isBlank()) {
|
||||
throw new IllegalArgumentException("canonicalArtifactName must not be blank");
|
||||
if (totalIncludedAssetCount < 0) {
|
||||
throw new IllegalArgumentException("totalIncludedAssetCount must not be negative");
|
||||
}
|
||||
assets = List.copyOf(Objects.requireNonNull(assets, "assets"));
|
||||
}
|
||||
}
|
||||
|
||||
+22
-5
@@ -1,18 +1,35 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PackerPackValidationAssetDTO(
|
||||
PackerAssetSummaryDTO asset,
|
||||
boolean blocked,
|
||||
int assetId,
|
||||
String assetName,
|
||||
Path assetPath,
|
||||
long lastModified,
|
||||
List<PackerDiagnosticDTO> diagnostics) {
|
||||
|
||||
public PackerPackValidationAssetDTO {
|
||||
Objects.requireNonNull(asset, "asset");
|
||||
if (assetId < 0) {
|
||||
throw new IllegalArgumentException("assetId must not be negative");
|
||||
}
|
||||
assetName = Objects.requireNonNull(assetName, "assetName").trim();
|
||||
assetPath = Objects.requireNonNull(assetPath, "assetPath").toAbsolutePath().normalize();
|
||||
diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
|
||||
if (blocked && diagnostics.stream().noneMatch(PackerDiagnosticDTO::blocking)) {
|
||||
throw new IllegalArgumentException("blocked validation asset must include at least one blocking diagnostic");
|
||||
if (assetName.isBlank()) {
|
||||
throw new IllegalArgumentException("assetName must not be blank");
|
||||
}
|
||||
if (lastModified < 0L) {
|
||||
throw new IllegalArgumentException("lastModified must not be negative");
|
||||
}
|
||||
if (diagnostics.stream().anyMatch(diagnostic -> !diagnostic.blocking())) {
|
||||
throw new IllegalArgumentException("validation diagnostics must be blocking in the first wave");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean blocked() {
|
||||
return !diagnostics.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
public record PackerPackValidationSummaryDTO(
|
||||
int totalAssetsInScope,
|
||||
int validAssetCount,
|
||||
int blockedAssetCount,
|
||||
boolean canPack) {
|
||||
|
||||
public PackerPackValidationSummaryDTO {
|
||||
if (totalAssetsInScope < 0) {
|
||||
throw new IllegalArgumentException("totalAssetsInScope must not be negative");
|
||||
}
|
||||
if (validAssetCount < 0) {
|
||||
throw new IllegalArgumentException("validAssetCount must not be negative");
|
||||
}
|
||||
if (blockedAssetCount < 0) {
|
||||
throw new IllegalArgumentException("blockedAssetCount must not be negative");
|
||||
}
|
||||
if (validAssetCount + blockedAssetCount > totalAssetsInScope) {
|
||||
throw new IllegalArgumentException("validAssetCount + blockedAssetCount must not exceed totalAssetsInScope");
|
||||
}
|
||||
if (canPack && blockedAssetCount > 0) {
|
||||
throw new IllegalArgumentException("canPack must be false when blockedAssetCount is greater than zero");
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -1,7 +1,6 @@
|
||||
package p.packer.messages;
|
||||
|
||||
import p.packer.dtos.PackerPackValidationAssetDTO;
|
||||
import p.packer.dtos.PackerPackValidationSummaryDTO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -9,16 +8,18 @@ import java.util.Objects;
|
||||
public record ValidatePackWorkspaceResult(
|
||||
PackerOperationStatus status,
|
||||
String summary,
|
||||
PackerPackValidationSummaryDTO validation,
|
||||
List<PackerPackValidationAssetDTO> assets) {
|
||||
|
||||
public ValidatePackWorkspaceResult {
|
||||
Objects.requireNonNull(status, "status");
|
||||
summary = Objects.requireNonNull(summary, "summary").trim();
|
||||
Objects.requireNonNull(validation, "validation");
|
||||
assets = List.copyOf(Objects.requireNonNull(assets, "assets"));
|
||||
if (summary.isBlank()) {
|
||||
throw new IllegalArgumentException("summary must not be blank");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canPack() {
|
||||
return assets.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user