From 120f61423eec1a827dd6ac7742acad1c46416af8 Mon Sep 17 00:00:00 2001 From: Frank Celler Date: Wed, 4 Jan 2012 09:47:33 +0100 Subject: [PATCH] reorganisation of directory tree structure --- .gitignore | 14 ++ GNUmakefile | 9 - Makefile.am | 262 ++++++++----------------- SessionManager/Session.cpp | 202 ------------------- SessionManager/Session.h | 169 ---------------- SessionManager/SessionHandler.cpp | 292 ---------------------------- SessionManager/SessionHandler.h | 98 ---------- UnitTests/georeg.c | 82 ++++---- UserManager/Role.cpp | 121 ------------ UserManager/Role.h | 124 ------------ UserManager/User.cpp | 309 ------------------------------ UserManager/User.h | 138 ------------- UserManager/UserHandler.cpp | 236 ----------------------- UserManager/UserHandler.h | 96 ---------- UserManager/UsersHandler.cpp | 83 -------- UserManager/UsersHandler.h | 85 -------- build.h | 2 +- config/revision.sh | 39 ---- configure.ac | 18 +- durham.h | 57 ------ 20 files changed, 156 insertions(+), 2280 deletions(-) delete mode 100644 SessionManager/Session.cpp delete mode 100644 SessionManager/Session.h delete mode 100644 SessionManager/SessionHandler.cpp delete mode 100644 SessionManager/SessionHandler.h delete mode 100644 UserManager/Role.cpp delete mode 100644 UserManager/Role.h delete mode 100644 UserManager/User.cpp delete mode 100644 UserManager/User.h delete mode 100644 UserManager/UserHandler.cpp delete mode 100644 UserManager/UserHandler.h delete mode 100644 UserManager/UsersHandler.cpp delete mode 100644 UserManager/UsersHandler.h delete mode 100755 config/revision.sh delete mode 100644 durham.h diff --git a/.gitignore b/.gitignore index 2c38dfc83e..1f8f9c813b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ aclocal.m4 autom4te.cache avocado +BasicsC/local-configuration.h config/compile config/config.guess config/config.sub @@ -17,3 +18,16 @@ Makefile.in *.o .svn *~ +js-*.h +JsonParser/json-parser.c +JsonParserX/JsonParserX.cpp +JsonParserX/JsonParserX.h +JsonParserX/JsonParserX.output +JsonParserX/JsonScannerX.cpp +JsonParserX/location.hh +JsonParserX/position.hh +JsonParserX/stack.hh +V8/v8-json.cpp +BasicsC/stamp-h1 +avocadodb +libavocadodb.a diff --git a/GNUmakefile b/GNUmakefile index 6858eebb26..799768f658 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -16,12 +16,3 @@ setup: @echo AUTOCONF @autoconf -I m4 @echo auto system configured, proceed with configure - -touch: - test -f configure - touch configure - test -f aclocal.m4 - touch aclocal.m4 - test -f Makefile.in - touch Makefile.in - touch config/* diff --git a/Makefile.am b/Makefile.am index 36e01fa2cf..c4ed3de83e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,189 +1,89 @@ -################################################################################ -## Makefile.am for AvocadoDB -################################################################################ - ACLOCAL_AMFLAGS = -I m4 + AM_CFLAGS = -AM_CPPFLAGS = @BOOST_CPPFLAGS@ @LIBEV_CPPFLAGS@ @OPENSSL_CPPFLAGS@ @V8_CPPFLAGS@ -AM_LDFLAGS = @BOOST_LDFLAGS@ @LIBEV_LDFLAGS@ @OPENSSL_LDFLAGS@ @V8_LDFLAGS@ +AM_CPPFLAGS = +AM_LDFLAGS = BUILT_SOURCES = -LIBS = @BOOST_LIBS@ @LIBEV_LIBS@ @OPENSSL_LIBS@ @V8_LIBS@ -lreadline -ldl -BUILD_H = $(top_srcdir)/build.h +LIBS = + +noinst_LIBRARIES = libavocadodb.a +bin_PROGRAMS = avocadodb ################################################################################ -## avocado program +## avocado ################################################################################ -bin_PROGRAMS = avocado +include Makefile.files + +################################################################################ +## FLEX +################################################################################ + +if ENABLE_FLEX + +@srcdir@/%.c: @srcdir@/%.l + @top_srcdir@/config/flex-c.sh $(LEX) `dirname $@` `basename $^ .l` + +else + +@srcdir@/%.c: @srcdir@/%.l + @echo '+---------------------------------------------------------------+' + @echo '| WARNING: required FLEX version not found, cannot update files |' + @echo '+---------------------------------------------------------------+' + +endif + +################################################################################ +## FLEX++ +################################################################################ + +if ENABLE_FLEX + +@srcdir@/%.cpp: @srcdir@/%.ll + @top_srcdir@/config/flex-c++.sh $(LEX) `dirname $@` `basename $^ .ll` + +else + +@srcdir@/%.cpp: @srcdir@/%.ll + @echo '+---------------------------------------------------------------+' + @echo '| WARNING: required FLEX version not found, cannot update files |' + @echo '+---------------------------------------------------------------+' + +endif + +################################################################################ +## BISON +################################################################################ + +if ENABLE_BISON + +@srcdir@/%.cpp: @srcdir@/%.yy + @top_srcdir@/config/bison-c.sh $(BISON) `dirname $@` `basename $^ .yy` + +else + +@srcdir@/%.cpp: @srcdir@/%.yy + @echo '+----------------------------------------------------------------+' + @echo '| WARNING: required BISON version not found, cannot update files |' + @echo '+----------------------------------------------------------------+' + +endif + +################################################################################ +## BISON++ +################################################################################ + +if ENABLE_BISON + +@srcdir@/%.cpp: @srcdir@/%.yy + @top_srcdir@/config/bison-c++.sh $(BISON) `dirname $@` `basename $^ .yy` + +else + +@srcdir@/%.cpp: @srcdir@/%.yy + @echo '+----------------------------------------------------------------+' + @echo '| WARNING: required BISON version not found, cannot update files |' + @echo '+----------------------------------------------------------------+' + +endif -avocado_SOURCES = \ - Admin/ApplicationAdminServer.cpp \ - Admin/RestAdminBaseHandler.cpp \ - Admin/RestAdminFeConfigurationHandler.cpp \ - Admin/RestAdminLogHandler.cpp \ - Admin/RestBaseHandler.cpp \ - Admin/RestVersionHandler.cpp \ - ApplicationServer/ApplicationHttpServerImpl.cpp \ - ApplicationServer/ApplicationHttpsServerImpl.cpp \ - ApplicationServer/ApplicationServerDispatcherImpl.cpp \ - ApplicationServer/ApplicationServerImpl.cpp \ - ApplicationServer/ApplicationServerSchedulerImpl.cpp \ - BasicsC/associative.c \ - BasicsC/associative-multi.c \ - BasicsC/conversions.c \ - BasicsC/csv.c \ - BasicsC/error.c \ - BasicsC/files.c \ - BasicsC/hashes.c \ - BasicsC/init.c \ - BasicsC/json.c \ - BasicsC/locks-macos.c \ - BasicsC/locks-posix.c \ - BasicsC/logging.c \ - BasicsC/memory.c \ - Basics/ConditionLocker.cpp \ - Basics/ConditionVariable-posix.cpp \ - BasicsC/random.c \ - BasicsC/string-buffer.c \ - BasicsC/strings.c \ - BasicsC/structures.c \ - BasicsC/system-functions.c \ - BasicsC/system-windows.c \ - BasicsC/terminal-utils.c \ - BasicsC/terminal-utils-ncurses.c \ - BasicsC/threads-posix.c \ - BasicsC/vector.c \ - Basics/FileUtils.cpp \ - Basics/Initialise.cpp \ - Basics/Logger.cpp \ - Basics/LoggerData.cpp \ - Basics/LoggerInfo.cpp \ - Basics/LoggerStream.cpp \ - Basics/LoggerTiming.cpp \ - Basics/Mutex.cpp \ - Basics/MutexLocker.cpp \ - Basics/ProgramOptions.cpp \ - Basics/ProgramOptionsDescription.cpp \ - Basics/Random.cpp \ - Basics/ReadLocker.cpp \ - Basics/ReadUnlocker.cpp \ - Basics/ReadWriteLock.cpp \ - Basics/SocketUtils.cpp \ - Basics/StringUtils.cpp \ - Basics/Thread-posix.cpp \ - Basics/Timing.cpp \ - Basics/VariantArray.cpp \ - Basics/VariantBlob.cpp \ - Basics/VariantBoolean.cpp \ - Basics/VariantDate.cpp \ - Basics/VariantDatetime.cpp \ - Basics/VariantDouble.cpp \ - Basics/VariantFloat.cpp \ - Basics/VariantInt16.cpp \ - Basics/VariantInt32.cpp \ - Basics/VariantInt64.cpp \ - Basics/VariantInt8.cpp \ - Basics/VariantMatrix2.cpp \ - Basics/VariantNull.cpp \ - Basics/VariantObject.cpp \ - Basics/VariantString.cpp \ - Basics/VariantUInt16.cpp \ - Basics/VariantUInt32.cpp \ - Basics/VariantUInt64.cpp \ - Basics/VariantUInt8.cpp \ - Basics/VariantVector.cpp \ - Basics/WriteLocker.cpp \ - Basics/WriteUnlocker.cpp \ - Dispatcher/DispatcherImpl.cpp \ - Dispatcher/DispatcherQueue.cpp \ - Dispatcher/DispatcherThread.cpp \ - GeneralServer/GeneralFigures.cpp \ - GeoIndex/GeoIndex.c \ - HttpServer/HttpCommTask.cpp \ - HttpServer/HttpsAsyncCommTask.cpp \ - HttpServer/HttpsServerImpl.cpp \ - HttpServer/PathHandler.cpp \ - HttpServer/RedirectHandler.cpp \ - HttpServer/ServiceUnavailableHandler.cpp \ - JsonParser/json-parser.c \ - JsonParserX/JsonParserX.cpp \ - JsonParserX/JsonParserXDriver.cpp \ - JsonParserX/JsonScannerX.cpp \ - ProgramOptions/program-options.c \ - Rest/AddressPort.cpp \ - Rest/AnyServer.cpp \ - Rest/ApplicationHttpServer.cpp \ - Rest/ApplicationHttpsServer.cpp \ - Rest/ApplicationServer.cpp \ - Rest/ApplicationServerDispatcher.cpp \ - Rest/AsyncTask.cpp \ - Rest/ConnectionTask.cpp \ - RestHandler/RestActionHandler.cpp \ - RestHandler/RestDocumentHandler.cpp \ - RestHandler/RestSystemActionHandler.cpp \ - RestHandler/RestVocbaseBaseHandler.cpp \ - Rest/HttpHandler.cpp \ - Rest/HttpHandlerFactory.cpp \ - Rest/HttpRequest.cpp \ - Rest/HttpResponse.cpp \ - Rest/HttpsServer.cpp \ - Rest/Initialise.cpp \ - Rest/InputParser.cpp \ - Rest/Job.cpp \ - Rest/LibraryLoader.cpp \ - Rest/ListenTask.cpp \ - Rest/OutputGenerator.cpp \ - Rest/PeriodicTask.cpp \ - Rest/RestHandlerFactory.cpp \ - Rest/RestModel.cpp \ - Rest/RestServer.cpp \ - Rest/Scheduler.cpp \ - RestServer/ActionDispatcherThread.cpp \ - RestServer/avocado.cpp \ - RestServer/AvocadoHttpServer.cpp \ - RestServer/AvocadoServer.cpp \ - RestServer/JSLoader.cpp \ - RestServer/SystemActionDispatcherThread.cpp \ - Rest/SignalTask.cpp \ - Rest/SocketTask.cpp \ - Rest/SslInterface.cpp \ - Rest/Task.cpp \ - Rest/TimerTask.cpp \ - Rest/Url.cpp \ - ResultGenerator/HtmlResultGenerator.cpp \ - ResultGenerator/JsonResultGenerator.cpp \ - ResultGenerator/JsonXResultGenerator.cpp \ - ResultGenerator/PhpResultGenerator.cpp \ - ResultGenerator/ResultGenerator.cpp \ - ResultGenerator/XmlResultGenerator.cpp \ - Scheduler/SchedulerImpl.cpp \ - Scheduler/SchedulerLibev.cpp \ - Scheduler/SchedulerThread.cpp \ - SessionManager/Session.cpp \ - SessionManager/SessionHandler.cpp \ - ShapedJson/json-shaper.c \ - ShapedJson/shape-accessor.c \ - ShapedJson/shaped-json.c \ - UserManager/Role.cpp \ - UserManager/User.cpp \ - UserManager/UserHandler.cpp \ - UserManager/UsersHandler.cpp \ - V8/v8-actions.cpp \ - V8/v8-json.cpp \ - V8/v8-shell.cpp \ - V8/v8-utils.cpp \ - V8/v8-vocbase.cpp \ - VocBase/blob-collection.c \ - VocBase/collection.c \ - VocBase/compactor.c \ - VocBase/datafile.c \ - VocBase/document-collection.c \ - VocBase/headers.c \ - VocBase/index.c \ - VocBase/query.c \ - VocBase/result-set.c \ - VocBase/simple-collection.c \ - VocBase/synchroniser.c \ - VocBase/vocbase.c \ - VocBase/voc-shaper.c \ - # end of file list diff --git a/SessionManager/Session.cpp b/SessionManager/Session.cpp deleted file mode 100644 index 43ffe68c41..0000000000 --- a/SessionManager/Session.cpp +++ /dev/null @@ -1,202 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief session management -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 2011, triagens GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#include "Session.h" - -#include -#include -#include - -#include "UserManager/User.h" - -using namespace std; -using namespace triagens::basics; -using namespace triagens::admin; - -// ----------------------------------------------------------------------------- -// session registry -// ----------------------------------------------------------------------------- - -namespace { - map SessionRegistry; - list Sessions; -} - -namespace triagens { - namespace admin { - - // ----------------------------------------------------------------------------- - // constants - // ----------------------------------------------------------------------------- - - string const Session::SID_CHARACTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; - Mutex Session::lock; - set Session::_rights; - - // ----------------------------------------------------------------------------- - // static public methods - // ----------------------------------------------------------------------------- - - Session* Session::lookup (string const& sid) { - map::const_iterator i = SessionRegistry.find(sid); - - if (i == SessionRegistry.end()) { - return 0; - } - else { - Session* session = i->second; - - list::iterator j = find(Sessions.begin(), Sessions.end(), session); - - if (j != Sessions.end()) { - Sessions.erase(j); - } - - Sessions.push_back(session); - - return session; - } - } - - - - Session* Session::create () { - if (Sessions.size() > MAXIMAL_OPEN_SESSION) { - Session* session = Sessions.front(); - - LOGGER_DEBUG << "too many admin sessions, throwing away '" << session->getSid() << "'"; - Sessions.pop_front(); - - remove(session); - } - - Random::UniformCharacter generator(SID_LENGTH, SID_CHARACTERS); - - string sid = generator.random(); - - while (SessionRegistry.find(sid) != SessionRegistry.end()) { - sid = generator.random(); - } - - Session* session = new Session(sid); - - SessionRegistry[sid] = session; - Sessions.push_back(session); - - LOGGER_DEBUG << "created admin session '" << session->getSid() << "'"; - - return session; - } - - - - bool Session::remove (Session* session) { - LOGGER_DEBUG << "removing admin session '" << session->getSid() << "'"; - - SessionRegistry.erase(session->getSid()); - - list::iterator j = find(Sessions.begin(), Sessions.end(), session); - - if (j != Sessions.end()) { - Sessions.erase(j); - } - - delete session; - - return true; - } - - // ----------------------------------------------------------------------------- - // constructors and destructors - // ----------------------------------------------------------------------------- - - - Session::Session (string const& sid) - : _sid(sid), _user(0) { - } - - - // ----------------------------------------------------------------------------- - // public methods - // ----------------------------------------------------------------------------- - - - bool Session::login (string const& username, string const& password, string& reason) { - User* user = User::lookup(username); - - if (user == 0) { - reason = "unknown user '" + username + "'"; - return false; - } - - bool ok = user->checkPassword(password); - - if (! ok) { - reason = "wrong password for user '" + username + "'"; - return false; - } - - _user = user; - - return true; - } - - - - bool Session::logout () { - if (_user != 0) { - _user = 0; - } - - return true; - } - - - - bool Session::hasRight (right_t right) { - if (_user == 0) { - return _rights.find(right) != _rights.end(); - } - else { - return _user->hasRight(right); - } - } - - - - - void Session::setAnonymousRights (vector const& rights) { - _rights.insert(rights.begin(), rights.end()); - } - - - - set const& Session::anonymousRights () { - return _rights; - } - } -} diff --git a/SessionManager/Session.h b/SessionManager/Session.h deleted file mode 100644 index 0947aec9b0..0000000000 --- a/SessionManager/Session.h +++ /dev/null @@ -1,169 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief session management -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 2011, triagens GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#ifndef TRIAGENS_BORNHOLM_SESSION_MANAGER_SESSION_H -#define TRIAGENS_BORNHOLM_SESSION_MANAGER_SESSION_H 1 - -#include - -#include -#include - -namespace triagens { - namespace admin { - class User; - - //////////////////////////////////////////////////////////////////////////////// - /// @brief session management - //////////////////////////////////////////////////////////////////////////////// - - class Session { - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief maximal number of open sessions - //////////////////////////////////////////////////////////////////////////////// - - static size_t const MAXIMAL_OPEN_SESSION = 10; - - //////////////////////////////////////////////////////////////////////////////// - /// @brief length of session identifier - //////////////////////////////////////////////////////////////////////////////// - - static size_t const SID_LENGTH = 10; - - //////////////////////////////////////////////////////////////////////////////// - /// @brief length of session characters - //////////////////////////////////////////////////////////////////////////////// - - static string const SID_CHARACTERS; - - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief access lock - //////////////////////////////////////////////////////////////////////////////// - - static basics::Mutex lock; - - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns a role by name - //////////////////////////////////////////////////////////////////////////////// - - static Session* lookup (string const& sid); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief creates a session - //////////////////////////////////////////////////////////////////////////////// - - static Session* create (); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief removes a session - /// - /// Remove will also delete the session object. - //////////////////////////////////////////////////////////////////////////////// - - static bool remove (Session*); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief sets a anonymous rights - //////////////////////////////////////////////////////////////////////////////// - - static void setAnonymousRights (vector const&); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief gets anonymous rights - //////////////////////////////////////////////////////////////////////////////// - - static set const& anonymousRights (); - - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns the session identifier - //////////////////////////////////////////////////////////////////////////////// - - string const& getSid () const { - return _sid; - } - - - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns the user of a session - //////////////////////////////////////////////////////////////////////////////// - - User* getUser () const { - return _user; - } - - - public: - - - //////////////////////////////////////////////////////////////////////////////// - /// @brief logs a user in - //////////////////////////////////////////////////////////////////////////////// - - bool login (string const& username, string const& password, string& reason); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief logs a user out - //////////////////////////////////////////////////////////////////////////////// - - bool logout (); - - - //////////////////////////////////////////////////////////////////////////////// - /// @brief checks for a right - //////////////////////////////////////////////////////////////////////////////// - - bool hasRight (right_t); - - protected: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief creates a new sessions - //////////////////////////////////////////////////////////////////////////////// - - Session (string const& sid); - - private: - static set _rights; - - private: - string const _sid; - - User* _user; - - }; - } -} - -#endif diff --git a/SessionManager/SessionHandler.cpp b/SessionManager/SessionHandler.cpp deleted file mode 100644 index 0f0bd757ec..0000000000 --- a/SessionManager/SessionHandler.cpp +++ /dev/null @@ -1,292 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief session handler -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 -/// @auther Martin Schoenert -/// @author Copyright 2011, triagens GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#include "SessionHandler.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "SessionManager/Session.h" - -#include "UserManager/Role.h" -#include "UserManager/User.h" - -using namespace triagens::basics; -using namespace triagens::rest; - -namespace triagens { - namespace admin { - - // ----------------------------------------------------------------------------- - // constructors and destructors - // ----------------------------------------------------------------------------- - - SessionHandler::SessionHandler (HttpRequest* request, ApplicationAdminServer* server) - : RestBaseHandler(request), _server(server) { - } - - // ----------------------------------------------------------------------------- - // HttpHandler methods - // ----------------------------------------------------------------------------- - - HttpHandler::status_e SessionHandler::execute () { - - // execute the request - switch (request->requestType()) { - case HttpRequest::HTTP_REQUEST_POST: return executePost(); - case HttpRequest::HTTP_REQUEST_GET: return executeGet(); - case HttpRequest::HTTP_REQUEST_PUT: return executePut(); - case HttpRequest::HTTP_REQUEST_DELETE: return executeDelete(); - - default: - generateError(HttpResponse::METHOD_NOT_ALLOWED, "method not supported"); - return HANDLER_DONE; - } - } - - // ----------------------------------------------------------------------------- - // private methods - // ----------------------------------------------------------------------------- - - HttpHandler::status_e SessionHandler::executePost () { - if (request->suffix().size() != 0) { - generateError(HttpResponse::BAD, "expecting POST /session"); - return HANDLER_DONE; - } - - // create a new session - MUTEX_LOCKER(Session::lock); - - Session* session = Session::create(); - - generateSession(session); - return HANDLER_DONE; - } - - - - HttpHandler::status_e SessionHandler::executeGet () { - vector const& suffix = request->suffix(); - - if (suffix.size() != 1) { - generateError(HttpResponse::BAD, "expecting GET /session/"); - return HANDLER_DONE; - } - - string const& sid = suffix[0]; - - // lookup an existing session - MUTEX_LOCKER(Session::lock); - - Session* session = Session::lookup(sid); - - if (session != 0) { - generateSession(session); - } - else { - generateError(HttpResponse::NOT_FOUND, "unknown session"); - } - - return HANDLER_DONE; - } - - - - HttpHandler::status_e SessionHandler::executePut () { - vector const& suffix = request->suffix(); - - if (suffix.size() != 2) { - generateError(HttpResponse::BAD, "expecting PUT /session//"); - return HANDLER_DONE; - } - - string const& sid = suffix[0]; - string const& method = suffix[1]; - - // lookup an existing session - MUTEX_LOCKER(Session::lock); - - Session* session = Session::lookup(sid); - - if (session != 0) { - if (method == "login") { - return executeLogin(session); - } - else if (method == "logout") { - return executeLogout(session); - } - else if (method == "password") { - return executePassword(session); - } - - generateError(HttpResponse::BAD, "unknown method '" + method + "'"); - return HANDLER_DONE; - } - else { - generateError(HttpResponse::NOT_FOUND, "unknown session"); - } - - return HANDLER_DONE; - } - - - - HttpHandler::status_e SessionHandler::executeDelete () { - vector const& suffix = request->suffix(); - - if (suffix.size() != 1) { - generateError(HttpResponse::BAD, "expecting DELETE /session/"); - return HANDLER_DONE; - } - - string const& sid = suffix[0]; - - // lookup an existing session - MUTEX_LOCKER(Session::lock); - - Session* session = Session::lookup(sid); - bool removed = false; - - if (session != 0) { - removed = Session::remove(session); - } - - VariantArray* result = new VariantArray(); - result->add("removed", new VariantBoolean(removed)); - - generateResult(result); - return HANDLER_DONE; - } - - - - - HttpHandler::status_e SessionHandler::executeLogin (Session* session) { - struct Description : public InputParser::ObjectDescription { - Description () { - attribute("user", user); - attribute("password", password); - } - - string user; - string password; - } desc; - - bool ok = parseBody(desc); - - if (! ok) { - return HANDLER_DONE; - } - - string reason; - ok = session->login(desc.user, desc.password, reason); - - if (! ok) { - generateError(HttpResponse::UNAUTHORIZED, reason); - return HANDLER_DONE; - } - - generateSession(session); - return HANDLER_DONE; - } - - - - HttpHandler::status_e SessionHandler::executeLogout (Session* session) { - session->logout(); - - generateSession(session); - return HANDLER_DONE; - } - - - - HttpHandler::status_e SessionHandler::executePassword (Session* session) { - User* user = session->getUser(); - - if (user == 0) { - generateError(HttpResponse::BAD, "session has not bound to user"); - return HANDLER_DONE; - } - - struct Description : public InputParser::ObjectDescription { - Description () { - attribute("password", password); - } - - string password; - } desc; - - bool ok = parseBody(desc); - - if (! ok) { - return HANDLER_DONE; - } - - bool changed = user->changePassword(desc.password); - - VariantArray* result = new VariantArray(); - result->add("changed", new VariantBoolean(changed)); - - generateResult(result); - return HANDLER_DONE; - } - - - - void SessionHandler::generateSession (Session* session) { - VariantArray* result = new VariantArray(); - result->add("sid", session->getSid()); - - User* user = session->getUser(); - - if (user != 0) { - result->add("user", user->getName()); - } - - VariantVector* r = new VariantVector(); - - set const& rights = (user == 0) ? Session::anonymousRights() : user->getRole()->getRights(); - - for (set::const_iterator i = rights.begin(); i != rights.end(); ++i) { - r->add(new VariantInt32(*i)); - } - - result->add("rights", r); - - generateResult(result); - } - - } -} diff --git a/SessionManager/SessionHandler.h b/SessionManager/SessionHandler.h deleted file mode 100644 index a79ca18334..0000000000 --- a/SessionManager/SessionHandler.h +++ /dev/null @@ -1,98 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief session handler -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 -/// @auther Martin Schoenert -/// @author Copyright 2010-2011, triAGENS GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#ifndef TRIAGENS_BORNHOLM_SESSION_MANAGER_SESSION_HANDLER_H -#define TRIAGENS_BORNHOLM_SESSION_MANAGER_SESSION_HANDLER_H 1 - -#include - -namespace triagens { - namespace admin { - class ApplicationAdminServer; - class Session; - - //////////////////////////////////////////////////////////////////////////////// - /// @brief session handler - //////////////////////////////////////////////////////////////////////////////// - - class SessionHandler : public RestBaseHandler { - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief static constructor - //////////////////////////////////////////////////////////////////////////////// - - static rest::HttpHandler* create (rest::HttpRequest* request, void* data) { - return new SessionHandler(request, (ApplicationAdminServer*) data); - } - - public: - - - //////////////////////////////////////////////////////////////////////////////// - /// {@inheritDoc} - //////////////////////////////////////////////////////////////////////////////// - - bool isDirect () { - return true; - } - - - //////////////////////////////////////////////////////////////////////////////// - /// {@inheritDoc} - //////////////////////////////////////////////////////////////////////////////// - - status_e execute (); - - protected: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief constructor - //////////////////////////////////////////////////////////////////////////////// - - SessionHandler (rest::HttpRequest* request, ApplicationAdminServer*); - - private: - status_e executePost (); - status_e executeGet (); - status_e executePut (); - status_e executeDelete (); - - status_e executeLogin (Session*); - status_e executeLogout (Session*); - status_e executePassword (Session*); - - void generateSession (Session*); - - private: - ApplicationAdminServer* _server; - }; - } -} - -#endif diff --git a/UnitTests/georeg.c b/UnitTests/georeg.c index 0fdcbc7136..91a7234b07 100644 --- a/UnitTests/georeg.c +++ b/UnitTests/georeg.c @@ -5,19 +5,29 @@ /// /// DISCLAIMER /// -/// Copyright 2010-2011 triagens GmbH, Cologne, Germany +/// Copyright by triAGENS GmbH - All rights reserved. /// -/// 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 +/// The Programs (which include both the software and documentation) +/// contain proprietary information of triAGENS GmbH; they are +/// provided under a license agreement containing restrictions on use and +/// disclosure and are also protected by copyright, patent and other +/// intellectual and industrial property laws. Reverse engineering, +/// disassembly or decompilation of the Programs, except to the extent +/// required to obtain interoperability with other independently created +/// software or as specified by law, is prohibited. /// -/// http://www.apache.org/licenses/LICENSE-2.0 +/// The Programs are not intended for use in any nuclear, aviation, mass +/// transit, medical, or other inherently dangerous applications. It shall +/// be the licensee's responsibility to take all appropriate fail-safe, +/// backup, redundancy, and other measures to ensure the safe use of such +/// applications if the Programs are used for such purposes, and triAGENS +/// GmbH disclaims liability for any damages caused by such use of +/// the Programs. /// -/// 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. +/// This software is the confidential and proprietary information of +/// triAGENS GmbH. You shall not disclose such confidential and +/// proprietary information and shall use it only in accordance with the +/// terms of the license agreement you entered into with triAGENS GmbH. /// /// Copyright holder is triAGENS GmbH, Cologne, Germany /// @@ -146,7 +156,7 @@ void coonum(GeoCoordinate * gc, int num) gc->data=&ix[num%997]; for(i=1;i<30;i++) { - lat=0.0; + lat=0.0; lon=0.0; if( (j&1)==1 ) { @@ -177,9 +187,9 @@ void coonum(GeoCoordinate * gc, int num) if(i==25) { lat=0.01822353; lon=0.01533208; } if(i==26) { lat=0.00934434; lon=0.00800233; } if(i==27) { lat=0.00634434; lon=0.00799320; } - if(i==28) { lat=0.00700493; lon=0.00800769; } - if(i==29) { lat=0.00480493; lon=0.00170769; } - } + if(i==28) { lat=0.00700493; lon=0.00800769; } + if(i==29) { lat=0.00480493; lon=0.00170769; } + } gc->latitude+=lat; gc->longitude+=lon; j>>=1; @@ -256,7 +266,7 @@ int main(int argc, char ** argv) gcp.data = ix + 64; r = GeoIndex_insert(gi,&gcp); list1 = GeoIndex_NearestCountPoints(gi,&gcp,1); - gccheck(13,list1, 1,"AAAAAAAAAAAAAAAABAAAAAAAA"); + gccheck(13,list1, 1,"AAAAAAAAAAAAAAAABAAAAAAAA"); gicheck(14,gi); GeoIndex_free(gi); @@ -270,26 +280,26 @@ int main(int argc, char ** argv) /* do both searches with an empty index */ list1 = GeoIndex_NearestCountPoints(gi,&gcp1,3); - gccheck(20,list1, 0,"AAAAAAAAAAAAAAAAAAAAAAAAA"); + gccheck(20,list1, 0,"AAAAAAAAAAAAAAAAAAAAAAAAA"); list1 = GeoIndex_PointsWithinRadius(gi,&gcp1,100000.0); - gccheck(21,list1,0,"AAAAAAAAAAAAAAAAAAAAAAAAA"); + gccheck(21,list1,0,"AAAAAAAAAAAAAAAAAAAAAAAAA"); /* stick in Jo'burg */ gcp4.data=ix + 4; r = GeoIndex_insert(gi,&gcp4); icheck(22,0,r); list1 = GeoIndex_NearestCountPoints(gi,&gcp1,3); - gccheck(23,list1, 1,"ABAAAAAAAAAAAAAAAAAAAAAAA"); + gccheck(23,list1, 1,"ABAAAAAAAAAAAAAAAAAAAAAAA"); list1 = GeoIndex_PointsWithinRadius(gi,&gcp1,10000000.0); - gccheck(24,list1,1,"ABAAAAAAAAAAAAAAAAAAAAAAA"); + gccheck(24,list1,1,"ABAAAAAAAAAAAAAAAAAAAAAAA"); /* then take it out again and repeat tests with empty index */ r = GeoIndex_remove(gi,&gcp4); icheck(25,0,r); list1 = GeoIndex_NearestCountPoints(gi,&gcp1,3); - gccheck(26,list1, 0,"AAAAAAAAAAAAAAAAAAAAAAAAA"); + gccheck(26,list1, 0,"AAAAAAAAAAAAAAAAAAAAAAAAA"); list1 = GeoIndex_PointsWithinRadius(gi,&gcp1,100000.0); - gccheck(27,list1,0,"AAAAAAAAAAAAAAAAAAAAAAAAA"); + gccheck(27,list1,0,"AAAAAAAAAAAAAAAAAAAAAAAAA"); /* try to delete from an empty index */ @@ -380,7 +390,7 @@ int main(int argc, char ** argv) icheck(65,-3,i); gicheck(66,gi); - + GeoIndex_free(gi); /* */ @@ -498,7 +508,7 @@ int main(int argc, char ** argv) pcheck(94,&ix[4],(char *)list1->coordinates[0].data); list1 = GeoIndex_NearestCountPoints(gi,&gcp,10); - gccheck(95,list1, 8,"OPBAAAAAAAAAAAAAAAAAAAAAA"); + gccheck(95,list1, 8,"OPBAAAAAAAAAAAAAAAAAAAAAA"); gcp.latitude = 0.0; gcp.longitude = 20.0; @@ -507,7 +517,7 @@ int main(int argc, char ** argv) icheck(96,0,i); list1 = GeoIndex_NearestCountPoints(gi,&gcp,10); - gccheck(97,list1, 7,"KPBAAAAAAAAAAAAAAAAAAAAAA"); + gccheck(97,list1, 7,"KPBAAAAAAAAAAAAAAAAAAAAAA"); gicheck(98,gi); GeoIndex_free(gi); @@ -540,39 +550,39 @@ int main(int argc, char ** argv) gcp.latitude = -83.2; gcp.longitude = 19.2; list1 = GeoIndex_NearestCountPoints(gi,&gcp,7); - gccheck(110,list1, 7,"AAAAAAAAAAAAAAAPHAAAAAAAA"); + gccheck(110,list1, 7,"AAAAAAAAAAAAAAAPHAAAAAAAA"); gcp.latitude = -83.2; gcp.longitude = 19.2; list1 = GeoIndex_NearestCountPoints(gi,&gcp,110); - gccheck(112,list1,100,"PPPPPPPPPPPPPPPPPPPPPPPPP"); + gccheck(112,list1,100,"PPPPPPPPPPPPPPPPPPPPPPPPP"); gcp.latitude = -88.2; gcp.longitude = 13.2; list1 = GeoIndex_NearestCountPoints(gi,&gcp,10); - gccheck(114,list1, 10,"AAMPPAAAAAAAAAAAAAAAAAAAA"); + gccheck(114,list1, 10,"AAMPPAAAAAAAAAAAAAAAAAAAA"); gcp.latitude = -83.2; gcp.longitude = -163.2; list1 = GeoIndex_NearestCountPoints(gi,&gcp,2); - gccheck(116,list1, 2,"AADAAAAAAAAAAAAAAAAAAAAAA"); + gccheck(116,list1, 2,"AADAAAAAAAAAAAAAAAAAAAAAA"); gcp.latitude = -87.2; gcp.longitude = 13.2; list1 = GeoIndex_NearestCountPoints(gi,&gcp,1); - gccheck(118,list1, 1,"AAAAABAAAAAAAAAAAAAAAAAAA"); + gccheck(118,list1, 1,"AAAAABAAAAAAAAAAAAAAAAAAA"); gcp.latitude = -83.2; gcp.longitude = 19.2; list1 = GeoIndex_NearestCountPoints(gi,&gcp,7); - gccheck(120,list1, 7,"AAAAAAAAAAAAAAAPHAAAAAAAA"); + gccheck(120,list1, 7,"AAAAAAAAAAAAAAAPHAAAAAAAA"); gcp.latitude = -83.7; gcp.longitude = 19.7; list1 = GeoIndex_NearestCountPoints(gi,&gcp,7); - gccheck(122,list1, 7,"AAAAAAAAAAAAMPBAAAAAAAAAA"); + gccheck(122,list1, 7,"AAAAAAAAAAAAMPBAAAAAAAAAA"); gcp.latitude = -83.2; gcp.longitude = 19.2; list1 = GeoIndex_NearestCountPoints(gi,&gcp,50); - gccheck(124,list1, 50,"AAAAAAAAAAPPPPPPPPPPPPDAA"); + gccheck(124,list1, 50,"AAAAAAAAAAPPPPPPPPPPPPDAA"); gcp.latitude = -83.2; gcp.longitude = 19.2; list1 = GeoIndex_NearestCountPoints(gi,&gcp,11); - gccheck(126,list1, 11,"AAAAAAAAAAAAADAPPBAAAAAAA"); + gccheck(126,list1, 11,"AAAAAAAAAAAAADAPPBAAAAAAA"); gcp.latitude = -83.2; gcp.longitude = 19.2; list1 = GeoIndex_NearestCountPoints(gi,&gcp,4); @@ -580,9 +590,9 @@ int main(int argc, char ** argv) gcp.latitude = -83.2; gcp.longitude = 19.2; list1 = GeoIndex_PointsWithinRadius(gi,&gcp,100000.0); - gccheck(150,list1,16,"AAAAAAAAAAAAMPAPPDAAAAAAA"); + gccheck(150,list1,16,"AAAAAAAAAAAAMPAPPDAAAAAAA"); gicheck(151,gi); - + GeoIndex_free(gi); /* */ @@ -1107,7 +1117,7 @@ int main(int argc, char ** argv) /* forgot to allow for distance greater than pi.radius */ /* this went into sin(theta) to give small value, so it */ /* found that many points were not within 30000 Km */ - + gi=GeoIndex_new(); la=41.23456789; lo=39.87654321; diff --git a/UserManager/Role.cpp b/UserManager/Role.cpp deleted file mode 100644 index a6c40c4d97..0000000000 --- a/UserManager/Role.cpp +++ /dev/null @@ -1,121 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief role of a user -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 2011, triagens GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#include "Role.h" - -#include -#include -#include - -using namespace std; -using namespace triagens::basics; -using namespace triagens::admin; - -// ----------------------------------------------------------------------------- -// role regestry -// ----------------------------------------------------------------------------- - -namespace { - Mutex RoleLock; - map RoleRegistry; -} - -namespace triagens { - namespace admin { - - // ----------------------------------------------------------------------------- - // static public methods - // ----------------------------------------------------------------------------- - - Role* Role::create (string const& name, right_t manage) { - MUTEX_LOCKER(RoleLock); - - map::const_iterator i = RoleRegistry.find(name); - - if (i != RoleRegistry.end()) { - LOGGER_DEBUG << "user '" << name << "' already exists"; - return 0; - } - - Role* user = new Role(name, manage); - - RoleRegistry[name] = user; - - return user; - } - - - - Role* Role::lookup (string const& name) { - MUTEX_LOCKER(RoleLock); - - map::const_iterator i = RoleRegistry.find(name); - - if (i == RoleRegistry.end()) { - return 0; - } - else { - return i->second; - } - } - - // ----------------------------------------------------------------------------- - // constructors and destructors - // ----------------------------------------------------------------------------- - - Role::Role (string const& name, right_t manage) - : _name(name), _rightToManage(manage) { - } - - // ----------------------------------------------------------------------------- - // public methods - // ----------------------------------------------------------------------------- - - void Role::addRight (right_t right) { - _rights.insert(right); - } - - - - void Role::setRights (vector const& rights) { - _rights.clear(); - _rights.insert(rights.begin(), rights.end()); - } - - - - void Role::removeRight (right_t right) { - _rights.erase(right); - } - - - - void Role::clearRights () { - _rights.clear(); - } - } -} diff --git a/UserManager/Role.h b/UserManager/Role.h deleted file mode 100644 index c158ca5f7f..0000000000 --- a/UserManager/Role.h +++ /dev/null @@ -1,124 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief role of a user -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 2011, triagens GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#ifndef TRIAGENS_BORNHOLM_USER_MANAGER_ROLE_H -#define TRIAGENS_BORNHOLM_USER_MANAGER_ROLE_H 1 - -#include - -#include -#include - -namespace triagens { - namespace admin { - - //////////////////////////////////////////////////////////////////////////////// - /// @brief role of a user - //////////////////////////////////////////////////////////////////////////////// - - class Role : noncopyable { - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief creates a new role - //////////////////////////////////////////////////////////////////////////////// - - static Role* create (string const& name, right_t manage); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns a role by name - //////////////////////////////////////////////////////////////////////////////// - - static Role* lookup (string const& name); - - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief constructor - //////////////////////////////////////////////////////////////////////////////// - - Role (string const& name, right_t manage); - - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns the name of a role - //////////////////////////////////////////////////////////////////////////////// - - string const& getName () const { - return _name; - } - - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns the rights of a role - //////////////////////////////////////////////////////////////////////////////// - - set const& getRights () const { - return _rights; - } - - //////////////////////////////////////////////////////////////////////////////// - /// @brief adds a right to a role - //////////////////////////////////////////////////////////////////////////////// - - void addRight (right_t); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief sets the rights of a role - //////////////////////////////////////////////////////////////////////////////// - - void setRights (vector const&); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief removes a right from a role - //////////////////////////////////////////////////////////////////////////////// - - void removeRight (right_t); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief clears all rights of a role - //////////////////////////////////////////////////////////////////////////////// - - void clearRights (); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns right required to manage this role - //////////////////////////////////////////////////////////////////////////////// - - right_t rightToManage () { - return _rightToManage; - } - - private: - string const _name; - set _rights; - right_t _rightToManage; - }; - } -} - -#endif diff --git a/UserManager/User.cpp b/UserManager/User.cpp deleted file mode 100644 index 66724d60f2..0000000000 --- a/UserManager/User.cpp +++ /dev/null @@ -1,309 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief a user -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 2011, triagens GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#include "User.h" - -#include - -#include -#include -#include -#include -#include - -#include "UserManager/Role.h" - -using namespace std; -using namespace triagens::basics; -using namespace triagens::admin; - -// ----------------------------------------------------------------------------- -// user registry -// ----------------------------------------------------------------------------- - -namespace { - Mutex UserLock; - map UserRegistry; - string userDatabase; -} - -namespace triagens { - namespace admin { - - // ----------------------------------------------------------------------------- - // static public methods - // ----------------------------------------------------------------------------- - - User* User::create (string const& name, Role* role) { - MUTEX_LOCKER(UserLock); - - map::const_iterator i = UserRegistry.find(name); - - if (i != UserRegistry.end()) { - LOGGER_DEBUG << "user '" << name << "' already exists"; - return 0; - } - - User* user = new User(name, role); - - UserRegistry[name] = user; - saveUser(); - - return user; - } - - - - User* User::lookup (string const& name) { - MUTEX_LOCKER(UserLock); - - map::const_iterator i = UserRegistry.find(name); - - if (i == UserRegistry.end()) { - return 0; - } - else { - return i->second; - } - } - - - - bool User::remove (User* user) { - MUTEX_LOCKER(UserLock); - - map::iterator i = UserRegistry.find(user->_name); - - if (i == UserRegistry.end()) { - LOGGER_DEBUG << "user '" << user->_name << "' is unknown"; - return false; - } - - if (i->second != user) { - LOGGER_WARNING << "user '" << user->_name << "' does not matched stored profile"; - return false; - } - - if (! user->hasRight(RIGHT_TO_BE_DELETED)) { - LOGGER_WARNING << "user '" << user->_name << "' cannot be deleted"; - return false; - } - - UserRegistry.erase(i); - saveUser(); - - // This is a simple user manager, we are not deleting any old users. - // Otherwise we would need to create locks outside the "lookup" function - // to avoid deleting the current user, or we would need to use smart - // pointer or objects. - - // delete user; - - return true; - } - - - - vector User::users () { - MUTEX_LOCKER(UserLock); - - vector result; - - for (map::const_iterator i = UserRegistry.begin(); i != UserRegistry.end(); ++i) { - result.push_back(i->second); - } - - return result; - } - - - - bool User::loadUser (string const& path) { - userDatabase = path; - bool found = true; - - if (userDatabase.empty()) { - return false; - } - - if (! FileUtils::exists(userDatabase)) { - ofstream* of = FileUtils::createOutput(userDatabase); - - if (of == 0) { - LOGGER_FATAL << "cannot create user database '" << userDatabase << "'"; - exit(EXIT_FAILURE); - } - - *of << "# EMPTY USER DATABASE\n"; - - if (of->fail()) { - LOGGER_FATAL << "cannot create user database '" << userDatabase << "'"; - exit(EXIT_FAILURE); - } - - delete of; - found = false; - } - - ifstream* is = FileUtils::createInput(userDatabase); - - if (is == 0) { - LOGGER_FATAL << "cannot read user database '" << userDatabase << "'"; - return false; - } - - while (true) { - string line; - getline(*is, line); - - if (is->eof()) { - break; - } - - if (is->fail()) { - LOGGER_FATAL << "cannot read user database '" << userDatabase << "'"; - return false; - } - - if (line.empty() || line[0] == '#') { - continue; - } - - vector split = StringUtils::split(line, ';'); - - if (split.size() != 3) { - LOGGER_FATAL << "corrupted user data '" << userDatabase << "'"; - return false; - } - - string const& name = split[2]; - Role* role = Role::lookup(name); - - if (role == 0) { - LOGGER_ERROR << "unknown role '" << name << "' in user database"; - continue; - } - - User* user = new User(split[0], role); - user->changePassword(split[1]); - - UserRegistry[name] = user; - } - - return found; - } - - - - void User::saveUser () { - if (userDatabase.empty()) { - LOGGER_DEBUG << "no user database defined, cannot save data"; - return; - } - - string tmp = userDatabase + ".tmp"; - - if (FileUtils::exists(tmp)) { - if (! FileUtils::remove(tmp)) { - LOGGER_FATAL << "cannot remove the temporary user database '" << tmp << "'"; - return; - } - } - - ofstream* of = FileUtils::createOutput(tmp); - - if (of == 0) { - LOGGER_FATAL << "cannot create the temporary user data '" << tmp << "'"; - return; - } - - for (map::const_iterator i = UserRegistry.begin(); i != UserRegistry.end(); ++i) { - User* user = i->second; - - *of << StringUtils::escape(user->_name, ";") << ";" - << StringUtils::escape(user->_password, ";") << ";" - << StringUtils::escape(user->_role->getName(), ";") - << "\n"; - - if (of->fail()) { - LOGGER_FATAL << "cannot write the temporary user data '" << tmp << "'"; - delete of; - FileUtils::remove(tmp); - return; - } - } - - delete of; - - FileUtils::remove(userDatabase); - - if (! FileUtils::rename(tmp, userDatabase)) { - LOGGER_FATAL << "could not rename the temporary user database '" << tmp << "'"; - return; - } - - LOGGER_DEBUG << "wrote user database '" << userDatabase << "'"; - } - - // ----------------------------------------------------------------------------- - // constructors and destructors - // ----------------------------------------------------------------------------- - - User::User (string const& name, Role* role) - : _name(name), _password(""), _role(role) { - } - - // ----------------------------------------------------------------------------- - // public methods - // ----------------------------------------------------------------------------- - - bool User::changePassword (string const& password) { - _password = password; - saveUser(); - return true; - } - - - - bool User::checkPassword (string const& password) { - return _password == password; - } - - - - bool User::hasRight (right_t right) { - if (_role == 0) { - return false; - } - else { - set const& rights = _role->getRights(); - - return rights.find(right) != rights.end(); - } - } - } -} diff --git a/UserManager/User.h b/UserManager/User.h deleted file mode 100644 index 032aca6a64..0000000000 --- a/UserManager/User.h +++ /dev/null @@ -1,138 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief a user -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 2011, triagens GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#ifndef TRIAGENS_BORNHOLM_USER_MANAGER_USER_H -#define TRIAGENS_BORNHOLM_USER_MANAGER_USER_H 1 - -#include - -#include - -namespace triagens { - namespace admin { - class Role; - - //////////////////////////////////////////////////////////////////////////////// - /// @brief a user - //////////////////////////////////////////////////////////////////////////////// - - class User : noncopyable { - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief adds a new user - //////////////////////////////////////////////////////////////////////////////// - - static User* create (string const& name, Role*); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns a role by name - //////////////////////////////////////////////////////////////////////////////// - - static User* lookup (string const& name); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief removes a user - /// - /// Remove will also delete the user object. - //////////////////////////////////////////////////////////////////////////////// - - static bool remove (User*); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns a role by name - //////////////////////////////////////////////////////////////////////////////// - - static vector users (); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief loads the user database - //////////////////////////////////////////////////////////////////////////////// - - static bool loadUser (string const& file); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief saves the user database - //////////////////////////////////////////////////////////////////////////////// - - static void saveUser (); - - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns the name of a user - //////////////////////////////////////////////////////////////////////////////// - - string const& getName () const { - return _name; - } - - //////////////////////////////////////////////////////////////////////////////// - /// @brief returns the role of a user - //////////////////////////////////////////////////////////////////////////////// - - Role* getRole () const { - return _role; - } - - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief changes the password of a user - //////////////////////////////////////////////////////////////////////////////// - - bool changePassword (string const& password); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief checks the password of a user - //////////////////////////////////////////////////////////////////////////////// - - bool checkPassword (string const& password); - - //////////////////////////////////////////////////////////////////////////////// - /// @brief has right - //////////////////////////////////////////////////////////////////////////////// - - bool hasRight (right_t); - - protected: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief creates a new user - //////////////////////////////////////////////////////////////////////////////// - - User (string const& name, Role*); - - private: - string const _name; - string _password; - Role* _role; - }; - } -} - -#endif diff --git a/UserManager/UserHandler.cpp b/UserManager/UserHandler.cpp deleted file mode 100644 index 5f00169eff..0000000000 --- a/UserManager/UserHandler.cpp +++ /dev/null @@ -1,236 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief user handler -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 2011, triagens GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#include "UserHandler.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "UserManager/User.h" -#include "UserManager/Role.h" -#include "SessionManager/Session.h" - -using namespace triagens::basics; -using namespace triagens::rest; - -namespace triagens { - namespace admin { - - // ----------------------------------------------------------------------------- - // constructors and destructors - // ----------------------------------------------------------------------------- - - UserHandler::UserHandler (HttpRequest* request, ApplicationAdminServer* server) - : RestAdminBaseHandler(request), _server(server) { - } - - // ----------------------------------------------------------------------------- - // HttpHandler methods - // ----------------------------------------------------------------------------- - - HttpHandler::status_e UserHandler::execute () { - - // extract the username - vector const& suffix = request->suffix(); - - if (suffix.size() != 1) { - generateError(HttpResponse::BAD, "expecting /user/"); - return HANDLER_DONE; - } - - string const& name = suffix[0]; - - // execute the request - switch (request->requestType()) { - case HttpRequest::HTTP_REQUEST_POST: return executePost(name); - case HttpRequest::HTTP_REQUEST_GET: return executeGet(name); - case HttpRequest::HTTP_REQUEST_PUT: return executePut(name); - case HttpRequest::HTTP_REQUEST_DELETE: return executeDelete(name); - - default: - generateError(HttpResponse::METHOD_NOT_ALLOWED, "method not supported"); - return HANDLER_DONE; - } - } - - // ----------------------------------------------------------------------------- - // private methods - // ----------------------------------------------------------------------------- - - HttpHandler::status_e UserHandler::executePost (string const& name) { - struct Description : public InputParser::ObjectDescription { - Description () { - attribute("role", role); - attribute("password", password); - } - - string role; - string password; - } desc; - - bool ok = parseBody(desc); - - if (! ok) { - return HANDLER_DONE; - } - - Role* role = Role::lookup(desc.role); - - if (role == 0) { - generateError(HttpResponse::NOT_FOUND, "role '" + desc.role + "' not found"); - return HANDLER_DONE; - } - - ok = hasRight(role->rightToManage()); - - if (! ok) { - generateError(HttpResponse::UNAUTHORIZED, "no permission to create user with role '" + desc.role + "'"); - return HANDLER_DONE; - } - - User* user = User::create(name, role); - - if (user == 0) { - generateError(HttpResponse::UNAUTHORIZED, "cannot create user '" + name + "'"); - return HANDLER_DONE; - } - - user->changePassword(desc.password); - - generateUser(user); - return HANDLER_DONE; - } - - - - HttpHandler::status_e UserHandler::executeGet (string const& name) { - User* user = User::lookup(name); - - if (user == 0) { - generateError(HttpResponse::NOT_FOUND, "user '" + name + "' not found"); - return HANDLER_DONE; - } - - generateUser(user); - return HANDLER_DONE; - } - - - - HttpHandler::status_e UserHandler::executePut (string const& name) { - if (! isSelf(name)) { - generateError(HttpResponse::UNAUTHORIZED, "cannot manage password for user '" + name + "'"); - return HANDLER_DONE; - } - - User* user = User::lookup(name); - - if (user == 0) { - generateError(HttpResponse::NOT_FOUND, "user '" + name + "' not found"); - return HANDLER_DONE; - } - - struct Description : public InputParser::ObjectDescription { - Description () { - optional("password", password, hasPassword); - } - - bool hasPassword; - string password; - } desc; - - bool ok = parseBody(desc); - - if (! ok) { - return HANDLER_DONE; - } - - bool changed = true; - - if (desc.hasPassword) { - changed = user->changePassword(desc.password); - } - - VariantArray* result = new VariantArray(); - result->add("changed", new VariantBoolean(changed)); - - generateResult(result); - return HANDLER_DONE; - } - - - - HttpHandler::status_e UserHandler::executeDelete (string const& name) { - User* user = User::lookup(name); - - bool removed = false; - - if (user != 0) { - bool ok = hasRight(user->getRole()->rightToManage()); - - if (! ok) { - generateError(HttpResponse::UNAUTHORIZED, - "no permission to create user with role '" + user->getRole()->getName() + "'"); - return HANDLER_DONE; - } - - removed = User::remove(user); - } - - VariantArray* result = new VariantArray(); - result->add("removed", new VariantBoolean(removed)); - - generateResult(result); - return HANDLER_DONE; - } - - - - void UserHandler::generateUser (User* user) { - VariantArray* result = new VariantArray(); - result->add("role", user->getRole()->getName()); - result->add("name", user->getName()); - - set const& rights = user->getRole()->getRights(); - - VariantVector* r = new VariantVector(); - - for (set::const_iterator i = rights.begin(); i != rights.end(); ++i) { - r->add(new VariantInt32(*i)); - } - - result->add("rights", r); - - generateResult(result); - } - } -} diff --git a/UserManager/UserHandler.h b/UserManager/UserHandler.h deleted file mode 100644 index 87ca0ae5e4..0000000000 --- a/UserManager/UserHandler.h +++ /dev/null @@ -1,96 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief user handler -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 2011, triagens GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#ifndef TRIAGENS_BORNHOLM_USER_MANAGER_USER_HANDLER_H -#define TRIAGENS_BORNHOLM_USER_MANAGER_USER_HANDLER_H 1 - -#include - -#include - -namespace triagens { - namespace admin { - class ApplicationAdminServer; - class User; - class Session; - - //////////////////////////////////////////////////////////////////////////////// - /// @brief user handler - //////////////////////////////////////////////////////////////////////////////// - - class UserHandler : public RestAdminBaseHandler { - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief static constructor - //////////////////////////////////////////////////////////////////////////////// - - static rest::HttpHandler* create (rest::HttpRequest* request, void* data) { - return new UserHandler(request, (ApplicationAdminServer*) data); - } - - public: - - - //////////////////////////////////////////////////////////////////////////////// - /// {@inheritDoc} - //////////////////////////////////////////////////////////////////////////////// - - bool isDirect () { - return true; - } - - - //////////////////////////////////////////////////////////////////////////////// - /// {@inheritDoc} - //////////////////////////////////////////////////////////////////////////////// - - status_e execute (); - - protected: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief constructor - //////////////////////////////////////////////////////////////////////////////// - - UserHandler (rest::HttpRequest* request, ApplicationAdminServer*); - - private: - status_e executePost (string const& name); - status_e executeGet (string const& name); - status_e executePut (string const& name); - status_e executeDelete (string const& name); - - void generateUser (User*); - - private: - ApplicationAdminServer* _server; - }; - } -} - -#endif diff --git a/UserManager/UsersHandler.cpp b/UserManager/UsersHandler.cpp deleted file mode 100644 index bb4f49a8ea..0000000000 --- a/UserManager/UsersHandler.cpp +++ /dev/null @@ -1,83 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief users handler -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 2011, triagens GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#include "UsersHandler.h" - -#include -#include -#include -#include -#include - -#include "UserManager/User.h" - -using namespace triagens::basics; -using namespace triagens::rest; - -namespace triagens { - namespace admin { - - // ----------------------------------------------------------------------------- - // constructors and destructors - // ----------------------------------------------------------------------------- - - UsersHandler::UsersHandler (HttpRequest* request, ApplicationAdminServer* server) - : RestAdminBaseHandler(request), _server(server) { - } - - // ----------------------------------------------------------------------------- - // HttpHandler methods - // ----------------------------------------------------------------------------- - - HttpHandler::status_e UsersHandler::execute () { - vector const& suffix = request->suffix(); - - if (suffix.size() != 0) { - generateError(HttpResponse::BAD, "expecting GET /users"); - return HANDLER_DONE; - } - - if (request->requestType() != HttpRequest::HTTP_REQUEST_GET) { - generateError(HttpResponse::METHOD_NOT_ALLOWED, "expecting GET"); - return HANDLER_DONE; - } - - vector users = User::users(); - - VariantArray* result = new VariantArray(); - VariantVector* list = new VariantVector(); - result->add("users", list); - - for (vector::iterator i = users.begin(); i != users.end(); ++i) { - list->add((*i)->getName()); - } - - generateResult(result); - return HANDLER_DONE; - } - } -} diff --git a/UserManager/UsersHandler.h b/UserManager/UsersHandler.h deleted file mode 100644 index b3552a9995..0000000000 --- a/UserManager/UsersHandler.h +++ /dev/null @@ -1,85 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief users handler -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 2011, triagens GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#ifndef TRIAGENS_BORNHOLM_USER_MANAGER_USERS_HANDLER_H -#define TRIAGENS_BORNHOLM_USER_MANAGER_USERS_HANDLER_H 1 - -#include - -namespace triagens { - namespace admin { - class ApplicationAdminServer; - class User; - - //////////////////////////////////////////////////////////////////////////////// - /// @brief user handler - //////////////////////////////////////////////////////////////////////////////// - - class UsersHandler : public RestAdminBaseHandler { - public: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief static constructor - //////////////////////////////////////////////////////////////////////////////// - - static rest::HttpHandler* create (rest::HttpRequest* request, void* data) { - return new UsersHandler(request, (ApplicationAdminServer*) data); - } - - public: - - - //////////////////////////////////////////////////////////////////////////////// - /// {@inheritDoc} - //////////////////////////////////////////////////////////////////////////////// - - bool isDirect () { - return true; - } - - - //////////////////////////////////////////////////////////////////////////////// - /// {@inheritDoc} - //////////////////////////////////////////////////////////////////////////////// - - status_e execute (); - - protected: - - //////////////////////////////////////////////////////////////////////////////// - /// @brief constructor - //////////////////////////////////////////////////////////////////////////////// - - UsersHandler (rest::HttpRequest* request, ApplicationAdminServer*); - - private: - ApplicationAdminServer* _server; - }; - } -} - -#endif diff --git a/build.h b/build.h index e3e137aa2c..23441c97e0 100644 --- a/build.h +++ b/build.h @@ -1 +1 @@ -#define TRIAGENS_VERSION "0.0.6 (9800:9802)" +#define TRIAGENS_VERSION "0.0.7" diff --git a/config/revision.sh b/config/revision.sh deleted file mode 100755 index 3ebeca8fb1..0000000000 --- a/config/revision.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash - -if [ $# -lt 4 ]; then - echo "usage: $0 ..." - exit 1 -fi - -NAME=$1 -shift - -name=`echo $NAME | awk '{print tolower($1)}'` - -GUARD=$1 -shift - -BUILD=$1 -shift - -echo "TRIAGENS_$GUARD" | tr "a-z" "A-Z" | awk '{print "#ifndef " $1}' -echo "TRIAGENS_$GUARD" | tr "a-z" "A-Z" | awk '{print "#define " $1 " 1"}' -echo "" -echo "$*" | tr " " "\n" | sort | awk '$1 != "" {print "#include <" $1 ">"}' -echo "" -echo "namespace triagens {" -echo " namespace $name {" -echo " inline string version () {" -echo " return " | tr -d "\n" -cat $BUILD | sed -e 's:^.*"\(.*\)":"\1";:' -echo " }" -echo "" -echo " inline string revision () {" -echo " return \"\$Revision: $NAME " | tr -d "\n" -echo `cat $BUILD | sed -e 's:.*"\(.*\)".*:\1:'` | tr -d "\n" -echo ' (c) triAGENS GmbH $";' -echo " }" -echo " }" -echo "}" -echo "" -echo "#endif" diff --git a/configure.ac b/configure.ac index d2d398caf1..901d3521ba 100644 --- a/configure.ac +++ b/configure.ac @@ -20,15 +20,24 @@ dnl CHECKS HOST, PROGRAMS, COMPILER, LIB, SYSTEM dnl ============================================================================ m4_include([m4/configure.basics]) +AC_PROG_RANLIB + m4_include([m4/configure.static]) m4_include([m4/configure.32bit]) +m4_include([m4/configure.logging]) m4_include([m4/configure.largefile]) m4_include([m4/configure.threads]) m4_include([m4/configure.flex-bison]) -m4_include([m4/configure.boost]) -m4_include([m4/configure.libev]) -m4_include([m4/configure.openssl]) -m4_include([m4/configure.v8]) + +m4_include([m4/external.boost]) +m4_include([m4/external.libev]) +m4_include([m4/external.math]) +m4_include([m4/external.ncurses]) +m4_include([m4/external.readline]) +m4_include([m4/external.openssl]) +m4_include([m4/external.v8]) + +CPPFLAGS="$CPPFLAGS -DGEO_TRIAGENS=1" dnl ============================================================================ dnl OUTPUT GENERATE FILES @@ -38,6 +47,7 @@ BUILD_H="\$(top_srcdir)/build.h" AC_SUBST(BUILD_H) AC_CONFIG_FILES([Makefile]) +AM_CONFIG_HEADER([BasicsC/local-configuration.h]) AC_OUTPUT dnl ============================================================================ diff --git a/durham.h b/durham.h deleted file mode 100644 index 2284362da5..0000000000 --- a/durham.h +++ /dev/null @@ -1,57 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief storage engine -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2010-2011 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 2011, triAGENS GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////// -/// @mainpage -/// -/// The Durham Storage Engine stores documents (aka objects or JSON documents) -/// in datafiles within the filesystem. These documents are mapped into the -/// process space using mmap. Instead of using JSON, BSON, or XML to store the -/// documents a very concise representation, namely JSON Shapes, is used. -/// This allows for verbose attributes name, while still being space efficient. -/// Access to attributes can be precompiled and is therefore incredible fast. -/// -/// @section Interface -/// -/// The Store Engine groups documents into collections. Each -/// collection can be accessed using queries. These queries can either -/// be expressed using a @ref FluentInterface "fluent interface" (see -/// @ref JavaScriptFuncIndex "Index of JavaScript Functions"), using -/// the SQL-select operator find, or using UNQL. -/// -/// @section DataStructures Data Structures -/// -/// The key data structures are @ref ShapedJson "JSON Shapes". JSON Shapes -/// allow the Durham Storage Engine to store documents in a very space -/// efficient way. -/// -/// @section CollectionsDatafiles Collections and Datafiles -/// -/// All data is stored in datafiles. The internal structure of a datafile is -/// described in @ref DurhamDatafiles "Datafiles". All datafiles of a set of -/// documents are grouped together in a @ref DurhamCollections "Collection". -////////////////////////////////////////////////////////////////////////////////