Search in sources :

Example 1 with FlowDTO

use of org.apache.nifi.web.api.dto.flow.FlowDTO in project nifi by apache.

the class StandardNiFiServiceFacade method copySnippet.

@Override
public FlowEntity copySnippet(final String groupId, final String snippetId, final Double originX, final Double originY, final String idGenerationSeed) {
    // create the new snippet
    final FlowSnippetDTO snippet = snippetDAO.copySnippet(groupId, snippetId, originX, originY, idGenerationSeed);
    // save the flow
    controllerFacade.save();
    // drop the snippet
    snippetDAO.dropSnippet(snippetId);
    // post process new flow snippet
    final FlowDTO flowDto = postProcessNewFlowSnippet(groupId, snippet);
    final FlowEntity flowEntity = new FlowEntity();
    flowEntity.setFlow(flowDto);
    return flowEntity;
}
Also used : FlowSnippetDTO(org.apache.nifi.web.api.dto.FlowSnippetDTO) VersionedFlowDTO(org.apache.nifi.web.api.dto.VersionedFlowDTO) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) FlowEntity(org.apache.nifi.web.api.entity.FlowEntity) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity) VersionedFlowEntity(org.apache.nifi.web.api.entity.VersionedFlowEntity)

Example 2 with FlowDTO

use of org.apache.nifi.web.api.dto.flow.FlowDTO in project nifi by apache.

the class DtoFactory method createFlowDto.

