Tabnine Logo
Response
Code IndexAdd Tabnine to your IDE (free)

How to use
Response
in
javax.ws.rs.core

Best Java code snippets using javax.ws.rs.core.Response (Showing top 20 results out of 15,246)

Refine searchRefine arrow

  • Response.ResponseBuilder
  • Path
  • Produces
  • GET
  • PathParam
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: dropwizard/dropwizard

  private Response createResponse(final WebApplicationException exception) {
    final ErrorMessage errorMessage = new ErrorMessage(exception.getResponse().getStatus(),
      exception.getLocalizedMessage());
    return Response.status(errorMessage.getCode())
      .type(APPLICATION_JSON_TYPE)
      .entity(errorMessage)
      .build();
  }
}
origin: apache/incubator-druid

@GET
@Produces({MediaType.APPLICATION_JSON, SmileMediaTypes.APPLICATION_JACKSON_SMILE})
public Response getAll()
{
 try {
  return handler.handleGETAll();
 }
 catch (Exception e) {
  LOG.error(e, "Exception in handling GETAll request");
  return Response.serverError().entity(ServletResourceUtils.sanitizeException(e)).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: apache/incubator-druid

@POST
@Path("/assignTask")
@Consumes({MediaType.APPLICATION_JSON, SmileMediaTypes.APPLICATION_JACKSON_SMILE})
public Response assignTask(Task task)
{
 try {
  workerTaskMonitor.assignTask(task);
  return Response.ok().build();
 }
 catch (RuntimeException ex) {
  return Response.serverError().entity(ex.getMessage()).build();
 }
}
origin: prestodb/presto

@DELETE
@Path("/v1/proxy")
@Produces(APPLICATION_JSON)
public void cancelQuery(
    @QueryParam("uri") String uri,
    @QueryParam("hmac") String hash,
    @Context HttpServletRequest servletRequest,
    @Suspended AsyncResponse asyncResponse)
{
  if (!hmac.hashString(uri, UTF_8).equals(HashCode.fromString(hash))) {
    throw badRequest(FORBIDDEN, "Failed to validate HMAC of URI");
  }
  Request.Builder request = prepareDelete().setUri(URI.create(uri));
  performRequest(servletRequest, asyncResponse, request, response -> responseWithHeaders(noContent(), response));
}
origin: apache/incubator-druid

@SuppressWarnings({"ConstantConditions"})
private int getNumSubTasks(Function<SinglePhaseParallelIndexingProgress, Integer> func)
{
 final Response response = task.getProgress(newRequest());
 Assert.assertEquals(200, response.getStatus());
 return func.apply((SinglePhaseParallelIndexingProgress) response.getEntity());
}
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: Graylog2/graylog2-server

@PUT
@RequiresPermissions(value = {RestPermissions.LDAPGROUPS_EDIT, RestPermissions.LDAP_EDIT}, logical = OR)
@ApiOperation(value = "Update the LDAP group to Graylog role mapping", notes = "Corresponds directly to the output of GET /system/ldap/settings/groups")
@Path("/settings/groups")
@Consumes(MediaType.APPLICATION_JSON)
@AuditEvent(type = AuditEventTypes.LDAP_GROUP_MAPPING_UPDATE)
public Response updateGroupMappingSettings(@ApiParam(name = "JSON body", required = true, value = "A hash in which the keys are the LDAP group names and values is the Graylog role name.")
                @NotNull Map<String, String> groupMapping) throws ValidationException {
  final LdapSettings ldapSettings = firstNonNull(ldapSettingsService.load(), ldapSettingsFactory.createEmpty());
  ldapSettings.setGroupMapping(groupMapping);
  ldapSettingsService.save(ldapSettings);
  return Response.noContent().build();
}
origin: apache/incubator-dubbo

  protected Response handleConstraintViolationException(ConstraintViolationException cve) {
    ViolationReport report = new ViolationReport();
    for (ConstraintViolation cv : cve.getConstraintViolations()) {
      report.addConstraintViolation(new RestConstraintViolation(
          cv.getPropertyPath().toString(),
          cv.getMessage(),
          cv.getInvalidValue() == null ? "null" : cv.getInvalidValue().toString()));
    }
    // TODO for now just do xml output
    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(report).type(ContentType.TEXT_XML_UTF_8).build();
  }
}
origin: confluentinc/ksql

private <T> RestResponse<T> getRequest(final String path, final Class<T> type) {
 try (Response response = client.target(serverAddress)
   .path(path)
   .request(MediaType.APPLICATION_JSON_TYPE)
   .get()) {
  return response.getStatus() == Response.Status.OK.getStatusCode()
    ? RestResponse.successful(response.readEntity(type))
    : createErrorResponse(path, response);
 } catch (final Exception e) {
  throw new KsqlRestClientException("Error issuing GET to KSQL server. path:" + path, e);
 }
}
origin: Netflix/eureka

@Override
public EurekaHttpResponse<ReplicationListResponse> submitBatchUpdates(ReplicationList replicationList) {
  Response response = null;
  try {
    response = jerseyClient.target(serviceUrl)
        .path(PeerEurekaNode.BATCH_URL_PATH)
        .request(MediaType.APPLICATION_JSON_TYPE)
        .post(Entity.json(replicationList));
    if (!isSuccess(response.getStatus())) {
      return anEurekaHttpResponse(response.getStatus(), ReplicationListResponse.class).build();
    }
    ReplicationListResponse batchResponse = response.readEntity(ReplicationListResponse.class);
    return anEurekaHttpResponse(response.getStatus(), batchResponse).type(MediaType.APPLICATION_JSON_TYPE).build();
  } finally {
    if (response != null) {
      response.close();
    }
  }
}
origin: apache/incubator-druid

@Test
public void testMissingProducerSequence() throws IOException
{
 setUpRequestExpectations("producer", null);
 final InputStream inputStream = IOUtils.toInputStream(inputRow, StandardCharsets.UTF_8);
 final Response response = firehose.addAll(inputStream, req);
 Assert.assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
 inputStream.close();
 EasyMock.verify(req);
 firehose.close();
}
origin: apache/incubator-druid

@Test
public void testGetTasksNegativeState()
{
 EasyMock.replay(taskRunner, taskMaster, taskStorageQueryAdapter, indexerMetadataStorageAdapter, req);
 Object responseObject = overlordResource
   .getTasks("blah", "ds_test", null, null, null, req)
   .getEntity();
 Assert.assertEquals(
   "Invalid state : blah, valid values are: [pending, waiting, running, complete]",
   responseObject.toString()
 );
}
origin: dropwizard/dropwizard

@Override
public Response toResponse(WebApplicationException exception) {
  LOGGER.error("Template Error", exception);
  return Response.serverError()
      .type(MediaType.TEXT_HTML_TYPE)
      .entity(TEMPLATE_ERROR_MSG)
      .build();
}
origin: confluentinc/ksql

public RestResponse<KsqlEntityList> makeKsqlRequest(final String ksql) {
 final KsqlRequest jsonRequest = new KsqlRequest(ksql, localProperties.toMap(), null);
 return postRequest("ksql", jsonRequest, Optional.empty(), true,
   r -> r.readEntity(KsqlEntityList.class));
}
origin: dropwizard/dropwizard

  @Override
  public Response toResponse(EmptyOptionalException exception) {
    return Response.noContent().build();
  }
}
origin: apache/incubator-druid

