asset workspace progress
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
import p.packer.messages.assets.OutputCodecCatalog;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PackerAssetDetailsDTO(
|
||||
PackerAssetSummaryDTO summary,
|
||||
String outputFormat,
|
||||
OutputCodecCatalog outputCodec,
|
||||
List<OutputCodecCatalog> availableOutputCodecs,
|
||||
Map<OutputCodecCatalog, List<PackerCodecConfigurationFieldDTO>> codecConfigurationFieldsByCodec,
|
||||
Map<String, List<Path>> inputsByRole,
|
||||
List<PackerDiagnosticDTO> diagnostics) {
|
||||
|
||||
public PackerAssetDetailsDTO {
|
||||
Objects.requireNonNull(summary, "summary");
|
||||
outputFormat = Objects.requireNonNullElse(outputFormat, "unknown").trim();
|
||||
outputCodec = Objects.requireNonNullElse(outputCodec, OutputCodecCatalog.UNKNOWN);
|
||||
availableOutputCodecs = List.copyOf(Objects.requireNonNull(availableOutputCodecs, "availableOutputCodecs"));
|
||||
codecConfigurationFieldsByCodec = Map.copyOf(Objects.requireNonNull(codecConfigurationFieldsByCodec, "codecConfigurationFieldsByCodec"));
|
||||
inputsByRole = Map.copyOf(Objects.requireNonNull(inputsByRole, "inputsByRole"));
|
||||
diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PackerAssetIdentityDTO(
|
||||
Integer assetId,
|
||||
String assetUuid,
|
||||
String assetName,
|
||||
Path assetRoot) {
|
||||
|
||||
public PackerAssetIdentityDTO {
|
||||
assetUuid = assetUuid == null ? null : assetUuid.trim();
|
||||
assetName = Objects.requireNonNull(assetName, "assetName").trim();
|
||||
assetRoot = Objects.requireNonNull(assetRoot, "assetRoot").toAbsolutePath().normalize();
|
||||
if (assetName.isBlank()) {
|
||||
throw new IllegalArgumentException("assetName must not be blank");
|
||||
}
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
import p.packer.messages.AssetReference;
|
||||
import p.packer.messages.assets.AssetFamilyCatalog;
|
||||
import p.packer.messages.assets.PackerAssetState;
|
||||
import p.packer.messages.assets.PackerBuildParticipation;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record PackerAssetSummaryDTO(
|
||||
AssetReference assetReference,
|
||||
PackerAssetIdentityDTO identity,
|
||||
PackerAssetState state,
|
||||
PackerBuildParticipation buildParticipation,
|
||||
AssetFamilyCatalog assetFamily,
|
||||
boolean preloadEnabled,
|
||||
boolean hasDiagnostics) {
|
||||
|
||||
public PackerAssetSummaryDTO {
|
||||
Objects.requireNonNull(assetReference, "assetReference");
|
||||
Objects.requireNonNull(identity, "identity");
|
||||
Objects.requireNonNull(state, "state");
|
||||
Objects.requireNonNull(buildParticipation, "buildParticipation");
|
||||
assetFamily = Objects.requireNonNullElse(assetFamily, AssetFamilyCatalog.UNKNOWN);
|
||||
if (state == PackerAssetState.REGISTERED && identity.assetId() == null) {
|
||||
throw new IllegalArgumentException("registered asset must expose assetId");
|
||||
}
|
||||
if (state == PackerAssetState.UNREGISTERED && buildParticipation != PackerBuildParticipation.EXCLUDED) {
|
||||
throw new IllegalArgumentException("unregistered asset must stay excluded from build participation");
|
||||
}
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
import p.packer.messages.assets.PackerCodecConfigurationFieldType;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PackerCodecConfigurationFieldDTO(
|
||||
String key,
|
||||
String label,
|
||||
PackerCodecConfigurationFieldType fieldType,
|
||||
String value,
|
||||
boolean required,
|
||||
List<String> options) {
|
||||
|
||||
public PackerCodecConfigurationFieldDTO {
|
||||
key = Objects.requireNonNull(key, "key").trim();
|
||||
label = Objects.requireNonNull(label, "label").trim();
|
||||
Objects.requireNonNull(fieldType, "fieldType");
|
||||
value = Objects.requireNonNullElse(value, "").trim();
|
||||
options = List.copyOf(Objects.requireNonNull(options, "options"));
|
||||
if (key.isBlank() || label.isBlank()) {
|
||||
throw new IllegalArgumentException("codec configuration field key and label must not be blank");
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package p.packer.dtos;
|
||||
|
||||
import p.packer.messages.diagnostics.PackerDiagnosticCategory;
|
||||
import p.packer.messages.diagnostics.PackerDiagnosticSeverity;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
public record PackerDiagnosticDTO(
|
||||
PackerDiagnosticSeverity severity,
|
||||
PackerDiagnosticCategory category,
|
||||
String message,
|
||||
Path evidencePath,
|
||||
boolean blocking) {
|
||||
|
||||
public PackerDiagnosticDTO {
|
||||
Objects.requireNonNull(severity, "severity");
|
||||
Objects.requireNonNull(category, "category");
|
||||
message = Objects.requireNonNull(message, "message").trim();
|
||||
evidencePath = evidencePath == null ? null : evidencePath.toAbsolutePath().normalize();
|
||||
if (message.isBlank()) {
|
||||
throw new IllegalArgumentException("message must not be blank");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user