javax.ws.rs.core.MediaType#WILDCARD源码实例Demo

下面列出了javax.ws.rs.core.MediaType#WILDCARD 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: nifi-registry   文件: ExtensionResource.java
@GET
@Path("/tags")
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Get extension tags",
        notes = "Gets all the extension tags known to this NiFi Registry instance, along with the " +
                "number of extensions that have the given tag." + NON_GUARANTEED_ENDPOINT,
        response = TagCount.class,
        responseContainer = "List"
)
@ApiResponses({
        @ApiResponse(code = 400, message = HttpStatusMessages.MESSAGE_400),
        @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401),
        @ApiResponse(code = 403, message = HttpStatusMessages.MESSAGE_403),
        @ApiResponse(code = 404, message = HttpStatusMessages.MESSAGE_404),
        @ApiResponse(code = 409, message = HttpStatusMessages.MESSAGE_409) })
public Response getTags() {
    final SortedSet<TagCount> tags = serviceFacade.getExtensionTags();
    return Response.status(Response.Status.OK).entity(tags).build();
}
 
源代码2 项目: nifi-registry   文件: ItemResource.java
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Get all items",
        notes = "Get items across all buckets. The returned items will include only items from buckets for which the user is authorized. " +
                "If the user is not authorized to any buckets, an empty list will be returned.",
        response = BucketItem.class,
        responseContainer = "List"
)
@ApiResponses({ @ApiResponse(code = 401, message = HttpStatusMessages.MESSAGE_401) })
public Response getItems() {
    // Service facade with return only items from authorized buckets
    // Note: We don't explicitly check for access to (READ, /buckets) or
    // (READ, /items ) because a user might have access to individual buckets
    // without top-level access. For example, a user that has
    // (READ, /buckets/bucket-id-1) but not access to /buckets should not
    // get a 403 error returned from this endpoint. This has the side effect
    // that a user with no access to any buckets gets an empty array returned
    // from this endpoint instead of 403 as one might expect.
    final List<BucketItem> items = serviceFacade.getBucketItems();
    return Response.status(Response.Status.OK).entity(items).build();
}
 
源代码3 项目: render   文件: ValidationService.java
@Path("v1/owner/{owner}/validate-json/render")
@PUT
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.TEXT_PLAIN)
public Response validateRenderParametersJson(@PathParam("owner") final String owner,
                                             final String json) {
    LOG.info("validateRenderParametersJson: entry, owner={}", owner);
    final String context = RenderParameters.class.getName() + " instance";
    Response response;
    try {
        final RenderParameters renderParameters = RenderParameters.parseJson(json);
        renderParameters.initializeDerivedValues();
        renderParameters.validate();
        response = getParseSuccessResponse(context, String.valueOf(renderParameters));
    } catch (final Throwable t) {
        response = getParseFailureResponse(t, context, json);
    }
    return response;
}
 
