packer (WIP)

This commit is contained in:
2026-03-24 13:42:55 +00:00
parent 5b6ed046fc
commit fac421e2ca
8 changed files with 127 additions and 67 deletions
@@ -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");
}
}
}
@@ -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"));
}
}
@@ -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();
}
}
@@ -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");
}
}
}