@Override public FlowRegistry getFlowRegistry(final String registryId) { final FlowRegistry registry = flowRegistryClient.getFlowRegistry(registryId); if (registry == null) { throw new ResourceNotFoundException("Unable to find Flow Registry with id '" + registryId + "'"); } return registry; }
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 FlowRegistry removeFlowRegistry(final String registryId) { final FlowRegistry registry = flowRegistryClient.removeFlowRegistry(registryId); if (registry == null) { throw new ResourceNotFoundException("Unable to find Flow Registry with id '" + registryId + "'"); } return registry; }
group.disconnectVersionControl(false); } else { final String registryId = flowController.getFlowRegistryClient().getFlowRegistryId(remoteCoordinates.getRegistryUrl()); final String bucketId = remoteCoordinates.getBucketId(); final String flowId = remoteCoordinates.getFlowId(); final int version = remoteCoordinates.getVersion(); final FlowRegistry flowRegistry = flowController.getFlowRegistryClient().getFlowRegistry(registryId); final String registryName = flowRegistry == null ? registryId : flowRegistry.getName();
&& flowManager.getAllReportingTasks().isEmpty() && flowManager.getAllControllerServices().isEmpty() && controller.getFlowRegistryClient().getRegistryIdentifiers().isEmpty(); } else { existingFlow = readFlowFromDisk(); client.addFlowRegistry(registryId, registryName, registryUrl, description);
@Override public Set<FlowRegistry> getFlowRegistries() { return flowRegistryClient.getRegistryIdentifiers().stream() .map(flowRegistryClient::getFlowRegistry) .collect(Collectors.toSet()); }
@Override public FlowRegistry createFlowRegistry(final RegistryDTO registryDto) { return flowRegistryClient.addFlowRegistry(registryDto.getId(), registryDto.getName(), registryDto.getUri(), registryDto.getDescription()); }
final int version = coordinates.getVersion(); final String registryId = flowRegistryClient.getFlowRegistryId(registryUrl); if (registryId == null) { throw new NiFiRegistryException("Flow contains a reference to another Versioned Flow located at URL " + registryUrl final FlowRegistry flowRegistry = flowRegistryClient.getFlowRegistry(registryId); final VersionedFlowSnapshot snapshot = flowRegistry.getFlowContents(bucketId, flowId, version, true, user); final VersionedProcessGroup contents = snapshot.getFlowContents();
@Override public CurrentUserEntity getCurrentUser() { final NiFiUser user = NiFiUserUtils.getNiFiUser(); final CurrentUserEntity entity = new CurrentUserEntity(); entity.setIdentity(user.getIdentity()); entity.setAnonymous(user.isAnonymous()); entity.setProvenancePermissions(dtoFactory.createPermissionsDto(authorizableLookup.getProvenance())); entity.setCountersPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getCounters())); entity.setTenantsPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getTenant())); entity.setControllerPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getController())); entity.setPoliciesPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getPolicies())); entity.setSystemPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getSystem())); entity.setCanVersionFlows(CollectionUtils.isNotEmpty(flowRegistryClient.getRegistryIdentifiers())); entity.setRestrictedComponentsPermissions(dtoFactory.createPermissionsDto(authorizableLookup.getRestrictedComponents())); final Set<ComponentRestrictionPermissionDTO> componentRestrictionPermissions = new HashSet<>(); Arrays.stream(RequiredPermission.values()).forEach(requiredPermission -> { final PermissionsDTO restrictionPermissions = dtoFactory.createPermissionsDto(authorizableLookup.getRestrictedComponents(requiredPermission)); final RequiredPermissionDTO requiredPermissionDto = new RequiredPermissionDTO(); requiredPermissionDto.setId(requiredPermission.getPermissionIdentifier()); requiredPermissionDto.setLabel(requiredPermission.getPermissionLabel()); final ComponentRestrictionPermissionDTO componentRestrictionPermissionDto = new ComponentRestrictionPermissionDTO(); componentRestrictionPermissionDto.setRequiredPermission(requiredPermissionDto); componentRestrictionPermissionDto.setPermissions(restrictionPermissions); componentRestrictionPermissions.add(componentRestrictionPermissionDto); }); entity.setComponentRestrictionPermissions(componentRestrictionPermissions); return entity; }
@Override public String getFlowRegistryName(final String flowRegistryId) { final FlowRegistry flowRegistry = flowRegistryClient.getFlowRegistry(flowRegistryId); return flowRegistry == null ? flowRegistryId : flowRegistry.getName(); }
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 VersionedFlow deleteVersionedFlow(final String registryId, final String bucketId, final String flowId) { final FlowRegistry registry = flowRegistryClient.getFlowRegistry(registryId); if (registry == null) { throw new IllegalArgumentException("No Flow Registry exists with ID " + registryId); } try { return registry.deleteVersionedFlow(bucketId, flowId, NiFiUserUtils.getNiFiUser()); } catch (final IOException | NiFiRegistryException e) { throw new NiFiCoreException("Failed to remove flow from Flow Registry due to " + e.getMessage(), e); } }
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 Set<Bucket> getBucketsForUser(final String registryId, final NiFiUser user) { try { final FlowRegistry flowRegistry = flowRegistryClient.getFlowRegistry(registryId); if (flowRegistry == null) { throw new IllegalArgumentException("The specified registry id is unknown to this NiFi."); } final Set<Bucket> buckets = flowRegistry.getBuckets(user); final Set<Bucket> sortedBuckets = new TreeSet<>((b1, b2) -> b1.getName().compareTo(b2.getName())); sortedBuckets.addAll(buckets); return sortedBuckets; } catch (final IOException | NiFiRegistryException ioe) { throw new NiFiCoreException("Unable to obtain listing of buckets: " + ioe, ioe); } }
@Override public Set<VersionedFlow> getFlowsForUser(String registryId, String bucketId, NiFiUser user) { try { final FlowRegistry flowRegistry = flowRegistryClient.getFlowRegistry(registryId); if (flowRegistry == null) { throw new IllegalArgumentException("The specified registry id is unknown to this NiFi."); } final Set<VersionedFlow> flows = flowRegistry.getFlows(bucketId, user); final Set<VersionedFlow> sortedFlows = new TreeSet<>((f1, f2) -> f1.getName().compareTo(f2.getName())); sortedFlows.addAll(flows); return sortedFlows; } catch (final IOException | NiFiRegistryException ioe) { throw new NiFiCoreException("Unable to obtain listing of flows for bucket with ID " + bucketId + ": " + ioe, ioe); } }
@Override public Set<VersionedFlowSnapshotMetadata> getFlowVersionsForUser(String registryId, String bucketId, String flowId, NiFiUser user) { try { final FlowRegistry flowRegistry = flowRegistryClient.getFlowRegistry(registryId); if (flowRegistry == null) { throw new IllegalArgumentException("The specified registry id is unknown to this NiFi."); } final Set<VersionedFlowSnapshotMetadata> flowVersions = flowRegistry.getFlowVersions(bucketId, flowId, user); final Set<VersionedFlowSnapshotMetadata> sortedFlowVersions = new TreeSet<>((f1, f2) -> Integer.compare(f1.getVersion(), f2.getVersion())); sortedFlowVersions.addAll(flowVersions); return sortedFlowVersions; } catch (final IOException | NiFiRegistryException ioe) { throw new NiFiCoreException("Unable to obtain listing of versions for bucket with ID " + bucketId + " and flow with ID " + flowId + ": " + ioe, ioe); } }
@Override public String getRegistryName() { final String registryId = versionControlInformation.getRegistryIdentifier(); final FlowRegistry registry = flowController.getFlowRegistryClient().getFlowRegistry(registryId); return registry == null ? registryId : registry.getName(); }
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 VersionedFlow registerVersionedFlow(final String registryId, final VersionedFlow flow) { final FlowRegistry registry = flowRegistryClient.getFlowRegistry(registryId); if (registry == null) { throw new ResourceNotFoundException("No Flow Registry exists with ID " + registryId); } try { return registry.registerVersionedFlow(flow, NiFiUserUtils.getNiFiUser()); } catch (final IOException | NiFiRegistryException e) { throw new NiFiCoreException("Failed to register flow with Flow Registry due to " + e.getMessage(), e); } }
@Override public VersionedFlowSnapshot registerVersionedFlowSnapshot(final String registryId, final VersionedFlow flow, final VersionedProcessGroup snapshot, final String comments, final int expectedVersion) { final FlowRegistry registry = flowRegistryClient.getFlowRegistry(registryId); if (registry == null) { throw new ResourceNotFoundException("No Flow Registry exists with ID " + registryId); } try { return registry.registerVersionedFlowSnapshot(flow, snapshot, comments, expectedVersion, NiFiUserUtils.getNiFiUser()); } catch (final IOException | NiFiRegistryException e) { throw new NiFiCoreException("Failed to register flow with Flow Registry due to " + e.getMessage(), e); } }