Search in sources :

Example 76 with PermissionsDTO

use of org.apache.nifi.web.api.dto.PermissionsDTO 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);
}
Also used : PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO) RevisionDTO(org.apache.nifi.web.api.dto.RevisionDTO) VariableRegistryDTO(org.apache.nifi.web.api.dto.VariableRegistryDTO) RegistryDTO(org.apache.nifi.web.api.dto.RegistryDTO)

Example 77 with PermissionsDTO

use of org.apache.nifi.web.api.dto.PermissionsDTO in project nifi by apache.

the class StandardNiFiServiceFacade method deleteControllerService.

@Override
public ControllerServiceEntity deleteControllerService(final Revision revision, final String controllerServiceId) {
    final ControllerServiceNode controllerService = controllerServiceDAO.getControllerService(controllerServiceId);
    final PermissionsDTO permissions = dtoFactory.createPermissionsDto(controllerService);
    final ControllerServiceDTO snapshot = deleteComponent(revision, controllerService.getResource(), () -> controllerServiceDAO.deleteControllerService(controllerServiceId), true, dtoFactory.createControllerServiceDto(controllerService));
    return entityFactory.createControllerServiceEntity(snapshot, null, permissions, null);
}
Also used : ControllerServiceDTO(org.apache.nifi.web.api.dto.ControllerServiceDTO) ControllerServiceNode(org.apache.nifi.controller.service.ControllerServiceNode) PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO)

Example 78 with PermissionsDTO

use of org.apache.nifi.web.api.dto.PermissionsDTO in project nifi by apache.

the class CurrentUserEndpointMergerTest method buildPermissions.

private PermissionsDTO buildPermissions(final boolean canRead, final boolean canWrite) {
    final PermissionsDTO permissionsDto = new PermissionsDTO();
    permissionsDto.setCanRead(canRead);
    permissionsDto.setCanWrite(canWrite);
    return permissionsDto;
}
Also used : PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO)

Example 79 with PermissionsDTO

use of org.apache.nifi.web.api.dto.PermissionsDTO in project nifi by apache.

the class AccessPolicyEntityMergerTest method testMergeAccessPolicy.

@Test
public void testMergeAccessPolicy() throws Exception {
    final NodeIdentifier node1 = new NodeIdentifier("node-1", "host-1", 8080, "host-1", 19998, null, null, null, false);
    final NodeIdentifier node2 = new NodeIdentifier("node-2", "host-2", 8081, "host-2", 19999, null, null, null, false);
    final PermissionsDTO permissed = new PermissionsDTO();
    permissed.setCanRead(true);
    permissed.setCanWrite(true);
    final TenantDTO user1DTO = new TenantDTO();
    user1DTO.setId("user-1");
    final TenantEntity user1Entity = new TenantEntity();
    user1Entity.setPermissions(permissed);
    user1Entity.setId(user1DTO.getId());
    user1Entity.setComponent(user1DTO);
    final TenantDTO user2DTO = new TenantDTO();
    user1DTO.setId("user-2");
    final TenantEntity user2Entity = new TenantEntity();
    user2Entity.setPermissions(permissed);
    user2Entity.setId(user2DTO.getId());
    user2Entity.setComponent(user2DTO);
    final AccessPolicyDTO accessPolicy1DTO = new AccessPolicyDTO();
    accessPolicy1DTO.setId("policy-1");
    accessPolicy1DTO.setUsers(Stream.of(user1Entity, user2Entity).collect(Collectors.toSet()));
    accessPolicy1DTO.setUserGroups(Stream.of(user2Entity).collect(Collectors.toSet()));
    final AccessPolicyEntity accessPolicy1Entity = new AccessPolicyEntity();
    accessPolicy1Entity.setPermissions(permissed);
    accessPolicy1Entity.setId(accessPolicy1DTO.getId());
    accessPolicy1Entity.setComponent(accessPolicy1DTO);
    final AccessPolicyDTO accessPolicy2DTO = new AccessPolicyDTO();
    accessPolicy2DTO.setId("policy-2");
    accessPolicy2DTO.setUsers(Stream.of(user1Entity).collect(Collectors.toSet()));
    accessPolicy2DTO.setUserGroups(Stream.of(user1Entity, user2Entity).collect(Collectors.toSet()));
    final AccessPolicyEntity accessPolicy2Entity = new AccessPolicyEntity();
    accessPolicy2Entity.setPermissions(permissed);
    accessPolicy2Entity.setId(accessPolicy2DTO.getId());
    accessPolicy2Entity.setComponent(accessPolicy2DTO);
    final Map<NodeIdentifier, AccessPolicyEntity> nodeMap = new HashMap<>();
    nodeMap.put(node1, accessPolicy1Entity);
    nodeMap.put(node2, accessPolicy2Entity);
    final AccessPolicyEntityMerger merger = new AccessPolicyEntityMerger();
    merger.merge(accessPolicy1Entity, nodeMap);
    assertEquals(1, accessPolicy1DTO.getUserGroups().size());
    assertTrue(accessPolicy1DTO.getUsers().contains(user1Entity));
    assertEquals(1, accessPolicy1DTO.getUserGroups().size());
    assertTrue(accessPolicy1DTO.getUserGroups().contains(user2Entity));
}
Also used : TenantEntity(org.apache.nifi.web.api.entity.TenantEntity) HashMap(java.util.HashMap) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO) TenantDTO(org.apache.nifi.web.api.dto.TenantDTO) AccessPolicyDTO(org.apache.nifi.web.api.dto.AccessPolicyDTO) AccessPolicyEntity(org.apache.nifi.web.api.entity.AccessPolicyEntity) Test(org.junit.Test)

Example 80 with PermissionsDTO

use of org.apache.nifi.web.api.dto.PermissionsDTO in project nifi by apache.

the class RemoteProcessGroupEntityMergerTest method testMergeRemoteProcessGroups.

@Test
public void testMergeRemoteProcessGroups() throws Exception {
    final NodeIdentifier node1 = new NodeIdentifier("node-1", "host-1", 8080, "host-1", 19998, null, null, null, false);
    final NodeIdentifier node2 = new NodeIdentifier("node-2", "host-2", 8081, "host-2", 19999, null, null, null, false);
    final PermissionsDTO permissed = new PermissionsDTO();
    permissed.setCanRead(true);
    permissed.setCanWrite(true);
    final RemoteProcessGroupStatusDTO status = new RemoteProcessGroupStatusDTO();
    status.setAggregateSnapshot(new RemoteProcessGroupStatusSnapshotDTO());
    final RemoteProcessGroupPortDTO in1_1 = new RemoteProcessGroupPortDTO();
    in1_1.setName("in1");
    final RemoteProcessGroupPortDTO in1_2 = new RemoteProcessGroupPortDTO();
    in1_2.setName("in2");
    final Set<RemoteProcessGroupPortDTO> inputs1 = new HashSet<>();
    inputs1.add(in1_1);
    inputs1.add(in1_2);
    final RemoteProcessGroupPortDTO out1_1 = new RemoteProcessGroupPortDTO();
    out1_1.setName("out1");
    final Set<RemoteProcessGroupPortDTO> outputs1 = new HashSet<>();
    outputs1.add(out1_1);
    final RemoteProcessGroupContentsDTO contents1 = new RemoteProcessGroupContentsDTO();
    contents1.setInputPorts(inputs1);
    contents1.setOutputPorts(outputs1);
    final RemoteProcessGroupDTO rpg1 = new RemoteProcessGroupDTO();
    rpg1.setContents(contents1);
    final RemoteProcessGroupEntity entity1 = new RemoteProcessGroupEntity();
    entity1.setPermissions(permissed);
    entity1.setStatus(status);
    entity1.setComponent(rpg1);
    final RemoteProcessGroupPortDTO in2_1 = new RemoteProcessGroupPortDTO();
    in2_1.setName("in1");
    final Set<RemoteProcessGroupPortDTO> inputs2 = new HashSet<>();
    inputs2.add(in2_1);
    final RemoteProcessGroupPortDTO out2_1 = new RemoteProcessGroupPortDTO();
    out2_1.setName("out1");
    final RemoteProcessGroupPortDTO out2_2 = new RemoteProcessGroupPortDTO();
    out2_2.setName("out2");
    final Set<RemoteProcessGroupPortDTO> outputs2 = new HashSet<>();
    outputs2.add(out2_1);
    outputs2.add(out2_2);
    final RemoteProcessGroupContentsDTO contents2 = new RemoteProcessGroupContentsDTO();
    contents2.setInputPorts(inputs2);
    contents2.setOutputPorts(outputs2);
    final RemoteProcessGroupDTO rpg2 = new RemoteProcessGroupDTO();
    rpg2.setContents(contents2);
    final RemoteProcessGroupEntity entity2 = new RemoteProcessGroupEntity();
    entity2.setPermissions(permissed);
    entity2.setStatus(status);
    entity2.setComponent(rpg2);
    final Map<NodeIdentifier, RemoteProcessGroupEntity> nodeMap = new HashMap<>();
    nodeMap.put(node1, entity1);
    nodeMap.put(node2, entity2);
    final RemoteProcessGroupEntityMerger merger = new RemoteProcessGroupEntityMerger();
    merger.merge(entity1, nodeMap);
    // should only include ports in common to all rpg's
    assertEquals(1, entity1.getComponent().getContents().getInputPorts().size());
    assertEquals("in1", entity1.getComponent().getContents().getInputPorts().iterator().next().getName());
    assertEquals(1, entity1.getComponent().getContents().getOutputPorts().size());
    assertEquals("out1", entity1.getComponent().getContents().getOutputPorts().iterator().next().getName());
}
Also used : HashMap(java.util.HashMap) PermissionsDTO(org.apache.nifi.web.api.dto.PermissionsDTO) RemoteProcessGroupContentsDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupContentsDTO) RemoteProcessGroupDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupDTO) RemoteProcessGroupPortDTO(org.apache.nifi.web.api.dto.RemoteProcessGroupPortDTO) RemoteProcessGroupEntity(org.apache.nifi.web.api.entity.RemoteProcessGroupEntity) NodeIdentifier(org.apache.nifi.cluster.protocol.NodeIdentifier) RemoteProcessGroupStatusSnapshotDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusSnapshotDTO) RemoteProcessGroupStatusDTO(org.apache.nifi.web.api.dto.status.RemoteProcessGroupStatusDTO) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

