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

The following examples show how to use org.apache.nifi.groups.ProcessGroup#getVersionControlInformation() . 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: StandardProcessGroupDAO.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Override
public void verifyDeleteFlowRegistry(String registryId) {
    final ProcessGroup rootGroup = flowController.getFlowManager().getRootGroup();

    final VersionControlInformation versionControlInformation = rootGroup.getVersionControlInformation();
    if (versionControlInformation != null && versionControlInformation.getRegistryIdentifier().equals(registryId)) {
        throw new IllegalStateException("The Registry cannot be removed because a Process Group currently under version control is tracking to it.");
    }

    final Set<VersionControlInformation> trackedVersionControlInformation = rootGroup.findAllProcessGroups().stream()
            .map(group -> group.getVersionControlInformation())
            .filter(Objects::nonNull)
            .filter(vci -> vci.getRegistryIdentifier().equals(registryId))
            .collect(Collectors.toSet());

    if (!trackedVersionControlInformation.isEmpty()) {
        throw new IllegalStateException("The Registry cannot be removed because a Process Group currently under version control is tracking to it.");
    }
}
 
Example 2
Source File: AbstractComponentSearchResultEnricher.java    From nifi with Apache License 2.0 6 votes vote down vote up
/**
 * Builds the nearest versioned parent result group for a given user.
 *
 * @param group The containing group
 * @param user The current NiFi user
 * @return Versioned parent group
 */
protected SearchResultGroupDTO buildVersionedGroup(final ProcessGroup group, final NiFiUser user) {
    if (group == null) {
        return null;
    }

    ProcessGroup current = group;

    // search for a versioned group by traversing the group tree up to the root
    while (!current.isRootGroup()) {
        if (current.getVersionControlInformation() != null) {
            return buildResultGroup(current, user);
        }

        current = current.getParent();
    }

    // traversed all the way to the root
    return null;
}
 
Example 3
Source File: ProcessGroupAuditor.java    From nifi with Apache License 2.0 6 votes vote down vote up
@Around("within(org.apache.nifi.web.dao.ProcessGroupDAO+) && "
        + "execution(org.apache.nifi.groups.ProcessGroup updateVersionControlInformation(..))")
public ProcessGroup updateVersionControlInformationAdvice(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
    final VersionControlInformationDTO vciDto = (VersionControlInformationDTO) proceedingJoinPoint.getArgs()[0];

    final ProcessGroupDAO processGroupDAO = getProcessGroupDAO();
    final ProcessGroup processGroup = processGroupDAO.getProcessGroup(vciDto.getGroupId());
    final VersionControlInformation vci = processGroup.getVersionControlInformation();

    final ProcessGroup updatedProcessGroup = (ProcessGroup) proceedingJoinPoint.proceed();

    final Operation operation;
    if (vci == null) {
        operation = Operation.StartVersionControl;
    } else {
        operation = Operation.CommitLocalChanges;
    }

    saveUpdateAction(vciDto.getGroupId(), operation);

    return updatedProcessGroup;
}
 
Example 4
Source File: SnippetUtils.java    From nifi with Apache License 2.0 6 votes vote down vote up
private static void verifyNoDuplicateVersionControlInfoDtos(final ProcessGroup group, final Collection<VersionControlInformationDTO> snippetVcis) {
    final VersionControlInformation vci = group.getVersionControlInformation();
    if (vci != null) {
        for (final VersionControlInformationDTO snippetVci : snippetVcis) {
            if (vci.getBucketIdentifier().equals(snippetVci.getBucketId()) && vci.getFlowIdentifier().equals(snippetVci.getFlowId())) {
                throw new IllegalArgumentException("Cannot place the given Process Group into the desired destination because the destination group or one of its ancestor groups is "
                    + "under Version Control and one of the selected Process Groups is also under Version Control with the same Flow. A Process Group that is under Version Control "
                    + "cannot contain a child Process Group that points to the same Versioned Flow.");
            }
        }
    }

    final ProcessGroup parent = group.getParent();
    if (parent != null) {
        verifyNoDuplicateVersionControlInfoDtos(parent, snippetVcis);
    }
}
 