public FlowDTO createFlowDto(final ProcessGroup group, final ProcessGroupStatus groupStatus, final FlowSnippetDTO snippet, final RevisionManager revisionManager, final Function<ProcessGroup, List<BulletinEntity>> getProcessGroupBulletins) {
    if (snippet == null) {
        return null;
    }
    final FlowDTO flow = new FlowDTO();
    for (final ConnectionDTO snippetConnection : snippet.getConnections()) {
        final Connection connection = group.getConnection(snippetConnection.getId());
        // marshal the actual connection as the snippet is pruned
        final ConnectionDTO dto = createConnectionDto(connection);
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(connection.getIdentifier()));
        final PermissionsDTO accessPolicy = createPermissionsDto(connection);
        final ConnectionStatusDTO status = getComponentStatus(() -> groupStatus.getConnectionStatus().stream().filter(connectionStatus -> connection.getIdentifier().equals(connectionStatus.getId())).findFirst().orElse(null), connectionStatus -> createConnectionStatusDto(connectionStatus));
        flow.getConnections().add(entityFactory.createConnectionEntity(dto, revision, accessPolicy, status));
    }
    for (final FunnelDTO snippetFunnel : snippet.getFunnels()) {
        final Funnel funnel = group.getFunnel(snippetFunnel.getId());
        // marshal the actual funnel as the snippet is pruned
        final FunnelDTO dto = createFunnelDto(funnel);
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(funnel.getIdentifier()));
        final PermissionsDTO accessPolicy = createPermissionsDto(funnel);
        flow.getFunnels().add(entityFactory.createFunnelEntity(dto, revision, accessPolicy));
    }
    for (final PortDTO snippetInputPort : snippet.getInputPorts()) {
        final Port inputPort = group.getInputPort(snippetInputPort.getId());
        // marshal the actual port as the snippet is pruned
        final PortDTO dto = createPortDto(inputPort);
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(inputPort.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(inputPort);
        final PortStatusDTO status = getComponentStatus(() -> groupStatus.getInputPortStatus().stream().filter(inputPortStatus -> inputPort.getIdentifier().equals(inputPortStatus.getId())).findFirst().orElse(null), inputPortStatus -> createPortStatusDto(inputPortStatus));
        final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(inputPort.getIdentifier()));
        final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
        flow.getInputPorts().add(entityFactory.createPortEntity(dto, revision, permissions, status, bulletinEntities));
    }
    for (final PortDTO snippetOutputPort : snippet.getOutputPorts()) {
        final Port outputPort = group.getOutputPort(snippetOutputPort.getId());
        // marshal the actual port as the snippet is pruned
        final PortDTO dto = createPortDto(outputPort);
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(outputPort.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(outputPort);
        final PortStatusDTO status = getComponentStatus(() -> groupStatus.getOutputPortStatus().stream().filter(outputPortStatus -> outputPort.getIdentifier().equals(outputPortStatus.getId())).findFirst().orElse(null), outputPortStatus -> createPortStatusDto(outputPortStatus));
        final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(outputPort.getIdentifier()));
        final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
        flow.getOutputPorts().add(entityFactory.createPortEntity(dto, revision, permissions, status, bulletinEntities));
    }
    for (final LabelDTO snippetLabel : snippet.getLabels()) {
        final Label label = group.getLabel(snippetLabel.getId());
        // marshal the actual label as the snippet is pruned
        final LabelDTO dto = createLabelDto(label);
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(label.getIdentifier()));
        final PermissionsDTO accessPolicy = createPermissionsDto(label);
        flow.getLabels().add(entityFactory.createLabelEntity(dto, revision, accessPolicy));
    }
    for (final ProcessGroupDTO snippetProcessGroup : snippet.getProcessGroups()) {
        final ProcessGroup processGroup = group.getProcessGroup(snippetProcessGroup.getId());
        // marshal the actual group as the snippet is pruned
        final ProcessGroupDTO dto = createProcessGroupDto(processGroup);
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(processGroup.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(processGroup);
        final ProcessGroupStatusDTO status = getComponentStatus(() -> groupStatus.getProcessGroupStatus().stream().filter(processGroupStatus -> processGroup.getIdentifier().equals(processGroupStatus.getId())).findFirst().orElse(null), processGroupStatus -> createConciseProcessGroupStatusDto(processGroupStatus));
        final List<BulletinEntity> bulletins = getProcessGroupBulletins.apply(processGroup);
        flow.getProcessGroups().add(entityFactory.createProcessGroupEntity(dto, revision, permissions, status, bulletins));
    }
    for (final ProcessorDTO snippetProcessor : snippet.getProcessors()) {
        final ProcessorNode processor = group.getProcessor(snippetProcessor.getId());
        // marshal the actual processor as the snippet is pruned
        final ProcessorDTO dto = createProcessorDto(processor);
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(processor.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(processor);
        final ProcessorStatusDTO status = getComponentStatus(() -> groupStatus.getProcessorStatus().stream().filter(processorStatus -> processor.getIdentifier().equals(processorStatus.getId())).findFirst().orElse(null), processorStatus -> createProcessorStatusDto(processorStatus));
        final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(processor.getIdentifier()));
        final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
        flow.getProcessors().add(entityFactory.createProcessorEntity(dto, revision, permissions, status, bulletinEntities));
    }
    for (final RemoteProcessGroupDTO snippetRemoteProcessGroup : snippet.getRemoteProcessGroups()) {
        final RemoteProcessGroup remoteProcessGroup = group.getRemoteProcessGroup(snippetRemoteProcessGroup.getId());
        // marshal the actual rpm as the snippet is pruned
        final RemoteProcessGroupDTO dto = createRemoteProcessGroupDto(remoteProcessGroup);
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(remoteProcessGroup.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(remoteProcessGroup);
        final RemoteProcessGroupStatusDTO status = getComponentStatus(() -> groupStatus.getRemoteProcessGroupStatus().stream().filter(rpgStatus -> remoteProcessGroup.getIdentifier().equals(rpgStatus.getId())).findFirst().orElse(null), remoteProcessGroupStatus -> createRemoteProcessGroupStatusDto(remoteProcessGroupStatus));
        final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(remoteProcessGroup.getIdentifier()));
        final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
        flow.getRemoteProcessGroups().add(entityFactory.createRemoteProcessGroupEntity(dto, revision, permissions, status, bulletinEntities));
    }
    return flow;
}
Also used : ProcessorStatusSnapshotEntity(org.apache.nifi.web.api.entity.ProcessorStatusSnapshotEntity) ConnectionDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.ConnectionDiagnosticsDTO) FlowComparison(org.apache.nifi.registry.flow.diff.FlowComparison) FlowModification(org.apache.nifi.web.FlowModification) StringUtils(org.apache.commons.lang3.StringUtils) DropFlowFileStatus(org.apache.nifi.controller.queue.DropFlowFileStatus) QueueSize(org.apache.nifi.controller.queue.QueueSize) ProcessorEntity(org.apache.nifi.web.api.entity.ProcessorEntity) VariableRegistryUpdateStep(org.apache.nifi.registry.variable.VariableRegistryUpdateStep) Scope(org.apache.nifi.components.state.Scope) ConnectDetails(org.apache.nifi.action.details.ConnectDetails) ControllerFacade(org.apache.nifi.web.controller.ControllerFacade) Map(java.util.Map) InstantiatedVersionedFunnel(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedFunnel) Connection(org.apache.nifi.connectable.Connection) NarClassLoaders(org.apache.nifi.nar.NarClassLoaders) FlowDifferenceFilters(org.apache.nifi.util.FlowDifferenceFilters) NodeEvent(org.apache.nifi.cluster.event.NodeEvent) VariableRegistryUpdateRequest(org.apache.nifi.registry.variable.VariableRegistryUpdateRequest) VersionedFlowStatus(org.apache.nifi.registry.flow.VersionedFlowStatus) AllowableValue(org.apache.nifi.components.AllowableValue) ComponentReferenceEntity(org.apache.nifi.web.api.entity.ComponentReferenceEntity) PortStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.PortStatusSnapshotDTO) AuthorizerCapabilityDetection(org.apache.nifi.authorization.AuthorizerCapabilityDetection) RemoteProcessGroupDetails(org.apache.nifi.action.component.details.RemoteProcessGroupDetails) ControllerService(org.apache.nifi.controller.ControllerService) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) InstantiatedVersionedProcessor(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessor) ExtensionManager(org.apache.nifi.nar.ExtensionManager) Tags(org.apache.nifi.annotation.documentation.Tags) AllowableValueEntity(org.apache.nifi.web.api.entity.AllowableValueEntity) ControllerServiceEntity(org.apache.nifi.web.api.entity.ControllerServiceEntity) RemoteProcessGroupCounts(org.apache.nifi.groups.RemoteProcessGroupCounts) ActionDTO(org.apache.nifi.web.api.dto.action.ActionDTO) Supplier(java.util.function.Supplier) LineageDTO(org.apache.nifi.web.api.dto.provenance.lineage.LineageDTO) LinkedHashMap(java.util.LinkedHashMap) Relationship(org.apache.nifi.processor.Relationship) ResourceClaim(org.apache.nifi.controller.repository.claim.ResourceClaim) ProcessGroupCounts(org.apache.nifi.groups.ProcessGroupCounts) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) JVMSystemDiagnosticsSnapshotDTO(org.apache.nifi.web.api.dto.diagnostics.JVMSystemDiagnosticsSnapshotDTO) Collator(java.text.Collator) Restricted(org.apache.nifi.annotation.behavior.Restricted) VersionedFlowState(org.apache.nifi.registry.flow.VersionedFlowState) ConnectionStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusSnapshotDTO) ProvenanceNodeDTO(org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceNodeDTO) ComponentDetailsDTO(org.apache.nifi.web.api.dto.action.component.details.ComponentDetailsDTO) RequestAction(org.apache.nifi.authorization.RequestAction) InstantiatedVersionedLabel(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedLabel) HistoryDTO(org.apache.nifi.web.api.dto.action.HistoryDTO) FlowChangeConnectDetails(org.apache.nifi.action.details.FlowChangeConnectDetails) ControllerServiceDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.ControllerServiceDiagnosticsDTO) TreeMap(java.util.TreeMap) RemoteProcessGroupDetailsDTO(org.apache.nifi.web.api.dto.action.component.details.RemoteProcessGroupDetailsDTO) ReportingTask(org.apache.nifi.reporting.ReportingTask) AffectedComponentEntity(org.apache.nifi.web.api.entity.AffectedComponentEntity) CoreAttributes(org.apache.nifi.flowfile.attributes.CoreAttributes) FlowFileQueue(org.apache.nifi.controller.queue.FlowFileQueue) FlowChangeConfigureDetails(org.apache.nifi.action.details.FlowChangeConfigureDetails) ProcessGroup(org.apache.nifi.groups.ProcessGroup) Date(java.util.Date) ConnectableType(org.apache.nifi.connectable.ConnectableType) ProcessorStatusDTO(org.apache.nifi.web.api.dto.status.ProcessorStatusDTO) InstantiatedVersionedRemoteGroupPort(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteGroupPort) SchedulingStrategy(org.apache.nifi.scheduling.SchedulingStrategy) RemoteProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO) Locale(java.util.Locale) VersionedComponent(org.apache.nifi.registry.flow.VersionedComponent) ConnectionStatusSnapshotEntity(org.apache.nifi.web.api.entity.ConnectionStatusSnapshotEntity) ActiveThreadInfo(org.apache.nifi.controller.ActiveThreadInfo) Label(org.apache.nifi.controller.label.Label) Authorizable(org.apache.nifi.authorization.resource.Authorizable) TimeZone(java.util.TimeZone) Collection(java.util.Collection) RemoteProcessGroupStatusSnapshotEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupStatusSnapshotEntity) ProcessorStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.ProcessorStatusSnapshotDTO) RevisionManager(org.apache.nifi.web.revision.RevisionManager) Snippet(org.apache.nifi.controller.Snippet) PortEntity(org.apache.nifi.web.api.entity.PortEntity) Collectors(java.util.stream.Collectors) StateMap(org.apache.nifi.components.state.StateMap) Processor(org.apache.nifi.processor.Processor) Entry(java.util.Map.Entry) ConnectionStatusDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusDTO) ProcessorNode(org.apache.nifi.controller.ProcessorNode) NodeHeartbeat(org.apache.nifi.cluster.coordination.heartbeat.NodeHeartbeat) ComputeLineageResult(org.apache.nifi.provenance.lineage.ComputeLineageResult) ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) ProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO) Group(org.apache.nifi.authorization.Group) BundleDetails(org.apache.nifi.bundle.BundleDetails) Function(java.util.function.Function) GarbageCollectionStatus(org.apache.nifi.controller.status.history.GarbageCollectionStatus) FlowRegistry(org.apache.nifi.registry.flow.FlowRegistry) HashSet(java.util.HashSet) ActionDetailsDTO(org.apache.nifi.web.api.dto.action.details.ActionDetailsDTO) ThreadDumpDTO(org.apache.nifi.web.api.dto.diagnostics.ThreadDumpDTO) GarbageCollection(org.apache.nifi.diagnostics.GarbageCollection) ReportingTaskNode(org.apache.nifi.controller.ReportingTaskNode) FlowBreadcrumbEntity(org.apache.nifi.web.api.entity.FlowBreadcrumbEntity) ValidationResult(org.apache.nifi.components.ValidationResult) PurgeDetailsDTO(org.apache.nifi.web.api.dto.action.details.PurgeDetailsDTO) JVMControllerDiagnosticsSnapshotDTO(org.apache.nifi.web.api.dto.diagnostics.JVMControllerDiagnosticsSnapshotDTO) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) FlowBreadcrumbDTO(org.apache.nifi.web.api.dto.flow.FlowBreadcrumbDTO) ProvenanceLinkDTO(org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceLinkDTO) ComputeLineageSubmission(org.apache.nifi.provenance.lineage.ComputeLineageSubmission) RemoteProcessGroupEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupEntity) NiFiUserUtils(org.apache.nifi.authorization.user.NiFiUserUtils) ProvenanceEventLineageNode(org.apache.nifi.provenance.lineage.ProvenanceEventLineageNode) BulletinRepository(org.apache.nifi.reporting.BulletinRepository) AccessPolicyEntity(org.apache.nifi.web.api.entity.AccessPolicyEntity) DigestUtils(org.apache.commons.codec.digest.DigestUtils) Comparator(java.util.Comparator) InstantiatedVersionedComponent(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedComponent) Bundle(org.apache.nifi.bundle.Bundle) StorageUsage(org.apache.nifi.diagnostics.StorageUsage) GCDiagnosticsSnapshotDTO(org.apache.nifi.web.api.dto.diagnostics.GCDiagnosticsSnapshotDTO) GarbageCollectionDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.GarbageCollectionDiagnosticsDTO) Arrays(java.util.Arrays) FlowChangePurgeDetails(org.apache.nifi.action.details.FlowChangePurgeDetails) PropertyDescriptor(org.apache.nifi.components.PropertyDescriptor) ClassLoaderDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.ClassLoaderDiagnosticsDTO) ProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.ProcessGroupStatusSnapshotDTO) ClassUtils(org.apache.commons.lang3.ClassUtils) TenantEntity(org.apache.nifi.web.api.entity.TenantEntity) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Connectable(org.apache.nifi.connectable.Connectable) Bulletin(org.apache.nifi.reporting.Bulletin) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus) Restriction(org.apache.nifi.annotation.behavior.Restriction) FlowFilePrioritizer(org.apache.nifi.flowfile.FlowFilePrioritizer) ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) History(org.apache.nifi.history.History) AccessPolicySummaryEntity(org.apache.nifi.web.api.entity.AccessPolicySummaryEntity) Set(java.util.Set) FlowChangeRemoteProcessGroupDetails(org.apache.nifi.action.component.details.FlowChangeRemoteProcessGroupDetails) StatusMerger(org.apache.nifi.cluster.manager.StatusMerger) FlowController(org.apache.nifi.controller.FlowController) ListFlowFileState(org.apache.nifi.controller.queue.ListFlowFileState) Stateful(org.apache.nifi.annotation.behavior.Stateful) ActionDetails(org.apache.nifi.action.details.ActionDetails) Position(org.apache.nifi.connectable.Position) ListFlowFileStatus(org.apache.nifi.controller.queue.ListFlowFileStatus) WebApplicationException(javax.ws.rs.WebApplicationException) ConnectionStatus(org.apache.nifi.controller.status.ConnectionStatus) LineageRequestDTO(org.apache.nifi.web.api.dto.provenance.lineage.LineageRequestDTO) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) Resource(org.apache.nifi.authorization.Resource) Counter(org.apache.nifi.controller.Counter) FlowFileRecord(org.apache.nifi.controller.repository.FlowFileRecord) InstantiatedVersionedProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup) NumberFormat(java.text.NumberFormat) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) NiFiUser(org.apache.nifi.authorization.user.NiFiUser) ControllerServiceProvider(org.apache.nifi.controller.service.ControllerServiceProvider) LineageEdge(org.apache.nifi.provenance.lineage.LineageEdge) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) ComponentDetails(org.apache.nifi.action.component.details.ComponentDetails) InstantiatedVersionedRemoteProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteProcessGroup) NodeConnectionStatus(org.apache.nifi.cluster.coordination.node.NodeConnectionStatus) LinkedHashSet(java.util.LinkedHashSet) ConfigureDetails(org.apache.nifi.action.details.ConfigureDetails) PurgeDetails(org.apache.nifi.action.details.PurgeDetails) ConfiguredComponent(org.apache.nifi.controller.ConfiguredComponent) MoveDetailsDTO(org.apache.nifi.web.api.dto.action.details.MoveDetailsDTO) InstantiatedVersionedControllerService(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedControllerService) DeprecationNotice(org.apache.nifi.annotation.documentation.DeprecationNotice) DropFlowFileState(org.apache.nifi.controller.queue.DropFlowFileState) Authorizer(org.apache.nifi.authorization.Authorizer) BulletinEntity(org.apache.nifi.web.api.entity.BulletinEntity) JVMFlowDiagnosticsSnapshotDTO(org.apache.nifi.web.api.dto.diagnostics.JVMFlowDiagnosticsSnapshotDTO) LineageResultsDTO(org.apache.nifi.web.api.dto.provenance.lineage.LineageResultsDTO) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) BundleCoordinate(org.apache.nifi.bundle.BundleCoordinate) Port(org.apache.nifi.connectable.Port) ConfigureDetailsDTO(org.apache.nifi.web.api.dto.action.details.ConfigureDetailsDTO) ComponentAuthorizable(org.apache.nifi.authorization.resource.ComponentAuthorizable) JVMDiagnosticsSnapshotDTO(org.apache.nifi.web.api.dto.diagnostics.JVMDiagnosticsSnapshotDTO) ProcessGroupStatusSnapshotEntity(org.apache.nifi.web.api.entity.ProcessGroupStatusSnapshotEntity) LineageNode(org.apache.nifi.provenance.lineage.LineageNode) DifferenceType(org.apache.nifi.registry.flow.diff.DifferenceType) SortedStateUtils(org.apache.nifi.controller.state.SortedStateUtils) Template(org.apache.nifi.controller.Template) InstantiatedVersionedConnection(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedConnection) GarbageCollectionHistory(org.apache.nifi.controller.status.history.GarbageCollectionHistory) User(org.apache.nifi.authorization.User) JVMDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.JVMDiagnosticsDTO) FlowChangeMoveDetails(org.apache.nifi.action.details.FlowChangeMoveDetails) PortStatusSnapshotEntity(org.apache.nifi.web.api.entity.PortStatusSnapshotEntity) SystemDiagnostics(org.apache.nifi.diagnostics.SystemDiagnostics) List(java.util.List) RepositoryUsageDTO(org.apache.nifi.web.api.dto.diagnostics.RepositoryUsageDTO) VersionControlInformation(org.apache.nifi.registry.flow.VersionControlInformation) MoveDetails(org.apache.nifi.action.details.MoveDetails) Action(org.apache.nifi.action.Action) InstantiatedVersionedPort(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedPort) ContentClaim(org.apache.nifi.controller.repository.claim.ContentClaim) Revision(org.apache.nifi.web.Revision) CapabilityDescription(org.apache.nifi.annotation.documentation.CapabilityDescription) Funnel(org.apache.nifi.connectable.Funnel) FlowFileSummary(org.apache.nifi.controller.queue.FlowFileSummary) VariableEntity(org.apache.nifi.web.api.entity.VariableEntity) FlowChangeExtensionDetails(org.apache.nifi.action.component.details.FlowChangeExtensionDetails) HashMap(java.util.HashMap) PortStatusDTO(org.apache.nifi.web.api.dto.status.PortStatusDTO) Iterator(java.util.Iterator) ProcessorDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.ProcessorDiagnosticsDTO) ExtensionDetails(org.apache.nifi.action.component.details.ExtensionDetails) TimeUnit(java.util.concurrent.TimeUnit) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) ComponentVariableRegistry(org.apache.nifi.registry.ComponentVariableRegistry) FlowDifference(org.apache.nifi.registry.flow.diff.FlowDifference) FormatUtils(org.apache.nifi.util.FormatUtils) ExtensionDetailsDTO(org.apache.nifi.web.api.dto.action.component.details.ExtensionDetailsDTO) AccessPolicy(org.apache.nifi.authorization.AccessPolicy) PortStatus(org.apache.nifi.controller.status.PortStatus) ConnectDetailsDTO(org.apache.nifi.web.api.dto.action.details.ConnectDetailsDTO) LineageRequestType(org.apache.nifi.web.api.dto.provenance.lineage.LineageRequestDTO.LineageRequestType) Collections(java.util.Collections) InstantiatedVersionedFunnel(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedFunnel) Funnel(org.apache.nifi.connectable.Funnel) InstantiatedVersionedRemoteGroupPort(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteGroupPort) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) InstantiatedVersionedPort(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedPort) PortStatusDTO(org.apache.nifi.web.api.dto.status.PortStatusDTO) InstantiatedVersionedLabel(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedLabel) Label(org.apache.nifi.controller.label.Label) BulletinEntity(org.apache.nifi.web.api.entity.BulletinEntity) ProcessorStatusDTO(org.apache.nifi.web.api.dto.status.ProcessorStatusDTO) ProcessorNode(org.apache.nifi.controller.ProcessorNode) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) InstantiatedVersionedRemoteProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteProcessGroup) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) ProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) Connection(org.apache.nifi.connectable.Connection) InstantiatedVersionedConnection(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedConnection) ConnectionStatusDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusDTO) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) InstantiatedVersionedProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup) InstantiatedVersionedRemoteProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteProcessGroup)

