Skip to content

Commit

Permalink
Write markerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
sven1103 committed Apr 16, 2024
1 parent cfc39b3 commit 2c2e892
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
import org.apache.logging.log4j.Logger;

/**
* <b>Evaluation Request</b>
* <b>Evaluation Request - Last process</b>
*
* <p>Currently only validates the presence of a QBiC measurement ID in the dataset root
* <p>Validates the presence of a QBiC measurement ID in the dataset root
* folder.</p>
* If a valid measurement ID is found, the process updates the provenance file with the ID and moves
* the dataset to the openBIS ETL. After successful transfer, an openBIS marker-file is created, to integrate
* the dataset registration with openBIS ETL.
* <p>
* If none is present, or the identifier does not match the requirements, it is moved back to the
* users error folder.
Expand Down Expand Up @@ -147,6 +150,12 @@ private void evaluateDirectory(File taskDir) {
var measurementIdResult = matcher.results().map(MatchResult::group).findFirst();
if (measurementIdResult.isPresent()) {
moveToTargetDir(taskDir);
try {
createMarkerFile(targetDirectory, taskDir.getName());
} catch (IOException e) {
LOG.error("Could not create marker file: %s".formatted(taskDir.getAbsolutePath()), e);
moveToSystemIntervention(taskDir, e.getMessage());
}
return;
}
var errorMessage = ErrorSummary.createSimple(taskDir.getName(), dataset.getName(), "Missing QBiC measurement ID",
Expand All @@ -157,6 +166,11 @@ private void evaluateDirectory(File taskDir) {
moveBackToOrigin(taskDir, provenance, errorMessage.toString());
}

private boolean createMarkerFile(Path targetDirectory, String name) throws IOException {
Path markerFileName = Paths.get(".MARKER_is_finished_" + name);
return targetDirectory.resolve(markerFileName).toFile().createNewFile();
}

private Optional<File> findDataset(File taskDir) {
return Arrays.stream(taskDir.listFiles()).filter(File::isDirectory).findFirst();
}
Expand Down

0 comments on commit 2c2e892

Please sign in to comment.