use of org.apache.nifi.web.api.dto.RevisionDTO in project nifi by apache.
the class StandardNiFiServiceFacade method createUserGroupEntity.
private UserGroupEntity createUserGroupEntity(final Group userGroup) {
final RevisionDTO userGroupRevision = dtoFactory.createRevisionDTO(revisionManager.getRevision(userGroup.getIdentifier()));
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(authorizableLookup.getTenant());
final Set<TenantEntity> users = userGroup.getUsers().stream().map(mapUserIdToTenantEntity()).collect(Collectors.toSet());
final Set<AccessPolicySummaryEntity> policyEntities = userGroupDAO.getAccessPoliciesForUserGroup(userGroup.getIdentifier()).stream().map(ap -> createAccessPolicySummaryEntity(ap)).collect(Collectors.toSet());
return entityFactory.createUserGroupEntity(dtoFactory.createUserGroupDto(userGroup, users, policyEntities), userGroupRevision, permissions);
}
use of org.apache.nifi.web.api.dto.RevisionDTO in project nifi by apache.
the class StandardNiFiServiceFacade method createControllerServiceReferencingComponentsEntity.
/**
* Creates entities for components referencing a ControllerServcie using the specified revisions.
*
* @param reference ControllerServiceReference
* @param revisions The revisions
* @param visited Which services we've already considered (in case of cycle)
* @return The entity
*/
private ControllerServiceReferencingComponentsEntity createControllerServiceReferencingComponentsEntity(final ControllerServiceReference reference, final Map<String, Revision> revisions, final Set<ControllerServiceNode> visited) {
final String modifier = NiFiUserUtils.getNiFiUserIdentity();
final Set<ConfiguredComponent> referencingComponents = reference.getReferencingComponents();
final Set<ControllerServiceReferencingComponentEntity> componentEntities = new HashSet<>();
for (final ConfiguredComponent refComponent : referencingComponents) {
PermissionsDTO permissions = null;
if (refComponent instanceof Authorizable) {
permissions = dtoFactory.createPermissionsDto(refComponent);
}
final Revision revision = revisions.get(refComponent.getIdentifier());
final FlowModification flowMod = new FlowModification(revision, modifier);
final RevisionDTO revisionDto = dtoFactory.createRevisionDTO(flowMod);
final ControllerServiceReferencingComponentDTO dto = dtoFactory.createControllerServiceReferencingComponentDTO(refComponent);
if (refComponent instanceof ControllerServiceNode) {
final ControllerServiceNode node = (ControllerServiceNode) refComponent;
// indicate if we've hit a cycle
dto.setReferenceCycle(visited.contains(node));
// mark node as visited before building the reference cycle
visited.add(node);
// if we haven't encountered this service before include it's referencing components
if (!dto.getReferenceCycle()) {
final ControllerServiceReference refReferences = node.getReferences();
final Map<String, Revision> referencingRevisions = new HashMap<>(revisions);
for (final ConfiguredComponent component : refReferences.getReferencingComponents()) {
referencingRevisions.putIfAbsent(component.getIdentifier(), revisionManager.getRevision(component.getIdentifier()));
}
final ControllerServiceReferencingComponentsEntity references = createControllerServiceReferencingComponentsEntity(refReferences, referencingRevisions, visited);
dto.setReferencingComponents(references.getControllerServiceReferencingComponents());
}
}
componentEntities.add(entityFactory.createControllerServiceReferencingComponentEntity(dto, revisionDto, permissions));
}
final ControllerServiceReferencingComponentsEntity entity = new ControllerServiceReferencingComponentsEntity();
entity.setControllerServiceReferencingComponents(componentEntities);
return entity;
}
use of org.apache.nifi.web.api.dto.RevisionDTO in project nifi by apache.
the class StandardNiFiServiceFacade method createFunnelEntity.
private FunnelEntity createFunnelEntity(final Funnel funnel) {
final RevisionDTO revision = dtoFactory.createRevisionDTO(revisionManager.getRevision(funnel.getIdentifier()));
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(funnel);
return entityFactory.createFunnelEntity(dtoFactory.createFunnelDto(funnel), revision, permissions);
}
use of org.apache.nifi.web.api.dto.RevisionDTO in project nifi by apache.
the class StandardNiFiServiceFacade method populateAffectedComponents.
@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);
}
use of org.apache.nifi.web.api.dto.RevisionDTO in project nifi by apache.
the class StandardNiFiServiceFacade method createRegistryClientEntity.
private RegistryClientEntity createRegistryClientEntity(final FlowRegistry flowRegistry) {
if (flowRegistry == null) {
return null;
}
final RevisionDTO revision = dtoFactory.createRevisionDTO(revisionManager.getRevision(flowRegistry.getIdentifier()));
final PermissionsDTO permissions = dtoFactory.createPermissionsDto(authorizableLookup.getController());
final RegistryDTO dto = dtoFactory.createRegistryDto(flowRegistry);
return entityFactory.createRegistryClientEntity(dto, revision, permissions);
}
Aggregations