Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix jsHint issues

  • Loading branch information...
commit 276630ad114afc95930beafed26cd563ccb47941 1 parent 487f571
@andrerod andrerod authored
Showing with 1,862 additions and 2,046 deletions.
  1. +27 −0 .jshintrc
  2. +5 −6 lib/azure.js
  3. +21 −22 lib/diagnostics/logger.js
  4. +47 −47 lib/http/webresource.js
  5. +4 −5 lib/serviceruntime/fileinputchannel.js
  6. +3 −4 lib/serviceruntime/goalstatedeserializer.js
  7. +23 −28 lib/serviceruntime/namedpipeinputchannel.js
  8. +3 −4 lib/serviceruntime/namedpipeoutputchannel.js
  9. +3 −4 lib/serviceruntime/protocol1runtimeclient.js
  10. +3 −4 lib/serviceruntime/protocol1runtimecurrentstateclient.js
  11. +3 −5 lib/serviceruntime/protocol1runtimegoalstateclient.js
  12. +59 −57 lib/serviceruntime/roleenvironment.js
  13. +3 −4 lib/serviceruntime/runtimekernel.js
  14. +9 −8 lib/serviceruntime/runtimeversionmanager.js
  15. +7 −8 lib/serviceruntime/runtimeversionprotocolclient.js
  16. +4 −7 lib/serviceruntime/xmlcurrentstateserializer.js
  17. +4 −5 lib/serviceruntime/xmlgoalstatedeserializer.js
  18. +27 −30 lib/serviceruntime/xmlroleenvironmentdatadeserializer.js
  19. +129 −150 lib/services/blob/blobservice.js
  20. +2 −6 lib/services/blob/hmacsha256sign.js
  21. +5 −6 lib/services/blob/models/blobresult.js
  22. +2 −4 lib/services/blob/models/blocklistresult.js
  23. +3 −4 lib/services/blob/models/containeraclresult.js
  24. +12 −11 lib/services/blob/models/containerresult.js
  25. +2 −3 lib/services/blob/models/leaseresult.js
  26. +3 −6 lib/services/blob/models/listblobsresultcontinuation.js
  27. +3 −6 lib/services/blob/models/listcontainersresultcontinuation.js
  28. +3 −6 lib/services/blob/models/servicepropertiesresult.js
  29. +17 −18 lib/services/blob/sharedaccesssignature.js
  30. +15 −11 lib/services/blob/sharedkey.js
  31. +9 −9 lib/services/blob/sharedkeylite.js
  32. +26 −26 lib/services/core/connectionstringparser.js
  33. +20 −20 lib/services/core/exponentialretrypolicyfilter.js
  34. +13 −13 lib/services/core/linearretrypolicyfilter.js
  35. +4 −9 lib/services/core/servicebusserviceclient.js
  36. +9 −10 lib/services/core/servicebussettings.js
  37. +53 −59 lib/services/core/serviceclient.js
  38. +25 −28 lib/services/core/servicemanagementclient.js
  39. +9 −12 lib/services/core/servicemanagementsettings.js
  40. +15 −22 lib/services/core/servicesettings.js
  41. +4 −9 lib/services/core/sqlserviceclient.js
  42. +9 −16 lib/services/core/storageserviceclient.js
  43. +14 −20 lib/services/core/storageservicesettings.js
  44. +3 −6 lib/services/queue/models/listqueuesresultcontinuation.js
  45. +2 −4 lib/services/queue/models/queuemessageresult.js
  46. +6 −5 lib/services/queue/models/queueresult.js
  47. +3 −6 lib/services/queue/models/servicepropertiesresult.js
  48. +54 −57 lib/services/queue/queueservice.js
  49. +3 −7 lib/services/serviceBus/models/acstokenresult.js
  50. +0 −3  lib/services/serviceBus/models/notificationhubresult.js
  51. +11 −15 lib/services/serviceBus/models/queuemessageresult.js
  52. +11 −11 lib/services/serviceBus/models/resourceresult.js
  53. +0 −2  lib/services/serviceBus/models/ruleresult.js
  54. +31 −33 lib/services/serviceBus/notificationhubservice.js
  55. +159 −157 lib/services/serviceBus/servicebusservice.js
  56. +21 −25 lib/services/serviceBus/servicebusservicebase.js
  57. +5 −14 lib/services/serviceBus/wrap.js
  58. +16 −20 lib/services/serviceBus/wrapservice.js
  59. +5 −15 lib/services/serviceBus/wraptokenmanager.js
  60. +1 −1  lib/services/serviceManagement/models/namevalidation.js
  61. +70 −76 lib/services/serviceManagement/models/roleparser.js
  62. +76 −78 lib/services/serviceManagement/models/servicemanagementserialize.js
  63. +66 −71 lib/services/serviceManagement/servicebusmanagementservice.js
  64. +242 −244 lib/services/serviceManagement/servicemanagementservice.js
  65. +4 −7 lib/services/serviceManagement/sqlmanagementservice.js
  66. +3 −11 lib/services/sqlAzure/models/databaseresult.js
  67. +6 −12 lib/services/sqlAzure/sqlserveracs.js
  68. +15 −19 lib/services/sqlAzure/sqlservice.js
  69. +19 −19 lib/services/table/batchserviceclient.js
  70. +5 −14 lib/services/table/models/entityresult.js
  71. +3 −4 lib/services/table/models/queryentitiesresultcontinuation.js
  72. +3 −4 lib/services/table/models/querytablesresultcontinuation.js
  73. +5 −15 lib/services/table/models/tableresult.js
  74. +4 −7 lib/services/table/sharedkeylitetable.js
  75. +4 −7 lib/services/table/sharedkeytable.js
  76. +16 −16 lib/services/table/tablequery.js
  77. +81 −83 lib/services/table/tableservice.js
  78. +34 −34 lib/util/atomhandler.js
  79. +0 −16 lib/util/constants.js
  80. +45 −45 lib/util/iso8061date.js
  81. +31 −31 lib/util/js2xml.js
  82. +108 −102 lib/util/odatahandler.js
  83. +1 −1  lib/util/rfc1123date.js
  84. +17 −13 lib/util/util.js
  85. +3 −3 lib/util/validate.js
  86. +9 −1 package.json
