Search in sources :

Example 1 with NotFoundException

use of org.apache.pulsar.packages.management.core.exceptions.PackagesManagementException.NotFoundException in project pulsar by apache.

the class PackagesManagementImpl method checkPackageExistsAndThrowException.

private CompletableFuture<Void> checkPackageExistsAndThrowException(PackageName packageName) {
    String path = packagePath(packageName);
    CompletableFuture<Void> future = new CompletableFuture<>();
    storage.existAsync(path).whenComplete((exist, throwable) -> {
        if (throwable != null) {
            future.completeExceptionally(throwable);
            return;
        }
        if (!exist) {
            future.complete(null);
        } else {
            future.completeExceptionally(new NotFoundException(String.format("Package '%s' already exists", packageName.toString())));
        }
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) NotFoundException(org.apache.pulsar.packages.management.core.exceptions.PackagesManagementException.NotFoundException)

Example 2 with NotFoundException

use of org.apache.pulsar.packages.management.core.exceptions.PackagesManagementException.NotFoundException in project pulsar by apache.

the class PackagesManagementImpl method checkMetadataNotExistsAndThrowException.

private CompletableFuture<Void> checkMetadataNotExistsAndThrowException(PackageName packageName) {
    String path = metadataPath(packageName);
    CompletableFuture<Void> future = new CompletableFuture<>();
    storage.existAsync(path).whenComplete((exist, throwable) -> {
        if (throwable != null) {
            future.completeExceptionally(throwable);
            return;
        }
        if (exist) {
            future.complete(null);
        } else {
            future.completeExceptionally(new NotFoundException(String.format("Package '%s' metadata does not exist", packageName)));
        }
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) NotFoundException(org.apache.pulsar.packages.management.core.exceptions.PackagesManagementException.NotFoundException)

Example 3 with NotFoundException

use of org.apache.pulsar.packages.management.core.exceptions.PackagesManagementException.NotFoundException in project pulsar by apache.

the class PackagesManagementImpl method checkMetadataExistsAndThrowException.

private CompletableFuture<Void> checkMetadataExistsAndThrowException(PackageName packageName) {
    String path = metadataPath(packageName);
    CompletableFuture<Void> future = new CompletableFuture<>();
    storage.existAsync(path).whenComplete((exist, throwable) -> {
        if (throwable != null) {
            future.completeExceptionally(throwable);
            return;
        }
        if (!exist) {
            future.complete(null);
        } else {
            future.completeExceptionally(new NotFoundException(String.format("Package '%s' metadata already exists", packageName)));
        }
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) NotFoundException(org.apache.pulsar.packages.management.core.exceptions.PackagesManagementException.NotFoundException)

Example 4 with NotFoundException

use of org.apache.pulsar.packages.management.core.exceptions.PackagesManagementException.NotFoundException in project pulsar by yahoo.

the class PackagesManagementImpl method checkPackageExistsAndThrowException.

private CompletableFuture<Void> checkPackageExistsAndThrowException(PackageName packageName) {
    String path = packagePath(packageName);
    CompletableFuture<Void> future = new CompletableFuture<>();
    storage.existAsync(path).whenComplete((exist, throwable) -> {
        if (throwable != null) {
            future.completeExceptionally(throwable);
            return;
        }
        if (!exist) {
            future.complete(null);
        } else {
            future.completeExceptionally(new NotFoundException(String.format("Package '%s' already exists", packageName.toString())));
        }
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) NotFoundException(org.apache.pulsar.packages.management.core.exceptions.PackagesManagementException.NotFoundException)

Example 5 with NotFoundException

use of org.apache.pulsar.packages.management.core.exceptions.PackagesManagementException.NotFoundException in project pulsar by yahoo.

the class PackagesManagementImpl method checkMetadataExistsAndThrowException.

private CompletableFuture<Void> checkMetadataExistsAndThrowException(PackageName packageName) {
    String path = metadataPath(packageName);
    CompletableFuture<Void> future = new CompletableFuture<>();
    storage.existAsync(path).whenComplete((exist, throwable) -> {
        if (throwable != null) {
            future.completeExceptionally(throwable);
            return;
        }
        if (!exist) {
            future.complete(null);
        } else {
            future.completeExceptionally(new NotFoundException(String.format("Package '%s' metadata already exists", packageName)));
        }
    });
    return future;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) NotFoundException(org.apache.pulsar.packages.management.core.exceptions.PackagesManagementException.NotFoundException)

Aggregations

CompletableFuture (java.util.concurrent.CompletableFuture)12 NotFoundException (org.apache.pulsar.packages.management.core.exceptions.PackagesManagementException.NotFoundException)12