Search in sources :

Example 6 with FlowDTO

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

the class ITFunnelAccessControl method getRandomFunnel.

private FunnelEntity getRandomFunnel(final NiFiTestUser user) throws Exception {
    final String url = helper.getBaseUrl() + "/flow/process-groups/root";
    // get the flow
    final Response response = user.testGet(url);
    // ensure the response was successful
    assertEquals(200, response.getStatus());
    // unmarshal
    final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class);
    final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow();
    final Set<FunnelEntity> funnels = flowDto.getFunnels();
    // ensure the correct number of funnels
    assertFalse(funnels.isEmpty());
    // use the first funnel as the target
    Iterator<FunnelEntity> funnelIter = funnels.iterator();
    assertTrue(funnelIter.hasNext());
    return funnelIter.next();
}
Also used : Response(javax.ws.rs.core.Response) FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity)

Example 7 with FlowDTO

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

the class ITLabelAccessControl method getRandomLabel.

private LabelEntity getRandomLabel(final NiFiTestUser user) throws Exception {
    final String url = helper.getBaseUrl() + "/flow/process-groups/root";
    // get the labels
    final Response response = user.testGet(url);
    // ensure the response was successful
    assertEquals(200, response.getStatus());
    // unmarshal
    final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class);
    final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow();
    final Set<LabelEntity> labels = flowDto.getLabels();
    // ensure the correct number of labels
    assertFalse(labels.isEmpty());
    // use the first label as the target
    Iterator<LabelEntity> labelIter = labels.iterator();
    assertTrue(labelIter.hasNext());
    return labelIter.next();
}
Also used : Response(javax.ws.rs.core.Response) LabelEntity(org.apache.nifi.web.api.entity.LabelEntity) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity)

Example 8 with FlowDTO

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

the class ITOutputPortAccessControl method getRandomOutputPort.

private PortEntity getRandomOutputPort(final NiFiTestUser user) throws Exception {
    final String url = helper.getBaseUrl() + "/flow/process-groups/root";
    // get the output ports
    final Response response = user.testGet(url);
    // ensure the response was successful
    assertEquals(200, response.getStatus());
    // unmarshal
    final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class);
    final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow();
    final Set<PortEntity> outputPorts = flowDto.getOutputPorts();
    // ensure the correct number of output ports
    assertFalse(outputPorts.isEmpty());
    // use the first output port as the target
    Iterator<PortEntity> outputPortIter = outputPorts.iterator();
    assertTrue(outputPortIter.hasNext());
    return outputPortIter.next();
}
Also used : Response(javax.ws.rs.core.Response) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity) PortEntity(org.apache.nifi.web.api.entity.PortEntity)

Example 9 with FlowDTO

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

the class ITProcessGroupAccessControl method getRandomProcessGroup.

private ProcessGroupEntity getRandomProcessGroup(final NiFiTestUser user) throws Exception {
    final String url = helper.getBaseUrl() + "/flow/process-groups/root";
    // get the process groups
    final Response response = user.testGet(url);
    // ensure the response was successful
    assertEquals(200, response.getStatus());
    // unmarshal
    final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class);
    final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow();
    final Set<ProcessGroupEntity> processGroups = flowDto.getProcessGroups();
    // ensure the correct number of process groups
    assertFalse(processGroups.isEmpty());
    // use the first process group as the target
    Iterator<ProcessGroupEntity> processGroupIter = processGroups.iterator();
    assertTrue(processGroupIter.hasNext());
    return processGroupIter.next();
}
Also used : Response(javax.ws.rs.core.Response) ProcessGroupEntity(org.apache.nifi.web.api.entity.ProcessGroupEntity) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity)

Example 10 with FlowDTO

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

the class FlowMerger method mergeResponses.

