/** * 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); }
/** * 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); }
/** * 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); } }
/** * 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); }