Java Code Examples for org.apache.nifi.web.api.dto.PortDTO#getPosition()
The following examples show how to use
org.apache.nifi.web.api.dto.PortDTO#getPosition() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlowController.java From localization_nifi with Apache License 2.0 | 6 votes |
public PortDTO updateInputPort(final String parentGroupId, final PortDTO dto) { final ProcessGroup parentGroup = lookupGroup(parentGroupId); final Port port = parentGroup.getInputPort(dto.getId()); if (port == null) { throw new IllegalStateException("No Input Port with ID " + dto.getId() + " is known as a child of ProcessGroup with ID " + parentGroupId); } final String name = dto.getName(); if (dto.getPosition() != null) { port.setPosition(toPosition(dto.getPosition())); } if (name != null) { port.setName(name); } return createDTO(port); }
Example 2
Source File: FlowController.java From localization_nifi with Apache License 2.0 | 6 votes |
public PortDTO updateOutputPort(final String parentGroupId, final PortDTO dto) { final ProcessGroup parentGroup = lookupGroup(parentGroupId); final Port port = parentGroup.getOutputPort(dto.getId()); if (port == null) { throw new IllegalStateException("No Output Port with ID " + dto.getId() + " is known as a child of ProcessGroup with ID " + parentGroupId); } final String name = dto.getName(); if (name != null) { port.setName(name); } if (dto.getPosition() != null) { port.setPosition(toPosition(dto.getPosition())); } return createDTO(port); }
Example 3
Source File: StandardInputPortDAO.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public Port createPort(String groupId, PortDTO portDTO) { if (isNotNull(portDTO.getParentGroupId()) && !flowController.areGroupsSame(groupId, portDTO.getParentGroupId())) { throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the InputPort is being added."); } // ensure the name has been specified if (portDTO.getName() == null) { throw new IllegalArgumentException("Port name must be specified."); } // get the desired group ProcessGroup group = locateProcessGroup(flowController, groupId); // determine if this is the root group Port port; if (group.getParent() == null) { port = flowController.createRemoteInputPort(portDTO.getId(), portDTO.getName()); } else { port = flowController.createLocalInputPort(portDTO.getId(), portDTO.getName()); } // ensure we can perform the update before we add the processor to the flow verifyUpdate(port, portDTO); // configure if (portDTO.getPosition() != null) { port.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY())); } port.setComments(portDTO.getComments()); // add the port group.addInputPort(port); return port; }
Example 4
Source File: StandardOutputPortDAO.java From localization_nifi with Apache License 2.0 | 5 votes |
@Override public Port createPort(String groupId, PortDTO portDTO) { if (isNotNull(portDTO.getParentGroupId()) && !flowController.areGroupsSame(groupId, portDTO.getParentGroupId())) { throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the OutputPort is being added."); } // ensure the name has been specified if (portDTO.getName() == null) { throw new IllegalArgumentException("Port name must be specified."); } // get the desired group ProcessGroup group = locateProcessGroup(flowController, groupId); // determine if this is the root group Port port; if (group.getParent() == null) { port = flowController.createRemoteOutputPort(portDTO.getId(), portDTO.getName()); } else { port = flowController.createLocalOutputPort(portDTO.getId(), portDTO.getName()); } // ensure we can perform the update before we add the processor to the flow verifyUpdate(port, portDTO); // configure if (portDTO.getPosition() != null) { port.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY())); } port.setComments(portDTO.getComments()); // add the port group.addOutputPort(port); return port; }
Example 5
Source File: StandardInputPortDAO.java From nifi with Apache License 2.0 | 5 votes |
@Override public Port createPort(String groupId, PortDTO portDTO) { if (isNotNull(portDTO.getParentGroupId()) && !flowController.getFlowManager().areGroupsSame(groupId, portDTO.getParentGroupId())) { throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the InputPort is being added."); } // ensure the name has been specified if (portDTO.getName() == null) { throw new IllegalArgumentException("Port name must be specified."); } // get the desired group ProcessGroup group = locateProcessGroup(flowController, groupId); // determine if this is the root group Port port; if (group.getParent() == null || Boolean.TRUE.equals(portDTO.getAllowRemoteAccess())) { port = flowController.getFlowManager().createPublicInputPort(portDTO.getId(), portDTO.getName()); } else { port = flowController.getFlowManager().createLocalInputPort(portDTO.getId(), portDTO.getName()); } // Unique public port check among all groups. if (port instanceof PublicPort) { verifyPublicPortUniqueness(port.getIdentifier(), port.getName()); } // ensure we can perform the update before we add the port to the flow verifyUpdate(port, portDTO); // configure if (portDTO.getPosition() != null) { port.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY())); } port.setComments(portDTO.getComments()); // add the port group.addInputPort(port); return port; }
Example 6
Source File: StandardOutputPortDAO.java From nifi with Apache License 2.0 | 5 votes |
@Override public Port createPort(String groupId, PortDTO portDTO) { if (isNotNull(portDTO.getParentGroupId()) && !flowController.getFlowManager().areGroupsSame(groupId, portDTO.getParentGroupId())) { throw new IllegalArgumentException("Cannot specify a different Parent Group ID than the Group to which the OutputPort is being added."); } // ensure the name has been specified if (portDTO.getName() == null) { throw new IllegalArgumentException("Port name must be specified."); } // get the desired group ProcessGroup group = locateProcessGroup(flowController, groupId); // determine if this is the root group Port port; if (group.getParent() == null || Boolean.TRUE.equals(portDTO.getAllowRemoteAccess())) { port = flowController.getFlowManager().createPublicOutputPort(portDTO.getId(), portDTO.getName()); } else { port = flowController.getFlowManager().createLocalOutputPort(portDTO.getId(), portDTO.getName()); } // Unique public port check among all groups. if (port instanceof PublicPort) { verifyPublicPortUniqueness(port.getIdentifier(), port.getName()); } // ensure we can perform the update before we add the port to the flow verifyUpdate(port, portDTO); // configure if (portDTO.getPosition() != null) { port.setPosition(new Position(portDTO.getPosition().getX(), portDTO.getPosition().getY())); } port.setComments(portDTO.getComments()); // add the port group.addOutputPort(port); return port; }
Example 7
Source File: InputPortResource.java From localization_nifi with Apache License 2.0 | 4 votes |
/** * Updates the specified input port. * * @param httpServletRequest request * @param id The id of the input port to update. * @param requestPortEntity A inputPortEntity. * @return A inputPortEntity. */ @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("{id}") @ApiOperation( value = "Updates an input port", response = PortEntity.class, authorizations = { @Authorization(value = "Write - /input-ports/{uuid}", type = "") } ) @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 updateInputPort( @Context HttpServletRequest httpServletRequest, @ApiParam( value = "The input port id.", required = true ) @PathParam("id") final String id, @ApiParam( value = "The input port configuration details.", required = true ) final PortEntity requestPortEntity) { if (requestPortEntity == null || requestPortEntity.getComponent() == null) { throw new IllegalArgumentException("Input port details must be specified."); } if (requestPortEntity.getRevision() == null) { throw new IllegalArgumentException("Revision must be specified."); } // ensure the ids are the same final PortDTO requestPortDTO = requestPortEntity.getComponent(); if (!id.equals(requestPortDTO.getId())) { throw new IllegalArgumentException(String.format("The input port id (%s) in the request body does not equal the " + "input port id of the requested resource (%s).", requestPortDTO.getId(), id)); } final PositionDTO proposedPosition = requestPortDTO.getPosition(); if (proposedPosition != null) { if (proposedPosition.getX() == null || proposedPosition.getY() == null) { throw new IllegalArgumentException("The x and y coordinate of the proposed position must be specified."); } } if (isReplicateRequest()) { return replicate(HttpMethod.PUT, requestPortEntity); } // handle expects request (usually from the cluster manager) final Revision requestRevision = getRevision(requestPortEntity, id); return withWriteLock( serviceFacade, requestPortEntity, requestRevision, lookup -> { Authorizable authorizable = lookup.getInputPort(id); authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser()); }, () -> serviceFacade.verifyUpdateInputPort(requestPortDTO), (revision, portEntity) -> { final PortDTO portDTO = portEntity.getComponent(); // update the input port final PortEntity entity = serviceFacade.updateInputPort(revision, portDTO); populateRemainingInputPortEntityContent(entity); return clusterContext(generateOkResponse(entity)).build(); } ); }
Example 8
Source File: OutputPortResource.java From localization_nifi with Apache License 2.0 | 4 votes |
/** * Updates the specified output port. * * @param httpServletRequest request * @param id The id of the output port to update. * @param requestPortEntity A outputPortEntity. * @return A outputPortEntity. */ @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("{id}") @ApiOperation( value = "Updates an output port", response = PortEntity.class, authorizations = { @Authorization(value = "Write - /output-ports/{uuid}", type = "") } ) @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 updateOutputPort( @Context final HttpServletRequest httpServletRequest, @ApiParam( value = "The output port id.", required = true ) @PathParam("id") final String id, @ApiParam( value = "The output port configuration details.", required = true ) final PortEntity requestPortEntity) { if (requestPortEntity == null || requestPortEntity.getComponent() == null) { throw new IllegalArgumentException("Output port details must be specified."); } if (requestPortEntity.getRevision() == null) { throw new IllegalArgumentException("Revision must be specified."); } // ensure the ids are the same PortDTO requestPortDTO = requestPortEntity.getComponent(); if (!id.equals(requestPortDTO.getId())) { throw new IllegalArgumentException(String.format("The output port id (%s) in the request body does not equal the " + "output port id of the requested resource (%s).", requestPortDTO.getId(), id)); } final PositionDTO proposedPosition = requestPortDTO.getPosition(); if (proposedPosition != null) { if (proposedPosition.getX() == null || proposedPosition.getY() == null) { throw new IllegalArgumentException("The x and y coordinate of the proposed position must be specified."); } } if (isReplicateRequest()) { return replicate(HttpMethod.PUT, requestPortEntity); } // handle expects request (usually from the cluster manager) final Revision requestRevision = getRevision(requestPortEntity, id); return withWriteLock( serviceFacade, requestPortEntity, requestRevision, lookup -> { Authorizable authorizable = lookup.getOutputPort(id); authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser()); }, () -> serviceFacade.verifyUpdateOutputPort(requestPortDTO), (revision, portEntity) -> { final PortDTO portDTO = portEntity.getComponent(); // update the output port final PortEntity entity = serviceFacade.updateOutputPort(revision, portDTO); populateRemainingOutputPortEntityContent(entity); return clusterContext(generateOkResponse(entity)).build(); } ); }
Example 9
Source File: InputPortResource.java From nifi with Apache License 2.0 | 4 votes |
/** * Updates the specified input port. * * @param httpServletRequest request * @param id The id of the input port to update. * @param requestPortEntity A inputPortEntity. * @return A inputPortEntity. */ @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("{id}") @ApiOperation( value = "Updates an input port", response = PortEntity.class, authorizations = { @Authorization(value = "Write - /input-ports/{uuid}") } ) @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 updateInputPort( @Context HttpServletRequest httpServletRequest, @ApiParam( value = "The input port id.", required = true ) @PathParam("id") final String id, @ApiParam( value = "The input port configuration details.", required = true ) final PortEntity requestPortEntity) { if (requestPortEntity == null || requestPortEntity.getComponent() == null) { throw new IllegalArgumentException("Input port details must be specified."); } if (requestPortEntity.getRevision() == null) { throw new IllegalArgumentException("Revision must be specified."); } // ensure the ids are the same final PortDTO requestPortDTO = requestPortEntity.getComponent(); if (!id.equals(requestPortDTO.getId())) { throw new IllegalArgumentException(String.format("The input port id (%s) in the request body does not equal the " + "input port id of the requested resource (%s).", requestPortDTO.getId(), id)); } final PositionDTO proposedPosition = requestPortDTO.getPosition(); if (proposedPosition != null) { if (proposedPosition.getX() == null || proposedPosition.getY() == null) { throw new IllegalArgumentException("The x and y coordinate of the proposed position must be specified."); } } if (isReplicateRequest()) { return replicate(HttpMethod.PUT, requestPortEntity); } else if (isDisconnectedFromCluster()) { verifyDisconnectedNodeModification(requestPortEntity.isDisconnectedNodeAcknowledged()); } // handle expects request (usually from the cluster manager) final Revision requestRevision = getRevision(requestPortEntity, id); return withWriteLock( serviceFacade, requestPortEntity, requestRevision, lookup -> { Authorizable authorizable = lookup.getInputPort(id); authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser()); }, () -> serviceFacade.verifyUpdateInputPort(requestPortDTO), (revision, portEntity) -> { final PortDTO portDTO = portEntity.getComponent(); // update the input port final PortEntity entity = serviceFacade.updateInputPort(revision, portDTO); populateRemainingInputPortEntityContent(entity); return generateOkResponse(entity).build(); } ); }
Example 10
Source File: OutputPortResource.java From nifi with Apache License 2.0 | 4 votes |
/** * Updates the specified output port. * * @param httpServletRequest request * @param id The id of the output port to update. * @param requestPortEntity A outputPortEntity. * @return A outputPortEntity. */ @PUT @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("{id}") @ApiOperation( value = "Updates an output port", response = PortEntity.class, authorizations = { @Authorization(value = "Write - /output-ports/{uuid}") } ) @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 updateOutputPort( @Context final HttpServletRequest httpServletRequest, @ApiParam( value = "The output port id.", required = true ) @PathParam("id") final String id, @ApiParam( value = "The output port configuration details.", required = true ) final PortEntity requestPortEntity) { if (requestPortEntity == null || requestPortEntity.getComponent() == null) { throw new IllegalArgumentException("Output port details must be specified."); } if (requestPortEntity.getRevision() == null) { throw new IllegalArgumentException("Revision must be specified."); } // ensure the ids are the same PortDTO requestPortDTO = requestPortEntity.getComponent(); if (!id.equals(requestPortDTO.getId())) { throw new IllegalArgumentException(String.format("The output port id (%s) in the request body does not equal the " + "output port id of the requested resource (%s).", requestPortDTO.getId(), id)); } final PositionDTO proposedPosition = requestPortDTO.getPosition(); if (proposedPosition != null) { if (proposedPosition.getX() == null || proposedPosition.getY() == null) { throw new IllegalArgumentException("The x and y coordinate of the proposed position must be specified."); } } if (isReplicateRequest()) { return replicate(HttpMethod.PUT, requestPortEntity); } else if (isDisconnectedFromCluster()) { verifyDisconnectedNodeModification(requestPortEntity.isDisconnectedNodeAcknowledged()); } // handle expects request (usually from the cluster manager) final Revision requestRevision = getRevision(requestPortEntity, id); return withWriteLock( serviceFacade, requestPortEntity, requestRevision, lookup -> { Authorizable authorizable = lookup.getOutputPort(id); authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser()); }, () -> serviceFacade.verifyUpdateOutputPort(requestPortDTO), (revision, portEntity) -> { final PortDTO portDTO = portEntity.getComponent(); // update the output port final PortEntity entity = serviceFacade.updateOutputPort(revision, portDTO); populateRemainingOutputPortEntityContent(entity); return generateOkResponse(entity).build(); } ); }