Search in sources :

Example 11 with BackupManager

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);
}
Also used : Path(java.nio.file.Path) Json(org.infinispan.commons.dataconversion.internal.Json) BackupManager(org.infinispan.server.core.BackupManager)

Aggregations

BackupManager (org.infinispan.server.core.BackupManager)11 IOException (java.io.IOException)3 Path (java.nio.file.Path)3 Set (java.util.Set)3 File (java.io.File)2 DefaultCacheManager (org.infinispan.manager.DefaultCacheManager)2 BlockingManager (org.infinispan.util.concurrent.BlockingManager)2 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)1 DefaultHttpDataFactory (io.netty.handler.codec.http.multipart.DefaultHttpDataFactory)1 DiskAttribute (io.netty.handler.codec.http.multipart.DiskAttribute)1 DiskFileUpload (io.netty.handler.codec.http.multipart.DiskFileUpload)1 HttpPostMultipartRequestDecoder (io.netty.handler.codec.http.multipart.HttpPostMultipartRequestDecoder)1 InterfaceHttpPostRequestDecoder (io.netty.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 ObjectInput (java.io.ObjectInput)1 ObjectOutput (java.io.ObjectOutput)1 URL (java.net.URL)1 Paths (java.nio.file.Paths)1 PrivilegedActionException (java.security.PrivilegedActionException)1