Search in sources :

Example 6 with ComponentReferenceEntity

use of org.apache.nifi.web.api.entity.ComponentReferenceEntity in project nifi by apache.

the class EntityFactory method createComponentReferenceEntity.

public ComponentReferenceEntity createComponentReferenceEntity(final ComponentReferenceDTO dto, final RevisionDTO revision, final PermissionsDTO permissions) {
    final ComponentReferenceEntity entity = new ComponentReferenceEntity();
    entity.setRevision(revision);
    if (dto != null) {
        entity.setPermissions(permissions);
        entity.setId(dto.getId());
        entity.setParentGroupId(dto.getParentGroupId());
        if (permissions != null && permissions.getCanRead()) {
            entity.setComponent(dto);
        }
    }
    return entity;
}
Also used : ComponentReferenceEntity(org.apache.nifi.web.api.entity.ComponentReferenceEntity)

Example 7 with ComponentReferenceEntity

use of org.apache.nifi.web.api.entity.ComponentReferenceEntity in project nifi by apache.

the class StandardNiFiServiceFacade method deleteAccessPolicy.

@Override
public AccessPolicyEntity deleteAccessPolicy(final Revision revision, final String accessPolicyId) {
    final AccessPolicy accessPolicy = accessPolicyDAO.getAccessPolicy(accessPolicyId);
    final ComponentReferenceEntity componentReference = createComponentReferenceEntity(accessPolicy.getResource());
    final PermissionsDTO permissions = dtoFactory.createPermissionsDto(authorizableLookup.getAccessPolicyById(accessPolicyId));
    final Set<TenantEntity> userGroups = accessPolicy != null ? accessPolicy.getGroups().stream().map(mapUserGroupIdToTenantEntity()).collect(Collectors.toSet()) : null;
    final Set<TenantEntity> users = accessPolicy != null ? accessPolicy.getUsers().stream().map(mapUserIdToTenantEntity()).collect(Collectors.toSet()) : null;
    final AccessPolicyDTO snapshot = deleteComponent(revision, new Resource() {

        @Override
        public String getIdentifier() {
            return accessPolicy.getResource();
        }

        @Override
        public String getName() {
            return accessPolicy.getResource();
        }

        @Override
        public String getSafeDescription() {
            return "Policy " + accessPolicyId;
        }
    }, () -> accessPolicyDAO.deleteAccessPolicy(accessPolicyId), // no need to clean up any policies as it's already been removed above
    false, dtoFactory.createAccessPolicyDto(accessPolicy, userGroups, users, componentReference));
    return entityFactory.createAccessPolicyEntity(snapshot, null, permissions);
}
Also used : ComponentReferenceEntity(org.apache.nifi.web.api.entity.ComponentReferenceEntity) TenantEntity(org.apache.nifi.web.api.entity.TenantEntity) PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO) EnforcePolicyPermissionsThroughBaseResource(org.apache.nifi.authorization.resource.EnforcePolicyPermissionsThroughBaseResource) Resource(org.apache.nifi.authorization.Resource) AccessPolicyDTO(org.apache.nifi.web.api.dto.AccessPolicyDTO) AccessPolicy(org.apache.nifi.authorization.AccessPolicy)

Aggregations

ComponentReferenceEntity (org.apache.nifi.web.api.entity.ComponentReferenceEntity)7 PermissionsDTO (org.apache.nifi.web.api.dto.PermissionsDTO)6 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)4 Authorizable (org.apache.nifi.authorization.resource.Authorizable)3 AccessPolicyDTO (org.apache.nifi.web.api.dto.AccessPolicyDTO)3 AccessPolicy (org.apache.nifi.authorization.AccessPolicy)2 EnforcePolicyPermissionsThroughBaseResource (org.apache.nifi.authorization.resource.EnforcePolicyPermissionsThroughBaseResource)2 TenantEntity (org.apache.nifi.web.api.entity.TenantEntity)2 Resource (org.apache.nifi.authorization.Resource)1 AccessPolicySummaryDTO (org.apache.nifi.web.api.dto.AccessPolicySummaryDTO)1 ComponentReferenceDTO (org.apache.nifi.web.api.dto.ComponentReferenceDTO)1