@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 ResolvedReference resolve(final CommandOption option, final Integer position) { final VersionedFlow versionedFlow = backRefs.get(position); if (versionedFlow != null) { if (option != null && option == CommandOption.BUCKET_ID) { return new ResolvedReference(option, position, versionedFlow.getBucketName(), versionedFlow.getBucketIdentifier()); } else { return new ResolvedReference(option, position, versionedFlow.getName(), versionedFlow.getIdentifier()); } } else { return null; } }
@Override protected void writeSimpleResult(PrintStream output) { if (versionedFlows.isEmpty()) { return; } final Table table = new Table.Builder() .column("#", 3, 3, false) .column("Name", 20, 36, true) .column("Id", 36, 36, false) .column("Description", 11, 40, true) .build(); for (int i = 0; i < versionedFlows.size(); ++i) { final VersionedFlow flow = versionedFlows.get(i); table.addRow(String.valueOf(i + 1), flow.getName(), flow.getIdentifier(), flow.getDescription()); } final TableWriter tableWriter = new DynamicTableWriter(); tableWriter.write(table, output); }
vci.setFlowDescription(flow.getDescription()); vci.setFlowId(flow.getIdentifier()); vci.setFlowName(flow.getName()); vci.setGroupId(groupId); vci.setRegistryId(requestVci.getRegistryId());
private VersionedFlowEntity createVersionedFlowEntity(final String registryId, final VersionedFlow versionedFlow) { if (versionedFlow == null) { return null; } final VersionedFlowDTO dto = new VersionedFlowDTO(); dto.setRegistryId(registryId); dto.setBucketId(versionedFlow.getBucketIdentifier()); dto.setFlowId(versionedFlow.getIdentifier()); dto.setFlowName(versionedFlow.getName()); dto.setDescription(versionedFlow.getDescription()); final VersionedFlowEntity entity = new VersionedFlowEntity(); entity.setVersionedFlow(dto); return entity; }
versionControlInfoDto.setBucketName(bucket.getName()); versionControlInfoDto.setFlowId(snapshotMetadata.getFlowIdentifier()); versionControlInfoDto.setFlowName(flow.getName()); versionControlInfoDto.setFlowDescription(flow.getDescription()); versionControlInfoDto.setGroupId(groupId);
final int latestVersion = (int) versionedFlow.getVersionCount(); vci.setBucketName(versionedFlow.getBucketName()); vci.setFlowName(versionedFlow.getName()); vci.setFlowDescription(versionedFlow.getDescription()); vci.setRegistryName(flowRegistry.getName());
versionControlInfo.setFlowName(flow.getName()); versionControlInfo.setFlowDescription(flow.getDescription());
vci.setBucketName(bucket.getName()); vci.setFlowId(flow.getIdentifier()); vci.setFlowName(flow.getName()); vci.setFlowDescription(flow.getDescription()); vci.setGroupId(groupId);
@Override public String toString() { final String flowName = (flow == null ? "null" : flow.getName()); return "VersionedFlowSnapshot[flowId=" + snapshotMetadata.getFlowIdentifier() + ", flowName=" + flowName + ", version=" + snapshotMetadata.getVersion() + ", comments=" + snapshotMetadata.getComments() + "]"; } }
if (versionedFlow.getName() != null && StringUtils.isBlank(versionedFlow.getName())) { throw new IllegalArgumentException("Versioned flow name cannot be blank"); if (StringUtils.isNotBlank(versionedFlow.getName())) { final List<FlowEntity> flowsWithSameName = metadataService.getFlowsByName(existingBucket.getId(), versionedFlow.getName()); if (flowsWithSameName != null) { for (final FlowEntity flowWithSameName : flowsWithSameName) { if (StringUtils.isNotBlank(versionedFlow.getName())) { existingFlow.setName(versionedFlow.getName());
final List<FlowEntity> flowsWithSameName = metadataService.getFlowsByName(existingBucket.getId(), versionedFlow.getName()); if (flowsWithSameName != null && flowsWithSameName.size() > 0) { throw new IllegalStateException("A versioned flow with the same name already exists in the selected bucket");
@Override public FlowControllerSchema apply(final VersionedFlowSnapshot versionedFlowSnapshot) { // If the VersionedFlowSnapshot came directly from NiFi Registry without modification, as would be the // case with C2 server, then we should have a non-null VersionedFlow, but if we're using a snapshot that // was export from another tool like the CLI, the flow may be null'd out, so fall back to root group. String name; String description; if (versionedFlowSnapshot.getFlow() == null) { name = versionedFlowSnapshot.getFlowContents().getName(); description = versionedFlowSnapshot.getFlowContents().getComments(); } else { name = versionedFlowSnapshot.getFlow().getName(); description = versionedFlowSnapshot.getFlow().getDescription(); } Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.NAME_KEY, name); map.put(CommonPropertyKeys.COMMENT_KEY, description); return new FlowControllerSchema(map); } }
@Override public FlowControllerSchema apply(final VersionedFlowSnapshot versionedFlowSnapshot) { // If the VersionedFlowSnapshot came directly from NiFi Registry without modification, as would be the // case with C2 server, then we should have a non-null VersionedFlow, but if we're using a snapshot that // was export from another tool like the CLI, the flow may be null'd out, so fall back to root group. String name; String description; if (versionedFlowSnapshot.getFlow() == null) { name = versionedFlowSnapshot.getFlowContents().getName(); description = versionedFlowSnapshot.getFlowContents().getComments(); } else { name = versionedFlowSnapshot.getFlow().getName(); description = versionedFlowSnapshot.getFlow().getDescription(); } Map<String, Object> map = new HashMap<>(); map.put(CommonPropertyKeys.NAME_KEY, name); map.put(CommonPropertyKeys.COMMENT_KEY, description); return new FlowControllerSchema(map); } }
public static FlowEntity map(final VersionedFlow versionedFlow) { final FlowEntity flowEntity = new FlowEntity(); flowEntity.setId(versionedFlow.getIdentifier()); flowEntity.setName(versionedFlow.getName()); flowEntity.setDescription(versionedFlow.getDescription()); flowEntity.setCreated(new Date(versionedFlow.getCreatedTimestamp())); flowEntity.setModified(new Date(versionedFlow.getModifiedTimestamp())); flowEntity.setType(BucketItemEntityType.FLOW); return flowEntity; }
public Builder(final Bucket bucket, final VersionedFlow versionedFlow, final VersionedFlowSnapshotMetadata snapshotMetadata) { bucketId(bucket.getIdentifier()); bucketName(bucket.getName()); flowId(snapshotMetadata.getFlowIdentifier()); flowName(versionedFlow.getName()); version(snapshotMetadata.getVersion()); comments(snapshotMetadata.getComments()); author(snapshotMetadata.getAuthor()); snapshotTimestamp(snapshotMetadata.getTimestamp()); }