From 04977725a07e0e53f15de7cbfb4e192256f337aa Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Tue, 24 May 2011 15:23:07 +0200 Subject: [PATCH] feature #662: moved error codes to Request.h class --- include/Request.h | 17 +++++++++++++++-- src/rm/Request.cc | 6 ++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/Request.h b/include/Request.h index 4aad0e00ff..85ef9c1c7a 100644 --- a/include/Request.h +++ b/include/Request.h @@ -24,7 +24,10 @@ using namespace std; - +/** + * The Request Class represents the basic abstraction for the OpenNebula + * XML-RPC API. This interface must be implemented by any XML-RPC API call + */ class Request: public xmlrpc_c::method { public: @@ -38,6 +41,16 @@ public: xmlrpc_c::paramList const& _paramList, xmlrpc_c::value * const _retval); + /** + * Error codes for the XML-RPC API + */ + enum ErrorCode { + AUTHENTICATION = 0x0100, + AUTHORIZATION = 0x0200, + GET = 0x0400, + ACTION = 0x0800 + }; + protected: Request(const string& mn, @@ -82,7 +95,7 @@ protected: * @param ec error code for this call * @param val string representation of the error */ - void failure_response(RequestManager::ErrorCode ec, const string& val); + void failure_response(ErrorCode ec, const string& val); /** * Logs authorization errors diff --git a/src/rm/Request.cc b/src/rm/Request.cc index d006ff98cd..6aae287d76 100644 --- a/src/rm/Request.cc +++ b/src/rm/Request.cc @@ -38,8 +38,7 @@ void Request::execute( if ( upool->authenticate(session, uid, gid) == false ) { - failure_response(RequestManager::AUTHENTICATION, - authenticate_error()); + failure_response(AUTHENTICATION, authenticate_error()); } else { @@ -50,8 +49,7 @@ void Request::execute( /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -void Request::failure_response(RequestManager::ErrorCode ec, - const string& str_val) +void Request::failure_response(ErrorCode ec, const string& str_val) { vector arrayData;