@Override
protected void mergeResponses(final ProcessGroupFlowDTO clientDto, final Map<NodeIdentifier, ProcessGroupFlowDTO> dtoMap, final Set<NodeResponse> successfulResponses, final Set<NodeResponse> problematicResponses) {
    final FlowDTO flowDto = clientDto.getFlow();
    final Set<ConnectionEntity> clientConnections = flowDto.getConnections();
    final Set<ProcessorEntity> clientProcessors = flowDto.getProcessors();
    final Set<PortEntity> clientInputPorts = flowDto.getInputPorts();
    final Set<PortEntity> clientOutputPorts = flowDto.getOutputPorts();
    final Set<RemoteProcessGroupEntity> clientRemoteProcessGroups = flowDto.getRemoteProcessGroups();
    final Set<ProcessGroupEntity> clientProcessGroups = flowDto.getProcessGroups();
    final Set<LabelEntity> clientLabels = flowDto.getLabels();
    final Set<FunnelEntity> clientFunnels = flowDto.getFunnels();
    final Map<String, Map<NodeIdentifier, ConnectionEntity>> connections = new HashMap<>();
    final Map<String, Map<NodeIdentifier, FunnelEntity>> funnels = new HashMap<>();
    final Map<String, Map<NodeIdentifier, PortEntity>> inputPorts = new HashMap<>();
    final Map<String, Map<NodeIdentifier, LabelEntity>> labels = new HashMap<>();
    final Map<String, Map<NodeIdentifier, PortEntity>> outputPorts = new HashMap<>();
    final Map<String, Map<NodeIdentifier, ProcessorEntity>> processors = new HashMap<>();
    final Map<String, Map<NodeIdentifier, RemoteProcessGroupEntity>> rpgs = new HashMap<>();
    final Map<String, Map<NodeIdentifier, ProcessGroupEntity>> processGroups = new HashMap<>();
    // Create mapping of ComponentID -> [nodeId, entity on that node]
    for (final Map.Entry<NodeIdentifier, ProcessGroupFlowDTO> nodeGroupFlowEntry : dtoMap.entrySet()) {
        final NodeIdentifier nodeIdentifier = nodeGroupFlowEntry.getKey();
        final ProcessGroupFlowDTO nodeGroupFlowDto = nodeGroupFlowEntry.getValue();
        final FlowDTO nodeFlowDto = nodeGroupFlowDto.getFlow();
        // Merge connection statuses
        for (final ConnectionEntity entity : nodeFlowDto.getConnections()) {
            connections.computeIfAbsent(entity.getId(), id -> new HashMap<>()).computeIfAbsent(nodeIdentifier, nodeId -> entity);
        }
        for (final FunnelEntity entity : nodeFlowDto.getFunnels()) {
            funnels.computeIfAbsent(entity.getId(), id -> new HashMap<>()).computeIfAbsent(nodeIdentifier, nodeId -> entity);
        }
        for (final PortEntity entity : nodeFlowDto.getInputPorts()) {
            inputPorts.computeIfAbsent(entity.getId(), id -> new HashMap<>()).computeIfAbsent(nodeIdentifier, nodeId -> entity);
        }
        for (final PortEntity entity : nodeFlowDto.getOutputPorts()) {
            outputPorts.computeIfAbsent(entity.getId(), id -> new HashMap<>()).computeIfAbsent(nodeIdentifier, nodeId -> entity);
        }
        for (final LabelEntity entity : nodeFlowDto.getLabels()) {
            labels.computeIfAbsent(entity.getId(), id -> new HashMap<>()).computeIfAbsent(nodeIdentifier, nodeId -> entity);
        }
        for (final ProcessorEntity entity : nodeFlowDto.getProcessors()) {
            processors.computeIfAbsent(entity.getId(), id -> new HashMap<>()).computeIfAbsent(nodeIdentifier, nodeId -> entity);
        }
        for (final RemoteProcessGroupEntity entity : nodeFlowDto.getRemoteProcessGroups()) {
            rpgs.computeIfAbsent(entity.getId(), id -> new HashMap<>()).computeIfAbsent(nodeIdentifier, nodeId -> entity);
        }
        for (final ProcessGroupEntity entity : nodeFlowDto.getProcessGroups()) {
            processGroups.computeIfAbsent(entity.getId(), id -> new HashMap<>()).computeIfAbsent(nodeIdentifier, nodeId -> entity);
        }
    }
    // 
    // Merge the components that are grouped together by ID
    // 
    // Merge connections
    ConnectionsEntityMerger.mergeConnections(clientConnections, connections);
    // Merge funnel statuses
    FunnelsEntityMerger.mergeFunnels(clientFunnels, funnels);
    // Merge input ports
    PortsEntityMerger.mergePorts(clientInputPorts, inputPorts);
    // Merge output ports
    PortsEntityMerger.mergePorts(clientOutputPorts, outputPorts);
    // Merge labels
    LabelsEntityMerger.mergeLabels(clientLabels, labels);
    // Merge processors
    ProcessorsEntityMerger.mergeProcessors(clientProcessors, processors);
    // Merge Remote Process Groups
    RemoteProcessGroupsEntityMerger.mergeRemoteProcessGroups(clientRemoteProcessGroups, rpgs);
    // Merge Process Groups
    ProcessGroupsEntityMerger.mergeProcessGroups(clientProcessGroups, processGroups);
}
Also used : LabelsEntityMerger(org.apache.nifi.cluster.manager.LabelsEntityMerger) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) ConnectionsEntityMerger(org.apache.nifi.cluster.manager.ConnectionsEntityMerger) RemoteProcessGroupsEntityMerger(org.apache.nifi.cluster.manager.RemoteProcessGroupsEntityMerger) FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) ProcessGroupsEntityMerger(org.apache.nifi.cluster.manager.ProcessGroupsEntityMerger) FunnelsEntityMerger(org.apache.nifi.cluster.manager.FunnelsEntityMerger) Set(java.util.Set) HashMap(java.util.HashMap) PortEntity(org.apache.nifi.web.api.entity.PortEntity) ProcessorEntity(org.apache.nifi.web.api.entity.ProcessorEntity) PortsEntityMerger(org.apache.nifi.cluster.manager.PortsEntityMerger) LabelEntity(org.apache.nifi.web.api.entity.LabelEntity) ConnectionEntity(org.apache.nifi.web.api.entity.ConnectionEntity) RemoteProcessGroupEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupEntity) ProcessGroupEntity(org.apache.nifi.web.api.entity.ProcessGroupEntity) Map(java.util.Map) ProcessGroupFlowEntity(org.apache.nifi.web.api.entity.ProcessGroupFlowEntity) ProcessorsEntityMerger(org.apache.nifi.cluster.manager.ProcessorsEntityMerger) ProcessGroupFlowDTO(org.apache.nifi.web.api.dto.flow.ProcessGroupFlowDTO) URI(java.net.URI) Pattern(java.util.regex.Pattern) FlowDTO(org.apache.nifi.web.api.dto.flow.FlowDTO) NodeResponse(org.apache.nifi.cluster.manager.NodeResponse) RemoteProcessGroupEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupEntity) ProcessGroupEntity(org.apache.nifi.web.api.entity.ProcessGroupEntity) HashMap(java.util.HashMap) ProcessorEntity(org.apache.nifi.web.api.entity.ProcessorEntity) RemoteProcessGroupEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupEntity) FunnelEntity(org.apache.nifi.web.api.entity.FunnelEntity) ConnectionEntity(org.apache.nifi.web.api.entity.ConnectionEntity) PortEntity(org.apache.nifi.web.api.entity.PortEntity) 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) LabelEntity(org.apache.nifi.web.api.entity.LabelEntity) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) HashMap(java.util.HashMap) Map(java.util.Map)

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