Search in sources :

Example 1 with BucketsResult

use of org.apache.nifi.toolkit.cli.impl.result.BucketsResult in project nifi by apache.

the class QuickImport method getQuickImportBucketId.

private String getQuickImportBucketId(final NiFiRegistryClient registryClient, final boolean isInteractive) throws IOException, NiFiRegistryException, MissingOptionException {
    final BucketsResult bucketsResult = listBuckets.doExecute(registryClient, new Properties());
    final Bucket quickImportBucket = bucketsResult.getResult().stream().filter(b -> BUCKET_NAME.equals(b.getName())).findFirst().orElse(null);
    // if it doesn't exist, then create the quick import bucket
    String quickImportBucketId = null;
    if (quickImportBucket != null) {
        quickImportBucketId = quickImportBucket.getIdentifier();
        if (isInteractive) {
            println();
            println("Found existing bucket '" + BUCKET_NAME + "'...");
        }
    } else {
        final Properties createBucketProps = new Properties();
        createBucketProps.setProperty(CommandOption.BUCKET_NAME.getLongName(), BUCKET_NAME);
        createBucketProps.setProperty(CommandOption.BUCKET_DESC.getLongName(), BUCKET_DESC);
        final StringResult createdBucketId = createBucket.doExecute(registryClient, createBucketProps);
        quickImportBucketId = createdBucketId.getResult();
        if (isInteractive) {
            println();
            println("Created new bucket '" + BUCKET_NAME + "'...");
        }
    }
    return quickImportBucketId;
}
Also used : BucketsResult(org.apache.nifi.toolkit.cli.impl.result.BucketsResult) Bucket(org.apache.nifi.registry.bucket.Bucket) CreateBucket(org.apache.nifi.toolkit.cli.impl.command.registry.bucket.CreateBucket) StringResult(org.apache.nifi.toolkit.cli.impl.result.StringResult) Properties(java.util.Properties)

Aggregations

Properties (java.util.Properties)1 Bucket (org.apache.nifi.registry.bucket.Bucket)1 CreateBucket (org.apache.nifi.toolkit.cli.impl.command.registry.bucket.CreateBucket)1 BucketsResult (org.apache.nifi.toolkit.cli.impl.result.BucketsResult)1 StringResult (org.apache.nifi.toolkit.cli.impl.result.StringResult)1