use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class OidcScopeManagementService method handleException.
/**
* Handle error cases.
*
* @param e Exception.
* @param message Error message.
* @return API error.
*/
private APIError handleException(IdentityOAuthAdminException e, String message) {
ErrorResponse.Builder builder = new ErrorResponse.Builder().withCode(e.getErrorCode()).withMessage(message).withDescription(e.getMessage());
ErrorResponse errorResponse = builder.build(LOG, e, message);
Response.Status status;
if (OidcScopeConstants.ErrorMessage.INVALID_REQUEST.getCode().equals(e.getErrorCode())) {
status = Response.Status.BAD_REQUEST;
} else if (OidcScopeConstants.ErrorMessage.ERROR_CONFLICT_REQUEST.getCode().equals(e.getErrorCode())) {
status = Response.Status.CONFLICT;
} else if (OidcScopeConstants.ErrorMessage.SCOPE_NOT_FOUND.getCode().equals(e.getErrorCode())) {
status = Response.Status.NOT_FOUND;
} else {
status = Response.Status.INTERNAL_SERVER_ERROR;
}
return new APIError(status, errorResponse);
}
use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class PermissionManagementService method handleException.
private APIError handleException(Exception e, String... data) {
ErrorResponse errorResponse = getErrorBuilder(data).build(LOG, e, buildErrorDescription(data));
Response.Status status = Response.Status.INTERNAL_SERVER_ERROR;
return new APIError(status, errorResponse);
}
use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class ServerUserStoreService method handleNotImplementedBehaviour.
/**
* To return error responses for the input params for the get request which are not yet supported by the server.
*
* @param limit items per page.
* @param offset to specify the offset param.
* @param filter to specify the filtering capabilities.
* @param sort to specify the sorting order.
*/
private void handleNotImplementedBehaviour(Integer limit, Integer offset, String filter, String sort) {
UserStoreConstants.ErrorMessage errorEnum = null;
if (limit != null) {
errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_PAGINATION_NOT_IMPLEMENTED;
} else if (offset != null) {
errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_PAGINATION_NOT_IMPLEMENTED;
} else if (filter != null) {
errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_FILTERING_NOT_IMPLEMENTED;
} else if (sort != null) {
errorEnum = UserStoreConstants.ErrorMessage.ERROR_CODE_SORTING_NOT_IMPLEMENTED;
}
if (errorEnum != null) {
ErrorResponse errorResponse = getErrorBuilder(errorEnum).build(LOG, errorEnum.getDescription());
Response.Status status = Response.Status.NOT_IMPLEMENTED;
throw new APIError(status, errorResponse);
}
}
use of org.wso2.carbon.identity.api.server.common.error.APIError in project identity-api-server by wso2.
the class ServerUserStoreService method handleClaimManagementException.
/**
* Handle ClaimManagementException, extract the error code and the error message from the corresponding
* exception and set it to the API Error Response.
*
* @param exception Exception thrown.
* @param errorEnum Corresponding error enum.
* @return API Error object.
*/
private APIError handleClaimManagementException(ClaimMetadataException exception, UserStoreConstants.ErrorMessage errorEnum) {
Response.Status status;
ErrorResponse errorResponse;
if (exception instanceof ClaimMetadataClientException) {
errorResponse = getErrorBuilder(errorEnum).build(LOG, exception.getMessage());
status = Response.Status.BAD_REQUEST;
return handleClaimManagementClientException(exception, errorResponse, status);
} else {
// Internal Server error
errorResponse = getErrorBuilder(errorEnum).build(LOG, exception, errorEnum.getDescription());
status = Response.Status.INTERNAL_SERVER_ERROR;
return new APIError(status, errorResponse);
}
}
Aggregations