You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ex...@apache.org on 2026/04/01 20:23:37 UTC
(nifi) branch main updated: NIFI-15777 Added missingContent property to AssetReferenceDTO (#11088)
This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push:
new 262b62bda1b NIFI-15777 Added missingContent property to AssetReferenceDTO (#11088)
262b62bda1b is described below
commit 262b62bda1b01ba25dd1bb1d2c524f7616f124d4
Author: Matt Gilman <ma...@gmail.com>
AuthorDate: Wed Apr 1 16:23:32 2026 -0400
NIFI-15777 Added missingContent property to AssetReferenceDTO (#11088)
Signed-off-by: David Handermann <ex...@apache.org>
---
.../apache/nifi/web/api/dto/AssetReferenceDTO.java | 10 ++++++
.../org/apache/nifi/web/api/dto/DtoFactory.java | 15 +++++++--
.../apache/nifi/web/api/dto/DtoFactoryTest.java | 38 ++++++++++++++++++++++
3 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AssetReferenceDTO.java b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AssetReferenceDTO.java
index dae300e9951..6fab87e031b 100644
--- a/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AssetReferenceDTO.java
+++ b/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/AssetReferenceDTO.java
@@ -27,6 +27,7 @@ public class AssetReferenceDTO {
private String id;
private String name;
+ private Boolean missingContent;
public AssetReferenceDTO() {
}
@@ -58,6 +59,15 @@ public class AssetReferenceDTO {
this.name = name;
}
+ @Schema(description = "Indicates if the content of the asset is missing.", accessMode = Schema.AccessMode.READ_ONLY)
+ public Boolean getMissingContent() {
+ return missingContent;
+ }
+
+ public void setMissingContent(final Boolean missingContent) {
+ this.missingContent = missingContent;
+ }
+
@Override
public boolean equals(final Object o) {
if (this == o) {
diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
index 945847b6398..eb76b674bbb 100644
--- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
+++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/api/dto/DtoFactory.java
@@ -1581,7 +1581,9 @@ public final class DtoFactory {
}
public AssetReferenceDTO createAssetReferenceDto(final Asset asset) {
- return new AssetReferenceDTO(asset.getIdentifier(), asset.getName());
+ final AssetReferenceDTO dto = new AssetReferenceDTO(asset.getIdentifier(), asset.getName());
+ dto.setMissingContent(!asset.getFile().exists());
+ return dto;
}
public ParameterEntity createParameterEntity(final ParameterContext parameterContext, final Parameter parameter, final RevisionManager revisionManager,
@@ -5501,8 +5503,15 @@ public final class DtoFactory {
}
private AssetReferenceDTO createConnectorAssetReferenceDto(final String assetId) {
- final String assetName = connectorRepository.getAsset(assetId).map(Asset::getName).orElse(assetId);
- return new AssetReferenceDTO(assetId, assetName);
+ final Optional<Asset> asset = connectorRepository.getAsset(assetId);
+ final String assetName = asset.map(Asset::getName).orElse(assetId);
+ final AssetReferenceDTO dto = new AssetReferenceDTO(assetId, assetName);
+ if (asset.isPresent()) {
+ dto.setMissingContent(!asset.get().getFile().exists());
+ } else {
+ dto.setMissingContent(true);
+ }
+ return dto;
}
private ConnectorPropertyDescriptorDTO createConnectorPropertyDescriptorDto(final ConnectorPropertyDescriptor propertyDescriptor) {
diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/api/dto/DtoFactoryTest.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/api/dto/DtoFactoryTest.java
index e4549bdd501..831821a1197 100644
--- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/api/dto/DtoFactoryTest.java
+++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/test/java/org/apache/nifi/web/api/dto/DtoFactoryTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.nifi.web.api.dto;
+import org.apache.nifi.asset.Asset;
import org.apache.nifi.bundle.Bundle;
import org.apache.nifi.bundle.BundleCoordinate;
import org.apache.nifi.bundle.BundleDetails;
@@ -61,6 +62,7 @@ import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotSame;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -718,4 +720,40 @@ public class DtoFactoryTest {
final DifferenceDTO dto = dtoFactory.createBundleDifferenceDto(difference);
assertTrue(dto.getEnvironmental());
}
+
+ @Test
+ void testCreateAssetReferenceDtoWhenContentFileExists() {
+ final Asset asset = mock(Asset.class);
+ when(asset.getIdentifier()).thenReturn("asset-id-1");
+ when(asset.getName()).thenReturn("asset-name-1");
+ final File contentFile = mock(File.class);
+ when(contentFile.exists()).thenReturn(true);
+ when(asset.getFile()).thenReturn(contentFile);
+
+ final DtoFactory dtoFactory = new DtoFactory();
+ final AssetReferenceDTO dto = dtoFactory.createAssetReferenceDto(asset);
+
+ assertEquals("asset-id-1", dto.getId());
+ assertEquals("asset-name-1", dto.getName());
+ assertNotNull(dto.getMissingContent());
+ assertFalse(dto.getMissingContent());
+ }
+
+ @Test
+ void testCreateAssetReferenceDtoWhenContentFileMissing() {
+ final Asset asset = mock(Asset.class);
+ when(asset.getIdentifier()).thenReturn("asset-id-2");
+ when(asset.getName()).thenReturn("asset-name-2");
+ final File contentFile = mock(File.class);
+ when(contentFile.exists()).thenReturn(false);
+ when(asset.getFile()).thenReturn(contentFile);
+
+ final DtoFactory dtoFactory = new DtoFactory();
+ final AssetReferenceDTO dto = dtoFactory.createAssetReferenceDto(asset);
+
+ assertEquals("asset-id-2", dto.getId());
+ assertEquals("asset-name-2", dto.getName());
+ assertNotNull(dto.getMissingContent());
+ assertTrue(dto.getMissingContent());
+ }
}