1
0
Fork 0

new name convention

This commit is contained in:
Frank Celler 2013-07-25 17:25:39 +02:00
parent 9bc0f82583
commit 1b6dfad627
15 changed files with 692 additions and 654 deletions

View File

@ -1,25 +0,0 @@
COMMAND SECTION "DATE" "" "ArangoDB"
NAME
COMMAND - user setup utility for the ArangoDB database server
SYNOPSIS
COMMAND database-directory username [password]
DESCRIPTION
The COMMAND utility can be used to create additional users in an
ArangoDB database server.
The utility must be run with exclusive access to the server's data directory,
meaning the ArangoDB server must not be running and accessing the
datafiles in the specified data directory.
OPTIONS
The options of the COMMAND utility are:
OPTION "--database.directory <string>"
path to the database directory ENDOPTION
OPTION "username"
name of the user to add ENDOPTION
OPTION "password"
password for the user. Leave empty for a password prompt ENDOPTION
EXAMPLES
EXAMPLE COMMAND --database.directory /data/arangodb fuchsia
creates a new user "fuchsia". Password prompt will follow ENDEXAMPLE
EXAMPLE COMMAND --database.directory /data/arangodb fuchsia "1234@ab"
creates a new user "fuchsia" with the specified password ENDEXAMPLE
AUTHOR

View File

@ -71,6 +71,7 @@ TRI_DATABASEDIR =
TRI_LOGDIR = /tmp
TRI_PKGDATADIR = .
TRI_SBINDIR = ${abs_builddir}/bin
TRI_BINDIR = ${abs_builddir}/bin
else
@ -78,6 +79,7 @@ TRI_DATABASEDIR = ${localstatedir}/lib/${PACKAGE_TARNAME}
TRI_LOGDIR = ${localstatedir}/log/${PACKAGE_TARNAME}
TRI_PKGDATADIR = ${pkgdatadir}
TRI_SBINDIR = ${sbindir}
TRI_BINDIR = ${bindir}
endif

View File