Example 3 with FlowDTO

use of org.apache.nifi.web.api.dto.flow.FlowDTO in project nifi by apache.

the class DtoFactory method createFlowDto.

public FlowDTO createFlowDto(final ProcessGroup group, final ProcessGroupStatus groupStatus, final RevisionManager revisionManager, final Function<ProcessGroup, List<BulletinEntity>> getProcessGroupBulletins) {
    final FlowDTO dto = new FlowDTO();
    for (final ProcessorNode procNode : group.getProcessors()) {
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(procNode.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(procNode);
        final ProcessorStatusDTO status = getComponentStatus(() -> groupStatus.getProcessorStatus().stream().filter(processorStatus -> procNode.getIdentifier().equals(processorStatus.getId())).findFirst().orElse(null), processorStatus -> createProcessorStatusDto(processorStatus));
        final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(procNode.getIdentifier()));
        final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
        dto.getProcessors().add(entityFactory.createProcessorEntity(createProcessorDto(procNode), revision, permissions, status, bulletinEntities));
    }
    for (final Connection connNode : group.getConnections()) {
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(connNode.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(connNode);
        final ConnectionStatusDTO status = getComponentStatus(() -> groupStatus.getConnectionStatus().stream().filter(connectionStatus -> connNode.getIdentifier().equals(connectionStatus.getId())).findFirst().orElse(null), connectionStatus -> createConnectionStatusDto(connectionStatus));
        dto.getConnections().add(entityFactory.createConnectionEntity(createConnectionDto(connNode), revision, permissions, status));
    }
    for (final Label label : group.getLabels()) {
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(label.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(label);
        dto.getLabels().add(entityFactory.createLabelEntity(createLabelDto(label), revision, permissions));
    }
    for (final Funnel funnel : group.getFunnels()) {
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(funnel.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(funnel);
        dto.getFunnels().add(entityFactory.createFunnelEntity(createFunnelDto(funnel), revision, permissions));
    }
    for (final ProcessGroup childGroup : group.getProcessGroups()) {
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(childGroup.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(childGroup);
        final ProcessGroupStatusDTO status = getComponentStatus(() -> groupStatus.getProcessGroupStatus().stream().filter(processGroupStatus -> childGroup.getIdentifier().equals(processGroupStatus.getId())).findFirst().orElse(null), processGroupStatus -> createConciseProcessGroupStatusDto(processGroupStatus));
        final List<BulletinEntity> bulletins = getProcessGroupBulletins.apply(childGroup);
        dto.getProcessGroups().add(entityFactory.createProcessGroupEntity(createProcessGroupDto(childGroup), revision, permissions, status, bulletins));
    }
    for (final RemoteProcessGroup rpg : group.getRemoteProcessGroups()) {
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(rpg.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(rpg);
        final RemoteProcessGroupStatusDTO status = getComponentStatus(() -> groupStatus.getRemoteProcessGroupStatus().stream().filter(remoteProcessGroupStatus -> rpg.getIdentifier().equals(remoteProcessGroupStatus.getId())).findFirst().orElse(null), remoteProcessGroupStatus -> createRemoteProcessGroupStatusDto(remoteProcessGroupStatus));
        final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(rpg.getIdentifier()));
        final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
        dto.getRemoteProcessGroups().add(entityFactory.createRemoteProcessGroupEntity(createRemoteProcessGroupDto(rpg), revision, permissions, status, bulletinEntities));
    }
    for (final Port inputPort : group.getInputPorts()) {
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(inputPort.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(inputPort);
        final PortStatusDTO status = getComponentStatus(() -> groupStatus.getInputPortStatus().stream().filter(inputPortStatus -> inputPort.getIdentifier().equals(inputPortStatus.getId())).findFirst().orElse(null), inputPortStatus -> createPortStatusDto(inputPortStatus));
        final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(inputPort.getIdentifier()));
        final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
        dto.getInputPorts().add(entityFactory.createPortEntity(createPortDto(inputPort), revision, permissions, status, bulletinEntities));
    }
    for (final Port outputPort : group.getOutputPorts()) {
        final RevisionDTO revision = createRevisionDTO(revisionManager.getRevision(outputPort.getIdentifier()));
        final PermissionsDTO permissions = createPermissionsDto(outputPort);
        final PortStatusDTO status = getComponentStatus(() -> groupStatus.getOutputPortStatus().stream().filter(outputPortStatus -> outputPort.getIdentifier().equals(outputPortStatus.getId())).findFirst().orElse(null), outputPortStatus -> createPortStatusDto(outputPortStatus));
        final List<BulletinDTO> bulletins = createBulletinDtos(bulletinRepository.findBulletinsForSource(outputPort.getIdentifier()));
        final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList());
        dto.getOutputPorts().add(entityFactory.createPortEntity(createPortDto(outputPort), revision, permissions, status, bulletinEntities));
    }
    return dto;
}
Also used : ProcessorStatusSnapshotEntity(org.apache.nifi.web.api.entity.ProcessorStatusSnapshotEntity) ConnectionDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.ConnectionDiagnosticsDTO) FlowComparison(org.apache.nifi.registry.flow.diff.FlowComparison) FlowModification(org.apache.nifi.web.FlowModification) StringUtils(org.apache.commons.lang3.StringUtils) DropFlowFileStatus(org.apache.nifi.controller.queue.DropFlowFileStatus) QueueSize(org.apache.nifi.controller.queue.QueueSize) ProcessorEntity(org.apache.nifi.web.api.entity.ProcessorEntity) VariableRegistryUpdateStep(org.apache.nifi.registry.variable.VariableRegistryUpdateStep) Scope(org.apache.nifi.components.state.Scope) ConnectDetails(org.apache.nifi.action.details.ConnectDetails) ControllerFacade(org.apache.nifi.web.controller.ControllerFacade) Map(java.util.Map) InstantiatedVersionedFunnel(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedFunnel) Connection(org.apache.nifi.connectable.Connection) NarClassLoaders(org.apache.nifi.nar.NarClassLoaders) FlowDifferenceFilters(org.apache.nifi.util.FlowDifferenceFilters) NodeEvent(org.apache.nifi.cluster.event.NodeEvent) VariableRegistryUpdateRequest(org.apache.nifi.registry.variable.VariableRegistryUpdateRequest) VersionedFlowStatus(org.apache.nifi.registry.flow.VersionedFlowStatus) AllowableValue(org.apache.nifi.components.AllowableValue) ComponentReferenceEntity(org.apache.nifi.web.api.entity.ComponentReferenceEntity) PortStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.PortStatusSnapshotDTO) AuthorizerCapabilityDetection(org.apache.nifi.authorization.AuthorizerCapabilityDetection) RemoteProcessGroupDetails(org.apache.nifi.action.component.details.RemoteProcessGroupDetails) ControllerService(org.apache.nifi.controller.ControllerService) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) InstantiatedVersionedProcessor(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessor) ExtensionManager(org.apache.nifi.nar.ExtensionManager) Tags(org.apache.nifi.annotation.documentation.Tags) AllowableValueEntity(org.apache.nifi.web.api.entity.AllowableValueEntity) ControllerServiceEntity(org.apache.nifi.web.api.entity.ControllerServiceEntity) RemoteProcessGroupCounts(org.apache.nifi.groups.RemoteProcessGroupCounts) ActionDTO(org.apache.nifi.web.api.dto.action.ActionDTO) Supplier(java.util.function.Supplier) LineageDTO(org.apache.nifi.web.api.dto.provenance.lineage.LineageDTO) LinkedHashMap(java.util.LinkedHashMap) Relationship(org.apache.nifi.processor.Relationship) ResourceClaim(org.apache.nifi.controller.repository.claim.ResourceClaim) ProcessGroupCounts(org.apache.nifi.groups.ProcessGroupCounts) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) JVMSystemDiagnosticsSnapshotDTO(org.apache.nifi.web.api.dto.diagnostics.JVMSystemDiagnosticsSnapshotDTO) Collator(java.text.Collator) Restricted(org.apache.nifi.annotation.behavior.Restricted) VersionedFlowState(org.apache.nifi.registry.flow.VersionedFlowState) ConnectionStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusSnapshotDTO) ProvenanceNodeDTO(org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceNodeDTO) ComponentDetailsDTO(org.apache.nifi.web.api.dto.action.component.details.ComponentDetailsDTO) RequestAction(org.apache.nifi.authorization.RequestAction) InstantiatedVersionedLabel(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedLabel) HistoryDTO(org.apache.nifi.web.api.dto.action.HistoryDTO) FlowChangeConnectDetails(org.apache.nifi.action.details.FlowChangeConnectDetails) ControllerServiceDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.ControllerServiceDiagnosticsDTO) TreeMap(java.util.TreeMap) RemoteProcessGroupDetailsDTO(org.apache.nifi.web.api.dto.action.component.details.RemoteProcessGroupDetailsDTO) ReportingTask(org.apache.nifi.reporting.ReportingTask) AffectedComponentEntity(org.apache.nifi.web.api.entity.AffectedComponentEntity) CoreAttributes(org.apache.nifi.flowfile.attributes.CoreAttributes) FlowFileQueue(org.apache.nifi.controller.queue.FlowFileQueue) FlowChangeConfigureDetails(org.apache.nifi.action.details.FlowChangeConfigureDetails) ProcessGroup(org.apache.nifi.groups.ProcessGroup) Date(java.util.Date) ConnectableType(org.apache.nifi.connectable.ConnectableType) ProcessorStatusDTO(org.apache.nifi.web.api.dto.status.ProcessorStatusDTO) InstantiatedVersionedRemoteGroupPort(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteGroupPort) SchedulingStrategy(org.apache.nifi.scheduling.SchedulingStrategy) RemoteProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO) Locale(java.util.Locale) VersionedComponent(org.apache.nifi.registry.flow.VersionedComponent) ConnectionStatusSnapshotEntity(org.apache.nifi.web.api.entity.ConnectionStatusSnapshotEntity) ActiveThreadInfo(org.apache.nifi.controller.ActiveThreadInfo) Label(org.apache.nifi.controller.label.Label) Authorizable(org.apache.nifi.authorization.resource.Authorizable) TimeZone(java.util.TimeZone) Collection(java.util.Collection) RemoteProcessGroupStatusSnapshotEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupStatusSnapshotEntity) ProcessorStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.ProcessorStatusSnapshotDTO) RevisionManager(org.apache.nifi.web.revision.RevisionManager) Snippet(org.apache.nifi.controller.Snippet) PortEntity(org.apache.nifi.web.api.entity.PortEntity) Collectors(java.util.stream.Collectors) StateMap(org.apache.nifi.components.state.StateMap) Processor(org.apache.nifi.processor.Processor) Entry(java.util.Map.Entry) ConnectionStatusDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusDTO) ProcessorNode(org.apache.nifi.controller.ProcessorNode) NodeHeartbeat(org.apache.nifi.cluster.coordination.heartbeat.NodeHeartbeat) ComputeLineageResult(org.apache.nifi.provenance.lineage.ComputeLineageResult) ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) ProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO) Group(org.apache.nifi.authorization.Group) BundleDetails(org.apache.nifi.bundle.BundleDetails) Function(java.util.function.Function) GarbageCollectionStatus(org.apache.nifi.controller.status.history.GarbageCollectionStatus) FlowRegistry(org.apache.nifi.registry.flow.FlowRegistry) HashSet(java.util.HashSet) ActionDetailsDTO(org.apache.nifi.web.api.dto.action.details.ActionDetailsDTO) ThreadDumpDTO(org.apache.nifi.web.api.dto.diagnostics.ThreadDumpDTO) GarbageCollection(org.apache.nifi.diagnostics.GarbageCollection) ReportingTaskNode(org.apache.nifi.controller.ReportingTaskNode) FlowBreadcrumbEntity(org.apache.nifi.web.api.entity.FlowBreadcrumbEntity) ValidationResult(org.apache.nifi.components.ValidationResult) PurgeDetailsDTO(org.apache.nifi.web.api.dto.action.details.PurgeDetailsDTO) JVMControllerDiagnosticsSnapshotDTO(org.apache.nifi.web.api.dto.diagnostics.JVMControllerDiagnosticsSnapshotDTO) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) FlowBreadcrumbDTO(org.apache.nifi.web.api.dto.flow.FlowBreadcrumbDTO) ProvenanceLinkDTO(org.apache.nifi.web.api.dto.provenance.lineage.ProvenanceLinkDTO) ComputeLineageSubmission(org.apache.nifi.provenance.lineage.ComputeLineageSubmission) RemoteProcessGroupEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupEntity) NiFiUserUtils(org.apache.nifi.authorization.user.NiFiUserUtils) ProvenanceEventLineageNode(org.apache.nifi.provenance.lineage.ProvenanceEventLineageNode) BulletinRepository(org.apache.nifi.reporting.BulletinRepository) AccessPolicyEntity(org.apache.nifi.web.api.entity.AccessPolicyEntity) DigestUtils(org.apache.commons.codec.digest.DigestUtils) Comparator(java.util.Comparator) InstantiatedVersionedComponent(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedComponent) Bundle(org.apache.nifi.bundle.Bundle) StorageUsage(org.apache.nifi.diagnostics.StorageUsage) GCDiagnosticsSnapshotDTO(org.apache.nifi.web.api.dto.diagnostics.GCDiagnosticsSnapshotDTO) GarbageCollectionDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.GarbageCollectionDiagnosticsDTO) Arrays(java.util.Arrays) FlowChangePurgeDetails(org.apache.nifi.action.details.FlowChangePurgeDetails) PropertyDescriptor(org.apache.nifi.components.PropertyDescriptor) ClassLoaderDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.ClassLoaderDiagnosticsDTO) ProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.ProcessGroupStatusSnapshotDTO) ClassUtils(org.apache.commons.lang3.ClassUtils) TenantEntity(org.apache.nifi.web.api.entity.TenantEntity) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Connectable(org.apache.nifi.connectable.Connectable) Bulletin(org.apache.nifi.reporting.Bulletin) ProcessorStatus(org.apache.nifi.controller.status.ProcessorStatus) Restriction(org.apache.nifi.annotation.behavior.Restriction) FlowFilePrioritizer(org.apache.nifi.flowfile.FlowFilePrioritizer) ProcessGroupStatus(org.apache.nifi.controller.status.ProcessGroupStatus) History(org.apache.nifi.history.History) AccessPolicySummaryEntity(org.apache.nifi.web.api.entity.AccessPolicySummaryEntity) Set(java.util.Set) FlowChangeRemoteProcessGroupDetails(org.apache.nifi.action.component.details.FlowChangeRemoteProcessGroupDetails) StatusMerger(org.apache.nifi.cluster.manager.StatusMerger) FlowController(org.apache.nifi.controller.FlowController) ListFlowFileState(org.apache.nifi.controller.queue.ListFlowFileState) Stateful(org.apache.nifi.annotation.behavior.Stateful) ActionDetails(org.apache.nifi.action.details.ActionDetails) Position(org.apache.nifi.connectable.Position) ListFlowFileStatus(org.apache.nifi.controller.queue.ListFlowFileStatus) WebApplicationException(javax.ws.rs.WebApplicationException) ConnectionStatus(org.apache.nifi.controller.status.ConnectionStatus) LineageRequestDTO(org.apache.nifi.web.api.dto.provenance.lineage.LineageRequestDTO) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) Resource(org.apache.nifi.authorization.Resource) Counter(org.apache.nifi.controller.Counter) FlowFileRecord(org.apache.nifi.controller.repository.FlowFileRecord) InstantiatedVersionedProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup) NumberFormat(java.text.NumberFormat) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) NiFiUser(org.apache.nifi.authorization.user.NiFiUser) ControllerServiceProvider(org.apache.nifi.controller.service.ControllerServiceProvider) LineageEdge(org.apache.nifi.provenance.lineage.LineageEdge) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) ComponentDetails(org.apache.nifi.action.component.details.ComponentDetails) InstantiatedVersionedRemoteProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteProcessGroup) NodeConnectionStatus(org.apache.nifi.cluster.coordination.node.NodeConnectionStatus) LinkedHashSet(java.util.LinkedHashSet) ConfigureDetails(org.apache.nifi.action.details.ConfigureDetails) PurgeDetails(org.apache.nifi.action.details.PurgeDetails) ConfiguredComponent(org.apache.nifi.controller.ConfiguredComponent) MoveDetailsDTO(org.apache.nifi.web.api.dto.action.details.MoveDetailsDTO) InstantiatedVersionedControllerService(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedControllerService) DeprecationNotice(org.apache.nifi.annotation.documentation.DeprecationNotice) DropFlowFileState(org.apache.nifi.controller.queue.DropFlowFileState) Authorizer(org.apache.nifi.authorization.Authorizer) BulletinEntity(org.apache.nifi.web.api.entity.BulletinEntity) JVMFlowDiagnosticsSnapshotDTO(org.apache.nifi.web.api.dto.diagnostics.JVMFlowDiagnosticsSnapshotDTO) LineageResultsDTO(org.apache.nifi.web.api.dto.provenance.lineage.LineageResultsDTO) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) BundleCoordinate(org.apache.nifi.bundle.BundleCoordinate) Port(org.apache.nifi.connectable.Port) ConfigureDetailsDTO(org.apache.nifi.web.api.dto.action.details.ConfigureDetailsDTO) ComponentAuthorizable(org.apache.nifi.authorization.resource.ComponentAuthorizable) JVMDiagnosticsSnapshotDTO(org.apache.nifi.web.api.dto.diagnostics.JVMDiagnosticsSnapshotDTO) ProcessGroupStatusSnapshotEntity(org.apache.nifi.web.api.entity.ProcessGroupStatusSnapshotEntity) LineageNode(org.apache.nifi.provenance.lineage.LineageNode) DifferenceType(org.apache.nifi.registry.flow.diff.DifferenceType) SortedStateUtils(org.apache.nifi.controller.state.SortedStateUtils) Template(org.apache.nifi.controller.Template) InstantiatedVersionedConnection(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedConnection) GarbageCollectionHistory(org.apache.nifi.controller.status.history.GarbageCollectionHistory) User(org.apache.nifi.authorization.User) JVMDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.JVMDiagnosticsDTO) FlowChangeMoveDetails(org.apache.nifi.action.details.FlowChangeMoveDetails) PortStatusSnapshotEntity(org.apache.nifi.web.api.entity.PortStatusSnapshotEntity) SystemDiagnostics(org.apache.nifi.diagnostics.SystemDiagnostics) List(java.util.List) RepositoryUsageDTO(org.apache.nifi.web.api.dto.diagnostics.RepositoryUsageDTO) VersionControlInformation(org.apache.nifi.registry.flow.VersionControlInformation) MoveDetails(org.apache.nifi.action.details.MoveDetails) Action(org.apache.nifi.action.Action) InstantiatedVersionedPort(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedPort) ContentClaim(org.apache.nifi.controller.repository.claim.ContentClaim) Revision(org.apache.nifi.web.Revision) CapabilityDescription(org.apache.nifi.annotation.documentation.CapabilityDescription) Funnel(org.apache.nifi.connectable.Funnel) FlowFileSummary(org.apache.nifi.controller.queue.FlowFileSummary) VariableEntity(org.apache.nifi.web.api.entity.VariableEntity) FlowChangeExtensionDetails(org.apache.nifi.action.component.details.FlowChangeExtensionDetails) HashMap(java.util.HashMap) PortStatusDTO(org.apache.nifi.web.api.dto.status.PortStatusDTO) Iterator(java.util.Iterator) ProcessorDiagnosticsDTO(org.apache.nifi.web.api.dto.diagnostics.ProcessorDiagnosticsDTO) ExtensionDetails(org.apache.nifi.action.component.details.ExtensionDetails) TimeUnit(java.util.concurrent.TimeUnit) RemoteProcessGroupStatus(org.apache.nifi.controller.status.RemoteProcessGroupStatus) ComponentVariableRegistry(org.apache.nifi.registry.ComponentVariableRegistry) FlowDifference(org.apache.nifi.registry.flow.diff.FlowDifference) FormatUtils(org.apache.nifi.util.FormatUtils) ExtensionDetailsDTO(org.apache.nifi.web.api.dto.action.component.details.ExtensionDetailsDTO) AccessPolicy(org.apache.nifi.authorization.AccessPolicy) PortStatus(org.apache.nifi.controller.status.PortStatus) ConnectDetailsDTO(org.apache.nifi.web.api.dto.action.details.ConnectDetailsDTO) LineageRequestType(org.apache.nifi.web.api.dto.provenance.lineage.LineageRequestDTO.LineageRequestType) Collections(java.util.Collections) InstantiatedVersionedFunnel(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedFunnel) Funnel(org.apache.nifi.connectable.Funnel) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) InstantiatedVersionedRemoteProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteProcessGroup) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) ProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.ProcessGroupStatusDTO) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) InstantiatedVersionedRemoteGroupPort(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteGroupPort) RemoteGroupPort(org.apache.nifi.remote.RemoteGroupPort) RootGroupPort(org.apache.nifi.remote.RootGroupPort) Port(org.apache.nifi.connectable.Port) InstantiatedVersionedPort(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedPort) Connection(org.apache.nifi.connectable.Connection) InstantiatedVersionedConnection(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedConnection) InstantiatedVersionedLabel(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedLabel) Label(org.apache.nifi.controller.label.Label) PortStatusDTO(org.apache.nifi.web.api.dto.status.PortStatusDTO) BulletinEntity(org.apache.nifi.web.api.entity.BulletinEntity) ProcessorStatusDTO(org.apache.nifi.web.api.dto.status.ProcessorStatusDTO) ProcessorNode(org.apache.nifi.controller.ProcessorNode) ConnectionStatusDTO(org.apache.nifi.web.api.dto.status.ConnectionStatusDTO) RemoteProcessGroup(org.apache.nifi.groups.RemoteProcessGroup) ProcessGroup(org.apache.nifi.groups.ProcessGroup) InstantiatedVersionedProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup) InstantiatedVersionedRemoteProcessGroup(org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteProcessGroup) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO)