源代码4 项目: localization_nifi   文件: FlowResource.java
/**
 * Retrieves the specified remote process groups status history.
 *
 * @param groupId The group id
 * @return A processorEntity.
 * @throws InterruptedException if interrupted
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("process-groups/{id}/status/history")
@ApiOperation(
        value = "Gets status history for a remote process group",
        response = StatusHistoryEntity.class,
        authorizations = {
                @Authorization(value = "Read - /flow", 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 getProcessGroupStatusHistory(
        @ApiParam(
                value = "The process group id.",
                required = true
        )
        @PathParam("id") String groupId) throws InterruptedException {

    authorizeFlow();

    // replicate if cluster manager
    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }

    // get the specified processor status history
    final StatusHistoryEntity entity = serviceFacade.getProcessGroupStatusHistory(groupId);
    return clusterContext(generateOkResponse(entity)).build();
}
 
源代码5 项目: nifi   文件: FlowResource.java
/**
 * Retrieves controller services for reporting tasks in this NiFi.
 *
 * @return A controllerServicesEntity.
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("controller/controller-services")
@ApiOperation(
        value = "Gets controller services for reporting tasks",
        response = ControllerServicesEntity.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 = 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 getControllerServicesFromController() {

    authorizeFlow();

    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }

    // get all the controller services
    final Set<ControllerServiceEntity> controllerServices = serviceFacade.getControllerServices(null, false, false);
    controllerServiceResource.populateRemainingControllerServiceEntitiesContent(controllerServices);

    // create the response entity
    final ControllerServicesEntity entity = new ControllerServicesEntity();
    entity.setCurrentTime(new Date());
    entity.setControllerServices(controllerServices);

    // generate the response
    return generateOkResponse(entity).build();
}
 
源代码6 项目: nifi   文件: ControllerResource.java
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("registry-clients")
@ApiOperation(value = "Gets the listing of available registry clients", response = RegistryClientsEntity.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 getRegistryClients() {
    authorizeController(RequestAction.READ);

    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }

    final Set<RegistryClientEntity> registries = serviceFacade.getRegistryClients();
    registries.forEach(registry -> populateRemainingRegistryEntityContent(registry));

    final RegistryClientsEntity registryEntities = new RegistryClientsEntity();
    registryEntities.setRegistries(registries);

    return generateOkResponse(registryEntities).build();
}
 
源代码7 项目: localization_nifi   文件: FlowResource.java
/**
 * Retrieves the types of reporting tasks that this NiFi supports.
 *
 * @return A controllerServicesTypesEntity.
 * @throws InterruptedException if interrupted
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("reporting-task-types")
@ApiOperation(
        value = "Retrieves the types of reporting tasks that this NiFi supports",
        notes = NON_GUARANTEED_ENDPOINT,
        response = ReportingTaskTypesEntity.class,
        authorizations = {
                @Authorization(value = "Read - /flow", 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 = 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 getReportingTaskTypes() throws InterruptedException {
    authorizeFlow();

    // create response entity
    final ReportingTaskTypesEntity entity = new ReportingTaskTypesEntity();
    entity.setReportingTaskTypes(serviceFacade.getReportingTaskTypes());

    // generate the response
    return clusterContext(generateOkResponse(entity)).build();
}
 
源代码8 项目: nifi   文件: VersionsResource.java
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("update-requests/{id}")
@ApiOperation(
        value = "Deletes the Update Request with the given ID",
        response = VersionedFlowUpdateRequestEntity.class,
        notes = "Deletes the Update Request with the given ID. After a request is created via a POST to /versions/update-requests/process-groups/{id}, it is expected "
            + "that the client will properly clean up the request by DELETE'ing it, once the Update process has completed. If the request is deleted before the request "
            + "completes, then the Update request will finish the step that it is currently performing and then will cancel any subsequent steps. "
            + NON_GUARANTEED_ENDPOINT,
        authorizations = {
            @Authorization(value = "Only the user that submitted the request can remove it")
        })
@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 deleteUpdateRequest(
        @ApiParam(
                value = "Acknowledges that this node is disconnected to allow for mutable requests to proceed.",
                required = false
        )
        @QueryParam(DISCONNECTED_NODE_ACKNOWLEDGED) @DefaultValue("false") final Boolean disconnectedNodeAcknowledged,
        @ApiParam("The ID of the Update Request") @PathParam("id") final String updateRequestId) {

    return deleteFlowUpdateRequest("update-requests", updateRequestId, disconnectedNodeAcknowledged.booleanValue());
}
 
源代码9 项目: localization_nifi   文件: TenantsResource.java
/**
 * Removes the specified user.
 *
 * @param httpServletRequest request
 * @param version            The revision is used to verify the client is working with
 *                           the latest version of the flow.
 * @param clientId           Optional client id. If the client id is not specified, a
 *                           new one will be generated. This value (whether specified or generated) is
 *                           included in the response.
 * @param id                 The id of the user to remove.
 * @return A entity containing the client id and an updated revision.
 */
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("users/{id}")
@ApiOperation(
        value = "Deletes a user",
        notes = NON_GUARANTEED_ENDPOINT,
        response = UserEntity.class,
        authorizations = {
                @Authorization(value = "Write - /tenants", 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 removeUser(
        @Context final HttpServletRequest httpServletRequest,
        @ApiParam(
                value = "The revision is used to verify the client is working with the latest version of the flow.",
                required = false
        )
        @QueryParam(VERSION) final LongParameter version,
        @ApiParam(
                value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
                required = false
        )
        @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) final ClientIdParameter clientId,
        @ApiParam(
                value = "The user id.",
                required = true
        )
        @PathParam("id") final String id) {

    // ensure we're running with a configurable authorizer
    if (!(authorizer instanceof AbstractPolicyBasedAuthorizer)) {
        throw new IllegalStateException(AccessPolicyDAO.MSG_NON_ABSTRACT_POLICY_BASED_AUTHORIZER);
    }

    if (isReplicateRequest()) {
        return replicate(HttpMethod.DELETE);
    }

    final UserEntity requestUserEntity = new UserEntity();
    requestUserEntity.setId(id);

    // handle expects request (usually from the cluster manager)
    final Revision requestRevision = new Revision(version == null ? null : version.getLong(), clientId.getClientId(), id);
    return withWriteLock(
            serviceFacade,
            requestUserEntity,
            requestRevision,
            lookup -> {
                final Authorizable tenants = lookup.getTenant();
                tenants.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
            },
            null,
            (revision, userEntity) -> {
                // delete the specified user
                final UserEntity entity = serviceFacade.deleteUser(revision, userEntity.getId());
                return clusterContext(generateOkResponse(entity)).build();
            }
    );
}
 
源代码10 项目: nifi   文件: TenantsResource.java
/**
 * Removes the specified user.
 *
 * @param httpServletRequest request
 * @param version            The revision is used to verify the client is working with
 *                           the latest version of the flow.
 * @param clientId           Optional client id. If the client id is not specified, a
 *                           new one will be generated. This value (whether specified or generated) is
 *                           included in the response.
 * @param id                 The id of the user to remove.
 * @return A entity containing the client id and an updated revision.
 */
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("users/{id}")
@ApiOperation(
        value = "Deletes a user",
        notes = NON_GUARANTEED_ENDPOINT,
        response = UserEntity.class,
        authorizations = {
                @Authorization(value = "Write - /tenants")
        }
)
@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 removeUser(
        @Context final HttpServletRequest httpServletRequest,
        @ApiParam(
                value = "The revision is used to verify the client is working with the latest version of the flow.",
                required = false
        )
        @QueryParam(VERSION) final LongParameter version,
        @ApiParam(
                value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
                required = false
        )
        @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) final ClientIdParameter clientId,
        @ApiParam(
                value = "Acknowledges that this node is disconnected to allow for mutable requests to proceed.",
                required = false
        )
        @QueryParam(DISCONNECTED_NODE_ACKNOWLEDGED) @DefaultValue("false") final Boolean disconnectedNodeAcknowledged,
        @ApiParam(
                value = "The user id.",
                required = true
        )
        @PathParam("id") final String id) {

    // ensure we're running with a configurable authorizer
    if (!AuthorizerCapabilityDetection.isConfigurableUserGroupProvider(authorizer)) {
        throw new IllegalStateException(AccessPolicyDAO.MSG_NON_CONFIGURABLE_USERS);
    }

    if (isReplicateRequest()) {
        return replicate(HttpMethod.DELETE);
    } else if (isDisconnectedFromCluster()) {
        verifyDisconnectedNodeModification(disconnectedNodeAcknowledged);
    }

    final UserEntity requestUserEntity = new UserEntity();
    requestUserEntity.setId(id);

    // handle expects request (usually from the cluster manager)
    final Revision requestRevision = new Revision(version == null ? null : version.getLong(), clientId.getClientId(), id);
    return withWriteLock(
            serviceFacade,
            requestUserEntity,
            requestRevision,
            lookup -> {
                final Authorizable tenants = lookup.getTenant();
                tenants.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
            },
            null,
            (revision, userEntity) -> {
                // delete the specified user
                final UserEntity entity = serviceFacade.deleteUser(revision, userEntity.getId());
                return generateOkResponse(entity).build();
            }
    );
}
 
源代码11 项目: nifi   文件: RemoteProcessGroupResource.java
/**
 * Gets the state for a RemoteProcessGroup.
 *
 * @param id The id of the RemoteProcessGroup
 * @return a componentStateEntity
 * @throws InterruptedException if interrupted
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/state")
@ApiOperation(
    value = "Gets the state for a RemoteProcessGroup",
    response = ComponentStateEntity.class,
    authorizations = {
        @Authorization(value = "Write - /remote-process-groups/{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 getState(
    @ApiParam(
        value = "The processor id.",
        required = true
    )
    @PathParam("id") final String id) throws InterruptedException {

    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }

    // authorize access
    serviceFacade.authorizeAccess(lookup -> {
        final Authorizable authorizable = lookup.getRemoteProcessGroup(id);
        authorizable.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
    });

    // get the component state
    final ComponentStateDTO state = serviceFacade.getRemoteProcessGroupState(id);

    // generate the response entity
    final ComponentStateEntity entity = new ComponentStateEntity();
    entity.setComponentState(state);

    // generate the response
    return generateOkResponse(entity).build();
}
 
源代码12 项目: nifi   文件: ProcessorResource.java
/**
 * Returns the descriptor for the specified property.
 *
 * @param id           The id of the processor
 * @param propertyName The property
 * @return a propertyDescriptorEntity
 * @throws InterruptedException if interrupted
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/descriptors")
@ApiOperation(
        value = "Gets the descriptor for a processor property",
        response = PropertyDescriptorEntity.class,
        authorizations = {
                @Authorization(value = "Read - /processors/{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 getPropertyDescriptor(
        @ApiParam(
                value = "If the client id is not specified, new one will be generated. This value (whether specified or generated) is included in the response.",
                required = false
        )
        @QueryParam(CLIENT_ID) @DefaultValue(StringUtils.EMPTY) final ClientIdParameter clientId,
        @ApiParam(
                value = "The processor id.",
                required = true
        )
        @PathParam("id") final String id,
        @ApiParam(
                value = "The property name.",
                required = true
        )
        @QueryParam("propertyName") final String propertyName) throws InterruptedException {

    // ensure the property name is specified
    if (propertyName == null) {
        throw new IllegalArgumentException("The property name must be specified.");
    }

    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }

    // authorize access
    serviceFacade.authorizeAccess(lookup -> {
        final Authorizable processor = lookup.getProcessor(id).getAuthorizable();
        processor.authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
    });

    // get the property descriptor
    final PropertyDescriptorDTO descriptor = serviceFacade.getProcessorPropertyDescriptor(id, propertyName);

    // generate the response entity
    final PropertyDescriptorEntity entity = new PropertyDescriptorEntity();
    entity.setPropertyDescriptor(descriptor);

    // generate the response
    return generateOkResponse(entity).build();
}
 
源代码13 项目: nifi   文件: TenantsResource.java
/**
 * Retrieves all the of user groups in this NiFi.
 *
 * @return A UserGroupsEntity.
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("user-groups")
@ApiOperation(
        value = "Gets all user groups",
        notes = NON_GUARANTEED_ENDPOINT,
        response = UserGroupsEntity.class,
        authorizations = {
                @Authorization(value = "Read - /tenants")
        }
)
@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 getUserGroups() {

    // ensure we're running with a configurable authorizer
    if (!AuthorizerCapabilityDetection.isManagedAuthorizer(authorizer)) {
        throw new IllegalStateException(AccessPolicyDAO.MSG_NON_MANAGED_AUTHORIZER);
    }

    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }

    // authorize access
    serviceFacade.authorizeAccess(lookup -> {
        final Authorizable tenants = lookup.getTenant();
        tenants.authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
    });

    // get all the user groups
    final Set<UserGroupEntity> users = serviceFacade.getUserGroups();

    // create the response entity
    final UserGroupsEntity entity = new UserGroupsEntity();
    entity.setUserGroups(populateRemainingUserGroupEntitiesContent(users));

    // generate the response
    return generateOkResponse(entity).build();
}
 
源代码14 项目: nifi   文件: ProcessorResource.java
/**
 * Clears the state for a processor.
 *
 * @param httpServletRequest servlet request
 * @param id                 The id of the processor
 * @return a componentStateEntity
 * @throws InterruptedException if interrupted
 */
@POST
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/state/clear-requests")
@ApiOperation(
        value = "Clears the state for a processor",
        response = ComponentStateEntity.class,
        authorizations = {
                @Authorization(value = "Write - /processors/{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 clearState(
        @Context final HttpServletRequest httpServletRequest,
        @ApiParam(
                value = "The processor id.",
                required = true
        )
        @PathParam("id") final String id) throws InterruptedException {

    if (isReplicateRequest()) {
        return replicate(HttpMethod.POST);
    }

    final ProcessorEntity requestProcessorEntity = new ProcessorEntity();
    requestProcessorEntity.setId(id);

    return withWriteLock(
            serviceFacade,
            requestProcessorEntity,
            lookup -> {
                final Authorizable processor = lookup.getProcessor(id).getAuthorizable();
                processor.authorize(authorizer, RequestAction.WRITE, NiFiUserUtils.getNiFiUser());
            },
            () -> serviceFacade.verifyCanClearProcessorState(id),
            (processorEntity) -> {
                // get the component state
                serviceFacade.clearProcessorState(processorEntity.getId());

                // generate the response entity
                final ComponentStateEntity entity = new ComponentStateEntity();

                // generate the response
                return generateOkResponse(entity).build();
            }
    );
}
 
源代码15 项目: nifi   文件: ControllerResource.java
/**
 * Gets the contents of this NiFi cluster. This includes all nodes and their status.
 *
 * @return A clusterEntity
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("cluster")
@ApiOperation(
        value = "Gets the contents of the cluster",
        notes = "Returns the contents of the cluster including all nodes and their status.",
        response = ClusterEntity.class,
        authorizations = {
                @Authorization(value = "Read - /controller")
        }
)
@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 = 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 getCluster() {

    authorizeController(RequestAction.READ);

    // ensure connected to the cluster
    if (!isConnectedToCluster()) {
        throw new IllegalClusterResourceRequestException("Only a node connected to a cluster can process the request.");
    }

    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET, getClusterCoordinatorNode());
    }

    final ClusterDTO dto = serviceFacade.getCluster();

    // create entity
    final ClusterEntity entity = new ClusterEntity();
    entity.setCluster(dto);

    // generate the response
    return generateOkResponse(entity).build();
}
 
源代码16 项目: localization_nifi   文件: FlowResource.java
/**
 * Gets the action for the corresponding id.
 *
 * @param id The id of the action to get.
 * @return An actionEntity.
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("history/{id}")
@ApiOperation(
        value = "Gets an action",
        notes = NON_GUARANTEED_ENDPOINT,
        response = ActionEntity.class,
        authorizations = {
                @Authorization(value = "Read - /flow", 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 getAction(
        @ApiParam(
                value = "The action id.",
                required = true
        )
        @PathParam("id") IntegerParameter id) {

    authorizeFlow();

    // ensure the id was specified
    if (id == null) {
        throw new IllegalArgumentException("The action id must be specified.");
    }

    // Note: History requests are not replicated throughout the cluster and are instead handled by the nodes independently

    // get the response entity for the specified action
    final ActionEntity entity = serviceFacade.getAction(id.getInteger());

    // generate the response
    return generateOkResponse(entity).build();
}
 
/**
 * Retrieves the specified controller service.
 *
 * @param id The id of the controller service to retrieve
 * @return A controllerServiceEntity.
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}")
@ApiOperation(
        value = "Gets a controller service",
        response = ControllerServiceEntity.class,
        authorizations = {
                @Authorization(value = "Read - /controller-services/{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 getControllerService(
        @ApiParam(
                value = "The controller service id.",
                required = true
        )
        @PathParam("id") final String id) {

    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }

    // authorize access
    serviceFacade.authorizeAccess(lookup -> {
        final Authorizable controllerService = lookup.getControllerService(id).getAuthorizable();
        controllerService.authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
    });

    // get the controller service
    final ControllerServiceEntity entity = serviceFacade.getControllerService(id);
    populateRemainingControllerServiceEntityContent(entity);

    return clusterContext(generateOkResponse(entity)).build();
}
 
源代码18 项目: nifi   文件: FlowFileQueueResource.java
/**
 * Deletes the specified listing request.
 *
 * @param httpServletRequest request
 * @param connectionId       The connection id
 * @param listingRequestId   The drop request id
 * @return A dropRequestEntity
 */
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("{id}/listing-requests/{listing-request-id}")
@ApiOperation(
        value = "Cancels and/or removes a request to list the contents of this 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 deleteListingRequest(
        @Context final HttpServletRequest httpServletRequest,
        @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.DELETE);
    }

    return withWriteLock(
            serviceFacade,
            new ListingEntity(connectionId, listingRequestId),
            lookup -> {
                final ConnectionAuthorizable connAuth = lookup.getConnection(connectionId);
                final Authorizable dataAuthorizable = connAuth.getSourceData();
                dataAuthorizable.authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser());
            },
            null,
            (listingEntity) -> {
                // delete the listing request
                final ListingRequestDTO listingRequest = serviceFacade.deleteFlowFileListingRequest(listingEntity.getConnectionId(), listingEntity.getListingRequestId());

                // prune the results as they were already received when the listing completed
                listingRequest.setFlowFileSummaries(null);

                // populate remaining content
                populateRemainingFlowFileListingContent(listingEntity.getConnectionId(), listingRequest);

                // create the response entity
                final ListingRequestEntity entity = new ListingRequestEntity();
                entity.setListingRequest(listingRequest);

                return generateOkResponse(entity).build();
            }
    );
}
 
