use of org.infinispan.server.core.BackupManager in project infinispan by infinispan.
the class BackupManagerResource method handleCreateBackup.
private static CompletionStage<RestResponse> handleCreateBackup(String name, RestRequest request, BackupManager backupManager, TriConsumer<String, Path, Json> creationConsumer) {
BackupManager.Status existingStatus = backupManager.getBackupStatus(name);
if (existingStatus != BackupManager.Status.NOT_FOUND)
return responseFuture(CONFLICT);
Json json = Json.read(request.contents().asString());
Json dirJson = json.at(DIR_KEY);
Path workingDir = dirJson == null ? null : Paths.get(dirJson.asString());
if (workingDir != null && !Files.isDirectory(workingDir))
return responseFuture(BAD_REQUEST, String.format("'%s' must be a directory", DIR_KEY));
Json requestsJson = json.at(RESOURCES_KEY);
creationConsumer.accept(name, workingDir, requestsJson);
return responseFuture(ACCEPTED);
}
Aggregations