@Test
public void testExceptionalHandleAll()
{
 shouldFail.set(true);
 final Response response = abstractListenerHandler.handleGETAll();
 Assert.assertEquals(500, response.getStatus());
 Assert.assertEquals(ImmutableMap.of("error", error_message), response.getEntity());
}
origin: apache/incubator-dubbo

  protected Response handleConstraintViolationException(ConstraintViolationException cve) {
    ViolationReport report = new ViolationReport();
    for (ConstraintViolation cv : cve.getConstraintViolations()) {
      report.addConstraintViolation(new RestConstraintViolation(
          cv.getPropertyPath().toString(),
          cv.getMessage(),
          cv.getInvalidValue() == null ? "null" : cv.getInvalidValue().toString()));
    }
    // TODO for now just do xml output
    return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(report).type(ContentType.TEXT_XML_UTF_8).build();
  }
}
origin: jersey/jersey

public String start() {
  final Response response = addProperties(client.target(requestTokenUri).request())
      .post(null);
  if (response.getStatus() != 200) {
    throw new RuntimeException(LocalizationMessages.ERROR_REQUEST_REQUEST_TOKEN(response.getStatus()));
  }
  final MultivaluedMap<String, String> formParams = response.readEntity(Form.class).asMap();
  parameters.token(formParams.getFirst(OAuth1Parameters.TOKEN));
  secrets.tokenSecret(formParams.getFirst(OAuth1Parameters.TOKEN_SECRET));
  return UriBuilder.fromUri(authorizationUri).queryParam(OAuth1Parameters.TOKEN, parameters.getToken())
      .build().toString();
}
javax.ws.rs.coreResponse

Javadoc

Defines the contract between a returned instance and the runtime when an application needs to provide meta-data to the runtime.

An application class should not extend this class directly. Response class is reserved for an extension by a JAX-RS implementation providers. An application should use one of the static methods to create a Response instance using a ResponseBuilder.

Several methods have parameters of type URI, UriBuilder provides convenient methods to create such values as does URI#create(java.lang.String).

Most used methods

  • status
    Create a new ResponseBuilder with the supplied status.
  • ok
    Create a new ResponseBuilder that contains a representation. It is the callers responsibility to wra
  • getStatus
    Get the status code associated with the response.
  • readEntity
    Read the message entity input stream as an instance of specified Java type using a javax.ws.rs.ext.M
  • serverError
    Create a new ResponseBuilder with an server error status.
  • noContent
    Create a new ResponseBuilder for an empty response.
  • getEntity
    Get the message entity Java instance. Returns null if the message does not contain an entity body. I
  • created
    Create a new ResponseBuilder for a created resource, set the location header using the supplied valu
  • getStatusInfo
    Get the complete status information associated with the response.
  • close
    Close the underlying message entity input stream (if available and open) as well as releases any oth
  • getHeaderString
    Get a message header as a single string value. Each single header value is converted to String using
  • getHeaders
    Get view of the response headers and their object values. The underlying header data may be subseque
  • getHeaderString,
  • getHeaders,
  • getMetadata,
  • seeOther,
  • hasEntity,
  • temporaryRedirect,
  • notModified,
  • getStringHeaders,
  • getMediaType,
  • accepted

Popular in Java

  • Start an intent from android
  • onRequestPermissionsResult (Fragment)
  • getExternalFilesDir (Context)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now