源代码19 项目: localization_nifi   文件: FlowResource.java
/**
 * Retrieves all the of templates in this NiFi.
 *
 * @return A templatesEntity.
 */
@GET
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("templates")
@ApiOperation(
        value = "Gets all templates",
        response = TemplatesEntity.class,
        authorizations = {
                @Authorization(value = "Read - /flow", 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 = 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 getTemplates() {

    if (isReplicateRequest()) {
        return replicate(HttpMethod.GET);
    }

    // authorize access
    authorizeFlow();

    // get all the templates
    final Set<TemplateEntity> templates = serviceFacade.getTemplates();
    templateResource.populateRemainingTemplateEntitiesContent(templates);

    // create the response entity
    final TemplatesEntity entity = new TemplatesEntity();
    entity.setTemplates(templates);
    entity.setGenerated(new Date());

    // generate the response
    return clusterContext(generateOkResponse(entity)).build();
}
 
源代码20 项目: localization_nifi   文件: ControllerResource.java
/**
 * Removes the specified from this NiFi cluster.
 *
 * @param id The id of the node
 * @return A nodeEntity
 */
@DELETE
@Consumes(MediaType.WILDCARD)
@Produces(MediaType.APPLICATION_JSON)
@Path("cluster/nodes/{id}")
@ApiOperation(
        value = "Removes a node from the cluster",
        response = NodeEntity.class,
        authorizations = {
                @Authorization(value = "Write - /controller", 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 deleteNode(
        @ApiParam(
                value = "The node id.",
                required = true
        )
        @PathParam("id") String id) {

    authorizeController(RequestAction.WRITE);

    // ensure connected to the cluster
    if (!isConnectedToCluster()) {
        throw new IllegalClusterResourceRequestException("Only a node connected to a cluster can process the request.");
    }

    if (isReplicateRequest()) {
        return replicateToCoordinator(HttpMethod.DELETE, getRequestParameters());
    }

    serviceFacade.deleteNode(id);

    // create the response entity
    final NodeEntity entity = new NodeEntity();

    // generate the response
    return generateOkResponse(entity).build();
}