diff --git a/arangod/Actions/RestActionHandler.cpp b/arangod/Actions/RestActionHandler.cpp index 7d88624b26..3bfa6a788c 100644 --- a/arangod/Actions/RestActionHandler.cpp +++ b/arangod/Actions/RestActionHandler.cpp @@ -111,19 +111,6 @@ string const& RestActionHandler::queue () const { //////////////////////////////////////////////////////////////////////////////// HttpHandler::status_e RestActionHandler::execute () { - static LoggerData::Task const logDelete("ACTION [delete]"); - static LoggerData::Task const logGet("ACTION [get]"); - static LoggerData::Task const logHead("ACTION [head]"); - static LoggerData::Task const logIllegal("ACTION [illegal]"); - static LoggerData::Task const logOptions("ACTION [options]"); - static LoggerData::Task const logPost("ACTION [post]"); - static LoggerData::Task const logPut("ACTION [put]"); - static LoggerData::Task const logPatch("ACTION [patch]"); - - LoggerData::Task const * task = &logIllegal; - - bool res = false; - // need an action if (_action == 0) { generateNotImplemented(_request->requestPath()); @@ -140,24 +127,6 @@ HttpHandler::status_e RestActionHandler::execute () { // extract the sub-request type HttpRequest::HttpRequestType type = _request->requestType(); - // prepare logging - switch (type) { - case HttpRequest::HTTP_REQUEST_DELETE: task = &logDelete; break; - case HttpRequest::HTTP_REQUEST_GET: task = &logGet; break; - case HttpRequest::HTTP_REQUEST_POST: task = &logPost; break; - case HttpRequest::HTTP_REQUEST_PUT: task = &logPut; break; - case HttpRequest::HTTP_REQUEST_HEAD: task = &logHead; break; - case HttpRequest::HTTP_REQUEST_OPTIONS: task = &logOptions; break; - case HttpRequest::HTTP_REQUEST_PATCH: task = &logPatch; break; - case HttpRequest::HTTP_REQUEST_ILLEGAL: task = &logIllegal; break; - } - - _timing << *task; -#ifdef TRI_ENABLE_LOGGER - // if ifdef is not used, the compiler will complain - LOGGER_REQUEST_IN_START_I(_timing, ""); -#endif - // execute one of the HTTP methods switch (type) { case HttpRequest::HTTP_REQUEST_GET: @@ -167,19 +136,16 @@ HttpHandler::status_e RestActionHandler::execute () { case HttpRequest::HTTP_REQUEST_HEAD: case HttpRequest::HTTP_REQUEST_OPTIONS: case HttpRequest::HTTP_REQUEST_PATCH: { - res = executeAction(); + executeAction(); break; } default: - res = false; generateNotImplemented("METHOD"); break; } } - _timingResult = res ? RES_ERR : RES_OK; - // this handler is done return HANDLER_DONE; } diff --git a/arangod/RestHandler/RestDocumentHandler.cpp b/arangod/RestHandler/RestDocumentHandler.cpp index 44c613d975..12c10d2012 100644 --- a/arangod/RestHandler/RestDocumentHandler.cpp +++ b/arangod/RestHandler/RestDocumentHandler.cpp @@ -97,49 +97,17 @@ string const& RestDocumentHandler::queue () const { //////////////////////////////////////////////////////////////////////////////// HttpHandler::status_e RestDocumentHandler::execute () { - // extract the sub-request type HttpRequest::HttpRequestType type = _request->requestType(); - // prepare logging - static LoggerData::Task const logCreate(DOCUMENT_PATH + " [create]"); - static LoggerData::Task const logRead(DOCUMENT_PATH + " [read]"); - static LoggerData::Task const logUpdate(DOCUMENT_PATH + " [update]"); - static LoggerData::Task const logDelete(DOCUMENT_PATH + " [delete]"); - static LoggerData::Task const logHead(DOCUMENT_PATH + " [head]"); - static LoggerData::Task const logOptions(DOCUMENT_PATH + " [options]"); - static LoggerData::Task const logPatch(DOCUMENT_PATH + " [patch]"); - static LoggerData::Task const logIllegal(DOCUMENT_PATH + " [illegal]"); - - LoggerData::Task const * task = &logCreate; - - switch (type) { - case HttpRequest::HTTP_REQUEST_DELETE: task = &logDelete; break; - case HttpRequest::HTTP_REQUEST_GET: task = &logRead; break; - case HttpRequest::HTTP_REQUEST_HEAD: task = &logHead; break; - case HttpRequest::HTTP_REQUEST_ILLEGAL: task = &logIllegal; break; - case HttpRequest::HTTP_REQUEST_OPTIONS: task = &logOptions; break; - case HttpRequest::HTTP_REQUEST_POST: task = &logCreate; break; - case HttpRequest::HTTP_REQUEST_PUT: task = &logUpdate; break; - case HttpRequest::HTTP_REQUEST_PATCH: task = &logUpdate; break; - } - - _timing << *task; -#ifdef TRI_ENABLE_LOGGER - // if logger is not activated, the compiler will complain, so enclose it in ifdef - LOGGER_REQUEST_IN_START_I(_timing, ""); -#endif - // execute one of the CRUD methods - bool res = false; - switch (type) { - case HttpRequest::HTTP_REQUEST_DELETE: res = deleteDocument(); break; - case HttpRequest::HTTP_REQUEST_GET: res = readDocument(); break; - case HttpRequest::HTTP_REQUEST_HEAD: res = checkDocument(); break; - case HttpRequest::HTTP_REQUEST_POST: res = createDocument(); break; - case HttpRequest::HTTP_REQUEST_PUT: res = replaceDocument(); break; - case HttpRequest::HTTP_REQUEST_PATCH: res = updateDocument(); break; + case HttpRequest::HTTP_REQUEST_DELETE: deleteDocument(); break; + case HttpRequest::HTTP_REQUEST_GET: readDocument(); break; + case HttpRequest::HTTP_REQUEST_HEAD: checkDocument(); break; + case HttpRequest::HTTP_REQUEST_POST: createDocument(); break; + case HttpRequest::HTTP_REQUEST_PUT: replaceDocument(); break; + case HttpRequest::HTTP_REQUEST_PATCH: updateDocument(); break; case HttpRequest::HTTP_REQUEST_ILLEGAL: default: { @@ -148,8 +116,6 @@ HttpHandler::status_e RestDocumentHandler::execute () { } } - _timingResult = res ? RES_ERR : RES_OK; - // this handler is done return HANDLER_DONE; } diff --git a/arangod/RestHandler/RestEdgeHandler.cpp b/arangod/RestHandler/RestEdgeHandler.cpp index 4093997aba..65377b5664 100644 --- a/arangod/RestHandler/RestEdgeHandler.cpp +++ b/arangod/RestHandler/RestEdgeHandler.cpp @@ -53,7 +53,8 @@ using namespace triagens::arango; /// @brief constructor //////////////////////////////////////////////////////////////////////////////// -RestEdgeHandler::RestEdgeHandler (HttpRequest* request, TRI_vocbase_t* vocbase) +RestEdgeHandler::RestEdgeHandler (HttpRequest* request, + TRI_vocbase_t* vocbase) : RestDocumentHandler(request, vocbase) { } diff --git a/arangod/RestHandler/RestImportHandler.cpp b/arangod/RestHandler/RestImportHandler.cpp index 088d1010af..4d4730da94 100644 --- a/arangod/RestHandler/RestImportHandler.cpp +++ b/arangod/RestHandler/RestImportHandler.cpp @@ -54,7 +54,8 @@ using namespace triagens::arango; /// @brief constructor //////////////////////////////////////////////////////////////////////////////// -RestImportHandler::RestImportHandler (HttpRequest* request, TRI_vocbase_t* vocbase) +RestImportHandler::RestImportHandler (HttpRequest* request, + TRI_vocbase_t* vocbase) : RestVocbaseBaseHandler(request, vocbase) { } @@ -94,30 +95,9 @@ string const& RestImportHandler::queue () const { //////////////////////////////////////////////////////////////////////////////// HttpHandler::status_e RestImportHandler::execute () { - // extract the sub-request type HttpRequest::HttpRequestType type = _request->requestType(); - // prepare logging - static LoggerData::Task const logCreate(DOCUMENT_IMPORT_PATH + " [create]"); - static LoggerData::Task const logIllegal(DOCUMENT_IMPORT_PATH + " [illegal]"); - - LoggerData::Task const * task = &logCreate; - - switch (type) { - case HttpRequest::HTTP_REQUEST_POST: task = &logCreate; break; - default: task = &logIllegal; break; - } - - _timing << *task; - - // if ifdef is not used, the compiler will complain -#ifdef TRI_ENABLE_LOGGER - LOGGER_REQUEST_IN_START_I(_timing, ""); -#endif - - bool res = false; - switch (type) { case HttpRequest::HTTP_REQUEST_POST: { // extract the import type @@ -129,23 +109,20 @@ HttpHandler::status_e RestImportHandler::execute () { documentType == "array" || documentType == "list" || documentType == "auto")) { - res = createFromJson(documentType); + createFromJson(documentType); } else { // CSV - res = createFromKeyValueList(); + createFromKeyValueList(); } break; } default: - res = false; generateNotImplemented("ILLEGAL " + DOCUMENT_IMPORT_PATH); break; } - _timingResult = res ? RES_ERR : RES_OK; - // this handler is done return HANDLER_DONE; } diff --git a/arangod/RestHandler/RestVocbaseBaseHandler.cpp b/arangod/RestHandler/RestVocbaseBaseHandler.cpp index 82466823cd..7ded3979c5 100644 --- a/arangod/RestHandler/RestVocbaseBaseHandler.cpp +++ b/arangod/RestHandler/RestVocbaseBaseHandler.cpp @@ -57,36 +57,12 @@ using namespace triagens::arango; /// @{ //////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -/// @brief result RES-OK -//////////////////////////////////////////////////////////////////////////////// - -LoggerData::Extra const RestVocbaseBaseHandler::RES_OK; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief result RES-ERR -//////////////////////////////////////////////////////////////////////////////// - -LoggerData::Extra const RestVocbaseBaseHandler::RES_ERR; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief result RES-ERR -//////////////////////////////////////////////////////////////////////////////// - -LoggerData::Extra const RestVocbaseBaseHandler::RES_FAIL; - //////////////////////////////////////////////////////////////////////////////// /// @brief batch path //////////////////////////////////////////////////////////////////////////////// string RestVocbaseBaseHandler::BATCH_PATH = "/_api/batch"; -//////////////////////////////////////////////////////////////////////////////// -/// @brief collection path -//////////////////////////////////////////////////////////////////////////////// - -string RestVocbaseBaseHandler::COLLECTION_PATH = "/_api/collection"; - //////////////////////////////////////////////////////////////////////////////// /// @brief document path //////////////////////////////////////////////////////////////////////////////// @@ -134,24 +110,15 @@ string RestVocbaseBaseHandler::UPLOAD_PATH = "/_api/upload"; /// @brief constructor //////////////////////////////////////////////////////////////////////////////// -RestVocbaseBaseHandler::RestVocbaseBaseHandler (HttpRequest* request, - TRI_vocbase_t* vocbase) +RestVocbaseBaseHandler::RestVocbaseBaseHandler (HttpRequest* request, + TRI_vocbase_t* vocbase) : RestBaseHandler(request), - _vocbase(vocbase), - _resolver(vocbase), - _timing(), - _timingResult(RES_FAIL) { + _context(static_cast(request->getRequestContext())), + _vocbase(_context->getVocbase()), + _resolver(_vocbase) { - RequestContext* rc = request->getRequestContext(); - _context = static_cast(rc); - - assert(_context != 0); - - // overwrite vocbase. TODO FIXME: move into init list - _vocbase = _context->getVocbase(); - assert(_vocbase != 0); - - _resolver = _context->getVocbase(); + // this is to ensure we have not forgotten anything + assert(_vocbase == vocbase); } //////////////////////////////////////////////////////////////////////////////// @@ -159,7 +126,6 @@ RestVocbaseBaseHandler::RestVocbaseBaseHandler (HttpRequest* request, //////////////////////////////////////////////////////////////////////////////// RestVocbaseBaseHandler::~RestVocbaseBaseHandler () { - LOGGER_REQUEST_IN_END_I(_timing, _timingResult); } //////////////////////////////////////////////////////////////////////////////// @@ -421,7 +387,7 @@ void RestVocbaseBaseHandler::generateTransactionError (const string& collectionN } else { // collection name specified but collection not found - generateError(HttpResponse::NOT_FOUND, res, "collection " + COLLECTION_PATH + "/" + collectionName + " not found"); + generateError(HttpResponse::NOT_FOUND, res, "collection '" + collectionName + "' not found"); } return; diff --git a/arangod/RestHandler/RestVocbaseBaseHandler.h b/arangod/RestHandler/RestVocbaseBaseHandler.h index 218c6c000c..9f6c06b4b0 100644 --- a/arangod/RestHandler/RestVocbaseBaseHandler.h +++ b/arangod/RestHandler/RestVocbaseBaseHandler.h @@ -45,11 +45,12 @@ // --SECTION-- forward declarations // ----------------------------------------------------------------------------- -struct TRI_primary_collection_s; -struct TRI_result_set_s; -struct TRI_vocbase_col_s; -struct TRI_vocbase_s; -struct TRI_json_s; +extern "C" { + struct TRI_json_s; + struct TRI_primary_collection_s; + struct TRI_vocbase_col_s; + struct TRI_vocbase_s; +} // ----------------------------------------------------------------------------- // --SECTION-- class RestVocbaseBaseHandler @@ -80,36 +81,12 @@ namespace triagens { public: -//////////////////////////////////////////////////////////////////////////////// -/// @brief result RES-OK -//////////////////////////////////////////////////////////////////////////////// - - static basics::LoggerData::Extra const RES_OK; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief result RES-ERR -//////////////////////////////////////////////////////////////////////////////// - - static basics::LoggerData::Extra const RES_ERR; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief result RES-ERR -//////////////////////////////////////////////////////////////////////////////// - - static basics::LoggerData::Extra const RES_FAIL; - //////////////////////////////////////////////////////////////////////////////// /// @brief batch path //////////////////////////////////////////////////////////////////////////////// static string BATCH_PATH; -//////////////////////////////////////////////////////////////////////////////// -/// @brief collection path -//////////////////////////////////////////////////////////////////////////////// - - static string COLLECTION_PATH; - //////////////////////////////////////////////////////////////////////////////// /// @brief document path //////////////////////////////////////////////////////////////////////////////// @@ -155,7 +132,8 @@ namespace triagens { /// @brief constructor //////////////////////////////////////////////////////////////////////////////// - RestVocbaseBaseHandler (rest::HttpRequest* request, struct TRI_vocbase_s* vocbase); + RestVocbaseBaseHandler (rest::HttpRequest*, + struct TRI_vocbase_s*); //////////////////////////////////////////////////////////////////////////////// /// @brief destructor @@ -314,7 +292,8 @@ namespace triagens { /// @note @FA{header} must be lowercase. //////////////////////////////////////////////////////////////////////////////// - TRI_voc_rid_t extractRevision (char const*, char const*); + TRI_voc_rid_t extractRevision (char const*, + char const*); //////////////////////////////////////////////////////////////////////////////// /// @brief extracts the update policy @@ -347,7 +326,9 @@ namespace triagens { /// @brief parses a document handle //////////////////////////////////////////////////////////////////////////////// - int parseDocumentId (string const&, TRI_voc_cid_t&, TRI_voc_key_t&); + int parseDocumentId (string const&, + TRI_voc_cid_t&, + TRI_voc_key_t&); //////////////////////////////////////////////////////////////////////////////// /// @} @@ -364,6 +345,12 @@ namespace triagens { /// @{ //////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// +/// @brief request context +//////////////////////////////////////////////////////////////////////////////// + + VocbaseContext* _context; + //////////////////////////////////////////////////////////////////////////////// /// @brief the vocbase //////////////////////////////////////////////////////////////////////////////// @@ -376,25 +363,6 @@ namespace triagens { triagens::arango::CollectionNameResolver _resolver; -//////////////////////////////////////////////////////////////////////////////// -/// @brief timing data structure -//////////////////////////////////////////////////////////////////////////////// - - triagens::basics::LoggerTiming _timing; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief timing result -//////////////////////////////////////////////////////////////////////////////// - - triagens::basics::LoggerData::Extra _timingResult; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief timing result -//////////////////////////////////////////////////////////////////////////////// - - VocbaseContext* _context; - - //////////////////////////////////////////////////////////////////////////////// /// @} ////////////////////////////////////////////////////////////////////////////////