1
0
Fork 0

Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel

This commit is contained in:
Michael Hackstein 2014-01-27 09:55:19 +01:00
commit 5ca6bc159d
16 changed files with 96 additions and 42 deletions

View File

@ -1,6 +1,15 @@
v1.5.0 (XXXX-XX-XX) v1.5.0 (XXXX-XX-XX)
------------------- -------------------
* issue #751: Create database through API should return HTTP status code 201
By default, the server now returns HTTP 201 (created) when creating a new
database successfully. To keep compatibility with older ArangoDB versions, the
startup parameter `--server.default-api-compatibility` can be set to a value
of `10400` to indicate API compatibility with ArangoDB 1.4. The compatibility
can also be enforced by setting the `X-Arango-Version` HTTP header in a
client request to this API on a per-request basis.
* issue #748: add vertex filtering to AQL's TRAVERSAL[_TREE]() function * issue #748: add vertex filtering to AQL's TRAVERSAL[_TREE]() function
* allow direct access from the `db` object to collections whose names start * allow direct access from the `db` object to collections whose names start
@ -114,6 +123,9 @@ v1.5.0 (XXXX-XX-XX)
result of <collection>.getIndexes() for each index. This is result of <collection>.getIndexes() for each index. This is
currently only implemented for hash indices and skiplist indices. currently only implemented for hash indices and skiplist indices.
v1.4.8 (xxxx-xx-xx)
-------------------
v1.4.7 (2014-01-23) v1.4.7 (2014-01-23)
------------------- -------------------

View File

@ -66,12 +66,34 @@ describe ArangoDB do
after do after do
ArangoDB.delete(api + "/#{name}") ArangoDB.delete(api + "/#{name}")
end end
it "creates a new database, old return code" do
body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-create", api, :body => body, :headers => { "X-Arango-Version" => "1.4" })
doc.code.should eq(200)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response
response["result"].should eq(true)
response["error"].should eq(false)
end
it "creates a new database, new return code" do
body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-create", api, :body => body, :headers => { "X-Arango-Version" => "1.5" })
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response
response["result"].should eq(true)
response["error"].should eq(false)
end
it "creates a new database" do it "creates a new database" do
body = "{\"name\" : \"#{name}\" }" body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-create", api, :body => body) doc = ArangoDB.log_post("#{prefix}-create", api, :body => body)
doc.code.should eq(200) doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8") doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response response = doc.parsed_response
response["result"].should eq(true) response["result"].should eq(true)
@ -115,7 +137,7 @@ describe ArangoDB do
body = "{\"name\" : \"#{name}\" }" body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-re-create", api, :body => body) doc = ArangoDB.log_post("#{prefix}-re-create", api, :body => body)
doc.code.should eq(200) doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8") doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc = ArangoDB.log_post("#{prefix}-post", api, :body => body) doc = ArangoDB.log_post("#{prefix}-post", api, :body => body)
@ -132,7 +154,7 @@ describe ArangoDB do
body = "{\"name\" : \"#{name}\" }" body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-drop", api, :body => body) doc = ArangoDB.log_post("#{prefix}-drop", api, :body => body)
doc.code.should eq(200) doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8") doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc = ArangoDB.log_delete("#{prefix}-drop", cmd) doc = ArangoDB.log_delete("#{prefix}-drop", cmd)
@ -158,7 +180,7 @@ describe ArangoDB do
body = "{\"name\" : \"#{name}\" }" body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-create-properties", api, :body => body) doc = ArangoDB.log_post("#{prefix}-create-properties", api, :body => body)
doc.code.should eq(200) doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8") doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response response = doc.parsed_response
response["result"].should eq(true) response["result"].should eq(true)
@ -206,7 +228,7 @@ describe ArangoDB do
body = "{\"name\" : \"#{name}\", \"users\": [ { \"username\": \"admin\", \"password\": \"secret\", \"extra\": { \"gender\": \"m\" } }, { \"username\": \"foxx\", \"active\": false } ] }" body = "{\"name\" : \"#{name}\", \"users\": [ { \"username\": \"admin\", \"password\": \"secret\", \"extra\": { \"gender\": \"m\" } }, { \"username\": \"foxx\", \"active\": false } ] }"
doc = ArangoDB.log_post("#{prefix}-create-users", api, :body => body) doc = ArangoDB.log_post("#{prefix}-create-users", api, :body => body)
doc.code.should eq(200) doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8") doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response response = doc.parsed_response
response["result"].should eq(true) response["result"].should eq(true)
@ -268,7 +290,7 @@ describe ArangoDB do
body = "{\"name\" : \"#{name}\", \"users\": [ { \"username\": \"\" } ] }" body = "{\"name\" : \"#{name}\", \"users\": [ { \"username\": \"\" } ] }"
doc = ArangoDB.log_post("#{prefix}-create-users-invalid", api, :body => body) doc = ArangoDB.log_post("#{prefix}-create-users-invalid", api, :body => body)
doc.code.should eq(200) doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8") doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response response = doc.parsed_response
response["result"].should eq(true) response["result"].should eq(true)
@ -305,7 +327,7 @@ describe ArangoDB do
body = "{\"name\" : \"#{name}\" }" body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-check-system", api, :body => body) doc = ArangoDB.log_post("#{prefix}-check-system", api, :body => body)
doc.code.should eq(200) doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8") doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response response = doc.parsed_response
response["result"].should eq(true) response["result"].should eq(true)