Example 5
Source File: SnippetUtils.java    From nifi with Apache License 2.0 6 votes vote down vote up
private static void verifyNoDuplicateVersionControlInfo(final ProcessGroup group, final Collection<VersionControlInformation> snippetVcis) {
    final VersionControlInformation vci = group.getVersionControlInformation();
    if (vci != null) {
        for (final VersionControlInformation snippetVci : snippetVcis) {
            if (vci.getBucketIdentifier().equals(snippetVci.getBucketIdentifier()) && vci.getFlowIdentifier().equals(snippetVci.getFlowIdentifier())) {
                throw new IllegalArgumentException("Cannot place the given Process Group into the desired destination because the destination group or one of its ancestor groups is "
                    + "under Version Control and one of the selected Process Groups is also under Version Control with the same Flow. A Process Group that is under Version Control "
                    + "cannot contain a child Process Group that points to the same Versioned Flow.");
            }
        }
    }

    final ProcessGroup parent = group.getParent();
    if (parent != null) {
        verifyNoDuplicateVersionControlInfo(parent, snippetVcis);
    }
}
 
Example 6
Source File: NiFiRegistryFlowMapper.java    From nifi with Apache License 2.0 6 votes vote down vote up
private void mapParameterContexts(final ProcessGroup processGroup, final boolean mapDescendantVersionedFlows,
                                  final Map<String, VersionedParameterContext> parameterContexts) {
    final ParameterContext parameterContext = processGroup.getParameterContext();
    if (parameterContext != null) {
        // map this process group's parameter context and add to the collection
        final Set<VersionedParameter> parameters = parameterContext.getParameters().values().stream()
                .map(this::mapParameter)
                .collect(Collectors.toSet());

        final VersionedParameterContext versionedContext = new VersionedParameterContext();
        versionedContext.setName(parameterContext.getName());
        versionedContext.setParameters(parameters);
        parameterContexts.put(versionedContext.getName(), versionedContext);
    }

    for (final ProcessGroup child : processGroup.getProcessGroups()) {
        // only include child process group parameter contexts if boolean indicator is true or process group is unversioned
        if (mapDescendantVersionedFlows || child.getVersionControlInformation() == null) {
            mapParameterContexts(child, mapDescendantVersionedFlows, parameterContexts);
        }
    }
}
 
Example 7
Source File: ProcessGroupAuditor.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Around("within(org.apache.nifi.web.dao.ProcessGroupDAO+) && "
        + "execution(org.apache.nifi.groups.ProcessGroup updateProcessGroupFlow(..))")
public ProcessGroup updateProcessGroupFlowAdvice(final ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
    final Object[] args = proceedingJoinPoint.getArgs();
    final String groupId = (String) args[0];

    final ProcessGroupDAO processGroupDAO = getProcessGroupDAO();
    final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId);
    final VersionControlInformation vci = processGroup.getVersionControlInformation();

    final ProcessGroup updatedProcessGroup = (ProcessGroup) proceedingJoinPoint.proceed();
    final VersionControlInformation updatedVci = updatedProcessGroup.getVersionControlInformation();

    final Operation operation;
    if (vci == null) {
        operation = Operation.StartVersionControl;
    } else {
        if (updatedVci == null) {
            operation = Operation.StopVersionControl;
        } else if (vci.getVersion() == updatedVci.getVersion()) {
            operation = Operation.RevertLocalChanges;
        } else {
            operation = Operation.ChangeVersion;
        }
    }

    saveUpdateAction(groupId, operation);

    return updatedProcessGroup;
}
 
Example 8
Source File: SnippetUtils.java    From nifi with Apache License 2.0 5 votes vote down vote up
private static void findAllVersionControlInfo(final ProcessGroup group, final List<VersionControlInformation> found) {
    if (group == null) {
        return;
    }

    final VersionControlInformation vci = group.getVersionControlInformation();
    if (vci != null) {
        found.add(vci);
    }

    for (final ProcessGroup childGroup : group.findAllProcessGroups()) {
        findAllVersionControlInfo(childGroup, found);
    }
}