//////////////////////////////////////////////////////////////////////////////// /// @brief abstract base request handler /// /// @file /// /// DISCLAIMER /// /// Copyright 2004-2012 triagens GmbH, Cologne, Germany /// /// Licensed under the Apache License, Version 2.0 (the "License"); /// you may not use this file except in compliance with the License. /// You may obtain a copy of the License at /// /// http://www.apache.org/licenses/LICENSE-2.0 /// /// Unless required by applicable law or agreed to in writing, software /// distributed under the License is distributed on an "AS IS" BASIS, /// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. /// See the License for the specific language governing permissions and /// limitations under the License. /// /// Copyright holder is triAGENS GmbH, Cologne, Germany /// /// @author Dr. Frank Celler /// @author Copyright 2010-2012, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// #ifndef TRIAGENS_REST_HANDLER_REST_VOCBASE_BASE_HANDLER_H #define TRIAGENS_REST_HANDLER_REST_VOCBASE_BASE_HANDLER_H 1 #include "Admin/RestBaseHandler.h" #include "Logger/Logger.h" #include "Rest/HttpResponse.h" #include "VocBase/document-collection.h" //////////////////////////////////////////////////////////////////////////////// /// @page HttpInterface Lightweight HTTP Interface /// /// The AvocadoDB has a REST interface for accessing the resources. It /// also provides a lightweight HTTP interface to execute actions. Actions are /// small JavaScript functions which encapsulate business logic. /// /// Each resource has an identifier, which allows to access the given resource. /// /// - collection: /// A collection can be referenced using the collection identifier or the /// collection name. /// - document: /// A document can be referenced using the collection identifier and the /// document identifier. Alternativly you can use a document reference which /// is a string of the form "collection-identifier:document-identifier". /// - index: /// An index can be referenced using the index identifier. /// - revision: /// Each document has a unique document identifier. However, it is possible /// to update documents. In this case the document identifier stays the /// same. Each new revision of such a document gets a new revision number. /// - etag: /// A revision of a document has an etag. /// /// Next steps: learn more about /// /// - the @ref RestDocument /// /// Advanced Topics: learn more about /// /// - @ref Actions //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @page RestSystemTOC /// ///
    ///
  1. @ref RestSystemCollections "GET /_system/collections"
  2. ///
  3. @ref RestSystemCollectionLoad "GET /_system/collection/load"
  4. ///
  5. @ref RestSystemCollectionInfo "GET /_system/collection/info"
  6. ///
  7. @ref RestSystemCollectionIndexes "GET /_system/collection/indexes"
  8. ///