Example 4 with FlowDTO

use of org.apache.nifi.web.api.dto.flow.FlowDTO in project nifi by apache.

the class ProcessGroupResource method instantiateTemplate.

/**
 * Instantiates the specified template within this ProcessGroup. The template instance that is instantiated cannot be referenced at a later time, therefore there is no
 * corresponding URI. Instead the request URI is returned.
 * <p>
 * Alternatively, we could have performed a PUT request. However, PUT requests are supposed to be idempotent and this endpoint is certainly not.
 *
 * @param httpServletRequest               request
 * @param groupId                          The group id
 * @param requestInstantiateTemplateRequestEntity The instantiate template request
 * @return A flowEntity.
 */
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/template-instance")
@ApiOperation(value = "Instantiates a template", response = FlowEntity.class, authorizations = { @Authorization(value = "Write - /process-groups/{uuid}"), @Authorization(value = "Read - /templates/{uuid}"), @Authorization(value = "Write - if the template contains any restricted components - /restricted-components") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response instantiateTemplate(@Context HttpServletRequest httpServletRequest, @ApiParam(value = "The process group id.", required = true) @PathParam("id") String groupId, @ApiParam(value = "The instantiate template request.", required = true) InstantiateTemplateRequestEntity requestInstantiateTemplateRequestEntity) {
    // ensure the position has been specified
    if (requestInstantiateTemplateRequestEntity == null || requestInstantiateTemplateRequestEntity.getOriginX() == null || requestInstantiateTemplateRequestEntity.getOriginY() == null) {
        throw new IllegalArgumentException("The origin position (x, y) must be specified.");
    }
    // ensure the template id was provided
    if (requestInstantiateTemplateRequestEntity.getTemplateId() == null) {
        throw new IllegalArgumentException("The template id must be specified.");
    }
    // ensure the template encoding version is valid
    if (requestInstantiateTemplateRequestEntity.getEncodingVersion() != null) {
        try {
            FlowEncodingVersion.parse(requestInstantiateTemplateRequestEntity.getEncodingVersion());
        } catch (final IllegalArgumentException e) {
            throw new IllegalArgumentException("The template encoding version is not valid. The expected format is <number>.<number>");
        }
    }
    // populate the encoding version if necessary
    if (requestInstantiateTemplateRequestEntity.getEncodingVersion() == null) {
        // if the encoding version is not specified, use the latest encoding version as these options were
        // not available pre 1.x, will be overridden if populating from the underlying template below
        requestInstantiateTemplateRequestEntity.setEncodingVersion(TemplateDTO.MAX_ENCODING_VERSION);
    }
    // populate the component bundles if necessary
    if (requestInstantiateTemplateRequestEntity.getSnippet() == null) {
        // get the desired template in order to determine the supported bundles
        final TemplateDTO requestedTemplate = serviceFacade.exportTemplate(requestInstantiateTemplateRequestEntity.getTemplateId());
        final FlowSnippetDTO requestTemplateContents = requestedTemplate.getSnippet();
        // determine the compatible bundles to use for each component in this template, this ensures the nodes in the cluster
        // instantiate the components from the same bundles
        discoverCompatibleBundles(requestTemplateContents);
        // update the requested template as necessary - use the encoding version from the underlying template
        requestInstantiateTemplateRequestEntity.setEncodingVersion(requestedTemplate.getEncodingVersion());
        requestInstantiateTemplateRequestEntity.setSnippet(requestTemplateContents);
    }
    if (isReplicateRequest()) {
        return replicate(HttpMethod.POST, requestInstantiateTemplateRequestEntity);
    }
    return withWriteLock(serviceFacade, requestInstantiateTemplateRequestEntity, lookup -> {
        final NiFiUser user = NiFiUserUtils.getNiFiUser();
        // ensure write on the group
        final Authorizable processGroup = lookup.getProcessGroup(groupId).getAuthorizable();
        processGroup.authorize(authorizer, RequestAction.WRITE, user);
        final Authorizable template = lookup.getTemplate(requestInstantiateTemplateRequestEntity.getTemplateId());
        template.authorize(authorizer, RequestAction.READ, user);
        // ensure read on the template
        final TemplateContentsAuthorizable templateContents = lookup.getTemplateContents(requestInstantiateTemplateRequestEntity.getSnippet());
        final Consumer<ComponentAuthorizable> authorizeRestricted = authorizable -> {
            if (authorizable.isRestricted()) {
                authorizeRestrictions(authorizer, authorizable);
            }
        };
        // ensure restricted access if necessary
        templateContents.getEncapsulatedProcessors().forEach(authorizeRestricted);
        templateContents.getEncapsulatedControllerServices().forEach(authorizeRestricted);
    }, () -> serviceFacade.verifyComponentTypes(requestInstantiateTemplateRequestEntity.getSnippet()), instantiateTemplateRequestEntity -> {
        // create the template and generate the json
        final FlowEntity entity = serviceFacade.createTemplateInstance(groupId, instantiateTemplateRequestEntity.getOriginX(), instantiateTemplateRequestEntity.getOriginY(), instantiateTemplateRequestEntity.getEncodingVersion(), instantiateTemplateRequestEntity.getSnippet(), getIdGenerationSeed().orElse(null));
        final FlowDTO flowSnippet = entity.getFlow();
        // prune response as necessary
        for (ProcessGroupEntity childGroupEntity : flowSnippet.getProcessGroups()) {
            childGroupEntity.getComponent().setContents(null);
        }
        // create the response entity
        populateRemainingSnippetContent(flowSnippet);
        // generate the response
        return generateCreatedResponse(getAbsolutePath(), entity).build();
    });
}
Also used : ComponentAuthorizable(org.apache.nifi.authorization.ComponentAuthorizable) FunnelsEntity(org.apache.nifi.web.api.entity.FunnelsEntity) Produces(javax.ws.rs.Produces) InstantiateTemplateRequestEntity(org.apache.nifi.web.api.entity.InstantiateTemplateRequestEntity) ApiParam(io.swagger.annotations.ApiParam) SiteToSiteRestApiClient(org.apache.nifi.remote.util.SiteToSiteRestApiClient) ConnectionDTO(org.apache.nifi.web.api.dto.ConnectionDTO) ComponentAuthorizable(org.apache.nifi.authorization.ComponentAuthorizable) StringUtils(org.apache.commons.lang3.StringUtils) ClientIdParameter(org.apache.nifi.web.api.request.ClientIdParameter) ProcessorEntity(org.apache.nifi.web.api.entity.ProcessorEntity) AuthorizeAccess(org.apache.nifi.authorization.AuthorizeAccess) VariableRegistryUpdateStep(org.apache.nifi.registry.variable.VariableRegistryUpdateStep) PositionDTO(org.apache.nifi.web.api.dto.PositionDTO) MediaType(javax.ws.rs.core.MediaType) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) NiFiRegistryException(org.apache.nifi.registry.client.NiFiRegistryException) Map(java.util.Map) ResourceNotFoundException(org.apache.nifi.web.ResourceNotFoundException) UriBuilder(javax.ws.rs.core.UriBuilder) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) ConnectionsEntity(org.apache.nifi.web.api.entity.ConnectionsEntity) FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) VariableRegistryUpdateRequest(org.apache.nifi.registry.variable.VariableRegistryUpdateRequest) ControllerServicesEntity(org.apache.nifi.web.api.entity.ControllerServicesEntity) Set(java.util.Set) InputPortsEntity(org.apache.nifi.web.api.entity.InputPortsEntity) Executors(java.util.concurrent.Executors) ArrayBlockingQueue(java.util.concurrent.ArrayBlockingQueue) FormDataParam(org.glassfish.jersey.media.multipart.FormDataParam) ProcessGroupsEntity(org.apache.nifi.web.api.entity.ProcessGroupsEntity) FlowComparisonEntity(org.apache.nifi.web.api.entity.FlowComparisonEntity) ScheduledState(org.apache.nifi.controller.ScheduledState) LabelsEntity(org.apache.nifi.web.api.entity.LabelsEntity) UriInfo(javax.ws.rs.core.UriInfo) ApiImplicitParams(io.swagger.annotations.ApiImplicitParams) DtoFactory(org.apache.nifi.web.api.dto.DtoFactory) Entity(org.apache.nifi.web.api.entity.Entity) GET(javax.ws.rs.GET) ControllerServiceEntity(org.apache.nifi.web.api.entity.ControllerServiceEntity) ConfigurableComponent(org.apache.nifi.components.ConfigurableComponent) TemplateEntity(org.apache.nifi.web.api.entity.TemplateEntity) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) HttpMethod(javax.ws.rs.HttpMethod) HttpServletRequest(javax.servlet.http.HttpServletRequest) NiFiUser(org.apache.nifi.authorization.user.NiFiUser) NiFiUserDetails(org.apache.nifi.authorization.user.NiFiUserDetails) Api(io.swagger.annotations.Api) VariableRegistryDTO(org.apache.nifi.web.api.dto.VariableRegistryDTO) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) VersionedFlowState(org.apache.nifi.registry.flow.VersionedFlowState) NiFiServiceFacade(org.apache.nifi.web.NiFiServiceFacade) AuthorizableLookup(org.apache.nifi.authorization.AuthorizableLookup) RequestAction(org.apache.nifi.authorization.RequestAction) FlowEncodingVersion(org.apache.nifi.controller.serialization.FlowEncodingVersion) JAXBElement(javax.xml.bind.JAXBElement) RemoteProcessGroupsEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupsEntity) IOException(java.io.IOException) VersionedFlowSnapshot(org.apache.nifi.registry.flow.VersionedFlowSnapshot) Authorizer(org.apache.nifi.authorization.Authorizer) ApiResponse(io.swagger.annotations.ApiResponse) FlowEntity(org.apache.nifi.web.api.entity.FlowEntity) AffectedComponentEntity(org.apache.nifi.web.api.entity.AffectedComponentEntity) OutputPortsEntity(org.apache.nifi.web.api.entity.OutputPortsEntity) ScheduleComponentsEntity(org.apache.nifi.web.api.entity.ScheduleComponentsEntity) XmlUtils(org.apache.nifi.security.xml.XmlUtils) BundleCoordinate(org.apache.nifi.bundle.BundleCoordinate) ProcessorConfigDTO(org.apache.nifi.web.api.dto.ProcessorConfigDTO) Date(java.util.Date) ConnectableType(org.apache.nifi.connectable.ConnectableType) ProcessorStatusDTO(org.apache.nifi.web.api.dto.status.ProcessorStatusDTO) URISyntaxException(java.net.URISyntaxException) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) BundleDTO(org.apache.nifi.web.api.dto.BundleDTO) ApiOperation(io.swagger.annotations.ApiOperation) AuthorizeControllerServiceReference(org.apache.nifi.authorization.AuthorizeControllerServiceReference) QueryParam(javax.ws.rs.QueryParam) Consumes(javax.ws.rs.Consumes) TemplateDTO(org.apache.nifi.web.api.dto.TemplateDTO) ActivateControllerServicesEntity(org.apache.nifi.web.api.entity.ActivateControllerServicesEntity) XMLStreamReader(javax.xml.stream.XMLStreamReader) DefaultValue(javax.ws.rs.DefaultValue) URI(java.net.URI) ThreadFactory(java.util.concurrent.ThreadFactory) NodeResponse(org.apache.nifi.cluster.manager.NodeResponse) DELETE(javax.ws.rs.DELETE) Context(javax.ws.rs.core.Context) Authorizable(org.apache.nifi.authorization.resource.Authorizable) ControllerServiceDTO(org.apache.nifi.web.api.dto.ControllerServiceDTO) ApiImplicitParam(io.swagger.annotations.ApiImplicitParam) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SnippetAuthorizable(org.apache.nifi.authorization.SnippetAuthorizable) UUID(java.util.UUID) BundleUtils(org.apache.nifi.util.BundleUtils) PortEntity(org.apache.nifi.web.api.entity.PortEntity) LongParameter(org.apache.nifi.web.api.request.LongParameter) JAXBException(javax.xml.bind.JAXBException) Collectors(java.util.stream.Collectors) List(java.util.List) Response(javax.ws.rs.core.Response) ProcessGroupEntity(org.apache.nifi.web.api.entity.ProcessGroupEntity) ProcessorDTO(org.apache.nifi.web.api.dto.ProcessorDTO) ControllerServiceState(org.apache.nifi.controller.service.ControllerServiceState) CopySnippetRequestEntity(org.apache.nifi.web.api.entity.CopySnippetRequestEntity) Authentication(org.springframework.security.core.Authentication) Pause(org.apache.nifi.web.util.Pause) FlowSnippetDTO(org.apache.nifi.web.api.dto.FlowSnippetDTO) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) PathParam(javax.ws.rs.PathParam) Bucket(org.apache.nifi.registry.bucket.Bucket) Revision(org.apache.nifi.web.Revision) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) HashMap(java.util.HashMap) ApiResponses(io.swagger.annotations.ApiResponses) Function(java.util.function.Function) AffectedComponentDTO(org.apache.nifi.web.api.dto.AffectedComponentDTO) ConcurrentMap(java.util.concurrent.ConcurrentMap) FlowRegistryUtils(org.apache.nifi.registry.flow.FlowRegistryUtils) CreateTemplateRequestEntity(org.apache.nifi.web.api.entity.CreateTemplateRequestEntity) VersionControlInformationDTO(org.apache.nifi.web.api.dto.VersionControlInformationDTO) VariableRegistryUpdateRequestEntity(org.apache.nifi.web.api.entity.VariableRegistryUpdateRequestEntity) NiFiAuthenticationToken(org.apache.nifi.web.security.token.NiFiAuthenticationToken) Status(javax.ws.rs.core.Response.Status) JAXBContext(javax.xml.bind.JAXBContext) ExecutorService(java.util.concurrent.ExecutorService) Unmarshaller(javax.xml.bind.Unmarshaller) TemplateContentsAuthorizable(org.apache.nifi.authorization.TemplateContentsAuthorizable) Logger(org.slf4j.Logger) POST(javax.ws.rs.POST) ProcessorsEntity(org.apache.nifi.web.api.entity.ProcessorsEntity) VariableRegistryEntity(org.apache.nifi.web.api.entity.VariableRegistryEntity) VersionedFlow(org.apache.nifi.registry.flow.VersionedFlow) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) LabelEntity(org.apache.nifi.web.api.entity.LabelEntity) ConnectionEntity(org.apache.nifi.web.api.entity.ConnectionEntity) ProcessGroupAuthorizable(org.apache.nifi.authorization.ProcessGroupAuthorizable) RemoteProcessGroupEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupEntity) NiFiUserUtils(org.apache.nifi.authorization.user.NiFiUserUtils) PUT(javax.ws.rs.PUT) Authorization(io.swagger.annotations.Authorization) Collections(java.util.Collections) InputStream(java.io.InputStream) ProcessGroupEntity(org.apache.nifi.web.api.entity.ProcessGroupEntity) RemoteProcessGroupEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupEntity) FlowSnippetDTO(org.apache.nifi.web.api.dto.FlowSnippetDTO) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) NiFiUser(org.apache.nifi.authorization.user.NiFiUser) TemplateDTO(org.apache.nifi.web.api.dto.TemplateDTO) ComponentAuthorizable(org.apache.nifi.authorization.ComponentAuthorizable) Authorizable(org.apache.nifi.authorization.resource.Authorizable) SnippetAuthorizable(org.apache.nifi.authorization.SnippetAuthorizable) TemplateContentsAuthorizable(org.apache.nifi.authorization.TemplateContentsAuthorizable) ProcessGroupAuthorizable(org.apache.nifi.authorization.ProcessGroupAuthorizable) TemplateContentsAuthorizable(org.apache.nifi.authorization.TemplateContentsAuthorizable) FlowEntity(org.apache.nifi.web.api.entity.FlowEntity) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 5 with FlowDTO

