@Override public Set<Bucket> getBuckets(final NiFiUser user) throws IOException, NiFiRegistryException { final BucketClient bucketClient = getBucketClient(user); return new HashSet<>(bucketClient.getAll()); }
@Override public VersionedFlow deleteVersionedFlow(final String bucketId, final String flowId, final NiFiUser user) throws IOException, NiFiRegistryException { final FlowClient flowClient = getFlowClient(user); return flowClient.delete(bucketId, flowId); }
@Override public VersionedFlowSnapshot getFlowContents(final String bucketId, final String flowId, final int version, final boolean fetchRemoteFlows) throws IOException, NiFiRegistryException { return getFlowContents(bucketId, flowId, version, fetchRemoteFlows, null); }
private FlowSnapshotClient getFlowSnapshotClient(final NiFiUser user) { final String identity = getIdentity(user); final NiFiRegistryClient registryClient = getRegistryClient(); final FlowSnapshotClient snapshotClient = identity == null ? registryClient.getFlowSnapshotClient() : registryClient.getFlowSnapshotClient(identity); return snapshotClient; }
@Override public VersionedFlowSnapshot getFlowContents(final String bucketId, final String flowId, final int version, final boolean fetchRemoteFlows, final NiFiUser user) throws IOException, NiFiRegistryException { final FlowSnapshotClient snapshotClient = getFlowSnapshotClient(user); final VersionedFlowSnapshot flowSnapshot = snapshotClient.get(bucketId, flowId, version); if (fetchRemoteFlows) { final VersionedProcessGroup contents = flowSnapshot.getFlowContents(); for (final VersionedProcessGroup child : contents.getProcessGroups()) { populateVersionedContentsRecursively(child, user); } } return flowSnapshot; }
@Override public VersionedFlowSnapshot registerVersionedFlowSnapshot(final VersionedFlow flow, final VersionedProcessGroup snapshot, final String comments, final int expectedVersion, final NiFiUser user) throws IOException, NiFiRegistryException { final FlowSnapshotClient snapshotClient = getFlowSnapshotClient(user); final VersionedFlowSnapshot versionedFlowSnapshot = new VersionedFlowSnapshot(); versionedFlowSnapshot.setFlowContents(snapshot); final VersionedFlowSnapshotMetadata metadata = new VersionedFlowSnapshotMetadata(); metadata.setBucketIdentifier(flow.getBucketIdentifier()); metadata.setFlowIdentifier(flow.getIdentifier()); metadata.setAuthor(getIdentity(user)); metadata.setTimestamp(System.currentTimeMillis()); metadata.setVersion(expectedVersion); metadata.setComments(comments); versionedFlowSnapshot.setSnapshotMetadata(metadata); return snapshotClient.create(versionedFlowSnapshot); }
@Override public synchronized void setURL(final String url) { this.url = url; invalidateClient(); }
@Override public Set<VersionedFlowSnapshotMetadata> getFlowVersions(final String bucketId, final String flowId, final NiFiUser user) throws IOException, NiFiRegistryException { final FlowSnapshotClient snapshotClient = getFlowSnapshotClient(user); return new HashSet<>(snapshotClient.getSnapshotMetadata(bucketId, flowId)); }
@Override public VersionedFlow getVersionedFlow(final String bucketId, final String flowId) throws IOException, NiFiRegistryException { final FlowClient flowClient = getRegistryClient().getFlowClient(); return flowClient.get(bucketId, flowId); } }
registry = new RestBasedFlowRegistry(this, registryId, registryBaseUrl, sslContext, registryName); registry.setDescription(description); } else {
populateVersionedContentsRecursively(child, user);
private BucketClient getBucketClient(final NiFiUser user) { final String identity = getIdentity(user); final NiFiRegistryClient registryClient = getRegistryClient(); final BucketClient bucketClient = identity == null ? registryClient.getBucketClient() : registryClient.getBucketClient(identity); return bucketClient; }
private FlowClient getFlowClient(final NiFiUser user) { final String identity = getIdentity(user); final NiFiRegistryClient registryClient = getRegistryClient(); final FlowClient flowClient = identity == null ? registryClient.getFlowClient() : registryClient.getFlowClient(identity); return flowClient; }
@Override public VersionedFlow registerVersionedFlow(final VersionedFlow flow, final NiFiUser user) throws IOException, NiFiRegistryException { final FlowClient flowClient = getFlowClient(user); return flowClient.create(flow); }
@Override public Bucket getBucket(final String bucketId, final NiFiUser user) throws IOException, NiFiRegistryException { final BucketClient bucketClient = getBucketClient(user); return bucketClient.get(bucketId); }
@Override public VersionedFlow getVersionedFlow(final String bucketId, final String flowId, final NiFiUser user) throws IOException, NiFiRegistryException { final FlowClient flowClient = getFlowClient(user); return flowClient.get(bucketId, flowId); }
@Override public Set<VersionedFlow> getFlows(final String bucketId, final NiFiUser user) throws IOException, NiFiRegistryException { final FlowClient flowClient = getFlowClient(user); return new HashSet<>(flowClient.getByBucket(bucketId)); }
@Override public int getLatestVersion(final String bucketId, final String flowId, final NiFiUser user) throws IOException, NiFiRegistryException { return (int) getFlowClient(user).get(bucketId, flowId).getVersionCount(); }