You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apex.apache.org by da...@apache.org on 2015/11/30 22:06:22 UTC
[16/98] [abbrv] [partial] incubator-apex-malhar git commit: Removing
all web demos
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/e1a45507/web/demos/package/node_modules/mongodb/lib/mongodb/collection/query.js
----------------------------------------------------------------------
diff --git a/web/demos/package/node_modules/mongodb/lib/mongodb/collection/query.js b/web/demos/package/node_modules/mongodb/lib/mongodb/collection/query.js
deleted file mode 100644
index 6f6efc7..0000000
--- a/web/demos/package/node_modules/mongodb/lib/mongodb/collection/query.js
+++ /dev/null
@@ -1,153 +0,0 @@
-var ObjectID = require('bson').ObjectID
- , Scope = require('../scope').Scope
- , shared = require('./shared')
- , utils = require('../utils');
-
-var testForFields = {
- limit: 1, sort: 1, fields:1, skip: 1, hint: 1, explain: 1, snapshot: 1, timeout: 1, tailable: 1, tailableRetryInterval: 1
- , numberOfRetries: 1, awaitdata: 1, exhaust: 1, batchSize: 1, returnKey: 1, maxScan: 1, min: 1, max: 1, showDiskLoc: 1
- , comment: 1, raw: 1, readPreference: 1, partial: 1, read: 1, dbName: 1, oplogReplay: 1
-};
-
-//
-// Find method
-//
-var find = function find () {
- var options
- , args = Array.prototype.slice.call(arguments, 0)
- , has_callback = typeof args[args.length - 1] === 'function'
- , has_weird_callback = typeof args[0] === 'function'
- , callback = has_callback ? args.pop() : (has_weird_callback ? args.shift() : null)
- , len = args.length
- , selector = len >= 1 ? args[0] : {}
- , fields = len >= 2 ? args[1] : undefined;
-
- if(len === 1 && has_weird_callback) {
- // backwards compat for callback?, options case
- selector = {};
- options = args[0];
- }
-
- if(len === 2 && !Array.isArray(fields)) {
- var fieldKeys = Object.getOwnPropertyNames(fields);
- var is_option = false;
-
- for(var i = 0; i < fieldKeys.length; i++) {
- if(testForFields[fieldKeys[i]] != null) {
- is_option = true;
- break;
- }
- }
-
- if(is_option) {
- options = fields;
- fields = undefined;
- } else {
- options = {};
- }
- } else if(len === 2 && Array.isArray(fields) && !Array.isArray(fields[0])) {
- var newFields = {};
- // Rewrite the array
- for(var i = 0; i < fields.length; i++) {
- newFields[fields[i]] = 1;
- }
- // Set the fields
- fields = newFields;
- }
-
- if(3 === len) {
- options = args[2];
- }
-
- // Ensure selector is not null
- selector = selector == null ? {} : selector;
- // Validate correctness off the selector
- var object = selector;
- if(Buffer.isBuffer(object)) {
- var object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24;
- if(object_size != object.length) {
- var error = new Error("query selector raw message size does not match message header size [" + object.length + "] != [" + object_size + "]");
- error.name = 'MongoError';
- throw error;
- }
- }
-
- // Validate correctness of the field selector
- var object = fields;
- if(Buffer.isBuffer(object)) {
- var object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24;
- if(object_size != object.length) {
- var error = new Error("query fields raw message size does not match message header size [" + object.length + "] != [" + object_size + "]");
- error.name = 'MongoError';
- throw error;
- }
- }
-
- // Check special case where we are using an objectId
- if(selector instanceof ObjectID || (selector != null && selector._bsontype == 'ObjectID')) {
- selector = {_id:selector};
- }
-
- // If it's a serialized fields field we need to just let it through
- // user be warned it better be good
- if(options && options.fields && !(Buffer.isBuffer(options.fields))) {
- fields = {};
-
- if(Array.isArray(options.fields)) {
- if(!options.fields.length) {
- fields['_id'] = 1;
- } else {
- for (var i = 0, l = options.fields.length; i < l; i++) {
- fields[options.fields[i]] = 1;
- }
- }
- } else {
- fields = options.fields;
- }
- }
-
- if (!options) options = {};
- options.skip = len > 3 ? args[2] : options.skip ? options.skip : 0;
- options.limit = len > 3 ? args[3] : options.limit ? options.limit : 0;
- options.raw = options.raw != null && typeof options.raw === 'boolean' ? options.raw : this.raw;
- options.hint = options.hint != null ? shared.normalizeHintField(options.hint) : this.internalHint;
- options.timeout = len == 5 ? args[4] : typeof options.timeout === 'undefined' ? undefined : options.timeout;
- // If we have overridden slaveOk otherwise use the default db setting
- options.slaveOk = options.slaveOk != null ? options.slaveOk : this.db.slaveOk;
-
- // Set option
- var o = options;
- // Support read/readPreference
- if(o["read"] != null) o["readPreference"] = o["read"];
- // Set the read preference
- o.read = o["readPreference"] ? o.readPreference : this.readPreference;
- // Adjust slave ok if read preference is secondary or secondary only
- if(o.read == "secondary" || o.read == "secondaryOnly") options.slaveOk = true;
-
- // Set the selector
- o.selector = selector;
-
- // Create precursor
- var scope = new Scope(this, {}, fields, o);
- // Callback for backward compatibility
- if(callback) return callback(null, scope.find(selector));
- // Return the pre cursor object
- return scope.find(selector);
-};
-
-var findOne = function findOne () {
- var self = this;
- var args = Array.prototype.slice.call(arguments, 0);
- var callback = args.pop();
- var cursor = this.find.apply(this, args).limit(-1).batchSize(1);
-
- // Return the item
- cursor.nextObject(function(err, item) {
- if(err != null) return callback(utils.toError(err), null);
- callback(null, item);
- });
-};
-
-
-exports.find = find;
-exports.findOne = findOne;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/e1a45507/web/demos/package/node_modules/mongodb/lib/mongodb/collection/shared.js
----------------------------------------------------------------------
diff --git a/web/demos/package/node_modules/mongodb/lib/mongodb/collection/shared.js b/web/demos/package/node_modules/mongodb/lib/mongodb/collection/shared.js
deleted file mode 100644
index 77eae03..0000000
--- a/web/demos/package/node_modules/mongodb/lib/mongodb/collection/shared.js
+++ /dev/null
@@ -1,120 +0,0 @@
-// ***************************************************
-// Write concerns
-// ***************************************************
-var _hasWriteConcern = function(errorOptions) {
- return errorOptions == true
- || errorOptions.w > 0
- || errorOptions.w == 'majority'
- || errorOptions.j == true
- || errorOptions.journal == true
- || errorOptions.fsync == true
-}
-
-var _setWriteConcernHash = function(options) {
- var finalOptions = {};
- if(options.w != null) finalOptions.w = options.w;
- if(options.journal == true) finalOptions.j = options.journal;
- if(options.j == true) finalOptions.j = options.j;
- if(options.fsync == true) finalOptions.fsync = options.fsync;
- if(options.wtimeout != null) finalOptions.wtimeout = options.wtimeout;
- return finalOptions;
-}
-
-var _getWriteConcern = function(self, options) {
- // Final options
- var finalOptions = {w:1};
- // Local options verification
- if(options.w != null || typeof options.j == 'boolean' || typeof options.journal == 'boolean' || typeof options.fsync == 'boolean') {
- finalOptions = _setWriteConcernHash(options);
- } else if(typeof options.safe == "boolean") {
- finalOptions = {w: (options.safe ? 1 : 0)};
- } else if(options.safe != null && typeof options.safe == 'object') {
- finalOptions = _setWriteConcernHash(options.safe);
- } else if(self.opts.w != null || typeof self.opts.j == 'boolean' || typeof self.opts.journal == 'boolean' || typeof self.opts.fsync == 'boolean') {
- finalOptions = _setWriteConcernHash(self.opts);
- } else if(typeof self.opts.safe == "boolean") {
- finalOptions = {w: (self.opts.safe ? 1 : 0)};
- } else if(self.db.safe.w != null || typeof self.db.safe.j == 'boolean' || typeof self.db.safe.journal == 'boolean' || typeof self.db.safe.fsync == 'boolean') {
- finalOptions = _setWriteConcernHash(self.db.safe);
- } else if(self.db.options.w != null || typeof self.db.options.j == 'boolean' || typeof self.db.options.journal == 'boolean' || typeof self.db.options.fsync == 'boolean') {
- finalOptions = _setWriteConcernHash(self.db.options);
- } else if(typeof self.db.safe == "boolean") {
- finalOptions = {w: (self.db.safe ? 1 : 0)};
- }
-
- // Ensure we don't have an invalid combination of write concerns
- if(finalOptions.w < 1
- && (finalOptions.journal == true || finalOptions.j == true || finalOptions.fsync == true)) throw new Error("No acknowlegement using w < 1 cannot be combined with journal:true or fsync:true");
-
- // Return the options
- return finalOptions;
-}
-
-var _getReadConcern = function(self, options) {
- if(options.readPreference) return options.readPreference;
- if(self.readPreference) return self.readPreference;
- if(self.db.readPreference) return self.readPreference;
- return 'primary';
-}
-
-/**
- * @ignore
- */
-var checkCollectionName = function checkCollectionName (collectionName) {
- if('string' !== typeof collectionName) {
- throw Error("collection name must be a String");
- }
-
- if(!collectionName || collectionName.indexOf('..') != -1) {
- throw Error("collection names cannot be empty");
- }
-
- if(collectionName.indexOf('$') != -1 &&
- collectionName.match(/((^\$cmd)|(oplog\.\$main))/) == null) {
- throw Error("collection names must not contain '$'");
- }
-
- if(collectionName.match(/^\.|\.$/) != null) {
- throw Error("collection names must not start or end with '.'");
- }
-
- // Validate that we are not passing 0x00 in the colletion name
- if(!!~collectionName.indexOf("\x00")) {
- throw new Error("collection names cannot contain a null character");
- }
-};
-
-
-/**
- * Normalizes a `hint` argument.
- *
- * @param {String|Object|Array} hint
- * @return {Object}
- * @api private
- */
-var normalizeHintField = function normalizeHintField(hint) {
- var finalHint = null;
-
- if(typeof hint == 'string') {
- finalHint = hint;
- } else if(Array.isArray(hint)) {
- finalHint = {};
-
- hint.forEach(function(param) {
- finalHint[param] = 1;
- });
- } else if(hint != null && typeof hint == 'object') {
- finalHint = {};
- for (var name in hint) {
- finalHint[name] = hint[name];
- }
- }
-
- return finalHint;
-};
-
-exports._getWriteConcern = _getWriteConcern;
-exports._hasWriteConcern = _hasWriteConcern;
-exports._getReadConcern = _getReadConcern;
-exports.checkCollectionName = checkCollectionName;
-exports.normalizeHintField = normalizeHintField;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/e1a45507/web/demos/package/node_modules/mongodb/lib/mongodb/command_cursor.js
----------------------------------------------------------------------
diff --git a/web/demos/package/node_modules/mongodb/lib/mongodb/command_cursor.js b/web/demos/package/node_modules/mongodb/lib/mongodb/command_cursor.js
deleted file mode 100644
index e973e2c..0000000
--- a/web/demos/package/node_modules/mongodb/lib/mongodb/command_cursor.js
+++ /dev/null
@@ -1,309 +0,0 @@
-var Long = require('bson').Long
- , GetMoreCommand = require('./commands/get_more_command').GetMoreCommand;
-
-var CommandCursor = function(db, collection, command, options) {
- // Ensure empty options if no options passed
- options = options || {};
-
- // Default cursor id is 0
- var cursorId = Long.fromInt(0);
- var zeroCursor = Long.fromInt(0);
- var state = 'init';
-
- // Hardcode batch size
- command.cursor.batchSize = 1;
-
- // BatchSize
- var batchSize = command.cursor.batchSize || 0;
- var raw = options.raw || false;
- var readPreference = options.readPreference || 'primary';
-
- // Checkout a connection
- var connection = db.serverConfig.checkoutReader(readPreference);
- // MaxTimeMS
- var maxTimeMS = options.maxTimeMS;
-
- // Contains all the items
- var items = null;
-
- // Execute getmore
- var getMore = function(callback) {
- // Resolve more of the cursor using the getMore command
- var getMoreCommand = new GetMoreCommand(db
- , db.databaseName + "." + collection.collectionName
- , batchSize
- , cursorId
- );
-
- // Set up options
- var command_options = { connection:connection };
-
- // Execute the getMore Command
- db._executeQueryCommand(getMoreCommand, command_options, function(err, result) {
- if(err) {
- items = [];
- state = 'closed';
- return callback(err);
- }
-
- // Return all the documents
- callback(null, result);
- });
- }
-
- var exhaustGetMore = function(callback) {
- getMore(function(err, result) {
- if(err) {
- items = [];
- state = 'closed';
- return callback(err, null);
- }
-
- // Add the items
- items = items.concat(result.documents);
-
- // Set the cursor id
- cursorId = result.cursorId;
- if(typeof cursorId == 'number') cursorId = Long.fromNumber(cursorId);
-
- // If the cursor is done
- if(result.cursorId.equals(zeroCursor)) {
- return callback(null, items);
- }
-
- // Check the cursor id
- exhaustGetMore(callback);
- });
- }
-
- var exhaustGetMoreEach = function(callback) {
- getMore(function(err, result) {
- if(err) {
- items = [];
- state = 'closed';
- return callback(err, null);
- }
-
- // Add the items
- items = result.documents;
-
- // Emit all the items in the first batch
- while(items.length > 0) {
- callback(null, items.shift());
- }
-
- // Set the cursor id
- cursorId = result.cursorId;
- if(typeof cursorId == 'number') cursorId = Long.fromNumber(cursorId);
-
- // If the cursor is done
- if(result.cursorId.equals(zeroCursor)) {
- state = "closed";
- return callback(null, null);
- }
-
- // Check the cursor id
- exhaustGetMoreEach(callback);
- });
- }
-
- //
- // Get all the elements
- //
- this.get = function(options, callback) {
- if(typeof options == 'function') {
- callback = options;
- options = {};
- }
-
- // Set the connection to the passed in one if it's provided
- connection = options.connection ? options.connection : connection;
-
- // Command options
- var _options = {connection:connection};
- if(typeof maxTimeMS == 'number') _options.maxTimeMS = maxTimeMS;
-
- // Execute the internal command first
- db.command(command, _options, function(err, result) {
- if(err) {
- state = 'closed';
- return callback(err, null);
- }
-
- // Retrieve the cursor id
- cursorId = result.cursor.id;
- if(typeof cursorId == 'number') cursorId = Long.fromNumber(cursorId);
-
- // Validate cursorId
- if(cursorId.equals(zeroCursor)) {
- return callback(null, result.cursor.firstBatch);
- };
-
- // Add to the items
- items = result.cursor.firstBatch;
- // Execute the getMore
- exhaustGetMore(callback);
- });
- }
-
- //
- // Iterate over all the items
- //
- this.each = function(options, callback) {
- if(typeof options == 'function') {
- callback = options;
- options = {};
- }
-
- // If it's a closed cursor return error
- if(this.isClosed()) return callback(new Error("cursor is closed"));
- // Set the connection to the passed in one if it's provided
- connection = options.connection ? options.connection : connection;
-
- // Command options
- var _options = {connection:connection};
- if(typeof maxTimeMS == 'number') _options.maxTimeMS = maxTimeMS;
-
- // Execute the internal command first
- db.command(command, _options, function(err, result) {
- if(err) {
- state = 'closed';
- return callback(err, null);
- }
-
- // Get all the items
- items = result.cursor.firstBatch;
-
- // Emit all the items in the first batch
- while(items.length > 0) {
- callback(null, items.shift());
- }
-
- // Retrieve the cursor id
- cursorId = result.cursor.id;
- if(typeof cursorId == 'number') cursorId = Long.fromNumber(cursorId);
-
- // If no cursor we just finish up the current batch of items
- if(cursorId.equals(zeroCursor)) {
- state = 'closed';
- return callback(null, null);
- }
-
- // Emit each until no more getMore's
- exhaustGetMoreEach(callback);
- });
- }
-
- //
- // Get the next object
- //
- this.next = function(options, callback) {
- if(typeof options == 'function') {
- callback = options;
- options = {};
- }
-
- // If it's a closed cursor return error
- if(this.isClosed()) return callback(new Error("cursor is closed"));
-
- // Set the connection to the passed in one if it's provided
- connection = options.connection ? options.connection : connection;
-
- // Command options
- var _options = {connection:connection};
- if(typeof maxTimeMS == 'number') _options.maxTimeMS = maxTimeMS;
-
- // Execute the internal command first
- if(!items) {
- db.command(command, _options, function(err, result) {
- if(err) {
- state = 'closed';
- return callback(err, null);
- }
-
- // Retrieve the cursor id
- cursorId = result.cursor.id;
- if(typeof cursorId == 'number') cursorId = Long.fromNumber(cursorId);
- // Get the first batch results
- items = result.cursor.firstBatch;
- // We have items return the first one
- if(items.length > 0) {
- callback(null, items.shift());
- } else {
- state = 'closed';
- callback(null, null);
- }
- });
- } else if(items.length > 0) {
- callback(null, items.shift());
- } else if(items.length == 0 && cursorId.equals(zeroCursor)) {
- state = 'closed';
- callback(null, null);
- } else {
- // Execute a getMore
- getMore(function(err, result) {
- if(err) {
- state = 'closed';
- return callback(err, null);
- }
-
- // Set the cursor id
- cursorId = result.cursorId;
- if(typeof cursorId == 'number') cursorId = Long.fromNumber(cursorId);
-
- // Add the items
- items = items.concat(result.documents);
- // If no more items
- if(items.length == 0) {
- state = 'closed';
- return callback(null, null);
- }
-
- // Return the item
- return callback(null, items.shift());
- })
- }
- }
-
- // Validate if the cursor is closed
- this.isClosed = function() {
- return state == 'closed';
- }
-
- // Allow us to set the MaxTimeMS
- this.maxTimeMS = function(_maxTimeMS) {
- maxTimeMS = _maxTimeMS;
- }
-
- // Close the cursor sending a kill cursor command if needed
- this.close = function(options, callback) {
- if(typeof options == 'function') {
- callback = options;
- options = {};
- }
-
- // Close the cursor if not needed
- if(cursorId instanceof Long && cursorId.greaterThan(Long.fromInt(0))) {
- try {
- var command = new KillCursorCommand(this.db, [cursorId]);
- // Added an empty callback to ensure we don't throw any null exceptions
- db._executeQueryCommand(command, {connection:connection});
- } catch(err) {}
- }
-
- // Null out the connection
- connection = null;
- // Reset cursor id
- cursorId = Long.fromInt(0);
- // Set to closed status
- state = 'closed';
- // Clear out all the items
- items = null;
-
- if(callback) {
- callback(null, null);
- }
- }
-}
-
-exports.CommandCursor = CommandCursor;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/e1a45507/web/demos/package/node_modules/mongodb/lib/mongodb/commands/base_command.js
----------------------------------------------------------------------
diff --git a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/base_command.js b/web/demos/package/node_modules/mongodb/lib/mongodb/commands/base_command.js
deleted file mode 100644
index 9558582..0000000
--- a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/base_command.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- Base object used for common functionality
-**/
-var BaseCommand = exports.BaseCommand = function BaseCommand() {
-};
-
-var id = 1;
-BaseCommand.prototype.getRequestId = function getRequestId() {
- if (!this.requestId) this.requestId = id++;
- return this.requestId;
-};
-
-BaseCommand.prototype.setMongosReadPreference = function setMongosReadPreference(readPreference, tags) {}
-
-BaseCommand.prototype.updateRequestId = function() {
- this.requestId = id++;
- return this.requestId;
-};
-
-// OpCodes
-BaseCommand.OP_REPLY = 1;
-BaseCommand.OP_MSG = 1000;
-BaseCommand.OP_UPDATE = 2001;
-BaseCommand.OP_INSERT = 2002;
-BaseCommand.OP_GET_BY_OID = 2003;
-BaseCommand.OP_QUERY = 2004;
-BaseCommand.OP_GET_MORE = 2005;
-BaseCommand.OP_DELETE = 2006;
-BaseCommand.OP_KILL_CURSORS = 2007;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/e1a45507/web/demos/package/node_modules/mongodb/lib/mongodb/commands/db_command.js
----------------------------------------------------------------------
diff --git a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/db_command.js b/web/demos/package/node_modules/mongodb/lib/mongodb/commands/db_command.js
deleted file mode 100644
index 1f5b065..0000000
--- a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/db_command.js
+++ /dev/null
@@ -1,253 +0,0 @@
-var QueryCommand = require('./query_command').QueryCommand,
- InsertCommand = require('./insert_command').InsertCommand,
- inherits = require('util').inherits,
- utils = require('../utils'),
- crypto = require('crypto');
-
-/**
- Db Command
-**/
-var DbCommand = exports.DbCommand = function(dbInstance, collectionName, queryOptions, numberToSkip, numberToReturn, query, returnFieldSelector, options) {
- QueryCommand.call(this);
- this.collectionName = collectionName;
- this.queryOptions = queryOptions;
- this.numberToSkip = numberToSkip;
- this.numberToReturn = numberToReturn;
- this.query = query;
- this.returnFieldSelector = returnFieldSelector;
- this.db = dbInstance;
-
- // Set the slave ok bit
- if(this.db && this.db.slaveOk) {
- this.queryOptions |= QueryCommand.OPTS_SLAVE;
- }
-
- // Make sure we don't get a null exception
- options = options == null ? {} : options;
-
- // Allow for overriding the BSON checkKeys function
- this.checkKeys = typeof options['checkKeys'] == 'boolean' ? options["checkKeys"] : true;
-
- // Let us defined on a command basis if we want functions to be serialized or not
- if(options['serializeFunctions'] != null && options['serializeFunctions']) {
- this.serializeFunctions = true;
- }
-};
-
-inherits(DbCommand, QueryCommand);
-
-// Constants
-DbCommand.SYSTEM_NAMESPACE_COLLECTION = "system.namespaces";
-DbCommand.SYSTEM_INDEX_COLLECTION = "system.indexes";
-DbCommand.SYSTEM_PROFILE_COLLECTION = "system.profile";
-DbCommand.SYSTEM_USER_COLLECTION = "system.users";
-DbCommand.SYSTEM_COMMAND_COLLECTION = "$cmd";
-DbCommand.SYSTEM_JS_COLLECTION = "system.js";
-
-// New commands
-DbCommand.NcreateIsMasterCommand = function(db, databaseName) {
- return new DbCommand(db, databaseName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'ismaster':1}, null);
-};
-
-// Provide constructors for different db commands
-DbCommand.createIsMasterCommand = function(db) {
- return new DbCommand(db, db.databaseName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'ismaster':1}, null);
-};
-
-DbCommand.createCollectionInfoCommand = function(db, selector) {
- return new DbCommand(db, db.databaseName + "." + DbCommand.SYSTEM_NAMESPACE_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, 0, selector, null);
-};
-
-DbCommand.createGetNonceCommand = function(db, options) {
- return new DbCommand(db, db.databaseName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'getnonce':1}, null);
-};
-
-DbCommand.createAuthenticationCommand = function(db, username, password, nonce, authdb) {
- // Use node md5 generator
- var md5 = crypto.createHash('md5');
- // Generate keys used for authentication
- md5.update(username + ":mongo:" + password);
- var hash_password = md5.digest('hex');
- // Final key
- md5 = crypto.createHash('md5');
- md5.update(nonce + username + hash_password);
- var key = md5.digest('hex');
- // Creat selector
- var selector = {'authenticate':1, 'user':username, 'nonce':nonce, 'key':key};
- // Create db command
- return new DbCommand(db, authdb + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NONE, 0, -1, selector, null);
-};
-
-DbCommand.createLogoutCommand = function(db) {
- return new DbCommand(db, db.databaseName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'logout':1}, null);
-};
-
-DbCommand.createCreateCollectionCommand = function(db, collectionName, options) {
- var selector = {'create':collectionName};
- // Modify the options to ensure correct behaviour
- for(var name in options) {
- if(options[name] != null && options[name].constructor != Function) selector[name] = options[name];
- }
- // Execute the command
- return new DbCommand(db, db.databaseName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, selector, null);
-};
-
-DbCommand.createDropCollectionCommand = function(db, collectionName) {
- return new DbCommand(db, db.databaseName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'drop':collectionName}, null);
-};
-
-DbCommand.createRenameCollectionCommand = function(db, fromCollectionName, toCollectionName, options) {
- var renameCollection = db.databaseName + "." + fromCollectionName;
- var toCollection = db.databaseName + "." + toCollectionName;
- var dropTarget = options && options.dropTarget ? options.dropTarget : false;
- return new DbCommand(db, "admin." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'renameCollection':renameCollection, 'to':toCollection, 'dropTarget':dropTarget}, null);
-};
-
-DbCommand.createGetLastErrorCommand = function(options, db) {
-
- if (typeof db === 'undefined') {
- db = options;
- options = {};
- }
- // Final command
- var command = {'getlasterror':1};
- // If we have an options Object let's merge in the fields (fsync/wtimeout/w)
- if('object' === typeof options) {
- for(var name in options) {
- command[name] = options[name]
- }
- }
-
- // Special case for w == 1, remove the w
- if(1 == command.w) {
- delete command.w;
- }
-
- // Execute command
- return new DbCommand(db, db.databaseName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, command, null);
-};
-
-DbCommand.createGetLastStatusCommand = DbCommand.createGetLastErrorCommand;
-
-DbCommand.createGetPreviousErrorsCommand = function(db) {
- return new DbCommand(db, db.databaseName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'getpreverror':1}, null);
-};
-
-DbCommand.createResetErrorHistoryCommand = function(db) {
- return new DbCommand(db, db.databaseName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'reseterror':1}, null);
-};
-
-DbCommand.createCreateIndexCommand = function(db, collectionName, fieldOrSpec, options) {
- var fieldHash = {};
- var indexes = [];
- var keys;
-
- // Get all the fields accordingly
- if('string' == typeof fieldOrSpec) {
- // 'type'
- indexes.push(fieldOrSpec + '_' + 1);
- fieldHash[fieldOrSpec] = 1;
-
- } else if(utils.isArray(fieldOrSpec)) {
-
- fieldOrSpec.forEach(function(f) {
- if('string' == typeof f) {
- // [{location:'2d'}, 'type']
- indexes.push(f + '_' + 1);
- fieldHash[f] = 1;
- } else if(utils.isArray(f)) {
- // [['location', '2d'],['type', 1]]
- indexes.push(f[0] + '_' + (f[1] || 1));
- fieldHash[f[0]] = f[1] || 1;
- } else if(utils.isObject(f)) {
- // [{location:'2d'}, {type:1}]
- keys = Object.keys(f);
- keys.forEach(function(k) {
- indexes.push(k + '_' + f[k]);
- fieldHash[k] = f[k];
- });
- } else {
- // undefined (ignore)
- }
- });
-
- } else if(utils.isObject(fieldOrSpec)) {
- // {location:'2d', type:1}
- keys = Object.keys(fieldOrSpec);
- keys.forEach(function(key) {
- indexes.push(key + '_' + fieldOrSpec[key]);
- fieldHash[key] = fieldOrSpec[key];
- });
- }
-
- // Generate the index name
- var indexName = typeof options.name == 'string'
- ? options.name
- : indexes.join("_");
-
- var selector = {
- 'ns': db.databaseName + "." + collectionName,
- 'key': fieldHash,
- 'name': indexName
- }
-
- // Ensure we have a correct finalUnique
- var finalUnique = options == null || 'object' === typeof options
- ? false
- : options;
-
- // Set up options
- options = options == null || typeof options == 'boolean'
- ? {}
- : options;
-
- // Add all the options
- var keys = Object.keys(options);
- for(var i = 0; i < keys.length; i++) {
- selector[keys[i]] = options[keys[i]];
- }
-
- if(selector['unique'] == null)
- selector['unique'] = finalUnique;
-
- var name = db.databaseName + "." + DbCommand.SYSTEM_INDEX_COLLECTION;
- var cmd = new InsertCommand(db, name, false);
- return cmd.add(selector);
-};
-
-DbCommand.logoutCommand = function(db, command_hash, options) {
- var dbName = options != null && options['authdb'] != null ? options['authdb'] : db.databaseName;
- return new DbCommand(db, dbName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, command_hash, null);
-}
-
-DbCommand.createDropIndexCommand = function(db, collectionName, indexName) {
- return new DbCommand(db, db.databaseName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'deleteIndexes':collectionName, 'index':indexName}, null);
-};
-
-DbCommand.createReIndexCommand = function(db, collectionName) {
- return new DbCommand(db, db.databaseName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'reIndex':collectionName}, null);
-};
-
-DbCommand.createDropDatabaseCommand = function(db) {
- return new DbCommand(db, db.databaseName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, {'dropDatabase':1}, null);
-};
-
-DbCommand.createDbCommand = function(db, command_hash, options, auth_db) {
- var db_name = (auth_db ? auth_db : db.databaseName) + "." + DbCommand.SYSTEM_COMMAND_COLLECTION;
- options = options == null ? {checkKeys: false} : options;
- return new DbCommand(db, db_name, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, command_hash, null, options);
-};
-
-DbCommand.createAdminDbCommand = function(db, command_hash) {
- return new DbCommand(db, "admin." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT, 0, -1, command_hash, null);
-};
-
-DbCommand.createAdminDbCommandSlaveOk = function(db, command_hash) {
- return new DbCommand(db, "admin." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT | QueryCommand.OPTS_SLAVE, 0, -1, command_hash, null);
-};
-
-DbCommand.createDbSlaveOkCommand = function(db, command_hash, options) {
- options = options == null ? {checkKeys: false} : options;
- var dbName = options.dbName ? options.dbName : db.databaseName;
- return new DbCommand(db, dbName + "." + DbCommand.SYSTEM_COMMAND_COLLECTION, QueryCommand.OPTS_NO_CURSOR_TIMEOUT | QueryCommand.OPTS_SLAVE, 0, -1, command_hash, null, options);
-};
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/e1a45507/web/demos/package/node_modules/mongodb/lib/mongodb/commands/delete_command.js
----------------------------------------------------------------------
diff --git a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/delete_command.js b/web/demos/package/node_modules/mongodb/lib/mongodb/commands/delete_command.js
deleted file mode 100644
index 61a37ed..0000000
--- a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/delete_command.js
+++ /dev/null
@@ -1,129 +0,0 @@
-var BaseCommand = require('./base_command').BaseCommand,
- inherits = require('util').inherits;
-
-/**
- Insert Document Command
-**/
-var DeleteCommand = exports.DeleteCommand = function(db, collectionName, selector, flags) {
- BaseCommand.call(this);
-
- // Validate correctness off the selector
- var object = selector;
- if(Buffer.isBuffer(object)) {
- var object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24;
- if(object_size != object.length) {
- var error = new Error("delete raw message size does not match message header size [" + object.length + "] != [" + object_size + "]");
- error.name = 'MongoError';
- throw error;
- }
- }
-
- this.flags = flags;
- this.collectionName = collectionName;
- this.selector = selector;
- this.db = db;
-};
-
-inherits(DeleteCommand, BaseCommand);
-
-DeleteCommand.OP_DELETE = 2006;
-
-/*
-struct {
- MsgHeader header; // standard message header
- int32 ZERO; // 0 - reserved for future use
- cstring fullCollectionName; // "dbname.collectionname"
- int32 ZERO; // 0 - reserved for future use
- mongo.BSON selector; // query object. See below for details.
-}
-*/
-DeleteCommand.prototype.toBinary = function(bsonSettings) {
- // Validate that we are not passing 0x00 in the colletion name
- if(!!~this.collectionName.indexOf("\x00")) {
- throw new Error("namespace cannot contain a null character");
- }
-
- // Calculate total length of the document
- var totalLengthOfCommand = 4 + Buffer.byteLength(this.collectionName) + 1 + 4 + this.db.bson.calculateObjectSize(this.selector, false, true) + (4 * 4);
-
- // Enforce maximum bson size
- if(!bsonSettings.disableDriverBSONSizeCheck
- && totalLengthOfCommand > bsonSettings.maxBsonSize)
- throw new Error("Document exceeds maximum allowed bson size of " + bsonSettings.maxBsonSize + " bytes");
-
- if(bsonSettings.disableDriverBSONSizeCheck
- && totalLengthOfCommand > bsonSettings.maxMessageSizeBytes)
- throw new Error("Command exceeds maximum message size of " + bsonSettings.maxMessageSizeBytes + " bytes");
-
- // Let's build the single pass buffer command
- var _index = 0;
- var _command = new Buffer(totalLengthOfCommand);
- // Write the header information to the buffer
- _command[_index + 3] = (totalLengthOfCommand >> 24) & 0xff;
- _command[_index + 2] = (totalLengthOfCommand >> 16) & 0xff;
- _command[_index + 1] = (totalLengthOfCommand >> 8) & 0xff;
- _command[_index] = totalLengthOfCommand & 0xff;
- // Adjust index
- _index = _index + 4;
- // Write the request ID
- _command[_index + 3] = (this.requestId >> 24) & 0xff;
- _command[_index + 2] = (this.requestId >> 16) & 0xff;
- _command[_index + 1] = (this.requestId >> 8) & 0xff;
- _command[_index] = this.requestId & 0xff;
- // Adjust index
- _index = _index + 4;
- // Write zero
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- // Write the op_code for the command
- _command[_index + 3] = (DeleteCommand.OP_DELETE >> 24) & 0xff;
- _command[_index + 2] = (DeleteCommand.OP_DELETE >> 16) & 0xff;
- _command[_index + 1] = (DeleteCommand.OP_DELETE >> 8) & 0xff;
- _command[_index] = DeleteCommand.OP_DELETE & 0xff;
- // Adjust index
- _index = _index + 4;
-
- // Write zero
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
-
- // Write the collection name to the command
- _index = _index + _command.write(this.collectionName, _index, 'utf8') + 1;
- _command[_index - 1] = 0;
-
- // Write the flags
- _command[_index + 3] = (this.flags >> 24) & 0xff;
- _command[_index + 2] = (this.flags >> 16) & 0xff;
- _command[_index + 1] = (this.flags >> 8) & 0xff;
- _command[_index] = this.flags & 0xff;
- // Adjust index
- _index = _index + 4;
-
- // Document binary length
- var documentLength = 0
-
- // Serialize the selector
- // If we are passing a raw buffer, do minimal validation
- if(Buffer.isBuffer(this.selector)) {
- documentLength = this.selector.length;
- // Copy the data into the current buffer
- this.selector.copy(_command, _index);
- } else {
- documentLength = this.db.bson.serializeWithBufferAndIndex(this.selector, false, _command, _index) - _index + 1;
- }
-
- // Write the length to the document
- _command[_index + 3] = (documentLength >> 24) & 0xff;
- _command[_index + 2] = (documentLength >> 16) & 0xff;
- _command[_index + 1] = (documentLength >> 8) & 0xff;
- _command[_index] = documentLength & 0xff;
- // Update index in buffer
- _index = _index + documentLength;
- // Add terminating 0 for the object
- _command[_index - 1] = 0;
- return _command;
-};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/e1a45507/web/demos/package/node_modules/mongodb/lib/mongodb/commands/get_more_command.js
----------------------------------------------------------------------
diff --git a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/get_more_command.js b/web/demos/package/node_modules/mongodb/lib/mongodb/commands/get_more_command.js
deleted file mode 100644
index 1b6b172..0000000
--- a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/get_more_command.js
+++ /dev/null
@@ -1,88 +0,0 @@
-var BaseCommand = require('./base_command').BaseCommand,
- inherits = require('util').inherits,
- binaryutils = require('../utils');
-
-/**
- Get More Document Command
-**/
-var GetMoreCommand = exports.GetMoreCommand = function(db, collectionName, numberToReturn, cursorId) {
- BaseCommand.call(this);
-
- this.collectionName = collectionName;
- this.numberToReturn = numberToReturn;
- this.cursorId = cursorId;
- this.db = db;
-};
-
-inherits(GetMoreCommand, BaseCommand);
-
-GetMoreCommand.OP_GET_MORE = 2005;
-
-GetMoreCommand.prototype.toBinary = function() {
- // Validate that we are not passing 0x00 in the colletion name
- if(!!~this.collectionName.indexOf("\x00")) {
- throw new Error("namespace cannot contain a null character");
- }
-
- // Calculate total length of the document
- var totalLengthOfCommand = 4 + Buffer.byteLength(this.collectionName) + 1 + 4 + 8 + (4 * 4);
- // Let's build the single pass buffer command
- var _index = 0;
- var _command = new Buffer(totalLengthOfCommand);
- // Write the header information to the buffer
- _command[_index++] = totalLengthOfCommand & 0xff;
- _command[_index++] = (totalLengthOfCommand >> 8) & 0xff;
- _command[_index++] = (totalLengthOfCommand >> 16) & 0xff;
- _command[_index++] = (totalLengthOfCommand >> 24) & 0xff;
-
- // Write the request ID
- _command[_index++] = this.requestId & 0xff;
- _command[_index++] = (this.requestId >> 8) & 0xff;
- _command[_index++] = (this.requestId >> 16) & 0xff;
- _command[_index++] = (this.requestId >> 24) & 0xff;
-
- // Write zero
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
-
- // Write the op_code for the command
- _command[_index++] = GetMoreCommand.OP_GET_MORE & 0xff;
- _command[_index++] = (GetMoreCommand.OP_GET_MORE >> 8) & 0xff;
- _command[_index++] = (GetMoreCommand.OP_GET_MORE >> 16) & 0xff;
- _command[_index++] = (GetMoreCommand.OP_GET_MORE >> 24) & 0xff;
-
- // Write zero
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
-
- // Write the collection name to the command
- _index = _index + _command.write(this.collectionName, _index, 'utf8') + 1;
- _command[_index - 1] = 0;
-
- // Number of documents to return
- _command[_index++] = this.numberToReturn & 0xff;
- _command[_index++] = (this.numberToReturn >> 8) & 0xff;
- _command[_index++] = (this.numberToReturn >> 16) & 0xff;
- _command[_index++] = (this.numberToReturn >> 24) & 0xff;
-
- // Encode the cursor id
- var low_bits = this.cursorId.getLowBits();
- // Encode low bits
- _command[_index++] = low_bits & 0xff;
- _command[_index++] = (low_bits >> 8) & 0xff;
- _command[_index++] = (low_bits >> 16) & 0xff;
- _command[_index++] = (low_bits >> 24) & 0xff;
-
- var high_bits = this.cursorId.getHighBits();
- // Encode high bits
- _command[_index++] = high_bits & 0xff;
- _command[_index++] = (high_bits >> 8) & 0xff;
- _command[_index++] = (high_bits >> 16) & 0xff;
- _command[_index++] = (high_bits >> 24) & 0xff;
- // Return command
- return _command;
-};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/e1a45507/web/demos/package/node_modules/mongodb/lib/mongodb/commands/insert_command.js
----------------------------------------------------------------------
diff --git a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/insert_command.js b/web/demos/package/node_modules/mongodb/lib/mongodb/commands/insert_command.js
deleted file mode 100644
index c6e51e9..0000000
--- a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/insert_command.js
+++ /dev/null
@@ -1,161 +0,0 @@
-var BaseCommand = require('./base_command').BaseCommand,
- inherits = require('util').inherits;
-
-/**
- Insert Document Command
-**/
-var InsertCommand = exports.InsertCommand = function(db, collectionName, checkKeys, options) {
- BaseCommand.call(this);
-
- this.collectionName = collectionName;
- this.documents = [];
- this.checkKeys = checkKeys == null ? true : checkKeys;
- this.db = db;
- this.flags = 0;
- this.serializeFunctions = false;
-
- // Ensure valid options hash
- options = options == null ? {} : options;
-
- // Check if we have keepGoing set -> set flag if it's the case
- if(options['keepGoing'] != null && options['keepGoing']) {
- // This will finish inserting all non-index violating documents even if it returns an error
- this.flags = 1;
- }
-
- // Check if we have keepGoing set -> set flag if it's the case
- if(options['continueOnError'] != null && options['continueOnError']) {
- // This will finish inserting all non-index violating documents even if it returns an error
- this.flags = 1;
- }
-
- // Let us defined on a command basis if we want functions to be serialized or not
- if(options['serializeFunctions'] != null && options['serializeFunctions']) {
- this.serializeFunctions = true;
- }
-};
-
-inherits(InsertCommand, BaseCommand);
-
-// OpCodes
-InsertCommand.OP_INSERT = 2002;
-
-InsertCommand.prototype.add = function(document) {
- if(Buffer.isBuffer(document)) {
- var object_size = document[0] | document[1] << 8 | document[2] << 16 | document[3] << 24;
- if(object_size != document.length) {
- var error = new Error("insert raw message size does not match message header size [" + document.length + "] != [" + object_size + "]");
- error.name = 'MongoError';
- throw error;
- }
- }
-
- this.documents.push(document);
- return this;
-};
-
-/*
-struct {
- MsgHeader header; // standard message header
- int32 ZERO; // 0 - reserved for future use
- cstring fullCollectionName; // "dbname.collectionname"
- BSON[] documents; // one or more documents to insert into the collection
-}
-*/
-InsertCommand.prototype.toBinary = function(bsonSettings) {
- // Validate that we are not passing 0x00 in the colletion name
- if(!!~this.collectionName.indexOf("\x00")) {
- throw new Error("namespace cannot contain a null character");
- }
-
- // Calculate total length of the document
- var totalLengthOfCommand = 4 + Buffer.byteLength(this.collectionName) + 1 + (4 * 4);
- // var docLength = 0
- for(var i = 0; i < this.documents.length; i++) {
- if(Buffer.isBuffer(this.documents[i])) {
- totalLengthOfCommand += this.documents[i].length;
- } else {
- // Calculate size of document
- totalLengthOfCommand += this.db.bson.calculateObjectSize(this.documents[i], this.serializeFunctions, true);
- }
- }
-
- // Enforce maximum bson size
- if(!bsonSettings.disableDriverBSONSizeCheck
- && totalLengthOfCommand > bsonSettings.maxBsonSize)
- throw new Error("Document exceeds maximum allowed bson size of " + bsonSettings.maxBsonSize + " bytes");
-
- if(bsonSettings.disableDriverBSONSizeCheck
- && totalLengthOfCommand > bsonSettings.maxMessageSizeBytes)
- throw new Error("Command exceeds maximum message size of " + bsonSettings.maxMessageSizeBytes + " bytes");
-
- // Let's build the single pass buffer command
- var _index = 0;
- var _command = new Buffer(totalLengthOfCommand);
- // Write the header information to the buffer
- _command[_index + 3] = (totalLengthOfCommand >> 24) & 0xff;
- _command[_index + 2] = (totalLengthOfCommand >> 16) & 0xff;
- _command[_index + 1] = (totalLengthOfCommand >> 8) & 0xff;
- _command[_index] = totalLengthOfCommand & 0xff;
- // Adjust index
- _index = _index + 4;
- // Write the request ID
- _command[_index + 3] = (this.requestId >> 24) & 0xff;
- _command[_index + 2] = (this.requestId >> 16) & 0xff;
- _command[_index + 1] = (this.requestId >> 8) & 0xff;
- _command[_index] = this.requestId & 0xff;
- // Adjust index
- _index = _index + 4;
- // Write zero
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- // Write the op_code for the command
- _command[_index + 3] = (InsertCommand.OP_INSERT >> 24) & 0xff;
- _command[_index + 2] = (InsertCommand.OP_INSERT >> 16) & 0xff;
- _command[_index + 1] = (InsertCommand.OP_INSERT >> 8) & 0xff;
- _command[_index] = InsertCommand.OP_INSERT & 0xff;
- // Adjust index
- _index = _index + 4;
- // Write flags if any
- _command[_index + 3] = (this.flags >> 24) & 0xff;
- _command[_index + 2] = (this.flags >> 16) & 0xff;
- _command[_index + 1] = (this.flags >> 8) & 0xff;
- _command[_index] = this.flags & 0xff;
- // Adjust index
- _index = _index + 4;
- // Write the collection name to the command
- _index = _index + _command.write(this.collectionName, _index, 'utf8') + 1;
- _command[_index - 1] = 0;
-
- // Write all the bson documents to the buffer at the index offset
- for(var i = 0; i < this.documents.length; i++) {
- // Document binary length
- var documentLength = 0
- var object = this.documents[i];
-
- // Serialize the selector
- // If we are passing a raw buffer, do minimal validation
- if(Buffer.isBuffer(object)) {
- documentLength = object.length;
- // Copy the data into the current buffer
- object.copy(_command, _index);
- } else {
- // Serialize the document straight to the buffer
- documentLength = this.db.bson.serializeWithBufferAndIndex(object, this.checkKeys, _command, _index, this.serializeFunctions) - _index + 1;
- }
-
- // Write the length to the document
- _command[_index + 3] = (documentLength >> 24) & 0xff;
- _command[_index + 2] = (documentLength >> 16) & 0xff;
- _command[_index + 1] = (documentLength >> 8) & 0xff;
- _command[_index] = documentLength & 0xff;
- // Update index in buffer
- _index = _index + documentLength;
- // Add terminating 0 for the object
- _command[_index - 1] = 0;
- }
-
- return _command;
-};
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/e1a45507/web/demos/package/node_modules/mongodb/lib/mongodb/commands/kill_cursor_command.js
----------------------------------------------------------------------
diff --git a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/kill_cursor_command.js b/web/demos/package/node_modules/mongodb/lib/mongodb/commands/kill_cursor_command.js
deleted file mode 100644
index d8ccb0c..0000000
--- a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/kill_cursor_command.js
+++ /dev/null
@@ -1,98 +0,0 @@
-var BaseCommand = require('./base_command').BaseCommand,
- inherits = require('util').inherits,
- binaryutils = require('../utils');
-
-/**
- Insert Document Command
-**/
-var KillCursorCommand = exports.KillCursorCommand = function(db, cursorIds) {
- BaseCommand.call(this);
-
- this.cursorIds = cursorIds;
- this.db = db;
-};
-
-inherits(KillCursorCommand, BaseCommand);
-
-KillCursorCommand.OP_KILL_CURSORS = 2007;
-
-/*
-struct {
- MsgHeader header; // standard message header
- int32 ZERO; // 0 - reserved for future use
- int32 numberOfCursorIDs; // number of cursorIDs in message
- int64[] cursorIDs; // array of cursorIDs to close
-}
-*/
-KillCursorCommand.prototype.toBinary = function() {
- // Calculate total length of the document
- var totalLengthOfCommand = 4 + 4 + (4 * 4) + (this.cursorIds.length * 8);
- // Let's build the single pass buffer command
- var _index = 0;
- var _command = new Buffer(totalLengthOfCommand);
- // Write the header information to the buffer
- _command[_index + 3] = (totalLengthOfCommand >> 24) & 0xff;
- _command[_index + 2] = (totalLengthOfCommand >> 16) & 0xff;
- _command[_index + 1] = (totalLengthOfCommand >> 8) & 0xff;
- _command[_index] = totalLengthOfCommand & 0xff;
- // Adjust index
- _index = _index + 4;
- // Write the request ID
- _command[_index + 3] = (this.requestId >> 24) & 0xff;
- _command[_index + 2] = (this.requestId >> 16) & 0xff;
- _command[_index + 1] = (this.requestId >> 8) & 0xff;
- _command[_index] = this.requestId & 0xff;
- // Adjust index
- _index = _index + 4;
- // Write zero
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- // Write the op_code for the command
- _command[_index + 3] = (KillCursorCommand.OP_KILL_CURSORS >> 24) & 0xff;
- _command[_index + 2] = (KillCursorCommand.OP_KILL_CURSORS >> 16) & 0xff;
- _command[_index + 1] = (KillCursorCommand.OP_KILL_CURSORS >> 8) & 0xff;
- _command[_index] = KillCursorCommand.OP_KILL_CURSORS & 0xff;
- // Adjust index
- _index = _index + 4;
-
- // Write zero
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
-
- // Number of cursors to kill
- var numberOfCursors = this.cursorIds.length;
- _command[_index + 3] = (numberOfCursors >> 24) & 0xff;
- _command[_index + 2] = (numberOfCursors >> 16) & 0xff;
- _command[_index + 1] = (numberOfCursors >> 8) & 0xff;
- _command[_index] = numberOfCursors & 0xff;
- // Adjust index
- _index = _index + 4;
-
- // Encode all the cursors
- for(var i = 0; i < this.cursorIds.length; i++) {
- // Encode the cursor id
- var low_bits = this.cursorIds[i].getLowBits();
- // Encode low bits
- _command[_index + 3] = (low_bits >> 24) & 0xff;
- _command[_index + 2] = (low_bits >> 16) & 0xff;
- _command[_index + 1] = (low_bits >> 8) & 0xff;
- _command[_index] = low_bits & 0xff;
- // Adjust index
- _index = _index + 4;
-
- var high_bits = this.cursorIds[i].getHighBits();
- // Encode high bits
- _command[_index + 3] = (high_bits >> 24) & 0xff;
- _command[_index + 2] = (high_bits >> 16) & 0xff;
- _command[_index + 1] = (high_bits >> 8) & 0xff;
- _command[_index] = high_bits & 0xff;
- // Adjust index
- _index = _index + 4;
- }
-
- return _command;
-};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/e1a45507/web/demos/package/node_modules/mongodb/lib/mongodb/commands/query_command.js
----------------------------------------------------------------------
diff --git a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/query_command.js b/web/demos/package/node_modules/mongodb/lib/mongodb/commands/query_command.js
deleted file mode 100644
index 1218206..0000000
--- a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/query_command.js
+++ /dev/null
@@ -1,283 +0,0 @@
-var BaseCommand = require('./base_command').BaseCommand,
- inherits = require('util').inherits;
-
-/**
- Insert Document Command
-**/
-var QueryCommand = exports.QueryCommand = function(db, collectionName, queryOptions, numberToSkip, numberToReturn, query, returnFieldSelector, options) {
- BaseCommand.call(this);
-
- // Validate correctness off the selector
- var object = query,
- object_size;
- if(Buffer.isBuffer(object)) {
- object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24;
- if(object_size != object.length) {
- var error = new Error("query selector raw message size does not match message header size [" + object.length + "] != [" + object_size + "]");
- error.name = 'MongoError';
- throw error;
- }
- }
-
- object = returnFieldSelector;
- if(Buffer.isBuffer(object)) {
- object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24;
- if(object_size != object.length) {
- var error = new Error("query fields raw message size does not match message header size [" + object.length + "] != [" + object_size + "]");
- error.name = 'MongoError';
- throw error;
- }
- }
-
- // Make sure we don't get a null exception
- options = options == null ? {} : options;
- // Set up options
- this.collectionName = collectionName;
- this.queryOptions = queryOptions;
- this.numberToSkip = numberToSkip;
- this.numberToReturn = numberToReturn;
-
- // Ensure we have no null query
- query = query == null ? {} : query;
- // Wrap query in the $query parameter so we can add read preferences for mongos
- this.query = query;
- this.returnFieldSelector = returnFieldSelector;
- this.db = db;
-
- // Force the slave ok flag to be set if we are not using primary read preference
- if(this.db && this.db.slaveOk) {
- this.queryOptions |= QueryCommand.OPTS_SLAVE;
- }
-
- // If checkKeys set
- this.checkKeys = typeof options.checkKeys == 'boolean' ? options.checkKeys : false;
-
- // Let us defined on a command basis if we want functions to be serialized or not
- if(options['serializeFunctions'] != null && options['serializeFunctions']) {
- this.serializeFunctions = true;
- }
-};
-
-inherits(QueryCommand, BaseCommand);
-
-QueryCommand.OP_QUERY = 2004;
-
-/*
- * Adds the read prefrence to the current command
- */
-QueryCommand.prototype.setMongosReadPreference = function(readPreference, tags) {
- // If we have readPreference set to true set to secondary prefered
- if(readPreference == true) {
- readPreference = 'secondaryPreferred';
- } else if(readPreference == 'false') {
- readPreference = 'primary';
- }
-
- // Force the slave ok flag to be set if we are not using primary read preference
- if(readPreference != false && readPreference != 'primary') {
- this.queryOptions |= QueryCommand.OPTS_SLAVE;
- }
-
- // Backward compatibility, ensure $query only set on read preference so 1.8.X works
- if((readPreference != null || tags != null) && this.query['$query'] == null) {
- this.query = {'$query': this.query};
- }
-
- // If we have no readPreference set and no tags, check if the slaveOk bit is set
- if(readPreference == null && tags == null) {
- // If we have a slaveOk bit set the read preference for MongoS
- if(this.queryOptions & QueryCommand.OPTS_SLAVE) {
- this.query['$readPreference'] = {mode: 'secondary'}
- } else {
- this.query['$readPreference'] = {mode: 'primary'}
- }
- }
-
- // Build read preference object
- if(typeof readPreference == 'object' && readPreference['_type'] == 'ReadPreference') {
- this.query['$readPreference'] = readPreference.toObject();
- } else if(readPreference != null) {
- // Add the read preference
- this.query['$readPreference'] = {mode: readPreference};
-
- // If we have tags let's add them
- if(tags != null) {
- this.query['$readPreference']['tags'] = tags;
- }
- }
-}
-
-/*
-struct {
- MsgHeader header; // standard message header
- int32 opts; // query options. See below for details.
- cstring fullCollectionName; // "dbname.collectionname"
- int32 numberToSkip; // number of documents to skip when returning results
- int32 numberToReturn; // number of documents to return in the first OP_REPLY
- BSON query ; // query object. See below for details.
- [ BSON returnFieldSelector; ] // OPTIONAL : selector indicating the fields to return. See below for details.
-}
-*/
-QueryCommand.prototype.toBinary = function(bsonSettings) {
- // Validate that we are not passing 0x00 in the colletion name
- if(!!~this.collectionName.indexOf("\x00")) {
- throw new Error("namespace cannot contain a null character");
- }
-
- // Total length of the command
- var totalLengthOfCommand = 0;
- // Calculate total length of the document
- if(Buffer.isBuffer(this.query)) {
- totalLengthOfCommand = 4 + Buffer.byteLength(this.collectionName) + 1 + 4 + 4 + this.query.length + (4 * 4);
- } else {
- totalLengthOfCommand = 4 + Buffer.byteLength(this.collectionName) + 1 + 4 + 4 + this.db.bson.calculateObjectSize(this.query, this.serializeFunctions, true) + (4 * 4);
- }
-
- // Calculate extra fields size
- if(this.returnFieldSelector != null && !(Buffer.isBuffer(this.returnFieldSelector))) {
- if(Object.keys(this.returnFieldSelector).length > 0) {
- totalLengthOfCommand += this.db.bson.calculateObjectSize(this.returnFieldSelector, this.serializeFunctions, true);
- }
- } else if(Buffer.isBuffer(this.returnFieldSelector)) {
- totalLengthOfCommand += this.returnFieldSelector.length;
- }
-
- // Enforce maximum bson size
- if(!bsonSettings.disableDriverBSONSizeCheck
- && totalLengthOfCommand > bsonSettings.maxBsonSize)
- throw new Error("Document exceeds maximum allowed bson size of " + bsonSettings.maxBsonSize + " bytes");
-
- if(bsonSettings.disableDriverBSONSizeCheck
- && totalLengthOfCommand > bsonSettings.maxMessageSizeBytes)
- throw new Error("Command exceeds maximum message size of " + bsonSettings.maxMessageSizeBytes + " bytes");
-
- // Let's build the single pass buffer command
- var _index = 0;
- var _command = new Buffer(totalLengthOfCommand);
- // Write the header information to the buffer
- _command[_index + 3] = (totalLengthOfCommand >> 24) & 0xff;
- _command[_index + 2] = (totalLengthOfCommand >> 16) & 0xff;
- _command[_index + 1] = (totalLengthOfCommand >> 8) & 0xff;
- _command[_index] = totalLengthOfCommand & 0xff;
- // Adjust index
- _index = _index + 4;
- // Write the request ID
- _command[_index + 3] = (this.requestId >> 24) & 0xff;
- _command[_index + 2] = (this.requestId >> 16) & 0xff;
- _command[_index + 1] = (this.requestId >> 8) & 0xff;
- _command[_index] = this.requestId & 0xff;
- // Adjust index
- _index = _index + 4;
- // Write zero
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- // Write the op_code for the command
- _command[_index + 3] = (QueryCommand.OP_QUERY >> 24) & 0xff;
- _command[_index + 2] = (QueryCommand.OP_QUERY >> 16) & 0xff;
- _command[_index + 1] = (QueryCommand.OP_QUERY >> 8) & 0xff;
- _command[_index] = QueryCommand.OP_QUERY & 0xff;
- // Adjust index
- _index = _index + 4;
-
- // Write the query options
- _command[_index + 3] = (this.queryOptions >> 24) & 0xff;
- _command[_index + 2] = (this.queryOptions >> 16) & 0xff;
- _command[_index + 1] = (this.queryOptions >> 8) & 0xff;
- _command[_index] = this.queryOptions & 0xff;
- // Adjust index
- _index = _index + 4;
-
- // Write the collection name to the command
- _index = _index + _command.write(this.collectionName, _index, 'utf8') + 1;
- _command[_index - 1] = 0;
-
- // Write the number of documents to skip
- _command[_index + 3] = (this.numberToSkip >> 24) & 0xff;
- _command[_index + 2] = (this.numberToSkip >> 16) & 0xff;
- _command[_index + 1] = (this.numberToSkip >> 8) & 0xff;
- _command[_index] = this.numberToSkip & 0xff;
- // Adjust index
- _index = _index + 4;
-
- // Write the number of documents to return
- _command[_index + 3] = (this.numberToReturn >> 24) & 0xff;
- _command[_index + 2] = (this.numberToReturn >> 16) & 0xff;
- _command[_index + 1] = (this.numberToReturn >> 8) & 0xff;
- _command[_index] = this.numberToReturn & 0xff;
- // Adjust index
- _index = _index + 4;
-
- // Document binary length
- var documentLength = 0
- var object = this.query;
-
- // Serialize the selector
- if(Buffer.isBuffer(object)) {
- documentLength = object.length;
- // Copy the data into the current buffer
- object.copy(_command, _index);
- } else {
- // Serialize the document straight to the buffer
- documentLength = this.db.bson.serializeWithBufferAndIndex(object, this.checkKeys, _command, _index, this.serializeFunctions) - _index + 1;
- }
-
- // Write the length to the document
- _command[_index + 3] = (documentLength >> 24) & 0xff;
- _command[_index + 2] = (documentLength >> 16) & 0xff;
- _command[_index + 1] = (documentLength >> 8) & 0xff;
- _command[_index] = documentLength & 0xff;
- // Update index in buffer
- _index = _index + documentLength;
- // Add terminating 0 for the object
- _command[_index - 1] = 0;
-
- // Push field selector if available
- if(this.returnFieldSelector != null && !(Buffer.isBuffer(this.returnFieldSelector))) {
- if(Object.keys(this.returnFieldSelector).length > 0) {
- var documentLength = this.db.bson.serializeWithBufferAndIndex(this.returnFieldSelector, this.checkKeys, _command, _index, this.serializeFunctions) - _index + 1;
- // Write the length to the document
- _command[_index + 3] = (documentLength >> 24) & 0xff;
- _command[_index + 2] = (documentLength >> 16) & 0xff;
- _command[_index + 1] = (documentLength >> 8) & 0xff;
- _command[_index] = documentLength & 0xff;
- // Update index in buffer
- _index = _index + documentLength;
- // Add terminating 0 for the object
- _command[_index - 1] = 0;
- }
- } if(this.returnFieldSelector != null && Buffer.isBuffer(this.returnFieldSelector)) {
- // Document binary length
- var documentLength = 0
- var object = this.returnFieldSelector;
-
- // Serialize the selector
- documentLength = object.length;
- // Copy the data into the current buffer
- object.copy(_command, _index);
-
- // Write the length to the document
- _command[_index + 3] = (documentLength >> 24) & 0xff;
- _command[_index + 2] = (documentLength >> 16) & 0xff;
- _command[_index + 1] = (documentLength >> 8) & 0xff;
- _command[_index] = documentLength & 0xff;
- // Update index in buffer
- _index = _index + documentLength;
- // Add terminating 0 for the object
- _command[_index - 1] = 0;
- }
-
- // Return finished command
- return _command;
-};
-
-// Constants
-QueryCommand.OPTS_NONE = 0;
-QueryCommand.OPTS_TAILABLE_CURSOR = 2;
-QueryCommand.OPTS_SLAVE = 4;
-QueryCommand.OPTS_OPLOG_REPLAY = 8;
-QueryCommand.OPTS_NO_CURSOR_TIMEOUT = 16;
-QueryCommand.OPTS_AWAIT_DATA = 32;
-QueryCommand.OPTS_EXHAUST = 64;
-QueryCommand.OPTS_PARTIAL = 128;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/e1a45507/web/demos/package/node_modules/mongodb/lib/mongodb/commands/update_command.js
----------------------------------------------------------------------
diff --git a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/update_command.js b/web/demos/package/node_modules/mongodb/lib/mongodb/commands/update_command.js
deleted file mode 100644
index daa3cba..0000000
--- a/web/demos/package/node_modules/mongodb/lib/mongodb/commands/update_command.js
+++ /dev/null
@@ -1,189 +0,0 @@
-var BaseCommand = require('./base_command').BaseCommand,
- inherits = require('util').inherits;
-
-/**
- Update Document Command
-**/
-var UpdateCommand = exports.UpdateCommand = function(db, collectionName, spec, document, options) {
- BaseCommand.call(this);
-
- var object = spec;
- if(Buffer.isBuffer(object)) {
- var object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24;
- if(object_size != object.length) {
- var error = new Error("update spec raw message size does not match message header size [" + object.length + "] != [" + object_size + "]");
- error.name = 'MongoError';
- throw error;
- }
- }
-
- var object = document;
- if(Buffer.isBuffer(object)) {
- var object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24;
- if(object_size != object.length) {
- var error = new Error("update document raw message size does not match message header size [" + object.length + "] != [" + object_size + "]");
- error.name = 'MongoError';
- throw error;
- }
- }
-
- this.collectionName = collectionName;
- this.spec = spec;
- this.document = document;
- this.db = db;
- this.serializeFunctions = false;
- this.checkKeys = typeof options.checkKeys != 'boolean' ? false : options.checkKeys;
-
- // Generate correct flags
- var db_upsert = 0;
- var db_multi_update = 0;
- db_upsert = options != null && options['upsert'] != null ? (options['upsert'] == true ? 1 : 0) : db_upsert;
- db_multi_update = options != null && options['multi'] != null ? (options['multi'] == true ? 1 : 0) : db_multi_update;
-
- // Flags
- this.flags = parseInt(db_multi_update.toString() + db_upsert.toString(), 2);
- // Let us defined on a command basis if we want functions to be serialized or not
- if(options['serializeFunctions'] != null && options['serializeFunctions']) {
- this.serializeFunctions = true;
- }
-};
-
-inherits(UpdateCommand, BaseCommand);
-
-UpdateCommand.OP_UPDATE = 2001;
-
-/*
-struct {
- MsgHeader header; // standard message header
- int32 ZERO; // 0 - reserved for future use
- cstring fullCollectionName; // "dbname.collectionname"
- int32 flags; // bit vector. see below
- BSON spec; // the query to select the document
- BSON document; // the document data to update with or insert
-}
-*/
-UpdateCommand.prototype.toBinary = function(bsonSettings) {
- // Validate that we are not passing 0x00 in the colletion name
- if(!!~this.collectionName.indexOf("\x00")) {
- throw new Error("namespace cannot contain a null character");
- }
-
- // Calculate total length of the document
- var totalLengthOfCommand = 4 + Buffer.byteLength(this.collectionName) + 1 + 4 + this.db.bson.calculateObjectSize(this.spec, false, true) +
- this.db.bson.calculateObjectSize(this.document, this.serializeFunctions, true) + (4 * 4);
-
- // Enforce maximum bson size
- if(!bsonSettings.disableDriverBSONSizeCheck
- && totalLengthOfCommand > bsonSettings.maxBsonSize)
- throw new Error("Document exceeds maximum allowed bson size of " + bsonSettings.maxBsonSize + " bytes");
-
- if(bsonSettings.disableDriverBSONSizeCheck
- && totalLengthOfCommand > bsonSettings.maxMessageSizeBytes)
- throw new Error("Command exceeds maximum message size of " + bsonSettings.maxMessageSizeBytes + " bytes");
-
- // Let's build the single pass buffer command
- var _index = 0;
- var _command = new Buffer(totalLengthOfCommand);
- // Write the header information to the buffer
- _command[_index + 3] = (totalLengthOfCommand >> 24) & 0xff;
- _command[_index + 2] = (totalLengthOfCommand >> 16) & 0xff;
- _command[_index + 1] = (totalLengthOfCommand >> 8) & 0xff;
- _command[_index] = totalLengthOfCommand & 0xff;
- // Adjust index
- _index = _index + 4;
- // Write the request ID
- _command[_index + 3] = (this.requestId >> 24) & 0xff;
- _command[_index + 2] = (this.requestId >> 16) & 0xff;
- _command[_index + 1] = (this.requestId >> 8) & 0xff;
- _command[_index] = this.requestId & 0xff;
- // Adjust index
- _index = _index + 4;
- // Write zero
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- // Write the op_code for the command
- _command[_index + 3] = (UpdateCommand.OP_UPDATE >> 24) & 0xff;
- _command[_index + 2] = (UpdateCommand.OP_UPDATE >> 16) & 0xff;
- _command[_index + 1] = (UpdateCommand.OP_UPDATE >> 8) & 0xff;
- _command[_index] = UpdateCommand.OP_UPDATE & 0xff;
- // Adjust index
- _index = _index + 4;
-
- // Write zero
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
- _command[_index++] = 0;
-
- // Write the collection name to the command
- _index = _index + _command.write(this.collectionName, _index, 'utf8') + 1;
- _command[_index - 1] = 0;
-
- // Write the update flags
- _command[_index + 3] = (this.flags >> 24) & 0xff;
- _command[_index + 2] = (this.flags >> 16) & 0xff;
- _command[_index + 1] = (this.flags >> 8) & 0xff;
- _command[_index] = this.flags & 0xff;
- // Adjust index
- _index = _index + 4;
-
- // Document binary length
- var documentLength = 0
- var object = this.spec;
-
- // Serialize the selector
- // If we are passing a raw buffer, do minimal validation
- if(Buffer.isBuffer(object)) {
- var object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24;
- if(object_size != object.length) throw new Error("raw message size does not match message header size [" + object.length + "] != [" + object_size + "]");
- documentLength = object.length;
- // Copy the data into the current buffer
- object.copy(_command, _index);
- } else {
- documentLength = this.db.bson.serializeWithBufferAndIndex(object, this.checkKeys, _command, _index, false) - _index + 1;
- }
-
- // Write the length to the document
- _command[_index + 3] = (documentLength >> 24) & 0xff;
- _command[_index + 2] = (documentLength >> 16) & 0xff;
- _command[_index + 1] = (documentLength >> 8) & 0xff;
- _command[_index] = documentLength & 0xff;
- // Update index in buffer
- _index = _index + documentLength;
- // Add terminating 0 for the object
- _command[_index - 1] = 0;
-
- // Document binary length
- var documentLength = 0
- var object = this.document;
-
- // Serialize the document
- // If we are passing a raw buffer, do minimal validation
- if(Buffer.isBuffer(object)) {
- var object_size = object[0] | object[1] << 8 | object[2] << 16 | object[3] << 24;
- if(object_size != object.length) throw new Error("raw message size does not match message header size [" + object.length + "] != [" + object_size + "]");
- documentLength = object.length;
- // Copy the data into the current buffer
- object.copy(_command, _index);
- } else {
- documentLength = this.db.bson.serializeWithBufferAndIndex(object, false, _command, _index, this.serializeFunctions) - _index + 1;
- }
-
- // Write the length to the document
- _command[_index + 3] = (documentLength >> 24) & 0xff;
- _command[_index + 2] = (documentLength >> 16) & 0xff;
- _command[_index + 1] = (documentLength >> 8) & 0xff;
- _command[_index] = documentLength & 0xff;
- // Update index in buffer
- _index = _index + documentLength;
- // Add terminating 0 for the object
- _command[_index - 1] = 0;
-
- return _command;
-};
-
-// Constants
-UpdateCommand.DB_UPSERT = 0;
-UpdateCommand.DB_MULTI_UPDATE = 1;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-apex-malhar/blob/e1a45507/web/demos/package/node_modules/mongodb/lib/mongodb/connection/base.js
----------------------------------------------------------------------
diff --git a/web/demos/package/node_modules/mongodb/lib/mongodb/connection/base.js b/web/demos/package/node_modules/mongodb/lib/mongodb/connection/base.js
deleted file mode 100644
index 8fbeabf..0000000
--- a/web/demos/package/node_modules/mongodb/lib/mongodb/connection/base.js
+++ /dev/null
@@ -1,504 +0,0 @@
-var EventEmitter = require('events').EventEmitter
- , inherits = require('util').inherits
- , utils = require('../utils')
- , mongodb_cr_authenticate = require('../auth/mongodb_cr.js').authenticate
- , mongodb_gssapi_authenticate = require('../auth/mongodb_gssapi.js').authenticate
- , mongodb_sspi_authenticate = require('../auth/mongodb_sspi.js').authenticate
- , mongodb_plain_authenticate = require('../auth/mongodb_plain.js').authenticate
- , mongodb_x509_authenticate = require('../auth/mongodb_x509.js').authenticate;
-
-var id = 0;
-
-/**
- * Internal class for callback storage
- * @ignore
- */
-var CallbackStore = function() {
- // Make class an event emitter
- EventEmitter.call(this);
- // Add a info about call variable
- this._notReplied = {};
- this.id = id++;
-}
-
-/**
- * @ignore
- */
-inherits(CallbackStore, EventEmitter);
-
-CallbackStore.prototype.notRepliedToIds = function() {
- return Object.keys(this._notReplied);
-}
-
-CallbackStore.prototype.callbackInfo = function(id) {
- return this._notReplied[id];
-}
-
-/**
- * Internal class for holding non-executed commands
- * @ignore
- */
-var NonExecutedOperationStore = function(config) {
- var commands = {
- read: []
- , write_reads: []
- , write: []
- };
-
- // Execute all callbacks
- var fireCallbacksWithError = function(error, commands) {
- while(commands.length > 0) {
- var command = commands.shift();
- if(typeof command.callback == 'function') {
- command.callback(error);
- }
- }
- }
-
- this.count = function() {
- return commands.read.length
- + commands.write_reads.length
- + commands.write.length;
- }
-
- this.write = function(op) {
- commands.write.push(op);
- }
-
- this.read_from_writer = function(op) {
- commands.write_reads.push(op);
- }
-
- this.read = function(op) {
- commands.read.push(op);
- }
-
- this.validateBufferLimit = function(numberToFailOn) {
- if(numberToFailOn == -1 || numberToFailOn == null)
- return true;
-
- // Error passed back
- var error = utils.toError("No connection operations buffering limit of " + numberToFailOn + " reached");
-
- // If we have passed the number of items to buffer we need to fail
- if(numberToFailOn < this.count()) {
- // Fail all of the callbacks
- fireCallbacksWithError(error, commands.read);
- fireCallbacksWithError(error, commands.write_reads);
- fireCallbacksWithError(error, commands.write);
- }
-
- // Return false
- return false;
- }
-
- this.execute_queries = function(executeInsertCommand) {
- var connection = config.checkoutReader();
- if(connection == null || connection instanceof Error) return;
-
- // Write out all the queries
- while(commands.read.length > 0) {
- // Get the next command
- var command = commands.read.shift();
- command.options.connection = connection;
- // Execute the next command
- command.executeQueryCommand(command.db, command.db_command, command.options, command.callback);
- }
- }
-
- this.execute_writes = function() {
- var connection = config.checkoutWriter();
- if(connection == null || connection instanceof Error) return;
-
- // Write out all the queries to the primary
- while(commands.write_reads.length > 0) {
- // Get the next command
- var command = commands.write_reads.shift();
- command.options.connection = connection;
- // Execute the next command
- command.executeQueryCommand(command.db, command.db_command, command.options, command.callback);
- }
-
- // Execute all write operations
- while(commands.write.length > 0) {
- // Get the next command
- var command = commands.write.shift();
- // Set the connection
- command.options.connection = connection;
- // Execute the next command
- command.executeInsertCommand(command.db, command.db_command, command.options, command.callback);
- }
- }
-}
-
-/**
- * Internal class for authentication storage
- * @ignore
- */
-var AuthStore = function() {
- var _auths = [];
-
- this.add = function(authMechanism, dbName, username, password, authdbName, gssapiServiceName) {
- // Check for duplicates
- if(!this.contains(dbName)) {
- // Base config
- var config = {
- 'username':username
- , 'password':password
- , 'db': dbName
- , 'authMechanism': authMechanism
- , 'gssapiServiceName': gssapiServiceName
- };
-
- // Add auth source if passed in
- if(typeof authdbName == 'string') {
- config['authdb'] = authdbName;
- }
-
- // Push the config
- _auths.push(config);
- }
- }
-
- this.contains = function(dbName) {
- for(var i = 0; i < _auths.length; i++) {
- if(_auths[i].db == dbName) return true;
- }
-
- return false;
- }
-
- this.remove = function(dbName) {
- var newAuths = [];
-
- // Filter out all the login details
- for(var i = 0; i < _auths.length; i++) {
- if(_auths[i].db != dbName) newAuths.push(_auths[i]);
- }
-
- // Set the filtered list
- _auths = newAuths;
- }
-
- this.get = function(index) {
- return _auths[index];
- }
-
- this.length = function() {
- return _auths.length;
- }
-
- this.toArray = function() {
- return _auths.slice(0);
- }
-}
-
-/**
- * Internal class for storing db references
- * @ignore
- */
-var DbStore = function() {
- var _dbs = [];
-
- this.add = function(db) {
- var found = false;
-
- // Only add if it does not exist already
- for(var i = 0; i < _dbs.length; i++) {
- if(db.databaseName == _dbs[i].databaseName) found = true;
- }
-
- // Only add if it does not already exist
- if(!found) {
- _dbs.push(db);
- }
- }
-
- this.reset = function() {
- _dbs = [];
- }
-
- this.db = function() {
- return _dbs;
- }
-
- this.fetch = function(databaseName) {
- // Only add if it does not exist already
- for(var i = 0; i < _dbs.length; i++) {
- if(databaseName == _dbs[i].databaseName)
- return _dbs[i];
- }
-
- return null;
- }
-
- this.emit = function(event, message, object, reset, filterDb, rethrow_if_no_listeners) {
- var emitted = false;
-
- // Not emitted and we have enabled rethrow, let process.uncaughtException
- // deal with the issue
- if(!emitted && rethrow_if_no_listeners) {
- return process.nextTick(function() {
- throw message;
- })
- }
-
- // Emit the events
- for(var i = 0; i < _dbs.length; i++) {
- if(_dbs[i].listeners(event).length > 0) {
- if(filterDb == null || filterDb.databaseName !== _dbs[i].databaseName
- || filterDb.tag !== _dbs[i].tag) {
- _dbs[i].emit(event, message, object == null ? _dbs[i] : object);
- emitted = true;
- }
- }
- }
-
- // Emit error message
- if(message
- && event == 'error'
- && !emitted
- && rethrow_if_no_listeners
- && object && object.db) {
- process.nextTick(function() {
- object.db.emit(event, message, null);
- })
- }
- }
-}
-
-var Base = function Base() {
- EventEmitter.call(this);
-
- // Callback store is part of connection specification
- if(Base._callBackStore == null) {
- Base._callBackStore = new CallbackStore();
- }
-
- // Create a new callback store
- this._callBackStore = new CallbackStore();
- // All commands not being executed
- this._commandsStore = new NonExecutedOperationStore(this);
- // Create a new auth store
- this.auth = new AuthStore();
- // Contains all the dbs attached to this server config
- this._dbStore = new DbStore();
-}
-
-/**
- * @ignore
- */
-inherits(Base, EventEmitter);
-
-/**
- * @ignore
- */
-Base.prototype._apply_auths = function(db, callback) {
- _apply_auths_serially(this, db, this.auth.toArray(), callback);
-}
-
-var _apply_auths_serially = function(self, db, auths, callback) {
- if(auths.length == 0) return callback(null, null);
- // Get the first auth
- var auth = auths.shift();
- var connections = self.allRawConnections();
- var connectionsLeft = connections.length;
- var options = {};
-
- if(auth.authMechanism == 'GSSAPI') {
- // We have the kerberos library, execute auth process
- if(process.platform == 'win32') {
- mongodb_sspi_authenticate(db, auth.username, auth.password, auth.authdb, options, callback);
- } else {
- mongodb_gssapi_authenticate(db, auth.username, auth.password, auth.authdb, options, callback);
- }
- } else if(auth.authMechanism == 'MONGODB-CR') {
- mongodb_cr_authenticate(db, auth.username, auth.password, auth.authdb, options, callback);
- } else if(auth.authMechanism == 'PLAIN') {
- mongodb_plain_authenticate(db, auth.username, auth.password, auth.authdb, options, callback);
- } else if(auth.authMechanism == 'MONGODB-X509') {
- mongodb_x509_authenticate(db, auth.username, auth.password, auth.authdb, options, callback);
- }
-}
-
-/**
- * Fire all the errors
- * @ignore
- */
-Base.prototype.__executeAllCallbacksWithError = function(err) {
- // Check all callbacks
- var keys = Object.keys(this._callBackStore._notReplied);
- // For each key check if it's a callback that needs to be returned
- for(var j = 0; j < keys.length; j++) {
- var info = this._callBackStore._notReplied[keys[j]];
- // Execute callback with error
- this._callBackStore.emit(keys[j], err, null);
- // Remove the key
- delete this._callBackStore._notReplied[keys[j]];
- // Force cleanup _events, node.js seems to set it as a null value
- if(this._callBackStore._events) {
- delete this._callBackStore._events[keys[j]];
- }
- }
-}
-
-/**
- * Fire all the errors
- * @ignore
- */
-Base.prototype.__executeAllServerSpecificErrorCallbacks = function(host, port, err) {
- // Check all callbacks
- var keys = Object.keys(this._callBackStore._notReplied);
- // For each key check if it's a callback that needs to be returned
- for(var j = 0; j < keys.length; j++) {
- var info = this._callBackStore._notReplied[keys[j]];
-
- if(info.connection) {
- // Unpack the connection settings
- var _host = info.connection.socketOptions.host;
- var _port = info.connection.socketOptions.port;
- // If the server matches execute the callback with the error
- if(_port == port && _host == host) {
- this._callBackStore.emit(keys[j], err, null);
- // Remove the key
- delete this._callBackStore._notReplied[keys[j]];
- // Force cleanup _events, node.js seems to set it as a null value
- if(this._callBackStore._events) {
- delete this._callBackStore._events[keys[j]];
- }
- }
- }
- }
-}
-
-/**
- * Register a handler
- * @ignore
- * @api private
- */
-Base.prototype._registerHandler = function(db_command, raw, connection, exhaust, callback) {
- // Check if we have exhausted
- if(typeof exhaust == 'function') {
- callback = exhaust;
- exhaust = false;
- }
-
- // Add the callback to the list of handlers
- this._callBackStore.once(db_command.getRequestId(), callback);
- // Add the information about the reply
- this._callBackStore._notReplied[db_command.getRequestId().toString()] = {start: new Date().getTime(), 'raw': raw, connection:connection, exhaust:exhaust};
-}
-
-/**
- * Re-Register a handler, on the cursor id f.ex
- * @ignore
- * @api private
- */
-Base.prototype._reRegisterHandler = function(newId, object, callback) {
- // Add the callback to the list of handlers
- this._callBackStore.once(newId, object.callback.listener);
- // Add the information about the reply
- this._callBackStore._notReplied[newId] = object.info;
-}
-
-/**
- *
- * @ignore
- * @api private
- */
-Base.prototype._flushAllCallHandlers = function(err) {
- var keys = Object.keys(this._callBackStore._notReplied);
-
- for(var i = 0; i < keys.length; i++) {
- this._callHandler(keys[i], null, err);
- }
-}
-
-/**
- *
- * @ignore
- * @api private
- */
-Base.prototype._callHandler = function(id, document, err) {
- var self = this;
-
- // If there is a callback peform it
- if(this._callBackStore.listeners(id).length >= 1) {
- // Get info object
- var info = this._callBackStore._notReplied[id];
- // Delete the current object
- delete this._callBackStore._notReplied[id];
- // Call the handle directly don't emit
- var callback = this._callBackStore.listeners(id)[0].listener;
- // Remove the listeners
- this._callBackStore.removeAllListeners(id);
- // Force key deletion because it nulling it not deleting in 0.10.X
- if(this._callBackStore._events) {
- delete this._callBackStore._events[id];
- }
-
- try {
- // Execute the callback if one was provided
- if(typeof callback == 'function') callback(err, document, info.connection);
- } catch(err) {
- self._emitAcrossAllDbInstances(self, null, "error", utils.toError(err), self, true, true);
- }
- }
-}
-
-/**
- *
- * @ignore
- * @api private
- */
-Base.prototype._hasHandler = function(id) {
- return this._callBackStore.listeners(id).length >= 1;
-}
-
-/**
- *
- * @ignore
- * @api private
- */
-Base.prototype._removeHandler = function(id) {
- // Remove the information
- if(this._callBackStore._notReplied[id] != null) delete this._callBackStore._notReplied[id];
- // Remove the callback if it's registered
- this._callBackStore.removeAllListeners(id);
- // Force cleanup _events, node.js seems to set it as a null value
- if(this._callBackStore._events) {
- delete this._callBackStore._events[id];
- }
-}
-
-/**
- *
- * @ignore
- * @api private
- */
-Base.prototype._findHandler = function(id) {
- var info = this._callBackStore._notReplied[id];
- // Return the callback
- return {info:info, callback:(this._callBackStore.listeners(id).length >= 1) ? this._callBackStore.listeners(id)[0] : null}
-}
-
-/**
- *
- * @ignore
- * @api private
- */
-Base.prototype._emitAcrossAllDbInstances = function(server, filterDb, event, message, object, resetConnection, rethrow_if_no_listeners) {
- if(resetConnection) {
- var dbs = this._dbStore.db();
-
- for(var i = 0; i < dbs.length; i++) {
- if(typeof dbs[i].openCalled != 'undefined')
- dbs[i].openCalled = false;
- }
- }
-
- // Fire event
- this._dbStore.emit(event, message, object, resetConnection, filterDb, rethrow_if_no_listeners);
-}
-
-exports.Base = Base;
\ No newline at end of file