Package javax.ws.rs.core.Response

Examples of javax.ws.rs.core.Response.Status


   @RolesAllowed("administrators")
   @Path("/workspaces/{repositoryName}")
   public Response getWorkspaceNames(@PathParam("repositoryName") String repositoryName)
   {
      String errorMessage = new String();
      Status status;

      try
      {
         List<String> workspaces = new ArrayList<String>();
View Full Code Here


  /**
   * Determines exception type, logs issue and returns appropriate http status with the exception message in the body.
   */
  public static Response handleException(final HttpServletRequest httpRequest, final String requestBody,
      final String requestMediaType, final SqlResourceException exception, RequestLogger requestLogger) {
    Status status;
    if (exception instanceof SqlResourceFactoryException) {
      status = Status.NOT_FOUND;
    } else if (exception instanceof InvalidRequestException) {
      status = Status.BAD_REQUEST;
    } else { // exception instanceof SqlResourceException
      status = Status.INTERNAL_SERVER_ERROR;
    }
    if (requestLogger == null) {
      requestLogger = Factory.getRequestLogger();
      final HttpRequestAttributes httpAttribs = getHttpRequestAttributes(httpRequest, requestBody,
          requestMediaType, requestMediaType);
      requestLogger.setHttpRequestAttributes(httpAttribs);
    }
    requestLogger.log(status.getStatusCode(), exception);
    return Response.status(status).entity(exception.getMessage()).type(MediaType.TEXT_PLAIN).build();
  }
View Full Code Here

    requestLogger.setHttpRequestAttributes(httpAttributes);

    // Authorize
    if (!SecurityFactory.getAuthorizer().isAuthorized(new SecurityContextAdapter(securityContext),
        requestType, resName)) {
      Status status = Status.FORBIDDEN;
      requestLogger.log(status.getStatusCode());
      return Response.status(status).build();
    }

    try {
      String responseBody = null;
View Full Code Here

      final String URI = details.getUrl();

      final IFixedTranslationResources client = ProxyFactory.create(IFixedTranslationResources.class, URI);
      final ClientResponse<Resource> response = client.getResource(id);

      final Status status = Response.Status.fromStatusCode(response.getStatus());
     
      return status == Response.Status.OK;

    }
    catch (final Exception ex)
View Full Code Here

      final String URI = details.getUrl();

      final IFixedTranslationResources client = ProxyFactory.create(IFixedTranslationResources.class, URI);
      final ClientResponse<Resource> response = client.getResource(id);

      final Status status = Response.Status.fromStatusCode(response.getStatus());
     
      if (status == Response.Status.OK)
      {
        final Resource entity = response.getEntity();
        return entity;
      }
      else
      {
        System.out.println("REST call to getResource() did not complete successfully. HTTP response code was " + status.getStatusCode() + ". Reason was " + status.getReasonPhrase());
      }
    }
    catch (final Exception ex)
    {
      ExceptionUtilities.handleException(ex);
View Full Code Here

      final String URI = details.getUrl();

      final IFixedTranslationResources client = ProxyFactory.create(IFixedTranslationResources.class, URI);
      final ClientResponse<String> response = client.createResource(details.getUsername(), details.getToken(), resource);
     
      final Status status = Response.Status.fromStatusCode(response.getStatus());
     
      if (status == Response.Status.CREATED)
      {
        final String entity = response.getEntity();
        if (entity.trim().length() != 0)
          System.out.println(entity);
      }
      else
      {
        System.out.println("REST call to createResource() did not complete successfully. HTTP response code was " + status.getStatusCode() + ". Reason was " + status.getReasonPhrase());
      }
     
     
    }
    catch (final Exception ex)
View Full Code Here

      final String URI = details.getUrl();

      final IFixedTranslationResources client = ProxyFactory.create(IFixedTranslationResources.class, URI);
      final ClientResponse<String> response = client.deleteResource(details.getUsername(), details.getToken(), id);
     
      final Status status = Response.Status.fromStatusCode(response.getStatus());
     
      if (status == Response.Status.OK)
      {
        final String entity = response.getEntity();
        if (entity.trim().length() != 0)
          System.out.println(entity);
      }
      else
      {
        System.out.println("REST call to deleteResource() did not complete successfully. HTTP response code was " + status.getStatusCode() + ". Reason was " + status.getReasonPhrase());
      }
    }
    catch (final Exception ex)
    {
      ExceptionUtilities.handleException(ex);
View Full Code Here

      Exception exception = message != null ? new HttpResponseException(command, response, message)
              : new HttpResponseException(command, response);
      message = message != null ? message : String.format("%s -> %s", command.getCurrentRequest().getRequestLine(),
              response.getStatusLine());
      Status status = Status.fromStatusCode(response.getStatusCode());
      switch (status) {
         case BAD_REQUEST:
            break;
         case UNAUTHORIZED:
         case FORBIDDEN:
View Full Code Here

        String messageFormat = Messages.getMessage("exceptionOccurredDuringInvocation");
        String exceptionName = t.getClass().getSimpleName();
        if (t instanceof WebApplicationException) {
            WebApplicationException wae = (WebApplicationException)t;
            int statusCode = wae.getResponse().getStatus();
            Status status = Response.Status.fromStatusCode(statusCode);
            String statusSep = "";
            String statusMessage = "";
            if (status != null) {
                statusSep = " - ";
                statusMessage = status.toString();
            }
            exceptionName =
                String.format("%s (%d%s%s)", exceptionName, statusCode, statusSep, statusMessage);
            if (statusCode >= 500) {
                if (logger.isDebugEnabled()) {
View Full Code Here

                ? ("?" + request.getQueryString()) : ""); //$NON-NLS-1$ $NON-NLS-2$         

        if (t instanceof WebApplicationException) {
            WebApplicationException wae = (WebApplicationException)t;
            int statusCode = wae.getResponse().getStatus();
            Status status = Response.Status.fromStatusCode(statusCode);
            String statusSep = ""; //$NON-NLS-1$
            String statusMessage = ""; //$NON-NLS-1$
            if (status != null) {
                statusSep = " - "; //$NON-NLS-1$
                statusMessage = status.toString();
            }

            String exceptionName =
                String
                    .format("%s (%d%s%s)", t.getClass().getSimpleName(), statusCode, statusSep, statusMessage); //$NON-NLS-1$
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.Response.Status

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.