View File

@ -1424,6 +1424,27 @@ describe ArangoDB do
doc.parsed_response['result'].count.should eq(4) doc.parsed_response['result'].count.should eq(4)
end end
it "checks list of vertices of a vertex with HAS and HAS_NOT compare" do
cmd = "/_api/graph/#{graph_name}/vertices"
body = "{\"batchSize\" : 100, \"filter\" : { \"properties\" : [ { \"key\" : \"optional1\", \"compare\" : \"HAS\" } ] } }"
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
doc.code.should eq(201)
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(201)
doc.parsed_response['result'].count.should eq(4)
cmd = "/_api/graph/#{graph_name}/vertices"
body = "{\"batchSize\" : 100, \"filter\" : { \"properties\" : [ { \"key\" : \"optional1\", \"compare\" : \"HAS_NOT\" } ] } }"
doc = ArangoDB.log_post("#{prefix}", cmd, :body => body)
doc.code.should eq(201)
doc.parsed_response['error'].should eq(false)
doc.parsed_response['code'].should eq(201)
doc.parsed_response['result'].count.should eq(1)
end
end end
################################################################################ ################################################################################

View File

@ -240,7 +240,7 @@ function get_api_database (req, res) {
/// ///
/// @RESTRETURNCODES /// @RESTRETURNCODES
/// ///
/// @RESTRETURNCODE{200} /// @RESTRETURNCODE{201}
/// is returned if the database was created successfully. /// is returned if the database was created successfully.
/// ///
/// @RESTRETURNCODE{400} /// @RESTRETURNCODE{400}
@ -272,7 +272,7 @@ function get_api_database (req, res) {
/// var response = logCurlRequest('POST', url, JSON.stringify(data)); /// var response = logCurlRequest('POST', url, JSON.stringify(data));
/// ///
/// db._dropDatabase(name); /// db._dropDatabase(name);
/// assert(response.code === 200); /// assert(response.code === 201);
/// ///
/// logJsonResponse(response); /// logJsonResponse(response);
/// @END_EXAMPLE_ARANGOSH_RUN /// @END_EXAMPLE_ARANGOSH_RUN
@ -306,7 +306,7 @@ function get_api_database (req, res) {
/// var response = logCurlRequest('POST', url, JSON.stringify(data)); /// var response = logCurlRequest('POST', url, JSON.stringify(data));
/// ///
/// db._dropDatabase(name); /// db._dropDatabase(name);
/// assert(response.code === 200); /// assert(response.code === 201);
/// ///
/// logJsonResponse(response); /// logJsonResponse(response);
/// @END_EXAMPLE_ARANGOSH_RUN /// @END_EXAMPLE_ARANGOSH_RUN
@ -374,7 +374,8 @@ function post_api_database (req, res) {
var result = arangodb.db._createDatabase(json.name || "", options, users); var result = arangodb.db._createDatabase(json.name || "", options, users);
actions.resultOk(req, res, actions.HTTP_OK, { result : result }); var returnCode = (req.compatibility <= 10400 ? actions.HTTP_OK : actions.HTTP_CREATED);
actions.resultOk(req, res, returnCode, { result : result });
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -30,9 +30,6 @@
var arangodb = require("org/arangodb"); var arangodb = require("org/arangodb");
var actions = require("org/arangodb/actions"); var actions = require("org/arangodb/actions");
var db = arangodb.db;
var internal = require("internal"); var internal = require("internal");
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -30,7 +30,6 @@
var actions = require("org/arangodb/actions"); var actions = require("org/arangodb/actions");
var ArangoError = require("org/arangodb").ArangoError;
var ERRORS = require("internal").errors; var ERRORS = require("internal").errors;
var EXPLAIN = require("internal").AQL_EXPLAIN; var EXPLAIN = require("internal").AQL_EXPLAIN;

View File

@ -1046,6 +1046,18 @@ function process_property_compare (compare) {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function process_property_filter (data, num, property, collname) { function process_property_filter (data, num, property, collname) {
if (property.key !== undefined && property.compare === "HAS") {
if (data.filter === "") { data.filter = " FILTER"; } else { data.filter += " &&";}
data.filter += " HAS(" + collname + ", @key" + num.toString() + ") ";
data.bindVars["key" + num.toString()] = property.key;
return;
}
if (property.key !== undefined && property.compare === "HAS_NOT") {
if (data.filter === "") { data.filter = " FILTER"; } else { data.filter += " &&";}
data.filter += " !HAS(" + collname + ", @key" + num.toString() + ") ";
data.bindVars["key" + num.toString()] = property.key;
return;
}
if (property.key !== undefined && property.value !== undefined) { if (property.key !== undefined && property.value !== undefined) {
if (data.filter === "") { data.filter = " FILTER"; } else { data.filter += " &&";} if (data.filter === "") { data.filter = " FILTER"; } else { data.filter += " &&";}
data.filter += " " + collname + "[@key" + num.toString() + "] " + data.filter += " " + collname + "[@key" + num.toString() + "] " +

View File

@ -29,7 +29,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var actions = require("org/arangodb/actions"); var actions = require("org/arangodb/actions");
var simple = require("org/arangodb/simple-query");
var db = require("org/arangodb").db; var db = require("org/arangodb").db;
var ERRORS = require("internal").errors; var ERRORS = require("internal").errors;

View File

@ -40,7 +40,6 @@ var console = require("console");
var actions = require("org/arangodb/actions"); var actions = require("org/arangodb/actions");
var arangodb = require("org/arangodb"); var arangodb = require("org/arangodb");
var db = arangodb.db; var db = arangodb.db;
var ERRORS = arangodb.errors;
var DEFAULT_KEY = "default"; var DEFAULT_KEY = "default";
var API = "_api/structure"; var API = "_api/structure";

View File

@ -30,9 +30,6 @@
var arangodb = require("org/arangodb"); var arangodb = require("org/arangodb");
var actions = require("org/arangodb/actions"); var actions = require("org/arangodb/actions");
var db = arangodb.db;
var internal = require("internal"); var internal = require("internal");
var console = require("console"); var console = require("console");

View File

@ -32,8 +32,6 @@ var arangodb = require("org/arangodb");
var actions = require("org/arangodb/actions"); var actions = require("org/arangodb/actions");
var users = require("org/arangodb/users"); var users = require("org/arangodb/users");
var ArangoError = arangodb.ArangoError;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- private functions // --SECTION-- private functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -163,7 +161,7 @@ function post_api_user (req, res) {
return; return;
} }
var result = users.save(json.username, json.passwd, json.active, json.extra); users.save(json.username, json.passwd, json.active, json.extra);
users.reload(); users.reload();
actions.resultOk(req, res, actions.HTTP_CREATED, { }); actions.resultOk(req, res, actions.HTTP_CREATED, { });
@ -251,7 +249,7 @@ function put_api_user (req, res) {
} }
try { try {
var result = users.replace(username, json.passwd, json.active, json.extra); users.replace(username, json.passwd, json.active, json.extra);
users.reload(); users.reload();
actions.resultOk(req, res, actions.HTTP_OK, { }); actions.resultOk(req, res, actions.HTTP_OK, { });
@ -350,7 +348,7 @@ function patch_api_user (req, res) {
} }
try { try {
var result = users.update(username, json.passwd, json.active, json.extra); users.update(username, json.passwd, json.active, json.extra);
users.reload(); users.reload();
actions.resultOk(req, res, actions.HTTP_OK, { }); actions.resultOk(req, res, actions.HTTP_OK, { });
} }
@ -419,7 +417,7 @@ function delete_api_user (req, res) {
var username = decodeURIComponent(req.suffix[0]); var username = decodeURIComponent(req.suffix[0]);
try { try {
var result = users.remove(username); users.remove(username);
users.reload(); users.reload();
actions.resultOk(req, res, actions.HTTP_ACCEPTED, { }); actions.resultOk(req, res, actions.HTTP_ACCEPTED, { });
} }

View File

@ -39,7 +39,6 @@
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
var actions = require("org/arangodb/actions"); var actions = require("org/arangodb/actions");
var simple = require("org/arangodb/simple-query");
var db = require("org/arangodb").db; var db = require("org/arangodb").db;
var internal = require("internal"); var internal = require("internal");
var arangodb = require("org/arangodb"); var arangodb = require("org/arangodb");

View File

@ -11,7 +11,6 @@
}, },
initialize: function(opts) { initialize: function(opts) {
var self = this;
this.current = opts.current; this.current = opts.current;
this.collection.fetch({ this.collection.fetch({
async: false async: false

View File

@ -94,7 +94,6 @@
}, },
renderVersion: function () { renderVersion: function () {
var self = this;
if (this.system.hasOwnProperty('database') && this.system.hasOwnProperty('name')) { if (this.system.hasOwnProperty('database') && this.system.hasOwnProperty('name')) {
$(this.el).html(this.template.render({ $(this.el).html(this.template.render({
name: this.system.name, name: this.system.name,
@ -116,7 +115,6 @@
}, },
render: function () { render: function () {
var self = this;
if (!this.system.version) { if (!this.system.version) {
this.getVersion(); this.getVersion();
} }

View File

@ -31,9 +31,7 @@
exports.Swagger = function () { exports.Swagger = function () {
"use strict"; "use strict";
// Define the Repository var db = require("internal").db,
var Foxx = require("org/arangodb/foxx"),
db = require("internal").db,
_routing = db._collection("_routing"), _routing = db._collection("_routing"),
_aal = db._collection("_aal"), _aal = db._collection("_aal"),
_ = require("underscore"), _ = require("underscore"),

View File

@ -187,18 +187,21 @@ static char * FillVariables (const char* value) {
if (v == NULL) { if (v == NULL) {
if (TRI_EqualString(k, "ROOTDIR")) { if (TRI_EqualString(k, "ROOTDIR")) {
char* vv = TRI_LocateInstallDirectory(); char* vv = TRI_LocateInstallDirectory();
size_t lv = strlen(vv);
if (0 < lv) { if (vv != NULL) {
if (vv[lv - 1] == TRI_DIR_SEPARATOR_CHAR || vv[lv - 1] == '/') { size_t lv = strlen(vv);
v = TRI_DuplicateString2(vv, lv - 1);
} if (0 < lv) {
else { if (vv[lv - 1] == TRI_DIR_SEPARATOR_CHAR || vv[lv - 1] == '/') {
v = TRI_DuplicateString2(vv, lv); v = TRI_DuplicateString2(vv, lv - 1);
}
else {
v = TRI_DuplicateString2(vv, lv);
}
} }
TRI_FreeString(TRI_CORE_MEM_ZONE, vv);
} }
TRI_FreeString(TRI_CORE_MEM_ZONE, vv);
} }
} }
else { else {