use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.
the class ITProcessGroupAccessControl method getRandomProcessGroup.
private ProcessGroupEntity getRandomProcessGroup(final NiFiTestUser user) throws Exception {
final String url = helper.getBaseUrl() + "/flow/process-groups/root";
// get the process groups
final Response response = user.testGet(url);
// ensure the response was successful
assertEquals(200, response.getStatus());
// unmarshal
final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class);
final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow();
final Set<ProcessGroupEntity> processGroups = flowDto.getProcessGroups();
// ensure the correct number of process groups
assertFalse(processGroups.isEmpty());
// use the first process group as the target
Iterator<ProcessGroupEntity> processGroupIter = processGroups.iterator();
assertTrue(processGroupIter.hasNext());
return processGroupIter.next();
}
use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.
the class JerseyFlowClient method getSuggestedProcessGroupCoordinates.
@Override
public ProcessGroupBox getSuggestedProcessGroupCoordinates(final String parentId) throws NiFiClientException, IOException {
if (StringUtils.isBlank(parentId)) {
throw new IllegalArgumentException("Process group id cannot be null");
}
final ProcessGroupFlowEntity processGroup = getProcessGroup(parentId);
final ProcessGroupFlowDTO processGroupFlowDTO = processGroup.getProcessGroupFlow();
final FlowDTO flowDTO = processGroupFlowDTO.getFlow();
final List<ComponentEntity> pgComponents = new ArrayList<>();
pgComponents.addAll(flowDTO.getProcessGroups());
pgComponents.addAll(flowDTO.getProcessors());
pgComponents.addAll(flowDTO.getRemoteProcessGroups());
pgComponents.addAll(flowDTO.getConnections());
pgComponents.addAll(flowDTO.getFunnels());
pgComponents.addAll(flowDTO.getInputPorts());
pgComponents.addAll(flowDTO.getOutputPorts());
pgComponents.addAll(flowDTO.getLabels());
final Set<PositionDTO> positions = pgComponents.stream().map(ComponentEntity::getPosition).collect(Collectors.toSet());
if (positions.isEmpty()) {
return ProcessGroupBox.CANVAS_CENTER;
}
final List<ProcessGroupBox> coords = positions.stream().filter(Objects::nonNull).map(p -> new ProcessGroupBox(p.getX().intValue(), p.getY().intValue())).collect(Collectors.toList());
final ProcessGroupBox freeSpot = coords.get(0).findFreeSpace(coords);
return freeSpot;
}
use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.
the class EntityFactory method createProcessGroupFlowEntity.
public ProcessGroupFlowEntity createProcessGroupFlowEntity(final ProcessGroupFlowDTO dto, final PermissionsDTO permissions) {
final ProcessGroupFlowEntity entity = new ProcessGroupFlowEntity();
entity.setProcessGroupFlow(dto);
entity.setPermissions(permissions);
return entity;
}
use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.
the class FlowResource method getFlow.
/**
* Retrieves the contents of the specified group.
*
* @param groupId The id of the process group.
* @return A processGroupEntity.
* @throws InterruptedException if interrupted
*/
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("process-groups/{id}")
@ApiOperation(value = "Gets a process group", response = ProcessGroupFlowEntity.class, authorizations = { @Authorization(value = "Read - /flow") })
@ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") })
public Response getFlow(@ApiParam(value = "The process group id.", required = false) @PathParam("id") String groupId) throws InterruptedException {
authorizeFlow();
if (isReplicateRequest()) {
return replicate(HttpMethod.GET);
}
// get this process group flow
final ProcessGroupFlowEntity entity = serviceFacade.getProcessGroupFlow(groupId);
populateRemainingFlowContent(entity.getProcessGroupFlow());
return generateOkResponse(entity).build();
}
use of org.apache.nifi.web.api.entity.ProcessGroupFlowEntity in project nifi by apache.
the class ITConnectionAccessControl method getRandomConnection.
private ConnectionEntity getRandomConnection(final NiFiTestUser user) throws Exception {
final String url = helper.getBaseUrl() + "/flow/process-groups/root";
// get the connections
final Response response = user.testGet(url);
// ensure the response was successful
assertEquals(200, response.getStatus());
// unmarshal
final ProcessGroupFlowEntity flowEntity = response.readEntity(ProcessGroupFlowEntity.class);
final FlowDTO flowDto = flowEntity.getProcessGroupFlow().getFlow();
final Set<ConnectionEntity> connections = flowDto.getConnections();
// ensure the correct number of connection
assertFalse(connections.isEmpty());
// use the first connection as the target
Iterator<ConnectionEntity> connectionIter = connections.iterator();
assertTrue(connectionIter.hasNext());
return connectionIter.next();
}
Aggregations