private BuildOutcome infer(BuildOutcome outcome) {
if (outcome instanceof UnknownBuildOutcome) {
return new UnknownBuildOutcome(outcome.getName(), outcome.getDescription());
} else if (outcome instanceof GeneratedArchiveBuildOutcome) {
GeneratedArchiveBuildOutcome archiveBuildOutcome = (GeneratedArchiveBuildOutcome) outcome;
File file = new File(baseDir, archiveBuildOutcome.getRootRelativePath());
String rootRelativePath = archiveBuildOutcome.getRootRelativePath();
// TODO - we are relying on knowledge that the name of the outcome is the task path
String taskPath = outcome.getName();
LocallyAvailableResource resource = null;
if (file.exists()) {
String filestoreDestination = String.format("%s/%s/%s", fileStorePrefix, taskPath, file.getName());
resource = fileStore.move(filestoreDestination, file);
}
return new GeneratedArchiveBuildOutcome(outcome.getName(), outcome.getDescription(), resource, rootRelativePath);
} else {
throw new IllegalStateException(String.format("Unhandled build outcome type: %s", outcome.getClass().getName()));
}
}