1
0
Fork 0

slightly adjusted

This commit is contained in:
Jan Steemann 2013-01-25 17:51:49 +01:00
parent 1666daa7b3
commit 13953ddbd6
2 changed files with 22 additions and 17 deletions

View File

@ -36,6 +36,7 @@
#include "VocBase/document-collection.h" #include "VocBase/document-collection.h"
#include "VocBase/vocbase.h" #include "VocBase/vocbase.h"
#include "Utils/Barrier.h" #include "Utils/Barrier.h"
#include "Utils/UserTransaction.h"
#include "Utilities/ResourceHolder.h" #include "Utilities/ResourceHolder.h"
using namespace std; using namespace std;
@ -139,9 +140,11 @@ HttpHandler::status_e RestDocumentHandler::execute () {
case HttpRequest::HTTP_REQUEST_PATCH: res = updateDocument(); break; case HttpRequest::HTTP_REQUEST_PATCH: res = updateDocument(); break;
case HttpRequest::HTTP_REQUEST_ILLEGAL: case HttpRequest::HTTP_REQUEST_ILLEGAL:
default: {
generateNotImplemented("ILLEGAL " + DOCUMENT_PATH); generateNotImplemented("ILLEGAL " + DOCUMENT_PATH);
break; break;
} }
}
_timingResult = res ? RES_ERR : RES_OK; _timingResult = res ? RES_ERR : RES_OK;
@ -732,9 +735,13 @@ bool RestDocumentHandler::modifyDocument (bool isPatch) {
vector<string> const& suffix = _request->suffix(); vector<string> const& suffix = _request->suffix();
if (suffix.size() != 2) { if (suffix.size() != 2) {
string msg("expecting ");
msg.append(isPatch ? "PATCH" : "PUT");
msg.append(" /_api/document/<document-handle>");
generateError(HttpResponse::BAD, generateError(HttpResponse::BAD,
TRI_ERROR_HTTP_BAD_PARAMETER, TRI_ERROR_HTTP_BAD_PARAMETER,
"expecting UPDATE /_api/document/<document-handle>"); msg);
return false; return false;
} }
@ -760,7 +767,6 @@ bool RestDocumentHandler::modifyDocument (bool isPatch) {
SelfContainedWriteTransaction<RestTransactionContext> trx(_vocbase, collection); SelfContainedWriteTransaction<RestTransactionContext> trx(_vocbase, collection);
TRI_doc_mptr_t* document = 0; TRI_doc_mptr_t* document = 0;
TRI_voc_rid_t rid = 0;
// ............................................................................. // .............................................................................
// inside write transaction // inside write transaction
@ -772,6 +778,8 @@ bool RestDocumentHandler::modifyDocument (bool isPatch) {
return false; return false;
} }
TRI_voc_rid_t rid = 0;
if (isPatch) { if (isPatch) {
// patching an existing document // patching an existing document
bool nullMeansRemove; bool nullMeansRemove;
@ -902,8 +910,6 @@ bool RestDocumentHandler::deleteDocument () {
string collection = suffix[0]; string collection = suffix[0];
string key = suffix[1]; string key = suffix[1];
// extract document identifier
// extract the revision // extract the revision
TRI_voc_rid_t revision = extractRevision("if-match", "rev"); TRI_voc_rid_t revision = extractRevision("if-match", "rev");
@ -917,9 +923,7 @@ bool RestDocumentHandler::deleteDocument () {
return false; return false;
} }
// find and load collection given by name or identifier
SelfContainedWriteTransaction<RestTransactionContext> trx(_vocbase, collection); SelfContainedWriteTransaction<RestTransactionContext> trx(_vocbase, collection);
TRI_voc_rid_t rid = 0;
// ............................................................................. // .............................................................................
// inside write transaction // inside write transaction
@ -931,6 +935,7 @@ bool RestDocumentHandler::deleteDocument () {
return false; return false;
} }
TRI_voc_rid_t rid = 0;
res = trx.deleteDocument(key, policy, extractWaitForSync(), revision, &rid); res = trx.deleteDocument(key, policy, extractWaitForSync(), revision, &rid);
if (res == TRI_ERROR_NO_ERROR) { if (res == TRI_ERROR_NO_ERROR) {
res = trx.commit(); res = trx.commit();

View File

@ -149,6 +149,12 @@ namespace triagens {
virtual bool readAllDocuments (); virtual bool readAllDocuments ();
////////////////////////////////////////////////////////////////////////////////
/// @brief reads a single document head
////////////////////////////////////////////////////////////////////////////////
virtual bool checkDocument ();
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief replaces a document /// @brief replaces a document
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -173,12 +179,6 @@ namespace triagens {
virtual bool deleteDocument (); virtual bool deleteDocument ();
////////////////////////////////////////////////////////////////////////////////
/// @brief reads a single document head
////////////////////////////////////////////////////////////////////////////////
virtual bool checkDocument ();
}; };
} }
} }