Commit ac7b32f6 authored by Marco Mariani's avatar Marco Mariani

fixed username checking in localstorage, updated jio.js and complex_queries.js

parent 49a12950
...@@ -1363,6 +1363,9 @@ SimpleQuery.prototype.match = function (item, wildcard_character) { ...@@ -1363,6 +1363,9 @@ SimpleQuery.prototype.match = function (item, wildcard_character) {
object_value = item[key]; object_value = item[key];
value = this.value; value = this.value;
} }
if (object_value === undefined || value === undefined) {
return RSVP.resolve(false);
}
return matchMethod(object_value, value, wildcard_character); return matchMethod(object_value, value, wildcard_character);
}; };
...@@ -1406,15 +1409,6 @@ SimpleQuery.prototype["="] = function (object_value, comparison_value, ...@@ -1406,15 +1409,6 @@ SimpleQuery.prototype["="] = function (object_value, comparison_value,
if (typeof value === 'object' && value.hasOwnProperty('content')) { if (typeof value === 'object' && value.hasOwnProperty('content')) {
value = value.content; value = value.content;
} }
if (comparison_value === undefined) {
if (value === undefined) {
return RSVP.resolve(true);
}
return RSVP.resolve(false);
}
if (value === undefined) {
return RSVP.resolve(false);
}
if (value.cmp !== undefined) { if (value.cmp !== undefined) {
return RSVP.resolve(value.cmp(comparison_value, return RSVP.resolve(value.cmp(comparison_value,
wildcard_character) === 0); wildcard_character) === 0);
...@@ -1451,15 +1445,6 @@ SimpleQuery.prototype["!="] = function (object_value, comparison_value, ...@@ -1451,15 +1445,6 @@ SimpleQuery.prototype["!="] = function (object_value, comparison_value,
if (typeof value === 'object' && value.hasOwnProperty('content')) { if (typeof value === 'object' && value.hasOwnProperty('content')) {
value = value.content; value = value.content;
} }
if (comparison_value === undefined) {
if (value === undefined) {
return RSVP.resolve(false);
}
return RSVP.resolve(true);
}
if (value === undefined) {
return RSVP.resolve(true);
}
if (value.cmp !== undefined) { if (value.cmp !== undefined) {
return RSVP.resolve(value.cmp(comparison_value, return RSVP.resolve(value.cmp(comparison_value,
wildcard_character) !== 0); wildcard_character) !== 0);
...@@ -1493,9 +1478,6 @@ SimpleQuery.prototype["<"] = function (object_value, comparison_value) { ...@@ -1493,9 +1478,6 @@ SimpleQuery.prototype["<"] = function (object_value, comparison_value) {
if (typeof value === 'object' && value.hasOwnProperty('content')) { if (typeof value === 'object' && value.hasOwnProperty('content')) {
value = value.content; value = value.content;
} }
if (value === undefined || comparison_value === undefined) {
return RSVP.resolve(false);
}
if (value.cmp !== undefined) { if (value.cmp !== undefined) {
return RSVP.resolve(value.cmp(comparison_value) < 0); return RSVP.resolve(value.cmp(comparison_value) < 0);
} }
...@@ -1520,9 +1502,6 @@ SimpleQuery.prototype["<="] = function (object_value, comparison_value) { ...@@ -1520,9 +1502,6 @@ SimpleQuery.prototype["<="] = function (object_value, comparison_value) {
if (typeof value === 'object' && value.hasOwnProperty('content')) { if (typeof value === 'object' && value.hasOwnProperty('content')) {
value = value.content; value = value.content;
} }
if (value === undefined || comparison_value === undefined) {
return RSVP.resolve(false);
}
if (value.cmp !== undefined) { if (value.cmp !== undefined) {
return RSVP.resolve(value.cmp(comparison_value) <= 0); return RSVP.resolve(value.cmp(comparison_value) <= 0);
} }
...@@ -1547,9 +1526,6 @@ SimpleQuery.prototype[">"] = function (object_value, comparison_value) { ...@@ -1547,9 +1526,6 @@ SimpleQuery.prototype[">"] = function (object_value, comparison_value) {
if (typeof value === 'object' && value.hasOwnProperty('content')) { if (typeof value === 'object' && value.hasOwnProperty('content')) {
value = value.content; value = value.content;
} }
if (value === undefined || comparison_value === undefined) {
return RSVP.resolve(false);
}
if (value.cmp !== undefined) { if (value.cmp !== undefined) {
return RSVP.resolve(value.cmp(comparison_value) > 0); return RSVP.resolve(value.cmp(comparison_value) > 0);
} }
...@@ -1574,9 +1550,6 @@ SimpleQuery.prototype[">="] = function (object_value, comparison_value) { ...@@ -1574,9 +1550,6 @@ SimpleQuery.prototype[">="] = function (object_value, comparison_value) {
if (typeof value === 'object' && value.hasOwnProperty('content')) { if (typeof value === 'object' && value.hasOwnProperty('content')) {
value = value.content; value = value.content;
} }
if (value === undefined || comparison_value === undefined) {
return RSVP.resolve(false);
}
if (value.cmp !== undefined) { if (value.cmp !== undefined) {
return RSVP.resolve(value.cmp(comparison_value) >= 0); return RSVP.resolve(value.cmp(comparison_value) >= 0);
} }
......
...@@ -2366,8 +2366,6 @@ function enableJobChecker(jio, shared, options) { ...@@ -2366,8 +2366,6 @@ function enableJobChecker(jio, shared, options) {
// emits 'job:modified', 'job:start', 'job:resolved', // emits 'job:modified', 'job:start', 'job:resolved',
// 'job:end', 'job:reject' events // 'job:end', 'job:reject' events
var i;
shared.job_rule_action_names = [undefined, "ok", "wait", "update", "deny"]; shared.job_rule_action_names = [undefined, "ok", "wait", "update", "deny"];
shared.job_rule_actions = { shared.job_rule_actions = {
...@@ -2549,6 +2547,8 @@ function enableJobChecker(jio, shared, options) { ...@@ -2549,6 +2547,8 @@ function enableJobChecker(jio, shared, options) {
} }
} }
var index;
if (options.job_management !== false) { if (options.job_management !== false) {
shared.job_rules = [{ shared.job_rules = [{
...@@ -2588,8 +2588,8 @@ function enableJobChecker(jio, shared, options) { ...@@ -2588,8 +2588,8 @@ function enableJobChecker(jio, shared, options) {
} }
if (Array.isArray(options.job_rules)) { if (Array.isArray(options.job_rules)) {
for (i = 0; i < options.job_rules.length; i += 1) { for (index = 0; index < options.job_rules.length; index += 1) {
addJobRule(deepClone(options.job_rules[i])); addJobRule(deepClone(options.job_rules[index]));
} }
} }
......
...@@ -124,9 +124,8 @@ ...@@ -124,9 +124,8 @@
* @constructor * @constructor
*/ */
function LocalStorage(spec) { function LocalStorage(spec) {
if (typeof spec.username !== 'string' && !spec.username) { if (typeof spec.username !== 'string' || spec.username === '') {
throw new TypeError("LocalStorage 'username' must be a string " + throw new TypeError("LocalStorage 'username' must be a non-empty string");
"which contains more than one character.");
} }
this._localpath = 'jio/localstorage/' + spec.username + '/' + ( this._localpath = 'jio/localstorage/' + spec.username + '/' + (
spec.application_name === null || spec.application_name === spec.application_name === null || spec.application_name ===
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment