@Override public String getFlowRegistryName(final String flowRegistryId) { final FlowRegistry flowRegistry = flowRegistryClient.getFlowRegistry(flowRegistryId); return flowRegistry == null ? flowRegistryId : flowRegistry.getName(); }
@Override public synchronized void setURL(final String url) { this.url = url; invalidateClient(); }
@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); }
@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); }
private static void populateComponentTypes(final VersionedProcessGroup group, final Set<Tuple<String, BundleCoordinate>> componentTypes) { group.getProcessors().stream() .map(versionedProc -> new Tuple<>(versionedProc.getType(), createBundleCoordinate(versionedProc.getBundle()))) .forEach(componentTypes::add); group.getControllerServices().stream() .map(versionedSvc -> new Tuple<>(versionedSvc.getType(), createBundleCoordinate(versionedSvc.getBundle()))) .forEach(componentTypes::add); for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { populateComponentTypes(childGroup, componentTypes); } }
private void addFlowRegistries(final Element parentElement, final FlowRegistryClient registryClient) { for (final String registryId : registryClient.getRegistryIdentifiers()) { final FlowRegistry flowRegistry = registryClient.getFlowRegistry(registryId); final Element registryElement = parentElement.getOwnerDocument().createElement("flowRegistry"); parentElement.appendChild(registryElement); addStringElement(registryElement, "id", flowRegistry.getIdentifier()); addStringElement(registryElement, "name", flowRegistry.getName()); addStringElement(registryElement, "url", flowRegistry.getURL()); addStringElement(registryElement, "description", flowRegistry.getDescription()); } }
@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; }
private void findAllConnectionIds(final VersionedProcessGroup group, final Set<String> ids) { for (final VersionedConnection connection : group.getConnections()) { ids.add(connection.getIdentifier()); } for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { findAllConnectionIds(childGroup, ids); } }
private void findAllProcessors(final VersionedProcessGroup group, final Map<String, VersionedProcessor> map) { for (final VersionedProcessor processor : group.getProcessors()) { map.put(processor.getIdentifier(), processor); } for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { findAllProcessors(childGroup, map); } }
private void findAllControllerServices(final VersionedProcessGroup group, final Map<String, VersionedControllerService> map) { for (final VersionedControllerService service : group.getControllerServices()) { map.put(service.getIdentifier(), service); } for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { findAllControllerServices(childGroup, map); } }
default String getFlowRegistryId(String registryUrl) { if (registryUrl.endsWith("/")) { registryUrl = registryUrl.substring(0, registryUrl.length() - 1); } for (final String registryClientId : getRegistryIdentifiers()) { final FlowRegistry registry = getFlowRegistry(registryClientId); String registryClientUrl = registry.getURL(); if (registryClientUrl.endsWith("/")) { registryClientUrl = registryClientUrl.substring(0, registryClientUrl.length() - 1); } if (registryClientUrl.equals(registryUrl)) { return registryClientId; } } return null; }
@Override public String getRegistryName() { final String registryId = versionControlInformation.getRegistryIdentifier(); final FlowRegistry registry = flowController.getFlowRegistryClient().getFlowRegistry(registryId); return registry == null ? registryId : registry.getName(); }
private void updatePort(final Port port, final VersionedPort proposed) { port.setComments(proposed.getComments()); port.setName(proposed.getName()); port.setPosition(new Position(proposed.getPosition().getX(), proposed.getPosition().getY())); }
private VersionedFlow getVersionedFlow(final String registryId, final String bucketId, final String flowId) throws IOException, NiFiRegistryException { final FlowRegistry registry = flowRegistryClient.getFlowRegistry(registryId); if (registry == null) { throw new ResourceNotFoundException("No Flow Registry exists with ID " + registryId); } return registry.getVersionedFlow(bucketId, flowId, NiFiUserUtils.getNiFiUser()); }
@Override public int getLatestVersion(final String bucketId, final String flowId, final NiFiUser user) throws IOException, NiFiRegistryException { return (int) getFlowClient(user).get(bucketId, flowId).getVersionCount(); }
private Bundle mapBundle(final BundleCoordinate coordinate) { final Bundle versionedBundle = new Bundle(); versionedBundle.setGroup(coordinate.getGroup()); versionedBundle.setArtifact(coordinate.getId()); versionedBundle.setVersion(coordinate.getVersion()); return versionedBundle; }
@Override public VersionedFlow registerVersionedFlow(final VersionedFlow flow, final NiFiUser user) throws IOException, NiFiRegistryException { final FlowClient flowClient = getFlowClient(user); return flowClient.create(flow); }
private void findAllConnections(final VersionedProcessGroup group, final Map<String, VersionedConnection> map) { for (final VersionedConnection connection : group.getConnections()) { map.put(connection.getIdentifier(), connection); } for (final VersionedProcessGroup childGroup : group.getProcessGroups()) { findAllConnections(childGroup, map); } }
@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); }