use of org.apache.nifi.web.api.dto.flow.FlowDTO in project nifi by apache.

the class PGList method doExecute.

@Override
public ProcessGroupsResult doExecute(final NiFiClient client, final Properties properties) throws NiFiClientException, IOException {
    final FlowClient flowClient = client.getFlowClient();
    // get the optional id of the parent PG, otherwise fallback to the root group
    String parentPgId = getArg(properties, CommandOption.PG_ID);
    if (StringUtils.isBlank(parentPgId)) {
        parentPgId = flowClient.getRootGroupId();
    }
    final ProcessGroupFlowEntity processGroupFlowEntity = flowClient.getProcessGroup(parentPgId);
    final ProcessGroupFlowDTO processGroupFlowDTO = processGroupFlowEntity.getProcessGroupFlow();
    final FlowDTO flowDTO = processGroupFlowDTO.getFlow();
    final List<ProcessGroupDTO> processGroups = new ArrayList<>();
    if (flowDTO.getProcessGroups() != null) {
        flowDTO.getProcessGroups().stream().map(pge -> pge.getComponent()).forEach(dto -> processGroups.add(dto));
    }
    return new ProcessGroupsResult(getResultType(properties), processGroups);
}
Also used : Properties(java.util.Properties) NiFiClientException(org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClientException) CommandOption(org.apache.nifi.toolkit.cli.impl.command.CommandOption) AbstractNiFiCommand(org.apache.nifi.toolkit.cli.impl.command.nifi.AbstractNiFiCommand) IOException(java.io.IOException) StringUtils(org.apache.commons.lang3.StringUtils) Context(org.apache.nifi.toolkit.cli.api.Context) ArrayList(java.util.ArrayList) NiFiClient(org.apache.nifi.toolkit.cli.impl.client.nifi.NiFiClient) List(java.util.List) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) ProcessGroupsResult(org.apache.nifi.toolkit.cli.impl.result.ProcessGroupsResult) FlowClient(org.apache.nifi.toolkit.cli.impl.client.nifi.FlowClient) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupsResult(org.apache.nifi.toolkit.cli.impl.result.ProcessGroupsResult) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity) ArrayList(java.util.ArrayList) ProcessGroupDTO(org.apache.nifi.web.api.dto.ProcessGroupDTO) FlowClient(org.apache.nifi.toolkit.cli.impl.client.nifi.FlowClient)

Aggregations

FlowDTO (org.apache.nifi.web.api.dto.flow.FlowDTO)20 ProcessGroupFlowEntity (org.apache.nifi.web.api.entity.ProcessGroupFlowEntity)13 Response (javax.ws.rs.core.Response)10 Map (java.util.Map)8 PortEntity (org.apache.nifi.web.api.entity.PortEntity)8 ProcessorEntity (org.apache.nifi.web.api.entity.ProcessorEntity)8 HashMap (java.util.HashMap)7 List (java.util.List)7 Set (java.util.Set)7 Collections (java.util.Collections)6 Collectors (java.util.stream.Collectors)6 StringUtils (org.apache.commons.lang3.StringUtils)6 FlowEntity (org.apache.nifi.web.api.entity.FlowEntity)6 ArrayList (java.util.ArrayList)5 Collection (java.util.Collection)5 Date (java.util.Date)5 Function (java.util.function.Function)5 Authorizer (org.apache.nifi.authorization.Authorizer)5 RequestAction (org.apache.nifi.authorization.RequestAction)5 Authorizable (org.apache.nifi.authorization.resource.Authorizable)5