Search in sources :

Example 6 with ListingRequestDTO

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

the class StandardNiFiServiceFacade method deleteFlowFileListingRequest.

@Override
public ListingRequestDTO deleteFlowFileListingRequest(final String connectionId, final String listingRequestId) {
    final Connection connection = connectionDAO.getConnection(connectionId);
    final ListingRequestDTO listRequest = dtoFactory.createListingRequestDTO(connectionDAO.deleteFlowFileListingRequest(connectionId, listingRequestId));
    // include whether the source and destination are running
    if (connection.getSource() != null) {
        listRequest.setSourceRunning(connection.getSource().isRunning());
    }
    if (connection.getDestination() != null) {
        listRequest.setDestinationRunning(connection.getDestination().isRunning());
    }
    return listRequest;
}
Also used : ListingRequestDTO(org.apache.nifi.web.api.dto.ListingRequestDTO) Connection(org.apache.nifi.connectable.Connection) VersionedConnection(org.apache.nifi.registry.flow.VersionedConnection)

Example 7 with ListingRequestDTO

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

the class FlowFileQueueResource method getListingRequest.

/**
 * Checks the status of an outstanding listing request.
 *
 * @param connectionId     The id of the connection
 * @param listingRequestId The id of the drop request
 * @return A dropRequestEntity
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/listing-requests/{listing-request-id}")
@ApiOperation(value = "Gets the current status of a listing request for the specified connection.", response = ListingRequestEntity.class, authorizations = { @Authorization(value = "Read Source Data - /data/{component-type}/{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 getListingRequest(@ApiParam(value = "The connection id.", required = true) @PathParam("id") final String connectionId, @ApiParam(value = "The listing request id.", required = true) @PathParam("listing-request-id") final String listingRequestId) {
    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }
    // authorize access
    serviceFacade.authorizeAccess(lookup -> {
        final ConnectionAuthorizable connAuth = lookup.getConnection(connectionId);
        final Authorizable dataAuthorizable = connAuth.getSourceData();
        dataAuthorizable.authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
    });
    // get the listing request
    final ListingRequestDTO listingRequest = serviceFacade.getFlowFileListingRequest(connectionId, listingRequestId);
    populateRemainingFlowFileListingContent(connectionId, listingRequest);
    // create the response entity
    final ListingRequestEntity entity = new ListingRequestEntity();
    entity.setListingRequest(listingRequest);
    return generateOkResponse(entity).build();
}
Also used : ListingRequestDTO(org.apache.nifi.web.api.dto.ListingRequestDTO) Authorizable(org.apache.nifi.authorization.resource.Authorizable) ConnectionAuthorizable(org.apache.nifi.authorization.ConnectionAuthorizable) ConnectionAuthorizable(org.apache.nifi.authorization.ConnectionAuthorizable) ListingRequestEntity(org.apache.nifi.web.api.entity.ListingRequestEntity) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Aggregations

ListingRequestDTO (org.apache.nifi.web.api.dto.ListingRequestDTO)7 ApiOperation (io.swagger.annotations.ApiOperation)3 ApiResponses (io.swagger.annotations.ApiResponses)3 Consumes (javax.ws.rs.Consumes)3 Path (javax.ws.rs.Path)3 Produces (javax.ws.rs.Produces)3 ConnectionAuthorizable (org.apache.nifi.authorization.ConnectionAuthorizable)3 Authorizable (org.apache.nifi.authorization.resource.Authorizable)3 Connection (org.apache.nifi.connectable.Connection)3 VersionedConnection (org.apache.nifi.registry.flow.VersionedConnection)3 ListingRequestEntity (org.apache.nifi.web.api.entity.ListingRequestEntity)3 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 Map (java.util.Map)1 TreeSet (java.util.TreeSet)1 DELETE (javax.ws.rs.DELETE)1 GET (javax.ws.rs.GET)1 POST (javax.ws.rs.POST)1 NodeIdentifier (org.apache.nifi.cluster.protocol.NodeIdentifier)1