PermissionsDTO (org.apache.nifi.web.api.dto.PermissionsDTO)87 RevisionDTO (org.apache.nifi.web.api.dto.RevisionDTO)48 RemoteProcessGroup (org.apache.nifi.groups.RemoteProcessGroup)42 HashMap (java.util.HashMap)38 Authorizable (org.apache.nifi.authorization.resource.Authorizable)38 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)37 ProcessGroup (org.apache.nifi.groups.ProcessGroup)37 VersionedProcessGroup (org.apache.nifi.registry.flow.VersionedProcessGroup)37 InstantiatedVersionedProcessGroup (org.apache.nifi.registry.flow.mapping.InstantiatedVersionedProcessGroup)37 Connection (org.apache.nifi.connectable.Connection)36 VersionedConnection (org.apache.nifi.registry.flow.VersionedConnection)36 InstantiatedVersionedRemoteGroupPort (org.apache.nifi.registry.flow.mapping.InstantiatedVersionedRemoteGroupPort)36 RemoteGroupPort (org.apache.nifi.remote.RemoteGroupPort)36 AccessPolicyDTO (org.apache.nifi.web.api.dto.AccessPolicyDTO)36 TenantEntity (org.apache.nifi.web.api.entity.TenantEntity)36 HashSet (java.util.HashSet)35 AffectedComponentDTO (org.apache.nifi.web.api.dto.AffectedComponentDTO)35 ConnectionStatusDTO (org.apache.nifi.web.api.dto.status.ConnectionStatusDTO)35 StatusHistoryDTO (org.apache.nifi.web.api.dto.status.StatusHistoryDTO)35 LinkedHashSet (java.util.LinkedHashSet)34