View
27 .jshintrc
@@ -0,0 +1,27 @@
+{
+ "node": true,
+ "bitwise": true,
+ "camelcase": true,
+ "curly": false,
+ "eqeqeq": false,
+ "forin": true,
+ "immed": true,
+ "indent": 2,
+ "latedef": true,
+ "newcap": true,
+ "noarg": true,
+ "noempty": true,
+ "nonew": true,
+ "plusplus": false,
+ "quotmark": "single",
+ "regexp": true,
+ "undef": true,
+ "unused": true,
+ "strict": false,
+ "trailing": true,
+ "maxparams": false,
+ "maxdepth": false,
+ "maxstatements": false,
+ "maxcomplexity": false,
+ "sub": true
+}
View
11 lib/azure.js
@@ -58,13 +58,12 @@ exports.createBlobService = function (storageAccountOrConnectionString, storageA
/**
* Queue client exports.
*/
-
var QueueService = require('./services/queue/queueservice');
exports.QueueService = QueueService;
/**
* Creates a new QueueService object.
-* If no storageAccount or storageAccessKey are provided, the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY
+* If no storageAccount or storageAccessKey are provided, the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY
* environment variables will be used.
*
* @param {string} [storageAccountOrConnectionString] The storage account or the connection string.
@@ -135,7 +134,7 @@ exports.SqlService = SqlService;
* @param {string} [acsHost] The acs host.
* @param {object} [authenticationProvider] The authentication provider.
*/
-exports.createSqlService = function(serverName, administratorLogin, administratorLoginPassword, host, acsHost, authenticationProvider) {
+exports.createSqlService = function (serverName, administratorLogin, administratorLoginPassword, host, acsHost, authenticationProvider) {
return new SqlService(serverName, administratorLogin, administratorLoginPassword, host, acsHost, authenticationProvider);
};
@@ -164,7 +163,7 @@ exports.ServiceManagementService = ServiceManagementService;
* serializetype: 'XML'
* }
*/
-exports.createServiceManagementService = function(subscriptionId, authentication, hostOptions) {
+exports.createServiceManagementService = function (subscriptionId, authentication, hostOptions) {
return new ServiceManagementService(subscriptionId, authentication, hostOptions);
};
@@ -193,7 +192,7 @@ exports.SqlManagementService = SqlManagementService;
* serializetype: 'XML'
* }
*/
-exports.createSqlManagementService = function(subscriptionId, authentication, hostOptions) {
+exports.createSqlManagementService = function (subscriptionId, authentication, hostOptions) {
return new SqlManagementService(subscriptionId, authentication, hostOptions);
};
@@ -222,7 +221,7 @@ exports.ServiceBusManagementService = ServiceBusManagementService;
* serializetype: 'XML'
* }
*/
-exports.createServiceBusManagementService = function(subscriptionId, authentication, hostOptions) {
+exports.createServiceBusManagementService = function (subscriptionId, authentication, hostOptions) {
return new ServiceBusManagementService(subscriptionId, authentication, hostOptions);
};
View
43 lib/diagnostics/logger.js
@@ -13,8 +13,23 @@
* limitations under the License.
*/
-// Expose 'Logger'.
-exports = module.exports = Logger;
+function Logger(level, loggerFunction) {
+ var self = this;
+
+ this.level = level;
+ this.loggerFunction = loggerFunction;
+
+ if (!this.loggerFunction) {
+ this.loggerFunction = function (logLevel, msg) {
+ var currentLevelIndex = Logger.logPriority.indexOf(self.level);
+ var logLeveLIndex = Logger.logPriority.indexOf(logLevel);
+
+ if (logLeveLIndex <= currentLevelIndex) {
+ console.log(self.level + ' : ' + msg);
+ }
+ };
+ }
+}
Logger.LogLevels = {
/**
@@ -58,7 +73,7 @@ Logger.LogLevels = {
DEBUG : 'debug'
};
-Logger.logPriority = [
+Logger.logPriority = [
Logger.LogLevels.EMERGENCY,
Logger.LogLevels.ALERT,
Logger.LogLevels.CRITICAL,
@@ -69,24 +84,8 @@ Logger.logPriority = [
Logger.LogLevels.DEBUG
];
-function Logger(level, loggerFunction) {
- var self = this;
-
- this.level = level;
- this.loggerFunction = loggerFunction;
-
- if (!this.loggerFunction) {
- this.loggerFunction = function (logLevel, msg) {
- var currentLevelIndex = Logger.logPriority.indexOf(self.level);
- var logLeveLIndex = Logger.logPriority.indexOf(logLevel);
-
- if (logLeveLIndex <= currentLevelIndex) {
- console.log(self.level + ' : ' + msg);
- }
- };
- }
-}
-
Logger.prototype.log = function (level, msg) {
this.loggerFunction(level, msg);
-};
+};
+
+module.exports = Logger;
View
94 lib/http/webresource.js
@@ -15,13 +15,13 @@
// Module dependencies.
var azureutil = require('../util/util');
-var ServiceClient = require('../services/core/serviceclient');
var Constants = require('../util/constants');
var HeaderConstants = Constants.HeaderConstants;
var HttpConstants = Constants.HttpConstants;
-// Expose 'WebResource'.
-exports = module.exports = WebResource;
+function encodeSpecialCharacters(path) {
+ return path.replace(/'/g, '%27');
+}
/**
* Creates a new WebResource object.
@@ -97,7 +97,7 @@ WebResource.del = function (path) {
* @param {string} path The path for the post operation.
* @return {WebResource} A new webresource with a post operation for the given path.
*/
-WebResource.post = function(path) {
+WebResource.post = function (path) {
var webResource = new WebResource();
webResource.path = path ? encodeSpecialCharacters(path) : null;
webResource.httpVerb = HttpConstants.HttpVerbs.POST;
@@ -205,10 +205,12 @@ WebResource.prototype.getQueryStringValues = function (uriEncode) {
var queryString = {};
if (this._queryString) {
for (var queryStringName in this._queryString) {
- var queryStringEntry = this._queryString[queryStringName];
- queryString[queryStringName] = (uriEncode && queryStringEntry.uriEncodable) ?
- azureutil.encodeUri(queryStringEntry.value) :
- queryStringEntry.value;
+ if (this._queryString.hasOwnProperty(queryStringName)) {
+ var queryStringEntry = this._queryString[queryStringName];
+ queryString[queryStringName] = (uriEncode && queryStringEntry.uriEncodable) ?
+ azureutil.encodeUri(queryStringEntry.value) :
+ queryStringEntry.value;
+ }
}
}
@@ -226,7 +228,9 @@ WebResource.prototype.getQueryString = function (uriEncode) {
if (queryStringValues) {
var parametersString = [];
for (var parameter in queryStringValues) {
- parametersString.push(parameter + '=' + queryStringValues[parameter]);
+ if (queryStringValues.hasOwnProperty(parameter)) {
+ parametersString.push(parameter + '=' + queryStringValues[parameter]);
+ }
}
if (parametersString.length > 0) {
@@ -278,7 +282,9 @@ WebResource.prototype.addOptionalHeader = function (name, value) {
WebResource.prototype.addOptionalMetadataHeaders = function (metadata) {
if (metadata) {
for (var metadataHeader in metadata) {
- this.addOptionalHeader(HeaderConstants.PREFIX_FOR_STORAGE_METADATA + metadataHeader.toLowerCase(), metadata[metadataHeader]);
+ if (metadata.hasOwnProperty(metadataHeader)) {
+ this.addOptionalHeader(HeaderConstants.PREFIX_FOR_STORAGE_METADATA + metadataHeader.toLowerCase(), metadata[metadataHeader]);
+ }
}
}
@@ -286,50 +292,46 @@ WebResource.prototype.addOptionalMetadataHeaders = function (metadata) {
};
WebResource.prototype.addOptionalAccessConditionHeader = function (accessConditionHeaders) {
- if (accessConditionHeaders) {
- var ifMatch = azureutil.tryGetValueInsensitive(HeaderConstants.IF_MATCH, accessConditionHeaders);
- if (ifMatch) {
- this.addOptionalHeader(HeaderConstants.IF_MATCH, ifMatch);
- }
+ var ifMatch = azureutil.tryGetValueInsensitive(HeaderConstants.IF_MATCH, accessConditionHeaders);
+ if (ifMatch) {
+ this.addOptionalHeader(HeaderConstants.IF_MATCH, ifMatch);
+ }
- var ifModifiedSince = azureutil.tryGetValueInsensitive(HeaderConstants.IF_MODIFIED_SINCE, accessConditionHeaders);
- if (ifModifiedSince) {
- this.addOptionalHeader(HeaderConstants.IF_MODIFIED_SINCE, ifModifiedSince);
- }
+ var ifModifiedSince = azureutil.tryGetValueInsensitive(HeaderConstants.IF_MODIFIED_SINCE, accessConditionHeaders);
+ if (ifModifiedSince) {
+ this.addOptionalHeader(HeaderConstants.IF_MODIFIED_SINCE, ifModifiedSince);
+ }
- var ifNoneMatch = azureutil.tryGetValueInsensitive(HeaderConstants.IF_NONE_MATCH, accessConditionHeaders);
- if (ifNoneMatch) {
- this.addOptionalHeader(HeaderConstants.IF_NONE_MATCH, ifNoneMatch);
- }
+ var ifNoneMatch = azureutil.tryGetValueInsensitive(HeaderConstants.IF_NONE_MATCH, accessConditionHeaders);
+ if (ifNoneMatch) {
+ this.addOptionalHeader(HeaderConstants.IF_NONE_MATCH, ifNoneMatch);
+ }
- var ifUnmodifiedSince = azureutil.tryGetValueInsensitive(HeaderConstants.IF_UNMODIFIED_SINCE, accessConditionHeaders);
- if (ifUnmodifiedSince) {
- this.addOptionalHeader(HeaderConstants.IF_UNMODIFIED_SINCE, ifUnmodifiedSince);
- }
+ var ifUnmodifiedSince = azureutil.tryGetValueInsensitive(HeaderConstants.IF_UNMODIFIED_SINCE, accessConditionHeaders);
+ if (ifUnmodifiedSince) {
+ this.addOptionalHeader(HeaderConstants.IF_UNMODIFIED_SINCE, ifUnmodifiedSince);
}
};
WebResource.prototype.addOptionalSourceAccessConditionHeader = function (accessConditionHeaders) {
- if (accessConditionHeaders) {
- var sourceIfMatch = azureutil.tryGetValueInsensitive(HeaderConstants.SOURCE_IF_MATCH_HEADER, accessConditionHeaders);
- if (sourceIfMatch) {
- this.addOptionalHeader(HeaderConstants.SOURCE_IF_MATCH_HEADER, sourceIfMatch);
- }
+ var sourceIfMatch = azureutil.tryGetValueInsensitive(HeaderConstants.SOURCE_IF_MATCH_HEADER, accessConditionHeaders);
+ if (sourceIfMatch) {
+ this.addOptionalHeader(HeaderConstants.SOURCE_IF_MATCH_HEADER, sourceIfMatch);
+ }
- var sourceIfModifiedSince = azureutil.tryGetValueInsensitive(HeaderConstants.SOURCE_IF_MODIFIED_SINCE_HEADER, accessConditionHeaders);
- if (sourceIfModifiedSince) {
- this.addOptionalHeader(HeaderConstants.SOURCE_IF_MODIFIED_SINCE_HEADER, sourceIfModifiedSince);
- }
+ var sourceIfModifiedSince = azureutil.tryGetValueInsensitive(HeaderConstants.SOURCE_IF_MODIFIED_SINCE_HEADER, accessConditionHeaders);
+ if (sourceIfModifiedSince) {
+ this.addOptionalHeader(HeaderConstants.SOURCE_IF_MODIFIED_SINCE_HEADER, sourceIfModifiedSince);
+ }
- var sourceIfNoneMatch = azureutil.tryGetValueInsensitive(HeaderConstants.SOURCE_IF_NONE_MATCH_HEADER, accessConditionHeaders);
- if (sourceIfNoneMatch) {
- this.addOptionalHeader(HeaderConstants.SOURCE_IF_NONE_MATCH_HEADER, sourceIfNoneMatch);
- }
+ var sourceIfNoneMatch = azureutil.tryGetValueInsensitive(HeaderConstants.SOURCE_IF_NONE_MATCH_HEADER, accessConditionHeaders);
+ if (sourceIfNoneMatch) {
+ this.addOptionalHeader(HeaderConstants.SOURCE_IF_NONE_MATCH_HEADER, sourceIfNoneMatch);
+ }
- var sourceIfUnmodifiedSince = azureutil.tryGetValueInsensitive(HeaderConstants.SOURCE_IF_UNMODIFIED_SINCE_HEADER, accessConditionHeaders);
- if (sourceIfUnmodifiedSince) {
- this.addOptionalHeader(HeaderConstants.SOURCE_IF_UNMODIFIED_SINCE_HEADER, sourceIfUnmodifiedSince);
- }
+ var sourceIfUnmodifiedSince = azureutil.tryGetValueInsensitive(HeaderConstants.SOURCE_IF_UNMODIFIED_SINCE_HEADER, accessConditionHeaders);
+ if (sourceIfUnmodifiedSince) {
+ this.addOptionalHeader(HeaderConstants.SOURCE_IF_UNMODIFIED_SINCE_HEADER, sourceIfUnmodifiedSince);
}
};
@@ -349,6 +351,4 @@ WebResource.prototype.validResponse = function (statusCode) {
return false;
};
-function encodeSpecialCharacters(path) {
- return path.replace(/'/g, '%27');
-}
+module.exports = WebResource;
View
9 lib/serviceruntime/fileinputchannel.js
@@ -17,10 +17,7 @@
var fs = require('fs');
var xml2js = require('xml2js');
-// Expose 'FileInputChannel'.
-exports = module.exports = FileInputChannel;
-
-function FileInputChannel() { }
+function FileInputChannel() {}
FileInputChannel.prototype.readInputChannel = function (name, parseXml, callback) {
this._readData(name, function (error, data) {
@@ -44,4 +41,6 @@ FileInputChannel.prototype.readInputChannel = function (name, parseXml, callback
FileInputChannel.prototype._readData = function (name, callback) {
fs.readFile(name, callback);
-};
+};
+
+module.exports = FileInputChannel;
View
7 lib/serviceruntime/goalstatedeserializer.js
@@ -16,9 +16,6 @@
// Module dependencies.
var XmlGoalStateDeserializer = require('./xmlgoalstatedeserializer');
-// Expose 'GoalStateDeserializer'.
-exports = module.exports = GoalStateDeserializer;
-
function GoalStateDeserializer() {
this.deserializer = new XmlGoalStateDeserializer();
}
@@ -29,4 +26,6 @@ GoalStateDeserializer.prototype.deserialize = function (xml) {
}
return this.deserializer.deserialize(xml);
-};
+};
+
+module.exports = GoalStateDeserializer;
View
51 lib/serviceruntime/namedpipeinputchannel.js
@@ -17,9 +17,6 @@
var net = require('net');
var xml2js = require('xml2js');
-// Expose 'NamedPipeInputChannel'.
-exports = module.exports = NamedPipeInputChannel;
-
function NamedPipeInputChannel() {
this.closeOnRead = true;
this.client = null;
@@ -32,36 +29,32 @@ NamedPipeInputChannel.prototype.readInputChannel = function (name, parseXml, cal
};
this._readData(name, function (error, data) {
- if (!error) {
- var parts = data.toString().split('\r\n');
+ if (error) {
+ return callbackError(error);
+ }
- var xml;
- // If there is more than one part (and the \r\n wasnt the final marker).
- if (parts.length > 1 && parts[1].length > 0) {
- xml = parts[1];
- } else {
- xml = parts[0];
- }
+ var parts = data.toString().split('\r\n');
- if (parseXml) {
- var parser = new xml2js.Parser();
- error = null;
- parser.on('error', function (e) { error = e; });
- parser.parseString(xml);
+ var xml;
+ // If there is more than one part (and the \r\n wasnt the final marker).
+ if (parts.length > 1 && parts[1].length > 0) {
+ xml = parts[1];
+ } else {
+ xml = parts[0];
+ }
- if (parser.resultObject) {
- xml = parser.resultObject;
- }
- }
+ if (parseXml) {
+ var parser = new xml2js.Parser();
+ error = null;
+ parser.on('error', function (e) { error = e; });
+ parser.parseString(xml);
- if (error) {
- callbackError(error);
- } else {
- callback(undefined, xml);
+ if (parser.resultObject) {
+ xml = parser.resultObject;
}
- } else {
- callbackError(error);
}
+
+ callback(error, xml);
});
};
@@ -84,4 +77,6 @@ NamedPipeInputChannel.prototype._readData = function (name, callback) {
self.client.on('error', function (error) {
callback(error);
});
-};
+};
+
+module.exports = NamedPipeInputChannel;
View
7 lib/serviceruntime/namedpipeoutputchannel.js
@@ -16,9 +16,6 @@
// Module dependencies.
var net = require('net');
-// Expose 'NamedPipeOutputChannel'.
-exports = module.exports = NamedPipeOutputChannel;
-
function NamedPipeOutputChannel() { }
NamedPipeOutputChannel.prototype.writeOutputChannel = function (name, data, callback) {
@@ -28,4 +25,6 @@ NamedPipeOutputChannel.prototype.writeOutputChannel = function (name, data, call
if (callback) {
callback();
}
-};
+};
+
+module.exports = NamedPipeOutputChannel;
View
7 lib/serviceruntime/protocol1runtimeclient.js
@@ -20,9 +20,6 @@ var util = require('util');
var Constants = require('../util/constants');
var ServiceRuntimeConstants = Constants.ServiceRuntimeConstants;
-// Expose 'Protocol1RuntimeClient'.
-exports = module.exports = Protocol1RuntimeClient;
-
function Protocol1RuntimeClient(goalStateClient, currentStateClient, endpoint) {
EventEmitter.call(this);
@@ -61,4 +58,6 @@ Protocol1RuntimeClient.prototype._addListeners = function () {
self.emit(ServiceRuntimeConstants.CHANGED, currentGoalState);
});
}
-};
+};
+
+module.exports = Protocol1RuntimeClient;
View
7 lib/serviceruntime/protocol1runtimecurrentstateclient.js
@@ -13,9 +13,6 @@
* limitations under the License.
*/
-// Expose 'Protocol1RuntimeCurrentStateClient'.
-exports = module.exports = Protocol1RuntimeCurrentStateClient;
-
function Protocol1RuntimeCurrentStateClient(currentStateSerializer, outputChannel) {
this.currentStateSerializer = currentStateSerializer;
this.outputChannel = outputChannel;
@@ -25,4 +22,6 @@ function Protocol1RuntimeCurrentStateClient(currentStateSerializer, outputChanne
Protocol1RuntimeCurrentStateClient.prototype.setCurrentState = function (state, callback) {
var serializedState = this.currentStateSerializer.serialize(state);
this.outputChannel.writeOutputChannel(this.endpoint, serializedState, callback);
-};
+};
+
+module.exports = Protocol1RuntimeCurrentStateClient;
View
8 lib/serviceruntime/protocol1runtimegoalstateclient.js
@@ -17,13 +17,9 @@
var EventEmitter = require('events').EventEmitter;
var util = require('util');
-var azureutil = require('../util/util');
var Constants = require('../util/constants');
var ServiceRuntimeConstants = Constants.ServiceRuntimeConstants;
-// Expose 'Protocol1RuntimeGoalStateClient'.
-exports = module.exports = Protocol1RuntimeGoalStateClient;
-
function Protocol1RuntimeGoalStateClient(currentStateClient, goalStateDeserializer, roleEnvironmentDataDeserializer, namedPipeInputChannel, fileInputChannel) {
EventEmitter.call(this);
@@ -113,4 +109,6 @@ Protocol1RuntimeGoalStateClient.prototype._ensurePolling = function (callback) {
}
}
});
-};
+};
+
+module.exports = Protocol1RuntimeGoalStateClient;
View
116 lib/serviceruntime/roleenvironment.js
@@ -39,6 +39,29 @@ RoleEnvironment.VersionEndpointFixedPath = '\\\\.\\pipe\\WindowsAzureRuntime';
RoleEnvironment.clientId = uuid();
RoleEnvironment.runtimeClient = null;
+/**
+* Validates a callback function.
+*
+* @param {function} callback The callback function.
+* @return {undefined}
+*/
+function validateCallback(callback) {
+ if (!callback) {
+ throw new Error(RoleEnvironment.incorrectCallbackErr);
+ }
+}
+
+function validateNodeVersion() {
+ var version = process.version.replace('v', '').split('.');
+ if (parseInt(version[0], 10) === 0 &&
+ (parseInt(version[1], 10) < Constants.SERVICERUNTIME_MIN_VERSION_MAJOR ||
+ (parseInt(version[1], 10) === Constants.SERVICERUNTIME_MIN_VERSION_MAJOR &&
+ version.length > 2 && parseInt(version[2], 10) < Constants.SERVICERUNTIME_MIN_VERSION_MINOR))) {
+ throw new Error('Service runtime need node version >= 0.' + Constants.SERVICERUNTIME_MIN_VERSION_MAJOR +
+ '.' + Constants.SERVICERUNTIME_MIN_VERSION_MINOR + ' to run');
+ }
+}
+
var currentGoalState = null;
var currentEnvironmentData = null;
var lastState = null;
@@ -99,7 +122,7 @@ RoleEnvironment.emit = function () {
/**
* Returns a RoleInstance object that represents the role instance
* in which this code is currently executing.
-*
+*
* @param {function(error, roleInstance)} callback The callback function.
*/
RoleEnvironment.getCurrentRoleInstance = function (callback) {
@@ -118,7 +141,7 @@ RoleEnvironment.getCurrentRoleInstance = function (callback) {
/**
* Returns the deployment ID that uniquely identifies the deployment in
* which this role instance is running.
-*
+*
* @param {function(error, deploymentId)} callback The callback function.
*/
RoleEnvironment.getDeploymentId = function (callback) {
@@ -137,7 +160,7 @@ RoleEnvironment.getDeploymentId = function (callback) {
/**
* Indicates whether the role instance is running in the Windows Azure
* environment.
-*
+*
* @param {function(error, isAvailable)} callback The callback function.
*/
RoleEnvironment.isAvailable = function (callback) {
@@ -155,7 +178,7 @@ RoleEnvironment.isAvailable = function (callback) {
/**
* Indicates whether the role instance is running in the development fabric.
-*
+*
* @param {function(error, isEmulated)} callback The callback function.
*/
RoleEnvironment.isEmulated = function (callback) {
@@ -174,7 +197,7 @@ RoleEnvironment.isEmulated = function (callback) {
/**
* Returns the set of Role objects defined for your service.
* Roles are defined in the service definition file.
-*
+*
* @param {function(error, roles)} callback The callback function.
*/
RoleEnvironment.getRoles = function (callback) {
@@ -194,7 +217,7 @@ RoleEnvironment.getRoles = function (callback) {
* Retrieves the settings in the service configuration file.
* A role's configuration settings are defined in the service definition file. Values for configuration settings are
* set in the service configuration file.
-*
+*
* @param {function(error, configurationSettings)} callback The callback function.
*/
RoleEnvironment.getConfigurationSettings = function (callback) {
@@ -212,7 +235,7 @@ RoleEnvironment.getConfigurationSettings = function (callback) {
/**
* Retrieves the set of named local storage resources.
-*
+*
* @param {function(error, localResources)} callback The callback function.
*/
RoleEnvironment.getLocalResources = function (callback) {
@@ -233,7 +256,7 @@ RoleEnvironment.getLocalResources = function (callback) {
*
* Before the role instance is recycled, the Windows Azure load balancer takes the role instance out of rotation.
* This ensures that no new requests are routed to the instance while it is restarting.
-*
+*
* A call to <code>RequestRecycle</code> initiates the normal shutdown cycle. Windows Azure raises the
* <code>Stopping</code> event and calls the <code>OnStop</code> method so that you can run the necessary code to
* prepare the instance to be recycled.
@@ -266,11 +289,11 @@ RoleEnvironment.requestRecycle = function (callback) {
* An instance may indicate that it is in one of two states: Ready or Busy. If an instance's state is Ready, it is
* prepared to receive requests from the load balancer. If the instance's state is Busy, it will not receive
* requests from the load balancer.
-*
+*
* @param {string} status A value that indicates whether the instance is ready or busy.
* @param {date} expiration_utc A date value that specifies the expiration date and time of the status.
* @param {function(error)} callback The callback function.
-*
+*
*/
RoleEnvironment.setStatus = function (roleInstanceStatus, expirationUtc, callback) {
validateNodeVersion();
@@ -281,12 +304,12 @@ RoleEnvironment.setStatus = function (roleInstanceStatus, expirationUtc, callbac
var currentStatus = ServiceRuntimeConstants.RoleStatus.STARTED;
switch (roleInstanceStatus) {
- case ServiceRuntimeConstants.RoleInstanceStatus.BUSY:
- currentStatus = ServiceRuntimeConstants.RoleStatus.BUSY;
- break;
- case ServiceRuntimeConstants.RoleInstanceStatus.READY:
- currentStatus = ServiceRuntimeConstants.RoleStatus.STARTED;
- break;
+ case ServiceRuntimeConstants.RoleInstanceStatus.BUSY:
+ currentStatus = ServiceRuntimeConstants.RoleStatus.BUSY;
+ break;
+ case ServiceRuntimeConstants.RoleInstanceStatus.READY:
+ currentStatus = ServiceRuntimeConstants.RoleStatus.STARTED;
+ break;
}
var newState = {
@@ -374,24 +397,24 @@ RoleEnvironment._initialize = function (callback) {
if (RoleEnvironment.runtimeClient.listeners(ServiceRuntimeConstants.CHANGED).length === 0) {
RoleEnvironment.runtimeClient.on(ServiceRuntimeConstants.CHANGED, function (newGoalState) {
switch (newGoalState.expectedState) {
- case ServiceRuntimeConstants.RoleStatus.STARTED:
- if (newGoalState.incarnation > currentGoalState.incarnation) {
- RoleEnvironment._processGoalStateChange(newGoalState);
- }
+ case ServiceRuntimeConstants.RoleStatus.STARTED:
+ if (newGoalState.incarnation > currentGoalState.incarnation) {
+ RoleEnvironment._processGoalStateChange(newGoalState);
+ }
- break;
- case ServiceRuntimeConstants.RoleStatus.STOPPED:
- RoleEnvironment._raiseStoppingEvent();
+ break;
+ case ServiceRuntimeConstants.RoleStatus.STOPPED:
+ RoleEnvironment._raiseStoppingEvent();
- var stoppedState = {
- clientId: RoleEnvironment.clientId,
- incarnation: newGoalState.incarnation,
- status: ServiceRuntimeConstants.RoleStatus.STOPPED,
- expiration: maxDateTime
- };
+ var stoppedState = {
+ clientId: RoleEnvironment.clientId,
+ incarnation: newGoalState.incarnation,
+ status: ServiceRuntimeConstants.RoleStatus.STOPPED,
+ expiration: maxDateTime
+ };
- RoleEnvironment.runtimeClient.setCurrentState(stoppedState);
- break;
+ RoleEnvironment.runtimeClient.setCurrentState(stoppedState);
+ break;
}
});
}
@@ -529,7 +552,7 @@ RoleEnvironment._calculateChanges = function (callback) {
if (currentEndpoint.protocol !== newEndpoint.protocol ||
currentEndpoint.address !== newEndpoint.address ||
currentEndpoint.port !== newEndpoint.port) {
- changedRoleSet[role] = role;
+ changedRoleSet[role] = role;
}
} else {
changedRoleSet[role] = role;
@@ -587,7 +610,9 @@ RoleEnvironment._calculateChanges = function (callback) {
}
for (var changedRole in changedRoleSet) {
- changes.push({ type: 'TopologyChange', name: changedRoleSet[changedRole] });
+ if (changedRoleSet.hasOwnProperty(changedRole)) {
+ changes.push({ type: 'TopologyChange', name: changedRoleSet[changedRole] });
+ }
}
callback(undefined, changes);
@@ -599,27 +624,4 @@ RoleEnvironment._calculateChanges = function (callback) {
RoleEnvironment._raiseStoppingEvent = function () {
RoleEnvironment.emit(ServiceRuntimeConstants.STOPPING);
-};
-
-/**
-* Validates a callback function.
-*
-* @param {function} callback The callback function.
-* @return {undefined}
-*/
-function validateCallback(callback) {
- if (!callback) {
- throw new Error(RoleEnvironment.incorrectCallbackErr);
- }
-}
-
-function validateNodeVersion() {
- var version = process.version.replace('v', '').split('.');
- if (parseInt(version[0], 10) === 0 &&
- (parseInt(version[1], 10) < Constants.SERVICERUNTIME_MIN_VERSION_MAJOR ||
- (parseInt(version[1], 10) === Constants.SERVICERUNTIME_MIN_VERSION_MAJOR &&
- version.length > 2 && parseInt(version[2], 10) < Constants.SERVICERUNTIME_MIN_VERSION_MINOR))) {
- throw new Error('Service runtime need node version >= 0.' + Constants.SERVICERUNTIME_MIN_VERSION_MAJOR +
- '.' + Constants.SERVICERUNTIME_MIN_VERSION_MINOR + ' to run');
- }
-}
+};
View
7 lib/serviceruntime/runtimekernel.js
@@ -29,9 +29,6 @@ var GoalStateDeserializer = require('./goalstatedeserializer');
var XmlRoleEnvironmentDataDeserializer = require('./xmlroleenvironmentdatadeserializer');
var XmlCurrentStateSerializer = require('./xmlcurrentstateserializer');
-// Expose 'RuntimeKernel'.
-exports = module.exports = RuntimeKernel;
-
var theKernel;
function RuntimeKernel() {
@@ -69,4 +66,6 @@ RuntimeKernel.prototype.getCurrentStateClient = function () {
RuntimeKernel.prototype.getRuntimeVersionManager = function () {
return this.runtimeVersionManager;
-};
+};
+
+module.exports = RuntimeKernel;
View
17 lib/serviceruntime/runtimeversionmanager.js
@@ -16,9 +16,6 @@
// Module dependencies.
var Protocol1RuntimeClient = require('./protocol1runtimeclient');
-// Expose 'RuntimeVersionManager'.
-exports = module.exports = RuntimeVersionManager;
-
function RuntimeVersionManager(runtimeVersionProtocolClient, runtimeKernel) {
this.protocolClient = runtimeVersionProtocolClient;
this.runtimeKernel = runtimeKernel;
@@ -48,15 +45,19 @@ RuntimeVersionManager.prototype.getRuntimeClient = function (versionEndpoint, ca
callback(error);
} else {
for (var i in self.supportedVersionList) {
- var factory = self.supportedVersionList[i];
+ if (self.supportedVersionList.hasOwnProperty(i)) {
+ var factory = self.supportedVersionList[i];
- if (versionMap[factory.getVersion()]) {
- callback(undefined, factory.createRuntimeClient(versionMap[factory.getVersion()]));
- return;
+ if (versionMap[factory.getVersion()]) {
+ callback(undefined, factory.createRuntimeClient(versionMap[factory.getVersion()]));
+ return;
+ }
}
}
callback('Server does not support any known protocol versions.');
}
});
-};
+};
+
+module.exports = RuntimeVersionManager;
View
15 lib/serviceruntime/runtimeversionprotocolclient.js
@@ -15,12 +15,10 @@
// Module dependencies.
+var _ = require('underscore');
var Constants = require('../util/constants');
var ServiceRuntimeConstants = Constants.ServiceRuntimeConstants;
-// Expose 'RuntimeVersionProtocolClient'.
-exports = module.exports = RuntimeVersionProtocolClient;
-
function RuntimeVersionProtocolClient(inputChannel) {
this.inputChannel = inputChannel;
}
@@ -38,14 +36,15 @@ RuntimeVersionProtocolClient.prototype.getVersionMap = function (connectionPath,
data[ServiceRuntimeConstants.RUNTIME_SERVER_DISCOVERY][ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINTS][0][ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINT]) {
var endpoints = data[ServiceRuntimeConstants.RUNTIME_SERVER_DISCOVERY][ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINTS][0][[ServiceRuntimeConstants.RUNTIME_SERVER_ENDPOINT]];
- for (var endpoint in endpoints) {
- var currentEndpoint = endpoints[endpoint];
-
+
+ _.each(endpoints, function (currentEndpoint) {
versions[currentEndpoint[Constants.XML_METADATA_MARKER].version] = currentEndpoint[Constants.XML_METADATA_MARKER].path;
- }
+ });
}
callback(undefined, versions);
}
});
-};
+};
+
+module.exports = RuntimeVersionProtocolClient;
View
11 lib/serviceruntime/xmlcurrentstateserializer.js
@@ -19,10 +19,7 @@ var js2xml = require('../util/js2xml');
var Constants = require('../util/constants');
var ServiceRuntimeConstants = Constants.ServiceRuntimeConstants;
-// Expose 'XmlCurrentStateSerializer'.
-exports = module.exports = XmlCurrentStateSerializer;
-
-function XmlCurrentStateSerializer() { }
+function XmlCurrentStateSerializer () {}
XmlCurrentStateSerializer.prototype.serialize = function (currentState) {
var currentStateXml = {};
@@ -45,7 +42,7 @@ XmlCurrentStateSerializer.prototype.serialize = function (currentState) {
}
// Serialize JSON object to XML
- var xml = js2xml.serialize(currentStateXml);
+ return js2xml.serialize(currentStateXml);
+};
- return xml;
-};
+module.exports = XmlCurrentStateSerializer;
View
9 lib/serviceruntime/xmlgoalstatedeserializer.js
@@ -17,10 +17,7 @@
var Constants = require('../util/constants');
var ServiceRuntimeConstants = Constants.ServiceRuntimeConstants;
-// Expose 'XmlGoalStateDeserializer'.
-exports = module.exports = XmlGoalStateDeserializer;
-
-function XmlGoalStateDeserializer() { }
+function XmlGoalStateDeserializer() {}
XmlGoalStateDeserializer.prototype.deserialize = function (xml) {
if (!xml) {
@@ -36,4 +33,6 @@ XmlGoalStateDeserializer.prototype.deserialize = function (xml) {
goalState.currentStateEndpoint = xml[ServiceRuntimeConstants.GOAL_STATE][ServiceRuntimeConstants.CURRENT_STATE_ENDPOINT][0];
return goalState;
-};
+};
+
+module.exports = XmlGoalStateDeserializer;
View
57 lib/serviceruntime/xmlroleenvironmentdatadeserializer.js
@@ -14,12 +14,10 @@
*/
// Module dependencies.
+var _ = require('underscore');
var Constants = require('../util/constants');
var ServiceRuntimeConstants = Constants.ServiceRuntimeConstants;
-// Expose 'XmlRoleEnvironmentDataDeserializer'.
-exports = module.exports = XmlRoleEnvironmentDataDeserializer;
-
function XmlRoleEnvironmentDataDeserializer() { }
XmlRoleEnvironmentDataDeserializer.prototype.deserialize = function (xml) {
@@ -51,10 +49,9 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateConfigurationSettings = f
xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.CONFIGURATION_SETTINGS][0][ServiceRuntimeConstants.CONFIGURATION_SETTING]) {
var configurationSettings = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.CONFIGURATION_SETTINGS][0][ServiceRuntimeConstants.CONFIGURATION_SETTING];
- for (var configurationSetting in configurationSettings) {
- var currentConfigurationSetting = configurationSettings[configurationSetting];
+ _.each(configurationSettings, function (currentConfigurationSetting) {
configurationSettingsMap[currentConfigurationSetting[Constants.XML_METADATA_MARKER].name] = currentConfigurationSetting[Constants.XML_METADATA_MARKER].value;
- }
+ });
}
return configurationSettingsMap;
@@ -68,12 +65,11 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateLocalResources = function
xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.LOCAL_RESOURCES][0][ServiceRuntimeConstants.LOCAL_RESOURCE]) {
var localResources = xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.LOCAL_RESOURCES][0][ServiceRuntimeConstants.LOCAL_RESOURCE];
- for (var localResource in localResources) {
- var currentLocalResource = localResources[localResource];
+ _.each(localResources, function (currentLocalResource) {
var currentLocalResourceName = currentLocalResource[Constants.XML_METADATA_MARKER].name;
localResourcesMap[currentLocalResourceName] = currentLocalResource[Constants.XML_METADATA_MARKER];
- }
+ });
}
return localResourcesMap;
@@ -90,9 +86,9 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateCurrentInstance = functio
if (xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.ENDPOINTS]) {
currentInstance.endpoints = this._translateRoleInstanceEndpoints(xml[ServiceRuntimeConstants.CURRENT_INSTANCE][0][ServiceRuntimeConstants.ENDPOINTS][0]);
- for (var endpoint in currentInstance.endpoints) {
- currentInstance.endpoints[endpoint].roleInstanceId = currentInstance.id;
- }
+ _.each(currentInstance.endpoints, function (currentEndpoint) {
+ currentEndpoint.roleInstanceId = currentInstance.id;
+ });
} else {
currentInstance.endpoints = {};
}
@@ -101,6 +97,7 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateCurrentInstance = functio
};
XmlRoleEnvironmentDataDeserializer.prototype._translateRoles = function (xml, currentInstance, currentRole) {
+ var self = this;
var rolesMap = {};
var roleInstances;
@@ -108,24 +105,23 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoles = function (xml, cu
xml[ServiceRuntimeConstants.ROLES][0][ServiceRuntimeConstants.ROLE]) {
var roles = xml[ServiceRuntimeConstants.ROLES][0][ServiceRuntimeConstants.ROLE];
- for (var role in roles) {
- var currentIterationRole = roles[role];
+ _.each(roles, function (currentIterationRole) {
var currentIterationRoleName = currentIterationRole[Constants.XML_METADATA_MARKER].name;
- roleInstances = this._translateRoleInstances(currentIterationRole);
+ roleInstances = self._translateRoleInstances(currentIterationRole);
if (currentIterationRoleName === currentRole) {
roleInstances[currentInstance.id] = currentInstance;
}
- for (var roleInstance in roleInstances) {
- roleInstances[roleInstance].roleName = currentIterationRoleName;
- }
+ _.each(roleInstances, function (currentRoleInstance) {
+ currentRoleInstance.roleName = currentIterationRoleName;
+ });
rolesMap[currentIterationRoleName] = {
name: currentIterationRoleName,
instances: roleInstances
};
- }
+ });
}
if (!rolesMap[currentRole]) {
@@ -145,26 +141,26 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoles = function (xml, cu
};
XmlRoleEnvironmentDataDeserializer.prototype._translateRoleInstances = function (xml) {
+ var self = this;
var roleInstancesMap = {};
if (xml[ServiceRuntimeConstants.INSTANCES] &&
xml[ServiceRuntimeConstants.INSTANCES][0][ServiceRuntimeConstants.INSTANCE]) {
var instances = xml[ServiceRuntimeConstants.INSTANCES][0][ServiceRuntimeConstants.INSTANCE];
- for (var instance in instances) {
- var currentIterationInstance = instances[instance];
+ _.each(instances, function (currentIterationInstance) {
var currentIterationInstanceId = currentIterationInstance[Constants.XML_METADATA_MARKER].id;
- var endpoints = this._translateRoleInstanceEndpoints(currentIterationInstance[ServiceRuntimeConstants.ENDPOINTS][0]);
+ var endpoints = self._translateRoleInstanceEndpoints(currentIterationInstance[ServiceRuntimeConstants.ENDPOINTS][0]);
- for (var endpoint in endpoints) {
- endpoints[endpoint].roleInstanceId = currentIterationInstanceId;
- }
+ _.each(endpoints, function (currentEndpoint) {
+ currentEndpoint.roleInstanceId = currentIterationInstanceId;
+ });
currentIterationInstance[Constants.XML_METADATA_MARKER].endpoints = endpoints;
roleInstancesMap[currentIterationInstanceId] = currentIterationInstance[Constants.XML_METADATA_MARKER];
- }
+ });
}
return roleInstancesMap;
@@ -177,13 +173,14 @@ XmlRoleEnvironmentDataDeserializer.prototype._translateRoleInstanceEndpoints = f
endpointsXml[ServiceRuntimeConstants.ENDPOINT]) {
var endpoints = endpointsXml[ServiceRuntimeConstants.ENDPOINT];
- for (var endpoint in endpoints) {
- var currentEndpoint = endpoints[endpoint];
+ _.each(endpoints, function (currentEndpoint) {
var currentEndpointName = currentEndpoint[Constants.XML_METADATA_MARKER].name;
endpointsMap[currentEndpointName] = currentEndpoint[Constants.XML_METADATA_MARKER];
- }
+ });
}
return endpointsMap;
-};
+};
+
+module.exports = XmlRoleEnvironmentDataDeserializer;
View
279 lib/services/blob/blobservice.js
@@ -17,10 +17,8 @@
var fs = require('fs');
var qs = require('querystring');
var url = require('url');
-var path = require('path');
var util = require('util');
var crypto = require('crypto');
-var xmlbuilder = require('xmlbuilder');
var mime = require('mime');
var _ = require('underscore');
@@ -30,7 +28,6 @@ var ISO8061Date = require('../../util/iso8061date');
var SharedKey = require('./sharedkey');
var SharedAccessSignature = require('./sharedaccesssignature');
var StorageServiceClient = require('../core/storageserviceclient');
-var ServiceClient = require('../core/serviceclient');
var WebResource = require('../../http/webresource');
var Constants = require('../../util/constants');
var HeaderConstants = Constants.HeaderConstants;
@@ -39,7 +36,7 @@ var BlobConstants = Constants.BlobConstants;
var HttpConstants = Constants.HttpConstants;
// Models requires
-var ServicePropertiesResult = require('./models/servicepropertiesresult');
+var servicePropertiesResult = require('./models/servicepropertiesresult');
var ContainerAclResult = require('./models/containeraclresult');
var BlockListResult = require('./models/blocklistresult');
var BlobResult = require('./models/blobresult');
@@ -48,23 +45,6 @@ var LeaseResult = require('./models/leaseresult');
var ListBlobsResultContinuation = require('./models/listblobsresultcontinuation');
var ListContainersResultContinuation = require('./models/listcontainersresultcontinuation');
-// Expose 'BlobService'.
-exports = module.exports = BlobService;
-
-// Validation error messages
-BlobService.needCntErr = "Container name must be specified in the 'name' parameter.";
-BlobService.needCntBlobErr = "Container and blob name must be specified in the 'name' parameter, separated with a forward slash.";
-BlobService.needBlobValErr = "Blob value must be specified in the 'data' parameter.";
-BlobService.incorrectContainerNameErr = 'Container name must be a non empty string.';
-BlobService.incorrectContainerNameFormatErr = 'Container name format is incorrect.';
-BlobService.incorrectBlobNameErr = 'Blob name is not specified.';
-BlobService.incorrectBlobNameFormatErr = 'Blob name format is incorrect.';
-BlobService.incorrectMetadataErr = 'Metadata should be a JSON object.';
-BlobService.incorrectCallbackErr = 'Callback must be specified.';
-BlobService.incorrectFilenameErr = 'Local filename is not specified.';
-BlobService.incorrectStartByteOffsetErr = 'Start byte offset must be a modulus of 512.';
-BlobService.incorrectEndByteOffsetErr = 'End byte offset must be a modulus of 512 minus 1.';
-
/**
* Creates a new BlobService object.
* If no storageaccount or storageaccesskey are provided, the AZURE_STORAGE_ACCOUNT and AZURE_STORAGE_ACCESS_KEY environment variables will be used.
@@ -80,7 +60,7 @@ BlobService.incorrectEndByteOffsetErr = 'End byte offset must be a modulus of 51
function BlobService(storageAccountOrConnectionString, storageAccessKey, host, authenticationProvider) {
var storageServiceSettings = StorageServiceClient.getStorageSettings(storageAccountOrConnectionString, storageAccessKey, host);
- BlobService.super_.call(this,
+ StorageServiceClient.call(this,
storageServiceSettings._name,
storageServiceSettings._key,
storageServiceSettings._blobEndpointUri,
@@ -101,6 +81,105 @@ function BlobService(storageAccountOrConnectionString, storageAccessKey, host, a
util.inherits(BlobService, StorageServiceClient);
+// Validation error messages
+BlobService.needCntErr = 'Container name must be specified in the \'name\' parameter.';
+BlobService.needCntBlobErr = 'Container and blob name must be specified in the \'name\' parameter, separated with a forward slash.';
+BlobService.needBlobValErr = 'Blob value must be specified in the \'data\' parameter.';
+BlobService.incorrectContainerNameErr = 'Container name must be a non empty string.';
+BlobService.incorrectContainerNameFormatErr = 'Container name format is incorrect.';
+BlobService.incorrectBlobNameErr = 'Blob name is not specified.';
+BlobService.incorrectBlobNameFormatErr = 'Blob name format is incorrect.';
+BlobService.incorrectMetadataErr = 'Metadata should be a JSON object.';
+BlobService.incorrectCallbackErr = 'Callback must be specified.';
+BlobService.incorrectFilenameErr = 'Local filename is not specified.';
+BlobService.incorrectStartByteOffsetErr = 'Start byte offset must be a modulus of 512.';
+BlobService.incorrectEndByteOffsetErr = 'End byte offset must be a modulus of 512 minus 1.';
+
+// Non-class methods
+
+/**
+* Create resource name
+*
+* @param {string} containerName Container name
+* @param {string} blobName Blob name
+* @return {string} The encoded resource name.
+*/
+function createResourceName(containerName, blobName) {
+ // Resource name
+ var resourceName = containerName + '/' + blobName;
+ if (!containerName || containerName === '$root') {
+ resourceName = blobName;
+ }
+
+ if (!blobName) {
+ resourceName = containerName;
+ }
+
+ // return URI encoded resource name
+ return encodeURI(resourceName);
+}
+
+/**
+* Validates a container name.
+*
+* @param {string} containerName The container name.
+* @return {undefined}
+*/
+function validateContainerName(containerName) {
+ if (!azureutil.objectIsString(containerName) || azureutil.stringIsEmpty(containerName)) {
+ throw new Error(BlobService.incorrectContainerNameErr);
+ }
+
+ if (containerName === '$root') {
+ return;
+ }
+
+ if (containerName.match('^[a-z0-9][a-z0-9-]*$') === null) {
+ throw new Error(BlobService.incorrectContainerNameFormatErr);
+ }
+
+ if (containerName.indexOf('--') !== -1) {
+ throw new Error(BlobService.incorrectContainerNameFormatErr);
+ }
+
+ if (containerName.length < 3 || containerName.length > 63) {
+ throw new Error(BlobService.incorrectContainerNameFormatErr);
+ }
+
+ if (containerName.substr(containerName.length - 1, 1) === '-') {
+ throw new Error(BlobService.incorrectContainerNameFormatErr);
+ }
+}
+
+/**
+* Validates a blob name.
+*
+* @param {string} containerName The container name.
+* @param {string} blobname The blob name.
+* @return {undefined}
+*/
+function validateBlobName(containerName, blobName) {
+ if (!blobName) {
+ throw new Error(BlobService.incorrectBlobNameErr);
+ }
+
+ if (containerName === '$root' && blobName.indexOf('/') !== -1) {
+ throw new Error(BlobService.incorrectBlobNameFormatErr);
+ }
+}
+
+/**
+* Validates a callback function.
+*
+* @param {function} callback The callback function.
+* @return {undefined}
+*/
+function validateCallback(callback) {
+ if (!callback) {
+ throw new Error(BlobService.incorrectCallbackErr);
+ }
+}
+
/**
* Gets the properties of a storage account’s Blob service, including Windows Azure Storage Analytics.
*
@@ -127,7 +206,7 @@ BlobService.prototype.getServiceProperties = function (optionsOrCallback, callba
var processResponseCallback = function (responseObject, next) {
responseObject.servicePropertiesResult = null;
if (!responseObject.error) {
- responseObject.servicePropertiesResult = ServicePropertiesResult.parse(responseObject.response.body.StorageServiceProperties);
+ responseObject.servicePropertiesResult = servicePropertiesResult.parse(responseObject.response.body.StorageServiceProperties);
}
// function to be called after all filters
@@ -163,7 +242,7 @@ BlobService.prototype.setServiceProperties = function (serviceProperties, option
validateCallback(callback);
- var servicePropertiesXml = ServicePropertiesResult.serialize(serviceProperties);
+ var servicePropertiesXml = servicePropertiesResult.serialize(serviceProperties);
var webResource = WebResource.put().withOkCode(HttpConstants.HttpResponseCodes.ACCEPTED_CODE);
webResource.addOptionalQueryParam(QueryStringConstants.COMP, 'properties');
@@ -433,7 +512,7 @@ BlobService.prototype.getContainerMetadata = function (container, optionsOrCallb
/**
* Sets the container's metadata.
*
-* Calling the Set Container Metadata operation overwrites all existing metadata that is associated with the container.
+* Calling the Set Container Metadata operation overwrites all existing metadata that is associated with the container.
* It's not possible to modify an individual name/value pair.
*
* @this {BlobService}
@@ -582,7 +661,7 @@ BlobService.prototype.setContainerAcl = function (container, publicAccessLevel,
};
/**
-* Marks the specified container for deletion.
+* Marks the specified container for deletion.
* The container and any blobs contained within it are later deleted during garbage collection.
*
* @this {BlobService}
@@ -746,8 +825,8 @@ BlobService.prototype.createPageBlob = function (container, blob, length, option
this.performRequest(webResource, null, options, processResponseCallback);
};
-/**
-* Creates a new block blob or page blob, or updates the content of an existing block blob.
+/**
+* Creates a new block blob or page blob, or updates the content of an existing block blob.
* Updating an existing block blob overwrites any existing metadata on the blob. Partial updates are not supported with Put Blob; the content of the existing blob is overwritten with the content of the new blob. To perform a partial update of the content of a block blob, use the Put Block List operation.
* Calling Put Blob to create a page blob only initializes the blob. To add content to a page blob, call the Put Page operation.
*
@@ -1642,7 +1721,7 @@ BlobService.prototype.acquireLease = function (container, blob, optionsOrCallbac
* @param {function(error, lease, response)} callback The callback function.
* @return {undefined}
*/
-BlobService.prototype.renewLease = function(container, blob, leaseId, optionsOrCallback, callback) {
+BlobService.prototype.renewLease = function (container, blob, leaseId, optionsOrCallback, callback) {
var options = null;
if (typeof optionsOrCallback === 'function' && !callback) {
callback = optionsOrCallback;
@@ -1690,7 +1769,7 @@ BlobService.prototype.releaseLease = function (container, blob, leaseId, options
* @param {function(error, lease, response)} callback The callback function.
* @return {undefined}
*/
-BlobService.prototype.breakLease = function(container, blob, leaseId, optionsOrCallback, callback) {
+BlobService.prototype.breakLease = function (container, blob, leaseId, optionsOrCallback, callback) {
var options = null;
if (typeof optionsOrCallback === 'function' && !callback) {
callback = optionsOrCallback;
@@ -1768,7 +1847,7 @@ BlobService.prototype.createBlobPagesFromStream = function (container, blob, rea
validateCallback(callback);
var webResource = this._updatePageBlobPagesImpl(container, blob,
- (rangeEnd - rangeStart) + 1, rangeStart, rangeEnd,
+ (rangeEnd - rangeStart) + 1, rangeStart, rangeEnd,
BlobConstants.PageWriteOptions.UPDATE, options);
var self = this;
@@ -2021,8 +2100,8 @@ BlobService.prototype.createBlobBlockFromStream = function (blockId, container,
};
/**
-* Writes a blob by specifying the list of block IDs that make up the blob.
-* In order to be written as part of a blob, a block must have been successfully written to the server in a prior
+* Writes a blob by specifying the list of block IDs that make up the blob.
+* In order to be written as part of a blob, a block must have been successfully written to the server in a prior
* createBlobBlock operation.
*
* @this {BlobService}
@@ -2253,22 +2332,22 @@ BlobService.prototype._leaseBlobImpl = function (container, blob, leaseId, lease
var expectedResponseCode = null;
switch (leaseAction) {
- case BlobConstants.LeaseOperation.ACQUIRE:
- // Acquire: A successful operation returns status code 201 (Created).
- expectedResponseCode = HttpConstants.HttpResponseCodes.CREATED_CODE;
- break;
- case BlobConstants.LeaseOperation.RENEW:
- // Renew: A successful operation returns status code 200 (OK).
- expectedResponseCode = HttpConstants.HttpResponseCodes.OK_CODE;
- break;
- case BlobConstants.LeaseOperation.RELEASE:
- // Release: A successful operation returns status code 200 (OK).
- expectedResponseCode = HttpConstants.HttpResponseCodes.OK_CODE;
- break;
- case BlobConstants.LeaseOperation.BREAK:
- // Break: A successful operation returns status code 202 (Accepted).
- expectedResponseCode = HttpConstants.HttpResponseCodes.ACCEPTED_CODE;
- break;
+ case BlobConstants.LeaseOperation.ACQUIRE:
+ // Acquire: A successful operation returns status code 201 (Created).
+ expectedResponseCode = HttpConstants.HttpResponseCodes.CREATED_CODE;
+ break;
+ case BlobConstants.LeaseOperation.RENEW:
+ // Renew: A successful operation returns status code 200 (OK).
+ expectedResponseCode = HttpConstants.HttpResponseCodes.OK_CODE;
+ break;
+ case BlobConstants.LeaseOperation.RELEASE:
+ // Release: A successful operation returns status code 200 (OK).
+ expectedResponseCode = HttpConstants.HttpResponseCodes.OK_CODE;
+ break;
+ case BlobConstants.LeaseOperation.BREAK:
+ // Break: A successful operation returns status code 202 (Accepted).
+ expectedResponseCode = HttpConstants.HttpResponseCodes.ACCEPTED_CODE;
+ break;
}
var resourceName = createResourceName(container, blob);
@@ -2450,104 +2529,4 @@ BlobService.prototype._analyzeStream = function (stream, calculateMD5, callback)
});
};
-// Non-class methods
-
-/**
-* Create resource name
-*
-* @param {string} containerName Container name
-* @param {string} blobName Blob name
-* @return {string} The encoded resource name.
-*/
-function createResourceName(containerName, blobName) {
- // Resource name
- var resourceName = containerName + '/' + blobName;
- if (!containerName || containerName === '$root') {
- resourceName = blobName;
- }
-
- if (!blobName) {
- resourceName = containerName;
- }
-
- // return URI encoded resource name
- return encodeURI(resourceName);
-}
-
-/**
-* Generate a block identifier.
-*
-* @param {int} part Block number
-* @return {string} The block identifier.
-*/
-function generateBlockId(part) {
- // make sure part becomes a string
- var returnValue = part + '';
-
- while (returnValue.length < 64) {
- returnValue = '0' + returnValue;
- }
-
- return returnValue;
-}
-
-/**
-* Validates a container name.
-*
-* @param {string} containerName The container name.
-* @return {undefined}
-*/
-function validateContainerName(containerName) {
- if (!azureutil.objectIsString(containerName) || azureutil.stringIsEmpty(containerName)) {
- throw new Error(BlobService.incorrectContainerNameErr);
- }
-
- if (containerName === '$root') {
- return;
- }
-
- if (containerName.match('^[a-z0-9][a-z0-9-]*$') === null) {
- throw new Error(BlobService.incorrectContainerNameFormatErr);
- }
-
- if (containerName.indexOf('--') !== -1) {
- throw new Error(BlobService.incorrectContainerNameFormatErr);
- }
-
- if (containerName.length < 3 || containerName.length > 63) {
- throw new Error(BlobService.incorrectContainerNameFormatErr);
- }
-
- if (containerName.substr(containerName.length - 1, 1) === '-') {
- throw new Error(BlobService.incorrectContainerNameFormatErr);
- }
-}
-
-/**
-* Validates a blob name.
-*
-* @param {string} containerName The container name.
-* @param {string} blobname The blob name.
-* @return {undefined}
-*/
-function validateBlobName(containerName, blobName) {
- if (!blobName) {
- throw new Error(BlobService.incorrectBlobNameErr);
- }
-
- if (containerName === '$root' && blobName.indexOf('/') !== -1) {
- throw new Error(BlobService.incorrectBlobNameFormatErr);
- }
-}
-
-/**
-* Validates a callback function.
-*
-* @param {function} callback The callback function.
-* @return {undefined}
-*/
-function validateCallback(callback) {
- if (!callback) {
- throw new Error(BlobService.incorrectCallbackErr);
- }
-}
+module.exports = BlobService;
View
8 lib/services/blob/hmacsha256sign.js
@@ -16,12 +16,6 @@
// Module dependencies.
var crypto = require('crypto');
-var azureutil = require('../../util/util');
-var HeaderConstants = require('../../util/constants').HeaderConstants;
-
-// Expose 'HmacSHA256Sign'.
-exports = module.exports = HmacSha256Sign;
-
/**
* Creates a new HmacSHA256Sign object.
*
@@ -44,3 +38,5 @@ HmacSha256Sign.prototype.sign = function (stringToSign) {
return crypto.createHmac('sha256', this._decodedAccessKey).update(stringToSign).digest('base64');
};
+
+module.exports = HmacSha256Sign;
View
11 lib/services/blob/models/blobresult.js
@@ -14,14 +14,9 @@
*/
// Module dependencies.
-var xmlbuilder = require('xmlbuilder');
-
var Constants = require('../../../util/constants');
var HeaderConstants = Constants.HeaderConstants;
-// Expose 'BlobResult'.
-exports = module.exports = BlobResult;
-
function BlobResult(container, blob) {
if (container) {
this.container = container;
@@ -38,7 +33,9 @@ BlobResult.parse = function (blobXml) {
if (propertyName === 'Properties' || propertyName === 'Metadata') {
blobResult[propertyName.toLowerCase()] = { };
for (var subPropertyName in blobXml[propertyName]) {
- blobResult[propertyName.toLowerCase()][subPropertyName.toLowerCase()] = blobXml[propertyName][subPropertyName];
+ if (blobXml[propertyName].hasOwnProperty(subPropertyName)) {
+ blobResult[propertyName.toLowerCase()][subPropertyName.toLowerCase()] = blobXml[propertyName][subPropertyName];
+ }
}
} else {
blobResult[propertyName.toLowerCase()] = blobXml[propertyName];
@@ -86,3 +83,5 @@ BlobResult.prototype.getPropertiesFromHeaders = function (headers) {
setBlobPropertyFromHeaders('leaseId', HeaderConstants.LEASE_ID_HEADER);
setBlobPropertyFromHeaders('sequenceNumberHeader', HeaderConstants.SEQUENCE_NUMBER);
};
+
+module.exports = BlobResult;
View
6 lib/services/blob/models/blocklistresult.js
@@ -15,13 +15,9 @@
// Module dependencies.
var xmlbuilder = require('xmlbuilder');
-var azureutil = require('../../../util/util');
var Constants = require('../../../util/constants');
-// Expose 'BlockListResult'.
-exports = module.exports = BlockListResult;
-
function BlockListResult(committedBlocks, uncommittedBlocks, latestBlocks) {
if (latestBlocks) {
this.LatestBlocks = latestBlocks;
@@ -90,3 +86,5 @@ BlockListResult.parse = function (blockListXml) {
return blockListResult;
};
+
+module.exports = BlockListResult;
View
7 lib/services/blob/models/containeraclresult.js
@@ -19,9 +19,6 @@ var xmlbuilder = require('xmlbuilder');
var Constants = require('../../../util/constants');
var ISO8061Date = require('../../../util/iso8061date');
-// Expose 'ContainerAclResult'.
-exports = module.exports = ContainerAclResult;
-
var ACL_MILLISECONDS_PADING = 7;
function ContainerAclResult(signedIdentifiers) {
@@ -117,4 +114,6 @@ ContainerAclResult.parse = function (signedIdentifiersXml) {
}
return signedIdentifiers;
-};
+};
+
+module.exports = ContainerAclResult;
View
23 lib/services/blob/models/containerresult.js
@@ -14,15 +14,10 @@
*/
// Module dependencies.
-var xmlbuilder = require('xmlbuilder');
-
var Constants = require('../../../util/constants');
var HeaderConstants = Constants.HeaderConstants;
var BlobConstants = Constants.BlobConstants;
-// Expose 'ContainerResult'.
-exports = module.exports = ContainerResult;
-
function ContainerResult(name, publicAccessLevel) {
if (name) {
this.name = name;
@@ -36,13 +31,17 @@ function ContainerResult(name, publicAccessLevel) {
ContainerResult.parse = function (containerXml) {
var containerResult = new ContainerResult();
for (var propertyName in containerXml) {
- if (propertyName === 'Properties' || propertyName === 'Metadata') {
- containerResult[propertyName.toLowerCase()] = { };
- for (var subPropertyName in containerXml[propertyName]) {
- containerResult[propertyName.toLowerCase()][subPropertyName.toLowerCase()] = containerXml[propertyName][subPropertyName];
+ if (containerXml.hasOwnProperty(propertyName)) {
+ if (propertyName === 'Properties' || propertyName === 'Metadata') {
+ containerResult[propertyName.toLowerCase()] = { };
+ for (var subPropertyName in containerXml[propertyName]) {
+ if (containerXml[propertyName].hasOwnProperty(subPropertyName)) {
+ containerResult[propertyName.toLowerCase()][subPropertyName.toLowerCase()] = containerXml[propertyName][subPropertyName];
+ }
+ }
+ } else {
+ containerResult[propertyName.toLowerCase()] = containerXml[propertyName];
}
- } else {
- containerResult[propertyName.toLowerCase()] = containerXml[propertyName];
}
}
@@ -73,3 +72,5 @@ ContainerResult.prototype.getPropertiesFromHeaders = function (headers) {
self.publicAccessLevel = BlobConstants.BlobContainerPublicAccessType.CONTAINER;
}
};
+
+module.exports = ContainerResult;
View
5 lib/services/blob/models/leaseresult.js
@@ -17,9 +17,6 @@
var Constants = require('../../../util/constants');
var HeaderConstants = Constants.HeaderConstants;
-// Expose 'LeaseResult'.
-exports = module.exports = LeaseResult;
-
function LeaseResult(container, blob, id, time) {
if (container) {
this.container = container;
@@ -50,3 +47,5 @@ LeaseResult.prototype.getPropertiesFromHeaders = function (headers) {
setPropertyFromHeaders('id', HeaderConstants.LEASE_ID_HEADER);
setPropertyFromHeaders('time', HeaderConstants.LEASE_TIME_HEADER);
};
+
+module.exports = LeaseResult;
View
9 lib/services/blob/models/listblobsresultcontinuation.js
@@ -16,11 +16,6 @@
// Module dependencies.
var azureutil = require('../../../util/util');
-var Constants = require('../../../util/constants');
-
-// Expose 'ListBlobsResultContinuation'.
-exports = module.exports = ListBlobsResultContinuation;
-
/**
* Creates a new ListBlobsResultContinuation object.
*/
@@ -55,4 +50,6 @@ ListBlobsResultContinuation.prototype.getNextPage = function (callback) {
ListBlobsResultContinuation.prototype.hasNextPage = function () {
return this.nextMarker !== undefined && this.nextMarker !== null;
-};
+};
+
+module.exports = ListBlobsResultContinuation;
View
9 lib/services/blob/models/listcontainersresultcontinuation.js
@@ -16,11 +16,6 @@
// Module dependencies.
var azureutil = require('../../../util/util');
-var Constants = require('../../../util/constants');
-
-// Expose 'ListContainersResultContinuation'.
-exports = module.exports = ListContainersResultContinuation;
-
/**
* Creates a new ListContainersResultContinuation object.
*/
@@ -51,4 +46,6 @@ ListContainersResultContinuation.prototype.getNextPage = function (callback) {
ListContainersResultContinuation.prototype.hasNextPage = function () {
return (this.nextMarker !== undefined && this.nextMarker !== null);
-};
+};
+
+module.exports = ListContainersResultContinuation;
View
9 lib/services/blob/models/servicepropertiesresult.js
@@ -18,12 +18,9 @@ var xmlbuilder = require('xmlbuilder');
var Constants = require('../../../util/constants');
-// Expose 'ServicePropertiesResult'.
-exports = module.exports = ServicePropertiesResult;
+exports = module.exports;
-function ServicePropertiesResult () {}
-
-ServicePropertiesResult.serialize = function (servicePropertiesJs) {
+exports.serialize = function (servicePropertiesJs) {
var doc = xmlbuilder.create();
doc = doc.begin(Constants.STORAGE_SERVICE_PROPERTIES_ELEMENT, { version: '1.0', encoding: 'utf-8' });
@@ -122,7 +119,7 @@ ServicePropertiesResult.serialize = function (servicePropertiesJs) {
return doc.doc().toString();
};
-ServicePropertiesResult.parse = function (servicePropertiesXml) {
+exports.parse = function (servicePropertiesXml) {
var serviceProperties = {};
if (servicePropertiesXml.Logging) {
View
35 lib/services/blob/sharedaccesssignature.js
@@ -14,20 +14,15 @@
*/
// Module dependencies.
-var crypto = require('crypto');
-var qs = require('querystring');
+var qs = require('querystring');
var azureutil = require('../../util/util');
-var ServiceClient = require('../core/serviceclient');
var HmacSha256Sign = require('./hmacsha256sign');
var Constants = require('../../util/constants');
var BlobConstants = Constants.BlobConstants;
var QueryStringConstants = Constants.QueryStringConstants;
-// Expose 'SharedAccessSignature'.
-exports = module.exports = SharedAccessSignature;
-
/**
* Creates a new SharedAccessSignature object.
*
@@ -86,20 +81,22 @@ SharedAccessSignature.prototype.signRequest = function (webResource, callback) {
var self = this;
for (var permission in this.permissionSet) {
- var sharedAccessSignature = this.permissionSet[permission];
+ if (this.permissionSet.hasOwnProperty(permission)) {
+ var sharedAccessSignature = this.permissionSet[permission];
- if (self._permissionMatchesRequest(sharedAccessSignature, webResource,
- webResource.properties[BlobConstants.ResourceTypeProperty],
- webResource.properties[BlobConstants.SharedAccessPermissionProperty])) {
+ if (self._permissionMatchesRequest(sharedAccessSignature, webResource,
+ webResource.properties[BlobConstants.ResourceTypeProperty],
+ webResource.properties[BlobConstants.SharedAccessPermissionProperty])) {
- if (webResource.requestUrl.indexOf('?') === -1) {
- webResource.requestUrl += '?';
- } else {
- webResource.requestUrl += '&';
- }
+ if (webResource.requestUrl.indexOf('?') === -1) {
+ webResource.requestUrl += '?';
+ } else {
+ webResource.requestUrl += '&';
+ }
- webResource.requestUrl += qs.stringify(sharedAccessSignature.queryString);
- break;
+ webResource.requestUrl += qs.stringify(sharedAccessSignature.queryString);
+ break;
+ }
}
}
@@ -175,4 +172,6 @@ SharedAccessSignature.prototype._permissionMatchesRequest = function (sharedAcce
}
return webResource.path.indexOf(sharedAccessSignature.path) !== -1;
-};
+};
+
+module.exports = SharedAccessSignature;
View
26 lib/services/blob/sharedkey.js
@@ -14,15 +14,12 @@
*/
// Module dependencies.
-var crypto = require('crypto');
+var _ = require('underscore');
var azureutil = require('../../util/util');
var HeaderConstants = require('../../util/constants').HeaderConstants;
var HmacSha256Sign = require('./hmacsha256sign');
-// Expose 'SharedKey'.
-exports = module.exports = SharedKey;
-
/**
* Creates a new SharedKey object.
*
@@ -40,7 +37,7 @@ function SharedKey(storageAccount, storageAccessKey, usePathStyleUri) {
/**
* Signs a request with the Authentication header.
-*
+*
* @param {WebResource} The webresource to be signed.
* @param {function(error)} callback The callback function.
* @return {undefined}
@@ -96,12 +93,16 @@ SharedKey.prototype._getCanonicalizedResource = function (webResource) {
if (queryStringValues) {
var paramNames = [];
for (var n in queryStringValues) {
- paramNames.push(n);
+ if (queryStringValues.hasOwnProperty(n)) {
+ paramNames.push(n);
+ }
}
paramNames = paramNames.sort();
for (var name in paramNames) {
- canonicalizedResource += '\n' + paramNames[name] + ':' + queryStringValues[paramNames[name]];
+ if (paramNames.hasOwnProperty(name)) {
+ canonicalizedResource += '\n' + paramNames[name] + ':' + queryStringValues[paramNames[name]];
+ }
}
}
@@ -137,10 +138,13 @@ SharedKey.prototype._getCanonicalizedHeaders = function (webResource) {
}
canonicalizedHeadersArray.sort();
- for (var headerName in canonicalizedHeadersArray) {
- canonicalizedHeaders += canonicalizedHeadersArray[headerName].toLowerCase() + ":" + webResource.headers[canonicalizedHeadersArray[headerName]] + '\n';
- }
+
+ _.each(canonicalizedHeadersArray, function (currentHeader) {
+ canonicalizedHeaders += currentHeader.toLowerCase() + ':' + webResource.headers[currentHeader] + '\n';
+ });
}
return canonicalizedHeaders;
-};
+};
+
+module.exports = SharedKey;
View
18 lib/services/blob/sharedkeylite.js
@@ -14,7 +14,7 @@
*/
// Module dependencies.
-var crypto = require('crypto');
+var _ = require('underscore');
var azureutil = require('../../util/util');
var HmacSha256Sign = require('./hmacsha256sign');
@@ -22,9 +22,6 @@ var Constants = require('../../util/constants');
var HeaderConstants = Constants.HeaderConstants;
var QueryStringConstants = Constants.QueryStringConstants;
-// Expose 'SharedKeyLite'.
-exports = module.exports = SharedKeyLite;
-
/**
* Creates a new SharedKey object.
*
@@ -42,7 +39,7 @@ function SharedKeyLite(storageAccount, storageAccessKey, usePathStyleUri) {
/**
* Signs a request with the Authentication header.
-*
+*
* @param {WebResource} The webresource to be signed.
* @param {function(error)} callback The callback function.
* @return {undefined}
@@ -120,10 +117,13 @@ SharedKeyLite.prototype._getCanonicalizedHeaders = function (webResource) {
}
canonicalizedHeadersArray.sort();
- for (var headerName in canonicalizedHeadersArray) {
- canonicalizedHeaders += canonicalizedHeadersArray[headerName].toLowerCase() + ":" + webResource.headers[canonicalizedHeadersArray[headerName]] + '\n';
- }
+
+ _.each(canonicalizedHeadersArray, function (currentHeader) {
+ canonicalizedHeaders += currentHeader.toLowerCase() + ':' + webResource.headers[currentHeader] + '\n';
+ });
}
return canonicalizedHeaders;
-};
+};
+
+module.exports = SharedKeyLite;
View
52 lib/services/core/connectionstringparser.js
@@ -13,8 +13,6 @@
* limitations under the License.
*/
-var util = require('../../util/util');
-
// Expose 'ConnectionStringParser'.
exports = module.exports;
@@ -51,28 +49,28 @@ ConnectionStringParser.prototype._parse = function () {
}
switch (this._state) {
- case 'ExpectKey':
- key = this._extractKey();
- this._state = 'ExpectAssignment';
- break;
+ case 'ExpectKey':
+ key = this._extractKey();
+ this._state = 'ExpectAssignment';
+ break;
- case 'ExpectAssignment':
- this._skipOperator('=');
- this._state = 'ExpectValue';
- break;
+ case 'ExpectAssignment':
+ this._skipOperator('=');
+ this._state = 'ExpectValue';
+ break;
- case 'ExpectValue':
- value = this._extractValue();
- this._state = 'ExpectSeparator';
- parsedConnectionString[key.toLowerCase()] = value;
- key = null;
- value = null;
- break;
+ case 'ExpectValue':
+ value = this._extractValue();
+ this._state = 'ExpectSeparator';
+ parsedConnectionString[key.toLowerCase()] = value;
+ key = null;
+ value = null;
+ break;
- default:
- this._skipOperator(';');
- this._state = 'ExpectKey';
- break;
+ default:
+ this._skipOperator(';');
+ this._state = 'ExpectKey';
+ break;
}
}
@@ -144,8 +142,8 @@ ConnectionStringParser.prototype._extractString = function (quote) {
}
if (this._pos === this._value.length) {
- // Runaway string.
- throw new Error('Unterminated string starting at position ' + firstPos);
+ // Runaway string.
+ throw new Error('Unterminated string starting at position ' + firstPos);
}
return this._value.substring(firstPos, this._pos++);
@@ -157,9 +155,11 @@ ConnectionStringParser.prototype._extractString = function (quote) {
* @param {string} operatorChar The oeprator to skip.
*/
ConnectionStringParser.prototype._skipOperator = function (operatorChar) {
- if (this._value[this._pos] != operatorChar) {
- // Character was expected.
- throw new Error('expecting ' + operatorChar + ' but instead got ' + currentChar + ' at position ' + this._pos);
+ var currentChar = this._value[this._pos];
+
+ if (currentChar != operatorChar) {
+ // Character was expected.
+ throw new Error('expecting ' + operatorChar + ' but instead got ' + currentChar + ' at position ' + this._pos);
}
this._pos++;
View
40 lib/services/core/exponentialretrypolicyfilter.js
@@ -15,7 +15,21 @@
var azureutil = require('../../util/util');
-exports = module.exports = ExponentialRetryPolicyFilter;
+/**
+* Creates a new 'ExponentialRetryPolicyFilter' instance.
+*