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;
}
Aggregations