From ddb057fa2711911320233a5c637a14b5008c3ae3 Mon Sep 17 00:00:00 2001 From: Frank Mayer Date: Fri, 4 Apr 2014 06:23:45 +0300 Subject: [PATCH 1/5] Fixes "New Collection" window not honoring user-specified journal size. The tests need to be extended for this, as I didn't have a proper development environment set up for this. Tested it manually though and it works. --- .../frontend/js/collections/arangoCollections.js | 3 +++ .../aardvark/frontend/js/views/newCollectionView.js | 10 ++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/js/apps/system/aardvark/frontend/js/collections/arangoCollections.js b/js/apps/system/aardvark/frontend/js/collections/arangoCollections.js index 47912408e1..2c6f858f77 100644 --- a/js/apps/system/aardvark/frontend/js/collections/arangoCollections.js +++ b/js/apps/system/aardvark/frontend/js/collections/arangoCollections.js @@ -270,6 +270,9 @@ var data = {}; data.name = collName; data.waitForSync = wfs; + if (journalSize > 0) { + data.journalSize = journalSize; + } data.isSystem = isSystem; data.type = parseInt(collType, 10); if (shards) { diff --git a/js/apps/system/aardvark/frontend/js/views/newCollectionView.js b/js/apps/system/aardvark/frontend/js/views/newCollectionView.js index 55c52b4e6c..1b7d08c284 100644 --- a/js/apps/system/aardvark/frontend/js/views/newCollectionView.js +++ b/js/apps/system/aardvark/frontend/js/views/newCollectionView.js @@ -91,15 +91,9 @@ } var isSystem = (collName.substr(0, 1) === '_'); var wfs = (collSync === "true"); - var journalSizeString; - - if (collSize === '') { - journalSizeString = ''; - } - else { + if (collSize > 0) { try { collSize = JSON.parse(collSize) * 1024 * 1024; - journalSizeString = ', "journalSize":' + collSize; } catch (e) { arangoHelper.arangoError('Please enter a valid number'); @@ -112,7 +106,7 @@ } var returnobj = window.arangoCollectionsStore.newCollection( - collName, wfs, isSystem, journalSizeString, collType, shards, shardBy + collName, wfs, isSystem, collSize, collType, shards, shardBy ); if (returnobj.status === true) { self.hidden(); From 9aaeafda10833ab319fe6480f267ac42bdc75969 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Fri, 4 Apr 2014 10:21:54 +0200 Subject: [PATCH 2/5] cpp --- lib/CMakeLists.txt | 6 +-- lib/Makefile.files | 6 +-- .../{json-shaper.c => json-shaper.cpp} | 6 +-- .../{shape-accessor.c => shape-accessor.cpp} | 25 ++++------ lib/ShapedJson/shape-accessor.h | 2 +- .../{shaped-json.c => shaped-json.cpp} | 48 ++++++++----------- 6 files changed, 37 insertions(+), 56 deletions(-) rename lib/ShapedJson/{json-shaper.c => json-shaper.cpp} (98%) rename lib/ShapedJson/{shape-accessor.c => shape-accessor.cpp} (95%) rename lib/ShapedJson/{shaped-json.c => shaped-json.cpp} (97%) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 1dea09c167..b7cb158333 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -117,9 +117,9 @@ add_library( Rest/SslInterface.cpp Rest/Version.cpp Rest/Url.cpp - ShapedJson/json-shaper.c - ShapedJson/shape-accessor.c - ShapedJson/shaped-json.c + ShapedJson/json-shaper.cpp + ShapedJson/shape-accessor.cpp + ShapedJson/shaped-json.cpp Statistics/statistics.cpp Utilities/ScriptLoader.cpp Zip/ioapi.c diff --git a/lib/Makefile.files b/lib/Makefile.files index f8ac985531..4017823529 100644 --- a/lib/Makefile.files +++ b/lib/Makefile.files @@ -90,9 +90,9 @@ lib_libarango_a_SOURCES = \ lib/Rest/SslInterface.cpp \ lib/Rest/Version.cpp \ lib/Rest/Url.cpp \ - lib/ShapedJson/json-shaper.c \ - lib/ShapedJson/shape-accessor.c \ - lib/ShapedJson/shaped-json.c \ + lib/ShapedJson/json-shaper.cpp \ + lib/ShapedJson/shape-accessor.cpp \ + lib/ShapedJson/shaped-json.cpp \ lib/Statistics/statistics.cpp \ lib/Utilities/ScriptLoader.cpp \ lib/Zip/ioapi.c \ diff --git a/lib/ShapedJson/json-shaper.c b/lib/ShapedJson/json-shaper.cpp similarity index 98% rename from lib/ShapedJson/json-shaper.c rename to lib/ShapedJson/json-shaper.cpp index e7be7c6285..9cfae6be3a 100644 --- a/lib/ShapedJson/json-shaper.c +++ b/lib/ShapedJson/json-shaper.cpp @@ -127,7 +127,7 @@ static bool EqualPidKeyAttributePath (TRI_associative_synced_t* array, void cons //////////////////////////////////////////////////////////////////////////////// static TRI_shape_path_t const* LookupPidAttributePath (TRI_shaper_t* shaper, TRI_shape_pid_t pid) { - return TRI_LookupByKeyAssociativeSynced(&shaper->_attributePathsByPid, &pid); + return static_cast(TRI_LookupByKeyAssociativeSynced(&shaper->_attributePathsByPid, &pid)); } //////////////////////////////////////////////////////////////////////////////// @@ -217,7 +217,7 @@ static TRI_shape_path_t const* FindShapePathByName (TRI_shaper_t* shaper, // split path into attribute pieces count = 0; - aids = TRI_Allocate(shaper->_memoryZone, len * sizeof(TRI_shape_aid_t), false); + aids = static_cast(TRI_Allocate(shaper->_memoryZone, len * sizeof(TRI_shape_aid_t), false)); if (aids == NULL) { TRI_UnlockMutex(&shaper->_attributePathLock); @@ -267,7 +267,7 @@ static TRI_shape_path_t const* FindShapePathByName (TRI_shaper_t* shaper, // create element total = sizeof(TRI_shape_path_t) + (len + 1) + (count * sizeof(TRI_shape_aid_t)); - result = TRI_Allocate(shaper->_memoryZone, total, false); + result = static_cast(TRI_Allocate(shaper->_memoryZone, total, false)); if (result == NULL) { TRI_UnlockMutex(&shaper->_attributePathLock); diff --git a/lib/ShapedJson/shape-accessor.c b/lib/ShapedJson/shape-accessor.cpp similarity index 95% rename from lib/ShapedJson/shape-accessor.c rename to lib/ShapedJson/shape-accessor.cpp index 83d5cbbb5d..2a4725f4ad 100644 --- a/lib/ShapedJson/shape-accessor.c +++ b/lib/ShapedJson/shape-accessor.cpp @@ -293,7 +293,7 @@ static bool BytecodeShapeAccessor (TRI_shaper_t* shaper, TRI_shape_access_t* acc } accessor->_shape = shape; - accessor->_code = TRI_Allocate(shaper->_memoryZone, ops._length * sizeof(void*), false); + accessor->_code = static_cast(TRI_Allocate(shaper->_memoryZone, ops._length * sizeof(void*), false)); if (accessor->_code == NULL) { LOG_ERROR("out of memory"); @@ -318,18 +318,15 @@ static bool ExecuteBytecodeShapeAccessor (TRI_shape_access_t const* accessor, TRI_shape_size_t e; TRI_shape_size_t pos; TRI_shape_size_t* offsetsV; - void* const* ops; if (accessor->_shape == NULL) { return false; } - ops = accessor->_code; + void const** ops = static_cast(accessor->_code); while (true) { - TRI_shape_ac_bc_e op; - - op = * (TRI_shape_ac_bc_e*) ops; + TRI_shape_ac_bc_e op = *(TRI_shape_ac_bc_e*) ops; ops++; switch (op) { @@ -401,10 +398,7 @@ void TRI_FreeShapeAccessor (TRI_shape_access_t* accessor) { TRI_shape_access_t* TRI_ShapeAccessor (TRI_shaper_t* shaper, TRI_shape_sid_t sid, TRI_shape_pid_t pid) { - TRI_shape_access_t* accessor; - bool ok; - - accessor = TRI_Allocate(shaper->_memoryZone, sizeof(TRI_shape_access_t), false); + TRI_shape_access_t* accessor = static_cast(TRI_Allocate(shaper->_memoryZone, sizeof(TRI_shape_access_t), false)); if (accessor == NULL) { TRI_set_errno(TRI_ERROR_OUT_OF_MEMORY); @@ -416,7 +410,7 @@ TRI_shape_access_t* TRI_ShapeAccessor (TRI_shaper_t* shaper, accessor->_code = NULL; accessor->_memoryZone = shaper->_memoryZone; - ok = BytecodeShapeAccessor(shaper, accessor); + bool ok = BytecodeShapeAccessor(shaper, accessor); if (ok) { return accessor; @@ -462,7 +456,6 @@ void TRI_PrintShapeAccessor (TRI_shape_access_t* accessor) { TRI_shape_size_t e; TRI_shape_size_t pos; TRI_shape_t const* shape; - void* const* ops; printf("shape accessor for sid: %lu, pid: %lu\n", (unsigned long) accessor->_sid, @@ -475,13 +468,11 @@ void TRI_PrintShapeAccessor (TRI_shape_access_t* accessor) { printf(" result shape: %lu\n", (unsigned long) accessor->_shape->_sid); - ops = accessor->_code; + void const** ops = static_cast(accessor->_code); shape = accessor->_shape; while (true) { - TRI_shape_ac_bc_e op; - - op = * (TRI_shape_ac_bc_e*) ops; + TRI_shape_ac_bc_e op = static_cast(*(TRI_shape_ac_bc_e*) ops); ops++; switch (op) { @@ -489,7 +480,7 @@ void TRI_PrintShapeAccessor (TRI_shape_access_t* accessor) { return; case TRI_SHAPE_AC_SHAPE_PTR: - shape = *ops++; + shape = static_cast(*ops++); printf(" OP: shape %lu\n", (unsigned long) shape->_sid); diff --git a/lib/ShapedJson/shape-accessor.h b/lib/ShapedJson/shape-accessor.h index d3566e08dc..542c5539fb 100644 --- a/lib/ShapedJson/shape-accessor.h +++ b/lib/ShapedJson/shape-accessor.h @@ -55,7 +55,7 @@ typedef struct TRI_shape_access_s { TRI_shape_pid_t _pid; // path identifier of the attribute path TRI_shape_t const* _shape; // resulting shape - void* const* _code; // bytecode + void const** _code; // bytecode TRI_memory_zone_t* _memoryZone; } diff --git a/lib/ShapedJson/shaped-json.c b/lib/ShapedJson/shaped-json.cpp similarity index 97% rename from lib/ShapedJson/shaped-json.c rename to lib/ShapedJson/shaped-json.cpp index 488f0c94fa..b225dc160c 100644 --- a/lib/ShapedJson/shaped-json.c +++ b/lib/ShapedJson/shaped-json.cpp @@ -381,7 +381,7 @@ static bool FillShapeValueBoolean (TRI_shaper_t* shaper, TRI_shape_value_t* dst, dst->_fixedSized = true; dst->_size = sizeof(TRI_shape_boolean_t); // no need to prefill dst->_value with 0, as it is overwritten directly afterwards - dst->_value = (char*) (ptr = TRI_Allocate(shaper->_memoryZone, dst->_size, false)); + dst->_value = (char*) (ptr = static_cast(TRI_Allocate(shaper->_memoryZone, dst->_size, false))); if (dst->_value == NULL) { return false; @@ -403,7 +403,7 @@ static bool FillShapeValueNumber (TRI_shaper_t* shaper, TRI_shape_value_t* dst, dst->_sid = TRI_LookupBasicSidShaper(TRI_SHAPE_NUMBER); dst->_fixedSized = true; dst->_size = sizeof(TRI_shape_number_t); - dst->_value = (char*) (ptr = TRI_Allocate(shaper->_memoryZone, dst->_size, true)); + dst->_value = (char*) (ptr = static_cast(TRI_Allocate(shaper->_memoryZone, dst->_size, true))); if (dst->_value == NULL) { return false; @@ -426,7 +426,7 @@ static bool FillShapeValueString (TRI_shaper_t* shaper, TRI_shape_value_t* dst, dst->_sid = TRI_LookupBasicSidShaper(TRI_SHAPE_SHORT_STRING); dst->_fixedSized = true; dst->_size = sizeof(TRI_shape_length_short_string_t) + TRI_SHAPE_SHORT_STRING_CUT; - dst->_value = (ptr = TRI_Allocate(shaper->_memoryZone, dst->_size, true)); + dst->_value = (ptr = static_cast(TRI_Allocate(shaper->_memoryZone, dst->_size, true))); if (dst->_value == NULL) { return false; @@ -443,7 +443,7 @@ static bool FillShapeValueString (TRI_shaper_t* shaper, TRI_shape_value_t* dst, dst->_sid = TRI_LookupBasicSidShaper(TRI_SHAPE_LONG_STRING); dst->_fixedSized = false; dst->_size = sizeof(TRI_shape_length_long_string_t) + json->_value._string.length; - dst->_value = (ptr = TRI_Allocate(shaper->_memoryZone, dst->_size, true)); + dst->_value = (ptr = static_cast(TRI_Allocate(shaper->_memoryZone, dst->_size, true))); if (dst->_value == NULL) { return false; @@ -501,7 +501,7 @@ static bool FillShapeValueList (TRI_shaper_t* shaper, dst->_fixedSized = false; dst->_size = sizeof(TRI_shape_length_list_t); - dst->_value = (ptr = TRI_Allocate(shaper->_memoryZone, dst->_size, true)); + dst->_value = (ptr = static_cast(TRI_Allocate(shaper->_memoryZone, dst->_size, true))); if (dst->_value == NULL) { return false; @@ -513,7 +513,7 @@ static bool FillShapeValueList (TRI_shaper_t* shaper, } // convert into TRI_shape_value_t array - p = (values = TRI_Allocate(shaper->_memoryZone, sizeof(TRI_shape_value_t) * n, true)); + p = (values = static_cast(TRI_Allocate(shaper->_memoryZone, sizeof(TRI_shape_value_t) * n, true))); if (p == NULL) { return false; @@ -562,9 +562,7 @@ static bool FillShapeValueList (TRI_shaper_t* shaper, // homogeneous sized if (hs && hl) { - TRI_homogeneous_sized_list_shape_t* shape; - - shape = TRI_Allocate(shaper->_memoryZone, sizeof(TRI_homogeneous_sized_list_shape_t), true); + TRI_homogeneous_sized_list_shape_t* shape = static_cast(TRI_Allocate(shaper->_memoryZone, sizeof(TRI_homogeneous_sized_list_shape_t), true)); if (shape == NULL) { for (p = values; p < e; ++p) { @@ -606,7 +604,7 @@ static bool FillShapeValueList (TRI_shaper_t* shaper, dst->_fixedSized = false; dst->_size = sizeof(TRI_shape_length_list_t) + total; - dst->_value = (ptr = TRI_Allocate(shaper->_memoryZone, dst->_size, true)); + dst->_value = (ptr = static_cast(TRI_Allocate(shaper->_memoryZone, dst->_size, true))); if (dst->_value == NULL) { for (p = values; p < e; ++p) { @@ -632,9 +630,7 @@ static bool FillShapeValueList (TRI_shaper_t* shaper, // homogeneous else if (hs) { - TRI_homogeneous_list_shape_t* shape; - - shape = TRI_Allocate(shaper->_memoryZone, sizeof(TRI_homogeneous_list_shape_t), true); + TRI_homogeneous_list_shape_t* shape = static_cast(TRI_Allocate(shaper->_memoryZone, sizeof(TRI_homogeneous_list_shape_t), true)); if (shape == NULL) { for (p = values; p < e; ++p) { @@ -677,7 +673,7 @@ static bool FillShapeValueList (TRI_shaper_t* shaper, dst->_fixedSized = false; dst->_size = offset + total; - dst->_value = (ptr = TRI_Allocate(shaper->_memoryZone, dst->_size, true)); + dst->_value = (ptr = static_cast(TRI_Allocate(shaper->_memoryZone, dst->_size, true))); if (dst->_value == NULL) { for (p = values; p < e; ++p) { @@ -721,7 +717,7 @@ static bool FillShapeValueList (TRI_shaper_t* shaper, dst->_fixedSized = false; dst->_size = offset + total; - dst->_value = (ptr = TRI_Allocate(shaper->_memoryZone, dst->_size, true)); + dst->_value = (ptr = static_cast(TRI_Allocate(shaper->_memoryZone, dst->_size, true))); if (dst->_value == NULL) { for (p = values; p < e; ++p) { @@ -807,7 +803,7 @@ static bool FillShapeValueArray (TRI_shaper_t* shaper, n = json->_value._objects._length / 2; // convert into TRI_shape_value_t array - p = (values = TRI_Allocate(shaper->_memoryZone, n * sizeof(TRI_shape_value_t), true)); + p = (values = static_cast(TRI_Allocate(shaper->_memoryZone, n * sizeof(TRI_shape_value_t), true))); if (p == NULL) { return false; @@ -818,12 +814,10 @@ static bool FillShapeValueArray (TRI_shaper_t* shaper, v = 0; for (i = 0; i < n; ++i, ++p) { - TRI_json_t* key; - TRI_json_t* val; bool ok; - key = TRI_AtVector(&json->_value._objects, 2 * i); - val = TRI_AtVector(&json->_value._objects, 2 * i + 1); + TRI_json_t* key = static_cast(TRI_AtVector(&json->_value._objects, 2 * i)); + TRI_json_t* val = static_cast(TRI_AtVector(&json->_value._objects, 2 * i + 1)); assert(key != NULL); assert(val != NULL); @@ -896,7 +890,7 @@ static bool FillShapeValueArray (TRI_shaper_t* shaper, + n * sizeof(TRI_shape_aid_t) + (f + 1) * sizeof(TRI_shape_size_t); - a = (TRI_array_shape_t*) (ptr = TRI_Allocate(shaper->_memoryZone, i, true)); + a = (TRI_array_shape_t*) (ptr = static_cast(TRI_Allocate(shaper->_memoryZone, i, true))); if (ptr == NULL) { e = values + n; @@ -938,7 +932,7 @@ static bool FillShapeValueArray (TRI_shaper_t* shaper, dst->_fixedSized = true; dst->_size = total; - dst->_value = (ptr = TRI_Allocate(shaper->_memoryZone, dst->_size, true)); + dst->_value = (ptr = static_cast(TRI_Allocate(shaper->_memoryZone, dst->_size, true))); if (ptr == NULL) { e = values + n; @@ -2208,21 +2202,18 @@ static bool StringifyJsonShapeData (TRI_shaper_t* shaper, //////////////////////////////////////////////////////////////////////////////// TRI_shaped_json_t* TRI_CopyShapedJson (TRI_shaper_t* shaper, TRI_shaped_json_t* oldShapedJson) { - TRI_shaped_json_t* newShapedJson; - int res; - if (oldShapedJson == NULL) { return NULL; } - newShapedJson = TRI_Allocate(shaper->_memoryZone, sizeof(TRI_shaped_json_t), true); + TRI_shaped_json_t* newShapedJson = static_cast(TRI_Allocate(shaper->_memoryZone, sizeof(TRI_shaped_json_t), true)); if (newShapedJson == NULL) { return NULL; } newShapedJson->_sid = oldShapedJson->_sid; - res = TRI_CopyToBlob(shaper->_memoryZone, &(newShapedJson->_data), &(oldShapedJson->_data)); + int res = TRI_CopyToBlob(shaper->_memoryZone, &(newShapedJson->_data), &(oldShapedJson->_data)); if (res != TRI_ERROR_NO_ERROR) { TRI_Free(shaper->_memoryZone, newShapedJson); @@ -2272,7 +2263,6 @@ TRI_shaped_json_t* TRI_ShapedJsonJson (TRI_shaper_t* shaper, TRI_json_t const* json, bool create, bool isLocked) { - TRI_shaped_json_t* shaped; TRI_shape_value_t dst; bool ok; @@ -2290,7 +2280,7 @@ TRI_shaped_json_t* TRI_ShapedJsonJson (TRI_shaper_t* shaper, #endif // no need to prefill shaped with 0's as all attributes are set directly afterwards - shaped = TRI_Allocate(shaper->_memoryZone, sizeof(TRI_shaped_json_t), false); + TRI_shaped_json_t* shaped = static_cast(TRI_Allocate(shaper->_memoryZone, sizeof(TRI_shaped_json_t), false)); if (shaped == NULL) { TRI_Free(shaper->_memoryZone, dst._value); From b922c74ab761781db52bbb5dc66ccfe211175aed Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Fri, 4 Apr 2014 10:23:41 +0200 Subject: [PATCH 3/5] removed unused Url class --- lib/CMakeLists.txt | 1 - lib/Makefile.files | 1 - lib/Rest/InitialiseRest.cpp | 3 - lib/Rest/Url.cpp | 214 ------------------------------------ lib/Rest/Url.h | 194 -------------------------------- 5 files changed, 413 deletions(-) delete mode 100644 lib/Rest/Url.cpp delete mode 100644 lib/Rest/Url.h diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index b7cb158333..2cdd54f6e2 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -116,7 +116,6 @@ add_library( Rest/InitialiseRest.cpp Rest/SslInterface.cpp Rest/Version.cpp - Rest/Url.cpp ShapedJson/json-shaper.cpp ShapedJson/shape-accessor.cpp ShapedJson/shaped-json.cpp diff --git a/lib/Makefile.files b/lib/Makefile.files index 4017823529..2bec1d3d68 100644 --- a/lib/Makefile.files +++ b/lib/Makefile.files @@ -89,7 +89,6 @@ lib_libarango_a_SOURCES = \ lib/Rest/InitialiseRest.cpp \ lib/Rest/SslInterface.cpp \ lib/Rest/Version.cpp \ - lib/Rest/Url.cpp \ lib/ShapedJson/json-shaper.cpp \ lib/ShapedJson/shape-accessor.cpp \ lib/ShapedJson/shaped-json.cpp \ diff --git a/lib/Rest/InitialiseRest.cpp b/lib/Rest/InitialiseRest.cpp index 63a7d2fae6..80f854b25a 100644 --- a/lib/Rest/InitialiseRest.cpp +++ b/lib/Rest/InitialiseRest.cpp @@ -44,7 +44,6 @@ #include "Basics/InitialiseBasics.h" #include "Rest/HttpResponse.h" #include "Rest/Version.h" -#include "Rest/Url.h" #include "Statistics/statistics.h" // ----------------------------------------------------------------------------- @@ -116,7 +115,6 @@ namespace triagens { void InitialiseRest (int argc, char* argv[]) { TRIAGENS_BASICS_INITIALISE(argc, argv); - TRI_InitialiseUrl(); TRI_InitialiseStatistics(); SSL_library_init(); @@ -138,7 +136,6 @@ namespace triagens { opensslCleanup(); #endif - TRI_ShutdownUrl(); TRI_ShutdownStatistics(); TRIAGENS_BASICS_SHUTDOWN; diff --git a/lib/Rest/Url.cpp b/lib/Rest/Url.cpp deleted file mode 100644 index b59b9fdad4..0000000000 --- a/lib/Rest/Url.cpp +++ /dev/null @@ -1,214 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief url class -/// -/// @file -/// -/// DISCLAIMER -/// -/// Copyright 2004-2013 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 Achim Brandt -/// @author Copyright 2007-2013, triAGENS GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#include "Url.h" - -#include - -#include - -#include "Basics/Exceptions.h" -#include "Basics/StringUtils.h" - -using namespace std; -using namespace triagens::basics; -using namespace triagens::rest; - -// ----------------------------------------------------------------------------- -// --SECTION-- private variables -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup Url -/// @{ -//////////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////// -/// @brief URL pattern -//////////////////////////////////////////////////////////////////////////////// - -static regex_t re; - -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup Url -/// @{ -//////////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////// -/// @brief constructor -//////////////////////////////////////////////////////////////////////////////// - -Url::Url (string const& urlName) - : _host("localhost"), - _port(80), - _service("http"), - _path("") { - int result; - regmatch_t matches[5]; - - result = regexec(&re, urlName.c_str(), sizeof(matches) / sizeof(matches[0]), matches, 0); - - if (result == 0) { - char const* ptr = urlName.c_str(); - string port = string(ptr + matches[3].rm_so, matches[3].rm_eo - matches[3].rm_so); - - _host = string(ptr + matches[2].rm_so, matches[2].rm_eo - matches[2].rm_so); - _port = port.empty() ? 80 : StringUtils::uint32(port.substr(1)); - _path = string(ptr + matches[4].rm_so, matches[4].rm_eo - matches[4].rm_so); - - if (matches[1].rm_so == matches[1].rm_eo) { - _service = "http"; - } - else { - _service = string(ptr + matches[1].rm_so, matches[1].rm_eo - matches[1].rm_so - 1); - } - } - else { - THROW_PARAMETER_ERROR("url", "url not valid", "constructor"); - } -} - -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - -// ----------------------------------------------------------------------------- -// --SECTION-- public methods -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup Url -/// @{ -//////////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////// -/// @brief returns the service part -//////////////////////////////////////////////////////////////////////////////// - -string const& Url::service () const { - return _service; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief returns the host part -//////////////////////////////////////////////////////////////////////////////// - -string const& Url::host () const { - return _host; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief returns the port -//////////////////////////////////////////////////////////////////////////////// - -uint16_t Url::port () const { - return _port; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief returns the path part -//////////////////////////////////////////////////////////////////////////////// - -string const& Url::path () const { - return _path; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - -// ----------------------------------------------------------------------------- -// --SECTION-- MODULE -// ----------------------------------------------------------------------------- - -// ----------------------------------------------------------------------------- -// --SECTION-- private variables -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup Url -/// @{ -//////////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////// -/// @brief already initialised -//////////////////////////////////////////////////////////////////////////////// - -static bool Initialised = false; - -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - -// ----------------------------------------------------------------------------- -// --SECTION-- public functions -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup Url -/// @{ -//////////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////// -/// @brief initialises the hashes components -//////////////////////////////////////////////////////////////////////////////// - -void TRI_InitialiseUrl () { - if (Initialised) { - return; - } - - regcomp(&re, "([a-z]*:)//([a-z0-9\\._-]*)(:[0-9]+)?(/.*)", REG_ICASE | REG_EXTENDED); - - Initialised = true; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief shut downs the hashes components -//////////////////////////////////////////////////////////////////////////////// - -void TRI_ShutdownUrl () { - regfree(&re); -} - -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: diff --git a/lib/Rest/Url.h b/lib/Rest/Url.h deleted file mode 100644 index c8b3fba12d..0000000000 --- a/lib/Rest/Url.h +++ /dev/null @@ -1,194 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -/// @brief url class -/// -/// @file -/// A class describing the various parts of an URL. -/// -/// DISCLAIMER -/// -/// Copyright 2004-2013 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 Achim Brandt -/// @author Copyright 2007-2013, triAGENS GmbH, Cologne, Germany -//////////////////////////////////////////////////////////////////////////////// - -#ifndef TRIAGENS_REST_URL_H -#define TRIAGENS_REST_URL_H 1 - -#include "Basics/Common.h" - -namespace triagens { - namespace rest { - -// ----------------------------------------------------------------------------- -// --SECTION-- class Url -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup Url -/// @{ -//////////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////// -/// @brief Url -//////////////////////////////////////////////////////////////////////////////// - - class Url { - -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - -// ----------------------------------------------------------------------------- -// --SECTION-- constructors and destructors -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup Url -/// @{ -//////////////////////////////////////////////////////////////////////////////// - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief constructor -//////////////////////////////////////////////////////////////////////////////// - - explicit - Url (string const& urlName); - -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - -// ----------------------------------------------------------------------------- -// --SECTION-- public methods -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup Url -/// @{ -//////////////////////////////////////////////////////////////////////////////// - - public: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief returns the service part -//////////////////////////////////////////////////////////////////////////////// - - string const& service () const; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief returns the host part -//////////////////////////////////////////////////////////////////////////////// - - string const& host () const; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief returns the port -//////////////////////////////////////////////////////////////////////////////// - - uint16_t port () const; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief returns the path part -//////////////////////////////////////////////////////////////////////////////// - - string const& path () const; - -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - -// ----------------------------------------------------------------------------- -// --SECTION-- private variables -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup Url -/// @{ -//////////////////////////////////////////////////////////////////////////////// - - private: - -//////////////////////////////////////////////////////////////////////////////// -/// @brief host -//////////////////////////////////////////////////////////////////////////////// - - string _host; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief port -//////////////////////////////////////////////////////////////////////////////// - - uint16_t _port; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief service -//////////////////////////////////////////////////////////////////////////////// - - string _service; - -//////////////////////////////////////////////////////////////////////////////// -/// @brief path -//////////////////////////////////////////////////////////////////////////////// - - string _path; - }; - } -} - -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - -// ----------------------------------------------------------------------------- -// --SECTION-- MODULE -// ----------------------------------------------------------------------------- - -// ----------------------------------------------------------------------------- -// --SECTION-- public functions -// ----------------------------------------------------------------------------- - -//////////////////////////////////////////////////////////////////////////////// -/// @addtogroup Url -/// @{ -//////////////////////////////////////////////////////////////////////////////// - -//////////////////////////////////////////////////////////////////////////////// -/// @brief initialises the url components -//////////////////////////////////////////////////////////////////////////////// - -void TRI_InitialiseUrl (void); - -//////////////////////////////////////////////////////////////////////////////// -/// @brief shut downs the url components -//////////////////////////////////////////////////////////////////////////////// - -void TRI_ShutdownUrl (void); - -//////////////////////////////////////////////////////////////////////////////// -/// @} -//////////////////////////////////////////////////////////////////////////////// - -#endif - -// Local Variables: -// mode: outline-minor -// outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" -// End: From cba524f15f150b707268b757299852895a6ff718 Mon Sep 17 00:00:00 2001 From: gschwab Date: Fri, 4 Apr 2014 11:13:53 +0200 Subject: [PATCH 4/5] refactored modal dialogs for databaseView --- .../frontend/js/templates/databaseView.ejs | 73 ---------- .../frontend/js/views/databaseView.js | 128 +++++++++++++----- .../aardvark/frontend/js/views/modalView.js | 6 + 3 files changed, 97 insertions(+), 110 deletions(-) diff --git a/js/apps/system/aardvark/frontend/js/templates/databaseView.ejs b/js/apps/system/aardvark/frontend/js/templates/databaseView.ejs index 3639ce77e0..8fefd60d5d 100644 --- a/js/apps/system/aardvark/frontend/js/templates/databaseView.ejs +++ b/js/apps/system/aardvark/frontend/js/templates/databaseView.ejs @@ -90,77 +90,4 @@ - - - - - - - - diff --git a/js/apps/system/aardvark/frontend/js/views/databaseView.js b/js/apps/system/aardvark/frontend/js/views/databaseView.js index e398e31e01..5cf5a38f7c 100644 --- a/js/apps/system/aardvark/frontend/js/views/databaseView.js +++ b/js/apps/system/aardvark/frontend/js/views/databaseView.js @@ -80,12 +80,18 @@ return true; }, + createDatabase: function(e) { + e.preventDefault(); + this.createAddDatabaseModal(); + }, + submitCreateDatabase: function() { var self = this; var name = $('#newDatabaseName').val(); var userName = $('#newUser').val(); var userPassword = $('#newPassword').val(); if (!this.validateDatabaseInfo(name, userName, userPassword)) { + console.log("VALIDATE"); return; } var options = { @@ -104,37 +110,17 @@ self.handleError(err.status, err.statusText, name); }, success: function(data) { - self.hideModal('createDatabaseModal'); self.updateDatabases(); + window.modalView.hide(); } }); }, - hideModal: function(modal) { - $('#' + modal).modal('hide'); - }, - - showModal: function(modal) { - $('#' + modal).modal('show'); - }, - - createDatabase: function(e) { - e.preventDefault(); - this.showModal('createDatabaseModal'); - }, - - submitDeleteDatabase: function(e) { - var toDelete = this.collection.where({name: this.dbToDelete}); - toDelete[0].destroy({wait: true, url:"/_api/database/"+this.dbToDelete}); - this.dbToDelete = ''; - this.hideModal('deleteDatabaseModal'); + submitDeleteDatabase: function(dbname) { + var toDelete = this.collection.where({name: dbname}); + toDelete[0].destroy({wait: true, url:"/_api/database/"+dbname}); this.updateDatabases(); - }, - - deleteDatabase: function(e) { - this.hideModal('editDatabaseModal'); - this.dbToDelete = $('#editDatabaseName').html(); - this.showModal('deleteDatabaseModal'); + window.modalView.hide(); }, currentDatabase: function() { @@ -158,20 +144,12 @@ }, editDatabase: function(e) { - var dbName = this.evaluateDatabaseName($(e.currentTarget).attr("id"), '_edit-database'); - $('#editDatabaseName').html(dbName); - var button = $('#deleteDatabase'); + var dbName = this.evaluateDatabaseName($(e.currentTarget).attr("id"), '_edit-database'), + isDeleteable = true; if(dbName === this.currentDB) { - var element; - button.prop('disabled', true); - button.removeClass('button-danger'); - button.addClass('button-neutral'); - } else { - button.prop('disabled', false); - button.removeClass('button-neutral'); - button.addClass('button-danger'); + isDeleteable = false; } - this.showModal('editDatabaseModal'); + this.createEditDatabaseModal(dbName, isDeleteable); }, search: function() { @@ -218,6 +196,82 @@ evaluateDatabaseName : function(str, substr) { var index = str.lastIndexOf(substr); return str.substring(0, index); + }, + + createEditDatabaseModal: function(dbName, isDeleteable) { + var buttons = [], + tableContent = []; + + tableContent.push( + window.modalView.createReadOnlyEntry("Name", dbName, "") + ); + if (isDeleteable) { + buttons.push( + window.modalView.createDeleteButton( + "Delete", + this.submitDeleteDatabase.bind(this, dbName) + ) + ); + } else { + buttons.push(window.modalView.createDisabledButton("Delete")); + } + window.modalView.show( + "modalTable.ejs", + "Edit database", + buttons, + tableContent + ); + }, + + createAddDatabaseModal: function() { + var buttons = [], + tableContent = []; + + tableContent.push( + window.modalView.createTextEntry( + "newDatabaseName", + "Name", + "", + false, + "Database Name", + true + ) + ); + tableContent.push( + window.modalView.createTextEntry( + "newUser", + "Username", + "", + "Please define the owner of this database. This will be the only user having " + + "initial access to this database. If the user is different to your account " + + "you will not be able to see the database. " + + "If there is a failure you will be informed.", + "Database Owner", + true + ) + ); + tableContent.push( + window.modalView.createPasswordEntry( + "newPassword", + "Password", + "", + false, + "", + false + ) + ); + buttons.push( + window.modalView.createSuccessButton( + "Create", + this.submitCreateDatabase.bind(this) + ) + ); + window.modalView.show( + "modalTable.ejs", + "Create Database", + buttons, + tableContent + ); } diff --git a/js/apps/system/aardvark/frontend/js/views/modalView.js b/js/apps/system/aardvark/frontend/js/views/modalView.js index 65077fb631..9baa2d533b 100644 --- a/js/apps/system/aardvark/frontend/js/views/modalView.js +++ b/js/apps/system/aardvark/frontend/js/views/modalView.js @@ -83,6 +83,12 @@ return createButtonStub(this.buttons.NEUTRAL, title, cb); }, + createDisabledButton: function(title) { + var disabledButton = createButtonStub(this.buttons.NEUTRAL, title); + disabledButton.disabled = true; + return disabledButton; + }, + createReadOnlyEntry: function(label, value, info) { return createTextStub(this.tables.READONLY, label, value, info); }, From 34f061f85cb71e51cd54433761dd059ecc0149f5 Mon Sep 17 00:00:00 2001 From: Heiko Kernbach Date: Fri, 4 Apr 2014 11:44:27 +0200 Subject: [PATCH 5/5] excluded libs from coverage tests --- .../aardvark/test/karma/karma_coverage.conf.js | 15 +++++++++++++-- .../test/karma/karma_coverage_local.conf.js | 17 ++++++++++++++--- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/js/apps/system/aardvark/test/karma/karma_coverage.conf.js b/js/apps/system/aardvark/test/karma/karma_coverage.conf.js index 61547c765e..2a6bfab427 100644 --- a/js/apps/system/aardvark/test/karma/karma_coverage.conf.js +++ b/js/apps/system/aardvark/test/karma/karma_coverage.conf.js @@ -27,8 +27,19 @@ module.exports = function(karma) { preprocessors: { 'test/karma/files.json': ['html2js'], - 'frontend/js/**/**.js': ['coverage'], - 'clusterFrontend/js/**/**.js': ['coverage'] + 'clusterFrontend/js/**/**.js': ['coverage'], + 'frontend/js/arango/**.js': ['coverage'], + 'frontend/js/bootstrap/**.js': ['coverage'], + 'frontend/js/client/**.js': ['coverage'], + 'frontend/js/collections/**.js': ['coverage'], + 'frontend/js/config/**.js': ['coverage'], + 'frontend/js/graphViewer/**.js': ['coverage'], + 'frontend/js/models/**.js': ['coverage'], + 'frontend/js/modules/**.js': ['coverage'], + 'frontend/js/routers/**.js': ['coverage'], + 'frontend/js/shell/**.js': ['coverage'], + 'frontend/js/templates/**.js': ['coverage'], + 'frontend/js/views/**.js': ['coverage'] }, // test results reporter to use diff --git a/js/apps/system/aardvark/test/karma/karma_coverage_local.conf.js b/js/apps/system/aardvark/test/karma/karma_coverage_local.conf.js index 98debacf70..aedb454b87 100644 --- a/js/apps/system/aardvark/test/karma/karma_coverage_local.conf.js +++ b/js/apps/system/aardvark/test/karma/karma_coverage_local.conf.js @@ -21,12 +21,23 @@ module.exports = function(karma) { // list of files to exclude exclude: [ - ], preprocessors: { - 'frontend/js/**/**.js': ['coverage'], - 'clusterFrontend/js/**/**.js': ['coverage'] + 'test/karma/files.json': ['html2js'], + 'clusterFrontend/js/**/**.js': ['coverage'], + 'frontend/js/arango/**.js': ['coverage'], + 'frontend/js/bootstrap/**.js': ['coverage'], + 'frontend/js/client/**.js': ['coverage'], + 'frontend/js/collections/**.js': ['coverage'], + 'frontend/js/config/**.js': ['coverage'], + 'frontend/js/graphViewer/**.js': ['coverage'], + 'frontend/js/models/**.js': ['coverage'], + 'frontend/js/modules/**.js': ['coverage'], + 'frontend/js/routers/**.js': ['coverage'], + 'frontend/js/shell/**.js': ['coverage'], + 'frontend/js/templates/**.js': ['coverage'], + 'frontend/js/views/**.js': ['coverage'] }, // test results reporter to use