//////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @page RestSystem HTTP Interface for System Administration /// ///
/// @copydoc RestSystemTOC ///
/// /// @anchor RestSystemCollections /// @copydetails JSA_collections /// /// @anchor RestSystemCollectionLoad /// @copydetails JSA_collection_load /// /// @anchor RestSystemCollectionInfo /// @copydetails JSA_collection_info /// /// @anchor RestSystemCollectionIndexes /// @copydetails JSA_collection_indexes //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- forward declarations // ----------------------------------------------------------------------------- struct TRI_doc_collection_s; struct TRI_result_set_s; struct TRI_vocbase_col_s; struct TRI_vocbase_s; struct TRI_json_s; // ----------------------------------------------------------------------------- // --SECTION-- REST_VOCBASE_BASE_HANDLER // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// /// @addtogroup AvocadoDB /// @{ //////////////////////////////////////////////////////////////////////////////// namespace triagens { namespace avocado { //////////////////////////////////////////////////////////////////////////////// /// @brief abstract base request handler //////////////////////////////////////////////////////////////////////////////// class RestVocbaseBaseHandler : public admin::RestBaseHandler { private: RestVocbaseBaseHandler (RestVocbaseBaseHandler const&); RestVocbaseBaseHandler& operator= (RestVocbaseBaseHandler const&); // ----------------------------------------------------------------------------- // --SECTION-- public constants // ----------------------------------------------------------------------------- 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 document path //////////////////////////////////////////////////////////////////////////////// static string DOCUMENT_PATH; //////////////////////////////////////////////////////////////////////////////// /// @brief collection path //////////////////////////////////////////////////////////////////////////////// static string COLLECTION_PATH; // ----------------------------------------------------------------------------- // --SECTION-- constructors and destructors // ----------------------------------------------------------------------------- public: //////////////////////////////////////////////////////////////////////////////// /// @addtogroup AvocadoDB /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief constructor //////////////////////////////////////////////////////////////////////////////// RestVocbaseBaseHandler (rest::HttpRequest* request, struct TRI_vocbase_s* vocbase); //////////////////////////////////////////////////////////////////////////////// /// @brief destructor //////////////////////////////////////////////////////////////////////////////// ~RestVocbaseBaseHandler (); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- protected methods // ----------------------------------------------------------------------------- protected: //////////////////////////////////////////////////////////////////////////////// /// @addtogroup AvocadoDB /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief generates ok message without content //////////////////////////////////////////////////////////////////////////////// void generateOk (); //////////////////////////////////////////////////////////////////////////////// /// @brief generates ok message without content //////////////////////////////////////////////////////////////////////////////// void generateOk (TRI_voc_cid_t, TRI_voc_did_t, TRI_voc_rid_t rid); //////////////////////////////////////////////////////////////////////////////// /// @brief generates created message without content but a location header //////////////////////////////////////////////////////////////////////////////// void generateCreated (TRI_voc_cid_t, TRI_voc_did_t, TRI_voc_rid_t); //////////////////////////////////////////////////////////////////////////////// /// @brief generates collection not found error message //////////////////////////////////////////////////////////////////////////////// void generateCollectionNotFound (string const& cid); //////////////////////////////////////////////////////////////////////////////// /// @brief generates document not found error message //////////////////////////////////////////////////////////////////////////////// void generateDocumentNotFound (string const& cid, string const& did); //////////////////////////////////////////////////////////////////////////////// /// @brief generates conflict message //////////////////////////////////////////////////////////////////////////////// void generateConflict (string const& cid, string const& did); //////////////////////////////////////////////////////////////////////////////// /// @brief generates not implemented //////////////////////////////////////////////////////////////////////////////// void generateNotImplemented (string const& path); //////////////////////////////////////////////////////////////////////////////// /// @brief generates first entry from a result set //////////////////////////////////////////////////////////////////////////////// void generateDocument (TRI_doc_mptr_t const*, bool generateBody); //////////////////////////////////////////////////////////////////////////////// /// @brief splits a document reference into to parts //////////////////////////////////////////////////////////////////////////////// bool splitDocumentReference (string const& name, string& did); //////////////////////////////////////////////////////////////////////////////// /// @brief extracts the revision //////////////////////////////////////////////////////////////////////////////// TRI_voc_rid_t extractRevision (); //////////////////////////////////////////////////////////////////////////////// /// @brief extracts the update policy //////////////////////////////////////////////////////////////////////////////// TRI_doc_update_policy_e extractUpdatePolicy (); //////////////////////////////////////////////////////////////////////////////// /// @brief sets the collection variable given a name or an identifier //////////////////////////////////////////////////////////////////////////////// bool findCollection (string const& name); //////////////////////////////////////////////////////////////////////////////// /// @brief creates or loads a collection //////////////////////////////////////////////////////////////////////////////// bool loadCollection (); //////////////////////////////////////////////////////////////////////////////// /// @brief parses the body //////////////////////////////////////////////////////////////////////////////// struct TRI_json_s* parseJsonBody (); //////////////////////////////////////////////////////////////////////////////// /// @brief sets the rest set, needs the collection //////////////////////////////////////////////////////////////////////////////// TRI_doc_mptr_t const* findDocument (string const& doc); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- protected variables // ----------------------------------------------------------------------------- protected: //////////////////////////////////////////////////////////////////////////////// /// @addtogroup AvocadoDB /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// @brief the vocbase //////////////////////////////////////////////////////////////////////////////// struct TRI_vocbase_s* _vocbase; //////////////////////////////////////////////////////////////////////////////// /// @brief a vocbase collection //////////////////////////////////////////////////////////////////////////////// struct TRI_vocbase_col_s const* _collection; //////////////////////////////////////////////////////////////////////////////// /// @brief corresponding loaded document collection //////////////////////////////////////////////////////////////////////////////// struct TRI_doc_collection_s* _documentCollection; //////////////////////////////////////////////////////////////////////////////// /// @brief a barrier for deletion //////////////////////////////////////////////////////////////////////////////// struct TRI_barrier_s* _barrier; //////////////////////////////////////////////////////////////////////////////// /// @brief timing data structure //////////////////////////////////////////////////////////////////////////////// triagens::basics::LoggerTiming _timing; //////////////////////////////////////////////////////////////////////////////// /// @brief timing result //////////////////////////////////////////////////////////////////////////////// triagens::basics::LoggerData::Extra _timingResult; //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// // ----------------------------------------------------------------------------- // --SECTION-- Handler methods // ----------------------------------------------------------------------------- public: //////////////////////////////////////////////////////////////////////////////// /// @addtogroup AvocadoDB /// @{ //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// /// {@inheritDoc} //////////////////////////////////////////////////////////////////////////////// bool isDirect (); //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// }; } } //////////////////////////////////////////////////////////////////////////////// /// @} //////////////////////////////////////////////////////////////////////////////// #endif // Local Variables: // mode: outline-minor // outline-regexp: "^\\(/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|// --SECTION--\\|/// @\\}\\)" // End: