asset details (WIP)
This commit is contained in:
+2
-5
@@ -480,7 +480,6 @@ public final class FileSystemPackerWorkspaceService implements PackerWorkspaceSe
|
||||
manifest.put("asset_uuid", assetUuid);
|
||||
manifest.put("name", request.assetName());
|
||||
manifest.put("type", request.assetFamily().manifestType());
|
||||
manifest.put("inputs", Map.of());
|
||||
manifest.put("output", Map.of(
|
||||
"format", request.outputFormat().manifestValue(),
|
||||
"codec", request.outputCodec().manifestValue()));
|
||||
@@ -760,8 +759,7 @@ public final class FileSystemPackerWorkspaceService implements PackerWorkspaceSe
|
||||
}
|
||||
|
||||
private void patchManifestArtifacts(ObjectNode manifest, ApplyBankCompositionRequest request) {
|
||||
final ObjectNode inputsNode = mutableObject(manifest, "inputs");
|
||||
inputsNode.removeAll();
|
||||
manifest.remove("inputs");
|
||||
|
||||
final var artifactsNode = manifest.putArray("artifacts");
|
||||
for (int index = 0; index < request.selectedFiles().size(); index += 1) {
|
||||
@@ -799,8 +797,7 @@ public final class FileSystemPackerWorkspaceService implements PackerWorkspaceSe
|
||||
}
|
||||
|
||||
private void clearManifestBankComposition(ObjectNode manifest) {
|
||||
final ObjectNode inputsNode = mutableObject(manifest, "inputs");
|
||||
inputsNode.removeAll();
|
||||
manifest.remove("inputs");
|
||||
manifest.putArray("artifacts");
|
||||
}
|
||||
|
||||
|
||||
+10
-44
@@ -45,7 +45,7 @@ public final class PackerAssetDeclarationParser {
|
||||
final var assetUuid = requiredText(root, "asset_uuid", diagnostics, manifestPath);
|
||||
final var name = requiredText(root, "name", diagnostics, manifestPath);
|
||||
final var assetFamily = requiredAssetFamily(root, diagnostics, manifestPath);
|
||||
final var inputsByRole = requiredInputs(root.path("inputs"), diagnostics, manifestPath);
|
||||
rejectLegacyInputs(root.path("inputs"), diagnostics, manifestPath);
|
||||
final var artifacts = optionalArtifacts(root.path("artifacts"), diagnostics, manifestPath);
|
||||
final var outputFormat = requiredOutputFormat(root.path("output"), diagnostics, manifestPath);
|
||||
final var outputCodec = requiredOutputCodec(root.path("output"), diagnostics, manifestPath);
|
||||
@@ -71,7 +71,6 @@ public final class PackerAssetDeclarationParser {
|
||||
assetUuid,
|
||||
name,
|
||||
assetFamily,
|
||||
inputsByRole,
|
||||
artifacts,
|
||||
outputFormat,
|
||||
outputCodec,
|
||||
@@ -229,52 +228,19 @@ public final class PackerAssetDeclarationParser {
|
||||
return Map.copyOf(metadata);
|
||||
}
|
||||
|
||||
private Map<String, List<String>> requiredInputs(
|
||||
private void rejectLegacyInputs(
|
||||
final JsonNode node,
|
||||
final List<PackerDiagnostic> diagnostics,
|
||||
final Path manifestPath) {
|
||||
if (!node.isObject()) {
|
||||
diagnostics.add(missingOrInvalid("inputs", "object of input roles", manifestPath));
|
||||
return Map.of();
|
||||
if (node.isMissingNode() || node.isNull()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Map<String, List<String>> result = new LinkedHashMap<>();
|
||||
node.fields().forEachRemaining(entry -> {
|
||||
if (!entry.getValue().isArray()) {
|
||||
diagnostics.add(new PackerDiagnostic(
|
||||
PackerDiagnosticSeverity.ERROR,
|
||||
PackerDiagnosticCategory.STRUCTURAL,
|
||||
"Input role '" + entry.getKey() + "' must be an array of relative paths.",
|
||||
manifestPath,
|
||||
true));
|
||||
return;
|
||||
}
|
||||
final List<String> values = new ArrayList<>();
|
||||
entry.getValue().forEach(value -> {
|
||||
if (!value.isTextual() || value.asText().isBlank()) {
|
||||
diagnostics.add(new PackerDiagnostic(
|
||||
PackerDiagnosticSeverity.ERROR,
|
||||
PackerDiagnosticCategory.STRUCTURAL,
|
||||
"Input role '" + entry.getKey() + "' must contain only non-blank path strings.",
|
||||
manifestPath,
|
||||
true));
|
||||
return;
|
||||
}
|
||||
final String relativePath = value.asText().trim();
|
||||
if (!isTrustedRelativePath(relativePath)) {
|
||||
diagnostics.add(new PackerDiagnostic(
|
||||
PackerDiagnosticSeverity.ERROR,
|
||||
PackerDiagnosticCategory.STRUCTURAL,
|
||||
"Input role '" + entry.getKey() + "' contains an untrusted path outside the asset root.",
|
||||
manifestPath,
|
||||
true));
|
||||
return;
|
||||
}
|
||||
values.add(relativePath);
|
||||
});
|
||||
result.put(entry.getKey(), List.copyOf(values));
|
||||
});
|
||||
return Map.copyOf(result);
|
||||
diagnostics.add(new PackerDiagnostic(
|
||||
PackerDiagnosticSeverity.ERROR,
|
||||
PackerDiagnosticCategory.STRUCTURAL,
|
||||
"Field 'inputs' is no longer supported; use 'artifacts' instead.",
|
||||
manifestPath,
|
||||
true));
|
||||
}
|
||||
|
||||
private List<PackerAssetArtifactSelection> optionalArtifacts(
|
||||
|
||||
+4
-21
@@ -80,7 +80,6 @@ public final class PackerAssetDetailsService {
|
||||
outputContract.codecConfigurationFieldsByCodec(),
|
||||
metadataFields(outputContract.metadataFields(), declaration.outputMetadata()),
|
||||
resolveBankCompositionDetails(runtimeAsset, declaration),
|
||||
resolveInputs(resolved.assetRoot(), declaration.inputsByRole()),
|
||||
diagnostics);
|
||||
return new GetAssetDetailsResult(
|
||||
diagnostics.stream().anyMatch(PackerDiagnostic::blocking) ? PackerOperationStatus.PARTIAL : PackerOperationStatus.SUCCESS,
|
||||
@@ -120,7 +119,6 @@ public final class PackerAssetDetailsService {
|
||||
Map.of(OutputCodecCatalog.NONE, List.of()),
|
||||
List.of(),
|
||||
PackerBankCompositionDetails.EMPTY,
|
||||
Map.of(),
|
||||
diagnostics);
|
||||
return new GetAssetDetailsResult(
|
||||
PackerOperationStatus.FAILED,
|
||||
@@ -129,16 +127,6 @@ public final class PackerAssetDetailsService {
|
||||
PackerReadMessageMapper.toDiagnosticDTOs(diagnostics));
|
||||
}
|
||||
|
||||
private Map<String, List<Path>> resolveInputs(
|
||||
final Path assetRoot,
|
||||
final Map<String, List<String>> inputsByRole) {
|
||||
final Map<String, List<Path>> resolved = new LinkedHashMap<>();
|
||||
inputsByRole.forEach((role, inputs) -> resolved.put(
|
||||
role,
|
||||
inputs.stream().map(input -> assetRoot.resolve(input).toAbsolutePath().normalize()).toList()));
|
||||
return Map.copyOf(resolved);
|
||||
}
|
||||
|
||||
private PackerBankCompositionDetails resolveBankCompositionDetails(
|
||||
final PackerRuntimeAsset runtimeAsset,
|
||||
final PackerAssetDeclaration declaration) {
|
||||
@@ -163,15 +151,10 @@ public final class PackerAssetDetailsService {
|
||||
}
|
||||
|
||||
private List<String> selectedPathsFor(PackerAssetDeclaration declaration) {
|
||||
if (!declaration.artifacts().isEmpty()) {
|
||||
return declaration.artifacts().stream()
|
||||
.sorted(Comparator.comparingInt(PackerAssetArtifactSelection::index))
|
||||
.map(PackerAssetArtifactSelection::file)
|
||||
.toList();
|
||||
}
|
||||
final List<String> selected = new ArrayList<>();
|
||||
declaration.inputsByRole().values().forEach(selected::addAll);
|
||||
return List.copyOf(selected);
|
||||
return declaration.artifacts().stream()
|
||||
.sorted(Comparator.comparingInt(PackerAssetArtifactSelection::index))
|
||||
.map(PackerAssetArtifactSelection::file)
|
||||
.toList();
|
||||
}
|
||||
|
||||
private Optional<PackerBankCompositionFile> resolveSelectedBankFile(
|
||||
|
||||
-1
@@ -32,7 +32,6 @@ public final class PackerReadMessageMapper {
|
||||
toCodecConfigurationFieldsByCodecDTO(details.codecConfigurationFieldsByCodec()),
|
||||
toCodecConfigurationFieldDTOs(details.metadataFields()),
|
||||
toBankCompositionDetailsDTO(details.bankComposition()),
|
||||
details.inputsByRole(),
|
||||
toDiagnosticDTOs(details.diagnostics()));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user