@ -54,11 +54,6 @@ size_t const ArangoClient::DEFAULT_RETRIES = 2;
// --SECTION-- public constants
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoShell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief ignore sequence used for prompt length calculation (starting point)
///
@ -75,19 +70,10 @@ char const * ArangoClient::PROMPT_IGNORE_START = "\001";
char const * ArangoClient::PROMPT_IGNORE_END = "\002";
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- constructors and destructors
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoShell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
@ -126,26 +112,17 @@ ArangoClient::ArangoClient ()
_requestTimeout(DEFAULT_REQUEST_TIMEOUT) {
char* p = TRI_GetTempPath();
if (p != NULL) {
_tempPath = string(p);
TRI_Free(TRI_CORE_MEM_ZONE, p);
TRI_Free(TRI_CORE_MEM_ZONE, p);
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public methods
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoShell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief sets up the general and logging options
////////////////////////////////////////////////////////////////////////////////
@ -344,12 +321,12 @@ void ArangoClient::parse (ProgramOptions& options,
// set temp path
if (options.has("temp-path")) {
TRI_SetUserTempPath((char*) _tempPath.c_str());
}
}
// check if have a password
_hasPassword = options.has("server.password") ||
_disableAuthentication ||
options.has("jslint");
_hasPassword = options.has("server.password")
|| _disableAuthentication
|| options.has("jslint");
// set colors
if (options.has("colors")) {
@ -745,10 +722,6 @@ double ArangoClient::requestTimeout () const {
return _requestTimeout;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------

View File

@ -74,11 +74,6 @@ using namespace triagens::arango;
// --SECTION-- private variables
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8Shell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief base class for clients
////////////////////////////////////////////////////////////////////////////////
@ -133,6 +128,12 @@ static string StartupPath = "";
static vector<string> ExecuteScripts;
////////////////////////////////////////////////////////////////////////////////
/// @brief javascript string to execute
////////////////////////////////////////////////////////////////////////////////
static string ExecuteString;
////////////////////////////////////////////////////////////////////////////////
/// @brief javascript files to syntax check
////////////////////////////////////////////////////////////////////////////////
@ -151,19 +152,10 @@ static vector<string> UnitTests;
static vector<string> JsLint;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- JavaScript functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8Shell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief outputs the arguments
///
@ -222,19 +214,10 @@ static v8::Handle<v8::Value> JS_StopOutputPager (v8::Arguments const& ) {
return v8::Undefined();
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- import function
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8Shell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief imports a CSV file
///
@ -362,11 +345,6 @@ static v8::Handle<v8::Value> JS_ImportJsonFile (v8::Arguments const& argv) {
TRI_V8_EXCEPTION_MESSAGE(scope, TRI_ERROR_FAILED, ih.getErrorMessage().c_str());
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief normalize UTF 16 strings
////////////////////////////////////////////////////////////////////////////////
@ -404,11 +382,6 @@ static v8::Handle<v8::Value> JS_compare_string (v8::Arguments const& argv) {
// --SECTION-- private functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8Shell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief return a new client connection instance
////////////////////////////////////////////////////////////////////////////////
@ -427,12 +400,13 @@ static V8ClientConnection* CreateConnection () {
/// @brief parses the program options
////////////////////////////////////////////////////////////////////////////////
static void ParseProgramOptions (int argc, char* argv[]) {
static vector<string> ParseProgramOptions (int argc, char* argv[]) {
ProgramOptionsDescription description("STANDARD options");
ProgramOptionsDescription javascript("JAVASCRIPT options");
javascript
("javascript.execute", &ExecuteScripts, "execute Javascript code from file")
("javascript.execute-string", &ExecuteString, "execute Javascript code from string")
("javascript.check", &CheckScripts, "syntax check code Javascript code from file")
("javascript.modules-path", &StartupModules, "one or more directories separated by semi-colons")
("javascript.package-path", &StartupPackages, "one or more directories separated by semi-colons")
@ -446,6 +420,10 @@ static void ParseProgramOptions (int argc, char* argv[]) {
(javascript, false)
;
vector<string> arguments;
description.arguments(&arguments);
// fill in used options
BaseClient.setupGeneral(description);
BaseClient.setupColors(description);
@ -473,9 +451,12 @@ static void ParseProgramOptions (int argc, char* argv[]) {
}
// disable excessive output in non-interactive mode
if (! ExecuteScripts.empty() || ! CheckScripts.empty() || ! UnitTests.empty() || ! JsLint.empty()) {
if (! ExecuteScripts.empty() || ! ExecuteString.empty() || ! CheckScripts.empty() || ! UnitTests.empty() || ! JsLint.empty()) {
BaseClient.shutup();
}
// return the positional arguments
return arguments;
}
////////////////////////////////////////////////////////////////////////////////
@ -570,7 +551,7 @@ static v8::Handle<v8::Value> ClientConnection_reconnect (v8::Arguments const& ar
v8::HandleScope scope;
V8ClientConnection* connection = TRI_UnwrapClass<V8ClientConnection>(argv.Holder(), WRAP_TYPE_CONNECTION);
if (connection == 0) {
TRI_V8_EXCEPTION_INTERNAL(scope, "connection class corrupted");
}
@ -580,7 +561,7 @@ static v8::Handle<v8::Value> ClientConnection_reconnect (v8::Arguments const& ar
}
string definition = TRI_ObjectToString(argv[0]);
string username;
if (argv.Length() < 2) {
username = BaseClient.username();
@ -607,7 +588,7 @@ static v8::Handle<v8::Value> ClientConnection_reconnect (v8::Arguments const& ar
else {
password = TRI_ObjectToString(argv[2]);
}
delete connection;
const string oldDefinition = BaseClient.endpointString();
@ -615,15 +596,15 @@ static v8::Handle<v8::Value> ClientConnection_reconnect (v8::Arguments const& ar
const string oldPassword = BaseClient.password();
BaseClient.setEndpointString(definition);
BaseClient.setUsername(username);
BaseClient.setPassword(password);
BaseClient.setUsername(username);
BaseClient.setPassword(password);
// re-connect using new options
BaseClient.createEndpoint();
if (BaseClient.endpointServer() == 0) {
BaseClient.setEndpointString(oldDefinition);
BaseClient.setUsername(oldUsername);
BaseClient.setPassword(oldPassword);
BaseClient.setUsername(oldUsername);
BaseClient.setPassword(oldPassword);
BaseClient.createEndpoint();
string errorMessage = "error in '" + definition + "'";
@ -635,7 +616,7 @@ static v8::Handle<v8::Value> ClientConnection_reconnect (v8::Arguments const& ar
if (newConnection->isConnected() && newConnection->getLastHttpReturnCode() == HttpResponse::OK) {
cout << "Connected to ArangoDB '" << BaseClient.endpointServer()->getSpecification()
<< "' version " << newConnection->getVersion() << ", username: '" << BaseClient.username() << "'" << endl;
argv.Holder()->SetInternalField(SLOT_CLASS, v8::External::New(newConnection));
v8::Handle<v8::Value> db = v8::Context::GetCurrent()->Global()->Get(TRI_V8_SYMBOL("db"));
@ -644,13 +625,13 @@ static v8::Handle<v8::Value> ClientConnection_reconnect (v8::Arguments const& ar
if (dbObj->Has(TRI_V8_STRING("_flushCache")) && dbObj->Get(TRI_V8_STRING("_flushCache"))->IsFunction()) {
v8::Handle<v8::Function> func = v8::Handle<v8::Function>::Cast(dbObj->Get(TRI_V8_STRING("_flushCache")));
v8::Handle<v8::Value>* args = 0;
func->Call(dbObj, 0, args);
}
}
// ok
// ok
return scope.Close(v8::True());
}
else {
@ -658,8 +639,8 @@ static v8::Handle<v8::Value> ClientConnection_reconnect (v8::Arguments const& ar
// rollback
BaseClient.setEndpointString(oldDefinition);
BaseClient.setUsername(oldUsername);
BaseClient.setPassword(oldPassword);
BaseClient.setUsername(oldUsername);
BaseClient.setPassword(oldPassword);
BaseClient.createEndpoint();
ClientConnection = CreateConnection();
@ -669,9 +650,9 @@ static v8::Handle<v8::Value> ClientConnection_reconnect (v8::Arguments const& ar
if (newConnection->getErrorMessage() != "") {
errorMsg = newConnection->getErrorMessage();
}
delete newConnection;
TRI_V8_EXCEPTION_MESSAGE(scope, TRI_SIMPLE_CLIENT_COULD_NOT_CONNECT, errorMsg.c_str());
}
}
@ -1024,20 +1005,20 @@ static v8::Handle<v8::Value> ClientConnection_httpSendFile (v8::Arguments const&
}
TRI_Utf8ValueNFC url(TRI_UNKNOWN_MEM_ZONE, argv[0]);
const string infile = TRI_ObjectToString(argv[1]);
if (! TRI_ExistsFile(infile.c_str())) {
TRI_V8_EXCEPTION(scope, TRI_ERROR_FILE_NOT_FOUND);
}
size_t bodySize;
char* body = TRI_SlurpFile(TRI_UNKNOWN_MEM_ZONE, infile.c_str(), &bodySize);
if (body == 0) {
TRI_V8_EXCEPTION_MESSAGE(scope, TRI_errno(), "could not read file");
}
v8::TryCatch tryCatch;
// check header fields
@ -1045,7 +1026,7 @@ static v8::Handle<v8::Value> ClientConnection_httpSendFile (v8::Arguments const&
v8::Handle<v8::Value> result = connection->postData(*url, body, bodySize, headerFields);
TRI_Free(TRI_UNKNOWN_MEM_ZONE, body);
if (tryCatch.HasCaught()) {
return scope.Close(v8::ThrowException(tryCatch.Exception()));
}
@ -1211,20 +1192,27 @@ static void RunShell (v8::Handle<v8::Context> context, bool promptError) {
string badPrompt;
#ifdef __APPLE__
// ........................................................................................
// MacOS uses libedit, which does not support ignoring of non-printable characters in the prompt
// using non-printable characters in the prompt will lead to wrong prompt lengths being calculated
// we will therefore disable colorful prompts for MacOS.
// ........................................................................................
goodPrompt = badPrompt = string("arangosh> ");
#elif _WIN32
// ........................................................................................
// Windows console is not coloured by escape sequences. So the method given below will not
// work. For now we simply ignore the colours until we move the windows version into
// a GUI Window.
// ........................................................................................
goodPrompt = string("arangosh> ");
badPrompt = string("arangosh> ");
goodPrompt = badPrompt = string("arangosh> ");
#else
if (BaseClient.colors()) {
goodPrompt = string(ArangoClient::PROMPT_IGNORE_START) + string(TRI_SHELL_COLOR_BOLD_GREEN) + string(ArangoClient::PROMPT_IGNORE_END) +
string("arangosh>") +
@ -1239,6 +1227,7 @@ static void RunShell (v8::Handle<v8::Context> context, bool promptError) {
else {
goodPrompt = badPrompt = string("arangosh> ");
}
#endif
cout << endl;
@ -1392,6 +1381,35 @@ static bool RunScripts (v8::Handle<v8::Context> context,
return ok;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief executes the Javascript string
////////////////////////////////////////////////////////////////////////////////
static bool RunString (v8::Handle<v8::Context> context,
const string& script) {
v8::HandleScope scope;
v8::TryCatch tryCatch;
bool ok = true;
TRI_ExecuteJavaScriptString(context,
v8::String::New(script.c_str()),
v8::String::New("(command-line)"),
false);
if (tryCatch.HasCaught()) {
string exception(TRI_StringifyV8Exception(&tryCatch));
cerr << exception << endl;
BaseClient.log("%s\n", exception.c_str());
ok = false;
}
BaseClient.flushLog();
return ok;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief runs the jslint tests
////////////////////////////////////////////////////////////////////////////////
@ -1428,20 +1446,10 @@ static bool RunJsLint (v8::Handle<v8::Context> context) {
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- public functions
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8Shell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief startup and exit functions
////////////////////////////////////////////////////////////////////////////////
@ -1535,7 +1543,7 @@ int main (int argc, char* argv[]) {
// parse the program options
// .............................................................................
ParseProgramOptions(argc, argv);
vector<string> positionals = ParseProgramOptions(argc, argv);
// .............................................................................
// set-up client connection
@ -1550,7 +1558,6 @@ int main (int argc, char* argv[]) {
}
if (useServer) {
BaseClient.createEndpoint();
if (BaseClient.endpointServer() == 0) {
@ -1558,7 +1565,6 @@ int main (int argc, char* argv[]) {
TRI_EXIT_FUNCTION(EXIT_FAILURE,NULL);
}
ClientConnection = CreateConnection();
}
@ -1635,15 +1641,15 @@ int main (int argc, char* argv[]) {
connection_proto->SetCallAsFunctionHandler(ClientConnection_ConstructorCallback);
v8::Handle<v8::ObjectTemplate> connection_inst = connection_templ->InstanceTemplate();
connection_inst->SetInternalFieldCount(2);
connection_inst->SetInternalFieldCount(2);
TRI_AddGlobalVariableVocbase(context, "ArangoConnection", connection_proto->NewInstance());
ConnectionTempl = v8::Persistent<v8::ObjectTemplate>::New(isolate, connection_inst);
// add the client connection to the context:
TRI_AddGlobalVariableVocbase(context, "SYS_ARANGO", wrapV8ClientConnection(ClientConnection));
}
TRI_AddGlobalVariableVocbase(context, "SYS_START_PAGER", v8::FunctionTemplate::New(JS_StartOutputPager)->GetFunction());
TRI_AddGlobalVariableVocbase(context, "SYS_STOP_PAGER", v8::FunctionTemplate::New(JS_StopOutputPager)->GetFunction());
TRI_AddGlobalVariableVocbase(context, "SYS_IMPORT_CSV_FILE", v8::FunctionTemplate::New(JS_ImportCsvFile)->GetFunction());
@ -1661,10 +1667,9 @@ int main (int argc, char* argv[]) {
#ifdef _WIN32
// .............................................................................
// Quick hack for windows
// .............................................................................
// .............................................................................
// Quick hack for windows
// .............................................................................
if (BaseClient.colors()) {
int greenColour = FOREGROUND_GREEN | FOREGROUND_INTENSITY;
@ -1716,10 +1721,10 @@ int main (int argc, char* argv[]) {
printf(" ");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColour);
printf("\n");
}
#else
char const* g = TRI_SHELL_COLOR_GREEN;
char const* r = TRI_SHELL_COLOR_RED;
char const* z = TRI_SHELL_COLOR_RESET;
@ -1738,6 +1743,7 @@ int main (int argc, char* argv[]) {
printf("%s| (_| | | | (_| | | | | (_| | (_) %s\\__ \\ | | |%s\n", g, r, z);
printf("%s \\__,_|_| \\__,_|_| |_|\\__, |\\___/%s|___/_| |_|%s\n", g, r, z);
printf("%s |___/ %s %s\n", g, r, z);
#endif
cout << endl << "Welcome to arangosh " << TRIAGENS_VERSION << ". Copyright (c) triAGENS GmbH" << endl;
@ -1795,6 +1801,7 @@ int main (int argc, char* argv[]) {
TRI_AddGlobalVariableVocbase(context, "VALGRIND", v8::Boolean::New((RUNNING_ON_VALGRIND) > 0));
bool isExecuteScript = false;
bool isExecuteString = false;
bool isCheckScripts = false;
bool isUnitTests = false;
bool isJsLint = false;
@ -1802,6 +1809,9 @@ int main (int argc, char* argv[]) {
if (! ExecuteScripts.empty()) {
isExecuteScript = true;
}
else if (! ExecuteString.empty()) {
isExecuteString = true;
}
else if (! CheckScripts.empty()) {
isCheckScripts = true;
}
@ -1813,6 +1823,7 @@ int main (int argc, char* argv[]) {
}
TRI_AddGlobalVariableVocbase(context, "IS_EXECUTE_SCRIPT", v8::Boolean::New(isExecuteScript));
TRI_AddGlobalVariableVocbase(context, "IS_EXECUTE_STRING", v8::Boolean::New(isExecuteString));
TRI_AddGlobalVariableVocbase(context, "IS_CHECK_SCRIPT", v8::Boolean::New(isCheckScripts));
TRI_AddGlobalVariableVocbase(context, "IS_UNIT_TESTS", v8::Boolean::New(isUnitTests));
TRI_AddGlobalVariableVocbase(context, "IS_JS_LINT", v8::Boolean::New(isJsLint));
@ -1844,13 +1855,29 @@ int main (int argc, char* argv[]) {
}
}
// .............................................................................
// create arguments
// .............................................................................
v8::Handle<v8::Array> p = v8::Array::New(positionals.size());
for (size_t i = 0; i < positionals.size(); ++i) {
p->Set(i, v8::String::New(positionals[i].c_str()));
}
TRI_AddGlobalVariableVocbase(context, "ARGUMENTS", p);
// .............................................................................
// start logging
// .............................................................................
BaseClient.openLog();
// .............................................................................
// run normal shell
// .............................................................................
if (! (isExecuteScript || isCheckScripts || isUnitTests || isJsLint)) {
if (! (isExecuteScript || isExecuteString || isCheckScripts || isUnitTests || isJsLint)) {
RunShell(context, promptError);
}
@ -1862,9 +1889,13 @@ int main (int argc, char* argv[]) {
bool ok = false;
if (isExecuteScript) {
// we have scripts to execute or syntax check
// we have scripts to execute
ok = RunScripts(context, ExecuteScripts, true);
}
else if (isExecuteString) {
// we have string to execute
ok = RunString(context, ExecuteString);
}
else if (isCheckScripts) {
// we have scripts to syntax check
ok = RunScripts(context, CheckScripts, false);
@ -1902,10 +1933,6 @@ int main (int argc, char* argv[]) {
return ret;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------

View File

@ -1,3 +1,6 @@
[server]
password =
[javascript]
startup-directory = ./js
modules-path = ./js/client/modules;./js/common/modules;./js/node

View File

@ -1,5 +1,5 @@
/*jslint indent: 2, nomen: true, maxlen: 120, sloppy: true, vars: true, nonpropdel: true, white: true, plusplus: true, evil: true */
/*global require, IS_EXECUTE_SCRIPT, IS_CHECK_SCRIPT, IS_UNIT_TESTS, IS_JS_LINT */
/*global require, IS_EXECUTE_SCRIPT, IS_EXECUTE_STRING, IS_CHECK_SCRIPT, IS_UNIT_TESTS, IS_JS_LINT */
////////////////////////////////////////////////////////////////////////////////
/// @brief ArangoShell client API
@ -94,12 +94,6 @@ var db = require("org/arangodb").db;
var arango = require("org/arangodb").arango;
////////////////////////////////////////////////////////////////////////////////
/// @brief global 'aal'
////////////////////////////////////////////////////////////////////////////////
var aal = require("org/arangodb/aal");
////////////////////////////////////////////////////////////////////////////////
/// @brief global 'Buffer'
////////////////////////////////////////////////////////////////////////////////
@ -129,7 +123,7 @@ var Buffer = require("buffer").Buffer;
try {
// these variables don't exist in the browser context
special = IS_EXECUTE_SCRIPT || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
special = IS_EXECUTE_SCRIPT || IS_EXECUTE_STRING || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
}
catch (err2) {
special = false;
@ -153,7 +147,7 @@ var Buffer = require("buffer").Buffer;
try {
// these variables are not defined in the browser context
__special__ = IS_EXECUTE_SCRIPT || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
__special__ = IS_EXECUTE_SCRIPT || IS_EXECUTE_STRING || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
}
catch (err) {
__special__ = true;
@ -177,6 +171,7 @@ var Buffer = require("buffer").Buffer;
try {
delete IS_EXECUTE_SCRIPT;
delete IS_EXECUTE_STRING;
delete IS_CHECK_SCRIPT;
delete IS_UNIT_TESTS;
delete IS_JS_LINT;

View File

@ -45,39 +45,6 @@ var foxxManager = require("org/arangodb/foxx-manager");
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief installs a FOXX application
////////////////////////////////////////////////////////////////////////////////
actions.defineHttp({
url : "_admin/foxx/install",
context : "admin",
prefix : false,
callback : function (req, res) {
'use strict';
var result;
var body = actions.getJsonBody(req, res);
if (body === undefined) {
return;
}
var appId = body.appId;
var mount = body.mount;
var options = body.options || {};
try {
result = foxxManager.installApp(appId, mount, options);
actions.resultOk(req, res, actions.HTTP_OK, result);
}
catch (err) {
actions.resultException(req, res, err);
}
}
});
////////////////////////////////////////////////////////////////////////////////
/// @brief sets up a FOXX dev application
////////////////////////////////////////////////////////////////////////////////
@ -141,42 +108,11 @@ actions.defineHttp({
});
////////////////////////////////////////////////////////////////////////////////
/// @brief uninstalls a FOXX application
/// @brief fetches a FOXX application
////////////////////////////////////////////////////////////////////////////////
actions.defineHttp({
url : "_admin/foxx/uninstall",
context : "admin",
prefix : false,
callback : function (req, res) {
'use strict';
var result;
var body = actions.getJsonBody(req, res);
if (body === undefined) {
return;
}
var key = body.key;
try {
result = foxxManager.uninstallApp(key);
actions.resultOk(req, res, actions.HTTP_OK, result);
}
catch (err) {
actions.resultException(req, res, err);
}
}
});
////////////////////////////////////////////////////////////////////////////////
/// @brief loads a FOXX application
////////////////////////////////////////////////////////////////////////////////
actions.defineHttp({
url : "_admin/foxx/load",
url : "_admin/foxx/fetch",
context : "admin",
prefix : false,
@ -245,6 +181,68 @@ actions.defineHttp({
}
});
////////////////////////////////////////////////////////////////////////////////
/// @brief mounts a FOXX application
////////////////////////////////////////////////////////////////////////////////
actions.defineHttp({
url : "_admin/foxx/mount",
context : "admin",
prefix : false,
callback : function (req, res) {
'use strict';
var body = actions.getJsonBody(req, res);
if (body === undefined) {
return;
}
var appId = body.appId;
var mount = body.mount;
var options = body.options || {};
try {
var result = foxxManager.mount(appId, mount, options);
actions.resultOk(req, res, actions.HTTP_OK, result);
}
catch (err) {
actions.resultException(req, res, err);
}
}
});
////////////////////////////////////////////////////////////////////////////////
/// @brief unmounts a FOXX application
////////////////////////////////////////////////////////////////////////////////
actions.defineHttp({
url : "_admin/foxx/unmount",
context : "admin",
prefix : false,
callback : function (req, res) {
'use strict';
var body = actions.getJsonBody(req, res);
if (body === undefined) {
return;
}
var key = body.key;
try {
var result = foxxManager.unmount(key);
actions.resultOk(req, res, actions.HTTP_OK, result);
}
catch (err) {
actions.resultException(req, res, err);
}
}
});
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////

View File

@ -67,12 +67,12 @@
},
install: function (name, mount, version) {
return foxxmanager.installApp(name, mount, version);
return foxxmanager.mount(name, mount, version);
},
// Define the functionality to uninstall an installed foxx
uninstall: function (key) {
return foxxmanager.uninstallApp(key);
return foxxmanager.unmount(key);
},
// Define the functionality to deactivate an installed foxx.

View File

@ -1,5 +1,5 @@
/*jslint indent: 2, nomen: true, maxlen: 120, sloppy: true, vars: true, nonpropdel: true, white: true, plusplus: true, evil: true */
/*global require, IS_EXECUTE_SCRIPT, IS_CHECK_SCRIPT, IS_UNIT_TESTS, IS_JS_LINT */
/*global require, IS_EXECUTE_SCRIPT, IS_EXECUTE_STRING, IS_CHECK_SCRIPT, IS_UNIT_TESTS, IS_JS_LINT */
////////////////////////////////////////////////////////////////////////////////
/// @brief ArangoShell client API
@ -94,12 +94,6 @@ var db = require("org/arangodb").db;
var arango = require("org/arangodb").arango;
////////////////////////////////////////////////////////////////////////////////
/// @brief global 'aal'
////////////////////////////////////////////////////////////////////////////////
var aal = require("org/arangodb/aal");
////////////////////////////////////////////////////////////////////////////////
/// @brief global 'Buffer'
////////////////////////////////////////////////////////////////////////////////
@ -129,7 +123,7 @@ var Buffer = require("buffer").Buffer;
try {
// these variables don't exist in the browser context
special = IS_EXECUTE_SCRIPT || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
special = IS_EXECUTE_SCRIPT || IS_EXECUTE_STRING || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
}
catch (err2) {
special = false;
@ -153,7 +147,7 @@ var Buffer = require("buffer").Buffer;
try {
// these variables are not defined in the browser context
__special__ = IS_EXECUTE_SCRIPT || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
__special__ = IS_EXECUTE_SCRIPT || IS_EXECUTE_STRING || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
}
catch (err) {
__special__ = true;
@ -177,6 +171,7 @@ var Buffer = require("buffer").Buffer;
try {
delete IS_EXECUTE_SCRIPT;
delete IS_EXECUTE_STRING;
delete IS_CHECK_SCRIPT;
delete IS_UNIT_TESTS;
delete IS_JS_LINT;

View File

@ -815,10 +815,10 @@ function require (path) {
return module.exports;
}
throw "cannot locate module '" + unormalizedPath + "'"
throw new Error("cannot locate module '" + unormalizedPath + "'"
+ " for package '" + this._package.id + "'"
+ " using module path '" + modulesPath + "'"
+ " and package path '" + this._package._paths + "'";
+ " and package path '" + this._package._paths + "'");
};
////////////////////////////////////////////////////////////////////////////////

View File

@ -169,7 +169,7 @@
var found = aal.firstExample({ type: "mount", mount: "/_admin/aardvark" });
if (found === null) {
fm.installApp("aardvark", "/_admin/aardvark", {reload: false});
fm.mount("aardvark", "/_admin/aardvark", {reload: false});
}
}
};

View File

@ -537,21 +537,13 @@ exports.scanAppDirectory = function () {
};
////////////////////////////////////////////////////////////////////////////////
/// @brief installs a FOXX application
/// @brief mounts a FOXX application
////////////////////////////////////////////////////////////////////////////////
exports.installApp = function (appId, mount, options) {
exports.mount = function (appId, mount, options) {
'use strict';
var aal;
var app;
var desc;
var doc;
var prefix;
var routes;
var version;
aal = getStorage();
var aal = getStorage();
// .............................................................................
// locate the application
@ -561,7 +553,7 @@ exports.installApp = function (appId, mount, options) {
appId = "app:" + appId + ":latest";
}
app = module.createApp(appId);
var app = module.createApp(appId);
if (app === null) {
throw new Error("cannot find application '" + appId + "'");
@ -571,8 +563,8 @@ exports.installApp = function (appId, mount, options) {
// compute the routing information
// .............................................................................
prefix = options && options.collectionPrefix;
routes = routingAalApp(app, mount, prefix, false);
var prefix = options && options.collectionPrefix;
var routes = routingAalApp(app, mount, prefix, false);
if (routes === null) {
throw new Error("cannot compute the routing table for fox application '"
@ -583,6 +575,9 @@ exports.installApp = function (appId, mount, options) {
// install the application
// .............................................................................
var doc;
var desc;
try {
doc = installAalApp(app, mount, prefix, false);
}
@ -609,21 +604,14 @@ exports.installApp = function (appId, mount, options) {
};
////////////////////////////////////////////////////////////////////////////////
/// @brief uninstalls a FOXX application
/// @brief unmounts a FOXX application
////////////////////////////////////////////////////////////////////////////////
exports.uninstallApp = function (key) {
exports.unmount = function (key) {
'use strict';
var aal;
var app;
var appDoc;
var context;
var doc;
var routing;
aal = getStorage();
doc = aal.firstExample({ type: "mount", _key: key });
var aal = getStorage();
var doc = aal.firstExample({ type: "mount", _key: key });
if (doc === null) {
doc = aal.firstExample({ type: "mount", mount: key });
@ -637,23 +625,20 @@ exports.uninstallApp = function (key) {
try {
if (appId.substr(0,4) === "app:") {
appDoc = aal.firstExample({ app: appId, type: "app" });
var appDoc = aal.firstExample({ app: appId, type: "app" });
if (appDoc === null) {
throw new Error("cannot find app '" + appId + "' in _aal collection");
}
}
app = module.createApp(appId);
var app = module.createApp(appId);
teardownApp(app, doc.mount, doc.collectionPrefix);
}
catch (err) {
console.error("teardown not possible for application '%s': %s", appId, String(err));
}
routing = arangodb.db._collection("_routing");
routing.removeByExample({ foxxMount: doc._key });
aal.remove(doc);
internal.executeGlobalContextFunction("require(\"org/arangodb/actions\").reloadRouting()");

View File

@ -10,7 +10,7 @@
bin_SCRIPTS += \
bin/arango-dfdb \
bin/arango-password
bin/foxx-manager
CLEANUP += $(bin_SCRIPTS)
@ -27,15 +27,14 @@ bin/arango-dfdb: utils/arango-dfdb.in
chmod 755 $@
################################################################################
### @brief arango password: this create a file with a warning message only
### as arango-password is deprecated
### @brief foxx manager
################################################################################
.PHONY: bin/arango-password
bin/arango-password:
@echo "echo \"arango-password is not part of this ArangoDB release.\"; exit 1" > $@
@chmod 755 $@
bin/foxx-manager: utils/foxx-manager.in
sed \
-e 's%@BINDIR@%${TRI_BINDIR}%g' \
$< > $@
chmod 755 $@
## -----------------------------------------------------------------------------
## --SECTION-- END-OF-FILE

17
utils/foxx-manager.in Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
# Placeholders starting with @ will be replaced by make
ARANGOSH="@BINDIR@/arangosh"
RCFILE=""
if [ "$1" == "--relative" ] ; then
shift
ARANGOSH="./bin/arangosh"
RCFILE="-c etc/relative/arangosh.conf"
fi
$ARANGOSH \
$RCFILE \
--javascript.execute-string 'require("org/arangodb/foxx-manager").run(ARGUMENTS);' \
$*