本文整理了Java中javax.ws.rs.core.Response.status
方法的一些代码示例,展示了Response.status
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.status
方法的具体详情如下:
包路径:javax.ws.rs.core.Response
类名称:Response
方法名:status
[英]Create a new ResponseBuilder with the supplied status.
[中]使用提供的状态创建新的ResponseBuilder。
代码示例来源:origin: prestodb/presto
private static WebApplicationException badRequest(String message)
{
throw new WebApplicationException(Response
.status(Status.BAD_REQUEST)
.type(MediaType.TEXT_PLAIN)
.entity(message)
.build());
}
代码示例来源:origin: prestodb/presto
@GET
@Path("coordinator")
@Produces(TEXT_PLAIN)
public Response getServerCoordinator()
{
if (coordinator) {
return Response.ok().build();
}
// return 404 to allow load balancers to only send traffic to the coordinator
return Response.status(Response.Status.NOT_FOUND).build();
}
}
代码示例来源:origin: apache/incubator-druid
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getDebugInfo()
{
if (httpServerInventoryView == null) {
return Response.status(Response.Status.FORBIDDEN).entity("HttpServerInventoryView is NULL.").build();
}
return Response.ok().entity(httpServerInventoryView.getDebugInfo()).build();
}
}
代码示例来源:origin: vert-x3/vertx-examples
@GET
@Path("/{name:.*}")
public Response doGet(@PathParam("name") String name) {
if (name == null || name.isEmpty()) {
name = "World";
}
return Response.status(200).entity("Hello " + name).build();
}
}
代码示例来源:origin: jersey/jersey
@POST
@Path("webapplication_entity")
public String testWebApplicationExceptionEntity(String s) {
String[] tokens = s.split(":");
assert tokens.length == 2;
int statusCode = Integer.valueOf(tokens[1]);
Response r = Response.status(statusCode).entity(s).build();
throw new WebApplicationException(r);
}
代码示例来源:origin: apache/incubator-druid
@GET
@Path("/readiness")
public Response getReadiness()
{
if (coordinator.isStarted()) {
return Response.ok().build();
} else {
return Response.status(Response.Status.SERVICE_UNAVAILABLE).build();
}
}
}
代码示例来源:origin: apache/incubator-druid
@Override
public final Response handleGET(String id)
{
try {
final Object returnObj = get(id);
if (returnObj == null) {
return Response.status(Response.Status.NOT_FOUND).build();
} else {
return Response.ok(returnObj).build();
}
}
catch (Exception e) {
LOG.error(e, "Error handling get request for [%s]", id);
return Response.serverError().entity(ServletResourceUtils.sanitizeException(e)).build();
}
}
代码示例来源:origin: apache/incubator-druid
@GET
@Path("/datasources/{dataSourceName}")
@Produces(MediaType.APPLICATION_JSON)
@ResourceFilters(DatasourceResourceFilter.class)
public Response getDatabaseSegmentDataSource(@PathParam("dataSourceName") final String dataSourceName)
{
ImmutableDruidDataSource dataSource = metadataSegmentManager.getDataSource(dataSourceName);
if (dataSource == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
return Response.status(Response.Status.OK).entity(dataSource).build();
}
代码示例来源:origin: Graylog2/graylog2-server
@POST
@Path("/{id}/{name}")
@RequiresPermissions({SidecarRestPermissions.CONFIGURATIONS_READ, SidecarRestPermissions.CONFIGURATIONS_CREATE})
@ApiOperation(value = "Copy a configuration")
@AuditEvent(type = SidecarAuditEventTypes.CONFIGURATION_CLONE)
public Response copyConfiguration(@ApiParam(name = "id", required = true)
@PathParam("id") String id,
@PathParam("name") String name) throws NotFoundException {
final Configuration configuration = configurationService.copyConfiguration(id, name);
final ValidationResult validationResult = validate(configuration);
if (validationResult.failed()) {
return Response.status(Response.Status.BAD_REQUEST).entity(validationResult).build();
}
configurationService.save(configuration);
return Response.accepted().build();
}
代码示例来源:origin: apache/incubator-druid
@POST
@Path("/resume")
public Response resumeHTTP(@Context final HttpServletRequest req) throws InterruptedException
{
authorizationCheck(req, Action.WRITE);
resume();
return Response.status(Response.Status.OK).build();
}
代码示例来源:origin: apache/incubator-druid
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getDebugInfo()
{
HttpRemoteTaskRunner httpRemoteTaskRunner = getHttpRemoteTaskRunner();
if (httpRemoteTaskRunner == null) {
return Response.status(Response.Status.FORBIDDEN).entity("HttpRemoteTaskRunner is NULL.").build();
}
return Response.ok().entity(httpRemoteTaskRunner.getDebugInfo()).build();
}
代码示例来源:origin: prestodb/presto
private static WebApplicationException badRequest(Status status, String message)
{
throw new WebApplicationException(
Response.status(status)
.type(TEXT_PLAIN_TYPE)
.entity(message)
.build());
}
代码示例来源:origin: Graylog2/graylog2-server
@POST
@Timed
@Path("/test")
@NoAuditEvent("Only used to test pattern.")
@ApiOperation(value = "Test pattern with sample data")
public Response testPattern(@ApiParam(name = "pattern", required = true) GrokPatternTestRequest request) {
Map<String, Object> result;
try {
result = grokPatternService.match(request.grokPattern(), request.sampleData());
} catch (GrokException | IllegalArgumentException e) {
Map<String, String> error = ImmutableMap.of("message", e.getMessage());
throw new BadRequestException(Response.status(Response.Status.BAD_REQUEST).entity(error).build());
}
return Response.ok(result).build();
}
代码示例来源:origin: apache/incubator-druid
@Override
public Response apply(TaskQueue taskQueue)
{
final List<TaskInfo<Task, TaskStatus>> tasks = taskStorageQueryAdapter.getActiveTaskInfo(dataSource);
if (tasks.isEmpty()) {
return Response.status(Status.NOT_FOUND).build();
} else {
for (final TaskInfo<Task, TaskStatus> task : tasks) {
taskQueue.shutdown(task.getId(), "Shutdown request from user");
}
return Response.ok(ImmutableMap.of("dataSource", dataSource)).build();
}
}
}
代码示例来源:origin: prestodb/presto
@DELETE
@Path("{queryId}/{token}")
@Produces(MediaType.APPLICATION_JSON)
public Response cancelQuery(@PathParam("queryId") QueryId queryId,
@PathParam("token") long token)
{
Query query = queries.get(queryId);
if (query == null) {
return Response.status(Status.NOT_FOUND).build();
}
query.cancel();
return Response.noContent().build();
}
代码示例来源:origin: prestodb/presto
@GET
@Path("{poolId}")
public Response getMemoryInfo(@PathParam("poolId") String poolId)
{
if (GENERAL_POOL.getId().equals(poolId)) {
return toSuccessfulResponse(memoryManager.getGeneralPool().getInfo());
}
if (SYSTEM_POOL.getId().equals(poolId) && memoryManager.getSystemPool().isPresent()) {
return toSuccessfulResponse(memoryManager.getSystemPool().get().getInfo());
}
if (RESERVED_POOL.getId().equals(poolId) && memoryManager.getReservedPool().isPresent()) {
return toSuccessfulResponse(memoryManager.getReservedPool().get().getInfo());
}
return Response.status(NOT_FOUND).build();
}
代码示例来源:origin: apache/incubator-druid
@Override
@POST
@Path("/stop")
public Response stop(@Context final HttpServletRequest req)
{
authorizationCheck(req, Action.WRITE);
stopGracefully();
return Response.status(Response.Status.OK).build();
}
代码示例来源:origin: apache/incubator-druid
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getMap()
{
try {
return Response.ok(getLatest()).build();
}
catch (ISE e) {
return Response.status(Response.Status.NOT_FOUND).entity(ServletResourceUtils.sanitizeException(e)).build();
}
}
代码示例来源:origin: apache/storm
/**
* Build a Response object representing success response with HTML entity.
*
* @param content HTML entity content, String type
*/
public static Response buildSuccessHtmlResponse(String content) {
return Response.status(OK).entity(content)
.type(MediaType.TEXT_HTML_TYPE).build();
}
代码示例来源:origin: prestodb/presto
@GET
@Path("{queryId}")
public Response getQueryInfo(@PathParam("queryId") QueryId queryId)
{
requireNonNull(queryId, "queryId is null");
try {
QueryInfo queryInfo = queryManager.getFullQueryInfo(queryId);
return Response.ok(queryInfo).build();
}
catch (NoSuchElementException e) {
return Response.status(Status.GONE).build();
}
}
内容来源于网络,如有侵权,请联系作者删除!