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

The following examples show how to use org.apache.nifi.groups.ProcessGroup#findRemoteProcessGroup() . 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 remote process group.
 *
 * @param remoteProcessGroupId remote process group id
 * @return status history
 */
public StatusHistoryDTO getRemoteProcessGroupStatusHistory(final String remoteProcessGroupId) {
    final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
    final RemoteProcessGroup remoteProcessGroup = root.findRemoteProcessGroup(remoteProcessGroupId);

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

    final StatusHistoryDTO statusHistory = flowController.getRemoteProcessGroupStatusHistory(remoteProcessGroupId);

    // if not authorized
    if (!remoteProcessGroup.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser())) {
        statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, remoteProcessGroupId);
        statusHistory.getComponentDetails().remove(ComponentStatusRepository.COMPONENT_DETAIL_URI);
    }

    return statusHistory;
}
 
Example 2
Source File: ControllerFacade.java    From localization_nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the status for the specified remote process group.
 *
 * @param remoteProcessGroupId remote process group id
 * @return the status for the specified remote process group
 */
public RemoteProcessGroupStatus getRemoteProcessGroupStatus(final String remoteProcessGroupId) {
    final ProcessGroup root = flowController.getGroup(flowController.getRootGroupId());
    final RemoteProcessGroup remoteProcessGroup = root.findRemoteProcessGroup(remoteProcessGroupId);

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

    final String groupId = remoteProcessGroup.getProcessGroup().getIdentifier();
    final ProcessGroupStatus groupStatus = flowController.getGroupStatus(groupId, NiFiUserUtils.getNiFiUser());
    if (groupStatus == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
    }

    final RemoteProcessGroupStatus status = groupStatus.getRemoteProcessGroupStatus().stream().filter(rpgStatus -> remoteProcessGroupId.equals(rpgStatus.getId())).findFirst().orElse(null);
    if (status == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId));
    }

    return status;
}
 
Example 3
Source File: ControllerFacade.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the status history for the specified remote process group.
 *
 * @param remoteProcessGroupId remote process group id
 * @return status history
 */
public StatusHistoryDTO getRemoteProcessGroupStatusHistory(final String remoteProcessGroupId) {
    final ProcessGroup root = getRootGroup();
    final RemoteProcessGroup remoteProcessGroup = root.findRemoteProcessGroup(remoteProcessGroupId);

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

    final StatusHistoryDTO statusHistory = flowController.getRemoteProcessGroupStatusHistory(remoteProcessGroupId);

    // if not authorized
    if (!remoteProcessGroup.isAuthorized(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser())) {
        statusHistory.getComponentDetails().put(ComponentStatusRepository.COMPONENT_DETAIL_NAME, remoteProcessGroupId);
        statusHistory.getComponentDetails().remove(ComponentStatusRepository.COMPONENT_DETAIL_URI);
    }

    return statusHistory;
}
 
Example 4
Source File: ControllerFacade.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the status for the specified remote process group.
 *
 * @param remoteProcessGroupId remote process group id
 * @return the status for the specified remote process group
 */
public RemoteProcessGroupStatus getRemoteProcessGroupStatus(final String remoteProcessGroupId) {
    final ProcessGroup root = getRootGroup();
    final RemoteProcessGroup remoteProcessGroup = root.findRemoteProcessGroup(remoteProcessGroupId);

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

    final String groupId = remoteProcessGroup.getProcessGroup().getIdentifier();
    final ProcessGroupStatus groupStatus = flowController.getEventAccess().getGroupStatus(groupId, NiFiUserUtils.getNiFiUser(), 1);
    if (groupStatus == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate group with id '%s'.", groupId));
    }

    final RemoteProcessGroupStatus status = groupStatus.getRemoteProcessGroupStatus().stream().filter(rpgStatus -> remoteProcessGroupId.equals(rpgStatus.getId())).findFirst().orElse(null);
    if (status == null) {
        throw new ResourceNotFoundException(String.format("Unable to locate remote process group with id '%s'.", remoteProcessGroupId));
    }

    return status;
}
 
Example 5
Source File: StandardRemoteProcessGroupDAO.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
private RemoteProcessGroup locateRemoteProcessGroup(final String remoteProcessGroupId) {
    final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    final RemoteProcessGroup remoteProcessGroup = rootGroup.findRemoteProcessGroup(remoteProcessGroupId);

    if (remoteProcessGroup == null) {
        throw new ResourceNotFoundException(String.format("Unable to find remote process group with id '%s'.", remoteProcessGroupId));
    } else {
        return remoteProcessGroup;
    }
}
 
Example 6
Source File: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 5 votes vote down vote up
private RemoteProcessGroup locateRemoteProcessGroup(final String remoteProcessGroupId) {
    final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup();
    final RemoteProcessGroup remoteProcessGroup = rootGroup.findRemoteProcessGroup(remoteProcessGroupId);

    if (remoteProcessGroup == null) {
        throw new ResourceNotFoundException(String.format("Unable to find remote process group with id '%s'.", remoteProcessGroupId));
    } else {
        return remoteProcessGroup;
    }
}
 
Example 7
Source File: StandardRemoteProcessGroupDAO.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
@Override
public boolean hasRemoteProcessGroup(String remoteProcessGroupId) {
    final ProcessGroup rootGroup = flowController.getGroup(flowController.getRootGroupId());
    return rootGroup.findRemoteProcessGroup(remoteProcessGroupId) != null;
}
 
Example 8
Source File: StandardRemoteProcessGroupDAO.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public boolean hasRemoteProcessGroup(String remoteProcessGroupId) {
    final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup();
    return rootGroup.findRemoteProcessGroup(remoteProcessGroupId) != null;
}