/** * Create the appropriate SCIMException from the provided information. * * @param statusCode The HTTP status code for this SCIM exception. * @param errorMessage The error message for this SCIM exception. * @return The appropriate SCIMException from the provided information. */ public static ScimException createException(final int statusCode, final String errorMessage) { return createException(statusCode, errorMessage, null); }
/** * {@inheritDoc} */ public Response toResponse(final ScimException throwable) { return ServerUtils.setAcceptableType( Response.status(throwable.getScimError().getStatus()). entity(throwable.getScimError()), headers.getAcceptableMediaTypes()).build(); } }
default : return new ScimException(scimError, cause);
/** * Test that modifying the service provider config results in error. */ @Test public void testPutServiceProviderConfig() { try { ScimService scimService = new ScimService(target()); scimService.modifyRequest( scimService.getServiceProviderConfig()).invoke(); } catch (WebApplicationException e) { assertEquals(e.getResponse().getStatus(), 501); ErrorResponse errorResponse = e.getResponse().readEntity(ErrorResponse.class); assertEquals(errorResponse.getStatus(), new Integer(501)); } catch (ScimException e) { e.printStackTrace(); } }
default : return new ScimException(scimError, cause);
/** * Create the appropriate SCIMException from the provided information. * * @param statusCode The HTTP status code for this SCIM exception. * @param errorMessage The error message for this SCIM exception. * @return The appropriate SCIMException from the provided information. */ public static ScimException createException(final int statusCode, final String errorMessage) { return createException(statusCode, errorMessage, null); }
status(e.getScimError().getStatus()). entity(e.getScimError()), requestContext.getAcceptableMediaTypes()).build());
/** * Convert a JAX-RS response to a ScimException. * * @param response The JAX-RS response. * @return the converted ScimException. */ static ScimException toScimException(final Response response) { try { ErrorResponse errorResponse = response.readEntity(ErrorResponse.class); // If are able to read an error response, use it to build the exception. // If not, use the http status code to determine the exception. ScimException exception = (errorResponse == null) ? ScimException.createException(response.getStatus(), null) : ScimException.createException(errorResponse, null); response.close(); return exception; } catch(ProcessingException ex) { return new ScimServiceException( response.getStatus(), ex.getMessage(), ex); } }
exception.getCause() instanceof ScimException) errorResponse = ((ScimException) exception.getCause()).getScimError();
/** * Convert a JAX-RS response to a ScimException. * * @param response The JAX-RS response. * @return the converted ScimException. */ static ScimException toScimException(final Response response) { try { ErrorResponse errorResponse = response.readEntity(ErrorResponse.class); // If are able to read an error response, use it to build the exception. // If not, use the http status code to determine the exception. ScimException exception = (errorResponse == null) ? ScimException.createException(response.getStatus(), null) : ScimException.createException(errorResponse, null); response.close(); return exception; } catch(ProcessingException ex) { return new ScimServiceException( response.getStatus(), ex.getMessage(), ex); } }
/** * Create the appropriate SCIMException from the provided information. * * @param statusCode The HTTP status code for this SCIM exception. * @param errorMessage The error message for this SCIM exception. * @param cause The cause (which is saved for later retrieval by the * {@link #getCause()} method). (A {@code null} value * is permitted, and indicates that the cause is * nonexistent or unknown.) * @return The appropriate SCIMException from the provided information. */ public static ScimException createException(final int statusCode, final String errorMessage, final Exception cause) { ErrorResponse scimError = new ErrorResponse(statusCode); scimError.setDetail(errorMessage); return createException(scimError, cause); }
/** * Create the appropriate SCIMException from the provided information. * * @param statusCode The HTTP status code for this SCIM exception. * @param errorMessage The error message for this SCIM exception. * @param cause The cause (which is saved for later retrieval by the * {@link #getCause()} method). (A {@code null} value * is permitted, and indicates that the cause is * nonexistent or unknown.) * @return The appropriate SCIMException from the provided information. */ public static ScimException createException(final int statusCode, final String errorMessage, final Exception cause) { ErrorResponse scimError = new ErrorResponse(statusCode); scimError.setDetail(errorMessage); return createException(scimError, cause); }