diff --git a/transfer/transfer-01-file-transfer/status-checker/src/main/java/org/eclipse/edc/sample/extension/checker/SampleFileStatusChecker.java b/transfer/transfer-01-file-transfer/status-checker/src/main/java/org/eclipse/edc/sample/extension/checker/SampleFileStatusChecker.java index f64e8581..9eb5268a 100644 --- a/transfer/transfer-01-file-transfer/status-checker/src/main/java/org/eclipse/edc/sample/extension/checker/SampleFileStatusChecker.java +++ b/transfer/transfer-01-file-transfer/status-checker/src/main/java/org/eclipse/edc/sample/extension/checker/SampleFileStatusChecker.java @@ -27,7 +27,7 @@ public class SampleFileStatusChecker implements StatusChecker { @Override public boolean isComplete(TransferProcess transferProcess, List resources) { var destination = transferProcess.getDataRequest().getDataDestination(); - var path = destination.getProperty("path"); + var path = destination.getStringProperty("path"); return Optional.ofNullable(path) .map(this::checkPath) .orElse(false); diff --git a/transfer/transfer-01-file-transfer/transfer-file-local/src/main/java/org/eclipse/edc/sample/extension/api/FileTransferDataSinkFactory.java b/transfer/transfer-01-file-transfer/transfer-file-local/src/main/java/org/eclipse/edc/sample/extension/api/FileTransferDataSinkFactory.java index 93b0472f..e7befc2a 100644 --- a/transfer/transfer-01-file-transfer/transfer-file-local/src/main/java/org/eclipse/edc/sample/extension/api/FileTransferDataSinkFactory.java +++ b/transfer/transfer-01-file-transfer/transfer-file-local/src/main/java/org/eclipse/edc/sample/extension/api/FileTransferDataSinkFactory.java @@ -40,17 +40,12 @@ public boolean canHandle(DataFlowRequest request) { return "file".equalsIgnoreCase(request.getDestinationDataAddress().getType()); } - @Override - public @NotNull Result validate(DataFlowRequest request) { - return Result.success(true); - } - @Override public DataSink createSink(DataFlowRequest request) { var destination = request.getDestinationDataAddress(); // verify destination path - var path = destination.getProperty("path"); + var path = destination.getStringProperty("path"); // As this is a controlled test input below is to avoid path-injection warning by CodeQL var destinationFile = new File(path.replaceAll("\\.", ".").replaceAll("/", "/")); @@ -62,4 +57,9 @@ public DataSink createSink(DataFlowRequest request) { .monitor(monitor) .build(); } + + @Override + public @NotNull Result validateRequest(DataFlowRequest request) { + return Result.success(); + } } diff --git a/transfer/transfer-01-file-transfer/transfer-file-local/src/main/java/org/eclipse/edc/sample/extension/api/FileTransferDataSourceFactory.java b/transfer/transfer-01-file-transfer/transfer-file-local/src/main/java/org/eclipse/edc/sample/extension/api/FileTransferDataSourceFactory.java index 459cce6d..3712b9ce 100644 --- a/transfer/transfer-01-file-transfer/transfer-file-local/src/main/java/org/eclipse/edc/sample/extension/api/FileTransferDataSourceFactory.java +++ b/transfer/transfer-01-file-transfer/transfer-file-local/src/main/java/org/eclipse/edc/sample/extension/api/FileTransferDataSourceFactory.java @@ -29,27 +29,27 @@ public boolean canHandle(DataFlowRequest dataRequest) { } @Override - public @NotNull Result validate(DataFlowRequest request) { + public DataSource createSource(DataFlowRequest request) { var source = getFile(request); - if (!source.exists()) { - return Result.failure("Source file " + source.getName() + " does not exist!"); - } - - return Result.success(true); + return new FileTransferDataSource(source); } @Override - public DataSource createSource(DataFlowRequest request) { + public @NotNull Result validateRequest(DataFlowRequest request) { var source = getFile(request); - return new FileTransferDataSource(source); + if (!source.exists()) { + return Result.failure("Source file " + source.getName() + " does not exist!"); + } + + return Result.success(); } @NotNull private File getFile(DataFlowRequest request) { var dataAddress = request.getSourceDataAddress(); // verify source path - var sourceFileName = dataAddress.getProperty("filename"); - var path = dataAddress.getProperty("path"); + var sourceFileName = dataAddress.getStringProperty("filename"); + var path = dataAddress.getStringProperty("path"); // As this is a controlled test input below is to avoid path-injection warning by CodeQL sourceFileName = sourceFileName.replaceAll("\\.", ".").replaceAll("/", "/"); path = path.replaceAll("\\.", ".").replaceAll("/", "/"); diff --git a/transfer/transfer-02-file-transfer-listener/listener/src/main/java/org/eclipse/edc/sample/extension/listener/MarkerFileCreator.java b/transfer/transfer-02-file-transfer-listener/listener/src/main/java/org/eclipse/edc/sample/extension/listener/MarkerFileCreator.java index 4caafabe..4f2714f4 100644 --- a/transfer/transfer-02-file-transfer-listener/listener/src/main/java/org/eclipse/edc/sample/extension/listener/MarkerFileCreator.java +++ b/transfer/transfer-02-file-transfer-listener/listener/src/main/java/org/eclipse/edc/sample/extension/listener/MarkerFileCreator.java @@ -39,7 +39,7 @@ public MarkerFileCreator(Monitor monitor) { */ @Override public void preCompleted(final TransferProcess process) { - Path path = Path.of(process.getDataRequest().getDataDestination().getProperty("path")); + Path path = Path.of(process.getDataRequest().getDataDestination().getStringProperty("path")); if (!Files.isDirectory(path)) { path = path.getParent(); } diff --git a/transfer/transfer-02-file-transfer-listener/listener/src/main/java/org/eclipse/edc/sample/extension/listener/TransferListenerExtension.java b/transfer/transfer-02-file-transfer-listener/listener/src/main/java/org/eclipse/edc/sample/extension/listener/TransferListenerExtension.java index bed49254..6534e2d0 100644 --- a/transfer/transfer-02-file-transfer-listener/listener/src/main/java/org/eclipse/edc/sample/extension/listener/TransferListenerExtension.java +++ b/transfer/transfer-02-file-transfer-listener/listener/src/main/java/org/eclipse/edc/sample/extension/listener/TransferListenerExtension.java @@ -43,7 +43,7 @@ public void initialize(ServiceExtensionContext context) { private static class FileStatusChecker implements StatusChecker { @Override public boolean isComplete(TransferProcess transferProcess, List resources) { - var path = transferProcess.getDataDestination().getProperty("path"); + var path = transferProcess.getDataDestination().getStringProperty("path"); return path != null && new File(path).exists(); } }