@Override public Set<Revision> getRevisionsFromGroup(final String groupId, final Function<ProcessGroup, Set<String>> getComponents) { final ProcessGroup group = processGroupDAO.getProcessGroup(groupId); final Set<String> componentIds = getComponents.apply(group); return componentIds.stream().map(id -> revisionManager.getRevision(id)).collect(Collectors.toSet()); }
@Override public void verifyImportProcessGroup(final VersionControlInformationDTO versionControlInfo, final VersionedProcessGroup contents, final String groupId) { final ProcessGroup group = processGroupDAO.getProcessGroup(groupId); verifyImportProcessGroup(versionControlInfo, contents, group); }
@Override public ProcessGroupEntity getProcessGroup(final String groupId) { final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId); return createProcessGroupEntity(processGroup); }
@Override public void verifyCanUpdate(final String groupId, final VersionedFlowSnapshot proposedFlow, final boolean verifyConnectionRemoval, final boolean verifyNotDirty) { final ProcessGroup group = processGroupDAO.getProcessGroup(groupId); group.verifyCanUpdate(proposedFlow, verifyConnectionRemoval, verifyNotDirty); }
@Override public void verifyCanSaveToFlowRegistry(final String groupId, final String registryId, final String bucketId, final String flowId) { final ProcessGroup group = processGroupDAO.getProcessGroup(groupId); group.verifyCanSaveToFlowRegistry(registryId, bucketId, flowId); }
@Override public VariableRegistryEntity getVariableRegistry(final String groupId, final boolean includeAncestorGroups) { final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId); if (processGroup == null) { throw new ResourceNotFoundException("Could not find group with ID " + groupId); } return createVariableRegistryEntity(processGroup, includeAncestorGroups); }
@Override public void verifyCanRevertLocalModifications(final String groupId, final VersionedFlowSnapshot versionedFlowSnapshot) { final ProcessGroup group = processGroupDAO.getProcessGroup(groupId); group.verifyCanRevertLocalModifications(); // verify that the process group can be updated to the given snapshot. We do not verify that connections can // be removed, because the flow may still be running, and it only matters that the connections can be removed once the components // have been stopped. group.verifyCanUpdate(versionedFlowSnapshot, false, false); }
@Override public ProcessGroupAuthorizable getProcessGroup(final String id) { final ProcessGroup processGroup = processGroupDAO.getProcessGroup(id); return new StandardProcessGroupAuthorizable(processGroup, controllerFacade.getExtensionManager()); }
@Override public StatusHistoryEntity getProcessGroupStatusHistory(final String groupId) { final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup); final StatusHistoryDTO dto = controllerFacade.getProcessGroupStatusHistory(groupId); return entityFactory.createStatusHistoryEntity(dto, permissions); }
@Override public ProcessGroupFlowEntity getProcessGroupFlow(final String groupId) { final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId); // Get the Process Group Status but we only need a status depth of one because for any child process group, // we ignore the status of each individual components. I.e., if Process Group A has child Group B, and child Group B // has a Processor, we don't care about the individual stats of that Processor because the ProcessGroupFlowEntity // doesn't include that anyway. So we can avoid including the information in the status that is returned. final ProcessGroupStatus groupStatus = controllerFacade.getProcessGroupStatus(groupId, 1); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup); return entityFactory.createProcessGroupFlowEntity(dtoFactory.createProcessGroupFlowDto(processGroup, groupStatus, revisionManager, this::getProcessGroupBulletins), permissions); }
private InstantiatedVersionedProcessGroup createFlowSnapshot(final String processGroupId) { final ProcessGroup processGroup = processGroupDAO.getProcessGroup(processGroupId); final NiFiRegistryFlowMapper mapper = new NiFiRegistryFlowMapper(controllerFacade.getExtensionManager()); final InstantiatedVersionedProcessGroup versionedGroup = mapper.mapProcessGroup(processGroup, controllerFacade.getControllerServiceProvider(), flowRegistryClient, false); return versionedGroup; }
@Override public VersionControlInformationEntity getVersionControlInformation(final String groupId) { final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId); final VersionControlInformation versionControlInfo = processGroup.getVersionControlInformation(); if (versionControlInfo == null) { return null; } final VersionControlInformationDTO versionControlDto = dtoFactory.createVersionControlInformationDto(processGroup); final RevisionDTO groupRevision = dtoFactory.createRevisionDTO(revisionManager.getRevision(groupId)); return entityFactory.createVersionControlInformationEntity(versionControlDto, groupRevision); }
@Override public ProcessGroupEntity createProcessGroup(final Revision revision, final String parentGroupId, final ProcessGroupDTO processGroupDTO) { final RevisionUpdate<ProcessGroupDTO> snapshot = createComponent( revision, processGroupDTO, () -> processGroupDAO.createProcessGroup(parentGroupId, processGroupDTO), processGroup -> dtoFactory.createProcessGroupDto(processGroup)); final ProcessGroup processGroup = processGroupDAO.getProcessGroup(processGroupDTO.getId()); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup); final ProcessGroupStatusDTO status = dtoFactory.createConciseProcessGroupStatusDto(controllerFacade.getProcessGroupStatus(processGroup.getIdentifier())); final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processGroup.getIdentifier())); final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList()); return entityFactory.createProcessGroupEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification()), permissions, status, bulletinEntities); }
@Override public VersionControlInformationEntity setVersionControlInformation(final Revision revision, final String processGroupId, final VersionControlInformationDTO versionControlInfo, final Map<String, String> versionedComponentMapping) { final ProcessGroup group = processGroupDAO.getProcessGroup(processGroupId); final RevisionUpdate<VersionControlInformationDTO> snapshot = updateComponent(revision, group, () -> processGroupDAO.updateVersionControlInformation(versionControlInfo, versionedComponentMapping), processGroup -> dtoFactory.createVersionControlInformationDto(processGroup)); return entityFactory.createVersionControlInformationEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification())); }
@Override public ProcessGroupEntity updateProcessGroup(final Revision revision, final ProcessGroupDTO processGroupDTO) { final ProcessGroup processGroupNode = processGroupDAO.getProcessGroup(processGroupDTO.getId()); final RevisionUpdate<ProcessGroupDTO> snapshot = updateComponent(revision, processGroupNode, () -> processGroupDAO.updateProcessGroup(processGroupDTO), processGroup -> dtoFactory.createProcessGroupDto(processGroup)); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroupNode); final RevisionDTO updatedRevision = dtoFactory.createRevisionDTO(snapshot.getLastModification()); final ProcessGroupStatusDTO status = dtoFactory.createConciseProcessGroupStatusDto(controllerFacade.getProcessGroupStatus(processGroupNode.getIdentifier())); final List<BulletinDTO> bulletins = dtoFactory.createBulletinDtos(bulletinRepository.findBulletinsForSource(processGroupNode.getIdentifier())); final List<BulletinEntity> bulletinEntities = bulletins.stream().map(bulletin -> entityFactory.createBulletinEntity(bulletin, permissions.getCanRead())).collect(Collectors.toList()); return entityFactory.createProcessGroupEntity(snapshot.getComponent(), updatedRevision, permissions, status, bulletinEntities); }
@Override public VersionControlInformationEntity deleteVersionControl(final Revision revision, final String processGroupId) { final ProcessGroup group = processGroupDAO.getProcessGroup(processGroupId); final RevisionUpdate<VersionControlInformationDTO> snapshot = updateComponent(revision, group, () -> processGroupDAO.disconnectVersionControl(processGroupId), processGroup -> dtoFactory.createVersionControlInformationDto(group)); return entityFactory.createVersionControlInformationEntity(snapshot.getComponent(), dtoFactory.createRevisionDTO(snapshot.getLastModification())); }
@Override public VariableRegistryEntity populateAffectedComponents(final VariableRegistryDTO variableRegistryDto) { final String groupId = variableRegistryDto.getProcessGroupId(); final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId); if (processGroup == null) { throw new ResourceNotFoundException("Could not find group with ID " + groupId); } final VariableRegistryDTO registryDto = dtoFactory.populateAffectedComponents(variableRegistryDto, processGroup, revisionManager); final RevisionDTO revision = dtoFactory.createRevisionDTO(revisionManager.getRevision(processGroup.getIdentifier())); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup); return entityFactory.createVariableRegistryEntity(registryDto, revision, permissions); }
@Override public VariableRegistryEntity updateVariableRegistry(Revision revision, VariableRegistryDTO variableRegistryDto) { final ProcessGroup processGroupNode = processGroupDAO.getProcessGroup(variableRegistryDto.getProcessGroupId()); final RevisionUpdate<VariableRegistryDTO> snapshot = updateComponent(revision, processGroupNode, () -> processGroupDAO.updateVariableRegistry(variableRegistryDto), processGroup -> dtoFactory.createVariableRegistryDto(processGroup, revisionManager)); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroupNode); final RevisionDTO updatedRevision = dtoFactory.createRevisionDTO(snapshot.getLastModification()); return entityFactory.createVariableRegistryEntity(snapshot.getComponent(), updatedRevision, permissions); }
private void saveUpdateAction(final String groupId, final Operation operation) throws Throwable { NiFiUser user = NiFiUserUtils.getNiFiUser(); ProcessGroupDAO processGroupDAO = getProcessGroupDAO(); ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId); // if the user was starting/stopping this process group FlowChangeAction action = new FlowChangeAction(); action.setUserIdentity(user.getIdentity()); action.setSourceId(processGroup.getIdentifier()); action.setSourceName(processGroup.getName()); action.setSourceType(Component.ProcessGroup); action.setTimestamp(new Date()); action.setOperation(operation); // add this action saveAction(action, logger); }
@Override public ProcessGroupStatusEntity getProcessGroupStatus(final String groupId, final boolean recursive) { final ProcessGroup processGroup = processGroupDAO.getProcessGroup(groupId); final PermissionsDTO permissions = dtoFactory.createPermissionsDto(processGroup); final ProcessGroupStatusDTO dto = dtoFactory.createProcessGroupStatusDto(processGroup, controllerFacade.getProcessGroupStatus(groupId)); // prune the response as necessary if (!recursive) { pruneChildGroups(dto.getAggregateSnapshot()); if (dto.getNodeSnapshots() != null) { for (final NodeProcessGroupStatusSnapshotDTO nodeSnapshot : dto.getNodeSnapshots()) { pruneChildGroups(nodeSnapshot.getStatusSnapshot()); } } } return entityFactory.createProcessGroupStatusEntity(dto, permissions); }