Java Code Examples for org.apache.nifi.groups.ProcessGroup#findProcessGroup()

The following examples show how to use org.apache.nifi.groups.ProcessGroup#findProcessGroup() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ControllerFacade.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the status history for the specified process group.
 *
 * @param groupId group id
 * @return status history
 */
public StatusHistoryDTO getProcessGroupStatusHistory(final String groupId) {
    final String searchId = groupId.equals(ROOT_GROUP_ID_ALIAS) ? flowController.getRootGroupId() : groupId;
    final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
    final ProcessGroup group = root.findProcessGroup(searchId);

    // ensure the processor was found
    if (group == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate process group with id '%s'.", groupId));
    }

    final StatusHistoryDTO statusHistory = flowController.getProcessGroupStatusHistory(groupId);

    // if not authorized
    if (!group.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser())) {
        statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, groupId);
    }

    return statusHistory;
}
 
Example 2
Source File: ControllerFacade.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the status history for the specified process group.
 *
 * @param groupId group id
 * @return status history
 */
public StatusHistoryDTO getProcessGroupStatusHistory(final String groupId) {
    final FlowManager flowManager = flowController.getFlowManager();

    final String searchId = groupId.equals(FlowManager.ROOT_GROUP_ID_ALIAS) ? flowManager.getRootGroupId() : groupId;
    final ProcessGroup root = flowManager.getRootGroup();
    final ProcessGroup group = root.findProcessGroup(searchId);

    // ensure the processor was found
    if (group == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate process group with id '%s'.", groupId));
    }

    final StatusHistoryDTO statusHistory = flowController.getProcessGroupStatusHistory(groupId);

    // if not authorized
    if (!group.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser())) {
        statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, groupId);
    }

    return statusHistory;
}
 
Example 3
Source File: StandardControllerServiceProvider.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public Set<String> getControllerServiceIdentifiers(final Class<? extends ControllerService> serviceType, final String groupId) {
    final Set<ControllerServiceNode> serviceNodes;
    if (groupId == null) {
        serviceNodes = flowManager.getRootControllerServices();
    } else {
        ProcessGroup group = getRootGroup();
        if (!FlowManager.ROOT_GROUP_ID_ALIAS.equals(groupId) && !group.getIdentifier().equals(groupId)) {
            group = group.findProcessGroup(groupId);
        }

        if (group == null) {
            return Collections.emptySet();
        }

        serviceNodes = group.getControllerServices(true);
    }

    return serviceNodes.stream()
        .filter(service -> serviceType.isAssignableFrom(service.getProxiedControllerService().getClass()))
        .map(ControllerServiceNode::getIdentifier)
        .collect(Collectors.toSet());
}
 
Example 4
Source File: StandardControllerServiceProvider.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
@Override
public Set<String> getControllerServiceIdentifiers(final Class<? extends ControllerService> serviceType, final String groupId) {
    final Set<ControllerServiceNode> serviceNodes;
    if (groupId == null) {
        serviceNodes = flowController.getRootControllerServices();
    } else {
        ProcessGroup group = getRootGroup();
        if (!FlowController.ROOT_GROUP_ID_ALIAS.equals(groupId) && !group.getIdentifier().equals(groupId)) {
            group = group.findProcessGroup(groupId);
        }

        if (group == null) {
            return Collections.emptySet();
        }

        serviceNodes = group.getControllerServices(true);
    }

    final Set<String> identifiers = new HashSet<>();
    for (final ControllerServiceNode serviceNode : serviceNodes) {
        if (requireNonNull(serviceType).isAssignableFrom(serviceNode.getProxiedControllerService().getClass())) {
            identifiers.add(serviceNode.getIdentifier());
        }
    }

    return identifiers;
}
 
Example 5
Source File: FlowController.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the ProcessGroup with the given ID
 *
 * @param id group id
 * @return the process group or null if not group is found
 */
public ProcessGroup getGroup(final String id) {
    requireNonNull(id);
    final ProcessGroup root = getRootGroup();
    final String searchId = id.equals(ROOT_GROUP_ID_ALIAS) ? getRootGroupId() : id;
    return root == null ? null : root.findProcessGroup(searchId);
}