1
0

M2 Vorläufige Freigabe nach Sonnet-Review

This commit is contained in:
2026-04-01 07:24:45 +02:00
parent 9d66a446b3
commit 09ad365308
5 changed files with 243 additions and 223 deletions

View File

@@ -7,6 +7,7 @@ import de.gecheckt.pdf.umbenenner.adapter.inbound.cli.SchedulerBatchCommand;
import de.gecheckt.pdf.umbenenner.adapter.outbound.configuration.PropertiesConfigurationPortAdapter;
import de.gecheckt.pdf.umbenenner.adapter.outbound.lock.FilesystemRunLockPortAdapter;
import de.gecheckt.pdf.umbenenner.application.config.InvalidStartConfigurationException;
import de.gecheckt.pdf.umbenenner.application.config.StartConfiguration;
import de.gecheckt.pdf.umbenenner.application.config.StartConfigurationValidator;
import de.gecheckt.pdf.umbenenner.application.port.in.BatchRunOutcome;
import de.gecheckt.pdf.umbenenner.application.port.in.RunBatchProcessingUseCase;
@@ -17,6 +18,7 @@ import de.gecheckt.pdf.umbenenner.domain.model.BatchRunContext;
import de.gecheckt.pdf.umbenenner.domain.model.RunId;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.Instant;
import java.util.UUID;
@@ -66,10 +68,13 @@ public class BootstrapRunner {
/**
* Functional interface for creating a RunBatchProcessingUseCase.
* <p>
* Receives the already-loaded and validated {@link StartConfiguration} so the use case
* does not need to re-read the configuration file.
*/
@FunctionalInterface
public interface UseCaseFactory {
RunBatchProcessingUseCase create(ConfigurationPort configPort, RunLockPort runLockPort);
RunBatchProcessingUseCase create(StartConfiguration config, RunLockPort runLockPort);
}
/**
@@ -89,7 +94,7 @@ public class BootstrapRunner {
this.configPortFactory = PropertiesConfigurationPortAdapter::new;
this.runLockPortFactory = FilesystemRunLockPortAdapter::new;
this.validatorFactory = StartConfigurationValidator::new;
this.useCaseFactory = M2BatchRunProcessingUseCase::new;
this.useCaseFactory = (config, lock) -> new M2BatchRunProcessingUseCase(config, lock);
this.commandFactory = SchedulerBatchCommand::new;
}
@@ -136,8 +141,13 @@ public class BootstrapRunner {
StartConfigurationValidator validator = validatorFactory.create();
validator.validate(config);
// Step 4: Create the run lock port from the validated config (AP-006)
RunLockPort runLockPort = runLockPortFactory.create(config.runtimeLockFile());
// Step 4: Resolve lock file path apply default if not configured (AP-006)
Path lockFilePath = config.runtimeLockFile();
if (lockFilePath == null || lockFilePath.toString().isBlank()) {
lockFilePath = Paths.get("pdf-umbenenner.lock");
LOG.info("runtime.lock.file not configured, using default lock path: {}", lockFilePath.toAbsolutePath());
}
RunLockPort runLockPort = runLockPortFactory.create(lockFilePath);
// Step 5: Create the batch run context (M2-AP-003)
// Generate a unique run ID and initialize the run context
@@ -145,8 +155,9 @@ public class BootstrapRunner {
BatchRunContext runContext = new BatchRunContext(runId, Instant.now());
LOG.info("Batch run started. RunId: {}", runId);
// Step 6: Create the use case with the configuration port and run lock (application layer)
RunBatchProcessingUseCase useCase = useCaseFactory.create(configPort, runLockPort);
// Step 6: Create the use case with the validated config and run lock (application layer)
// Config is passed directly; the use case does not re-read the properties file.
RunBatchProcessingUseCase useCase = useCaseFactory.create(config, runLockPort);
// Step 7: Create the CLI command adapter with the use case
SchedulerBatchCommand command = commandFactory.create(useCase);