Permalink
Browse files

Finish v0.8.12

  • Loading branch information...
itayw committed Aug 17, 2015
2 parents 6cc9317 + 330e4bd commit c4ed60648f0875c9e315954defa6a30c03341ce0
View
@@ -1,9 +1,8 @@
language: node_js
node_js:
- "0.10"
# - "0.11"
# - "0.12"
# - "iojs"
- "0.12"
- "iojs"
services:
- redis-server
@@ -18,12 +17,10 @@ branches:
only:
- master
- develop
#matrix:
# fast_finish: true
# allow_failures:
# - node_js: "0.11"
# - node_js: "0.12"
# - node_js: "iojs"
matrix:
fast_finish: true
allow_failures:
- node_js: "iojs"
before_install:
- wget http://apache.claz.org/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz
- tar -zxvf zookeeper*tar.gz
View
@@ -1,4 +1,4 @@
version: 0.2.8
version: 0.3.8
interfaces:
webserver:
enabled: true
@@ -74,6 +74,7 @@ authentication:
guest: 60
user: 9999999999
force404: false
requireroles: false
#sdk:
# url: https://raw.githubusercontent.com/joola/joola.sdk/feature/%2376/bin/joola.js
query:
View
@@ -67,7 +67,7 @@ common.uuid = function (length) {
common.stringify = function (obj, callback) {
callback = callback || function () {
};
};
return callback(null, stringify.stringify(obj));
};
@@ -315,5 +315,14 @@ common.hashPassword = function (plainPassword, salt) {
};
common.inspect = function (obj) {
return require('util').inspect(obj, {depth: null, colors: true});
};
return require('util').inspect(obj, {depth: null, colors: true});
};
common.cleanupArray = function (array) {
var clean = [];
array.forEach(function (item) {
if (item)
clean.push(item);
});
return clean;
};
View
@@ -13,23 +13,8 @@
var
joola = require('../joola'),
cluster = require('cluster'),
usage = require('usage'),
os = require('os');
//check for any event loop block
function watch_eventloop() {
var lastTime = new Date().getTime();
setInterval(function () {
var delta = new Date().getTime() - lastTime;
if (delta > 1500) {
joola.stats.emit({event: 'eventlooplocks', eventlooplocks: 1});
joola.logger.warn('Blocked event-loop, ' + delta.toString() + 'ms, since: ' + new Date(lastTime).format('hh:nn:ss.fff'));
joola.events.emit('elb', delta);
}
lastTime = new Date().getTime();
}, 1000);
}
function watch_state() {
var lastStatus = 'failure';
joola.dispatch.on('nodes:state:change', function (channel, message) {
@@ -83,23 +68,6 @@ function node_ping() {
}, 1000);
}
/* istanbul ignore next */
function watch_usage() {
var pid = process.pid;
var options = { keepHistory: true };
var run = function () {
usage.lookup(pid, options, function (err, result) {
/* istanbul ignore if */
if (err)
return;
result.cpuInfo.cpuTime = result.cpuInfo.cpuTime || null;
joola.events.emit('usage', result);
joola.stats.emit(joola.common.extend({event: 'nodeusage'}, result));
});
};
setInterval(run, 60000);
}
function watch_eps() {
var template = {
eps: 0,
@@ -118,10 +86,8 @@ function watch_eps() {
}
joola.events.on('datastore:ready', function () {
watch_eventloop();
node_ping();
watch_state();
watch_usage();
});
watch_eps();
View
@@ -21,6 +21,7 @@
var
joola = require('../joola'),
_ = require('underscore'),
async = require('async'),
router = require('../webserver/routes/index'),
Proto = require('./prototypes/canvas');
@@ -55,7 +56,7 @@ exports.list = {
},
run: function (context, workspace, callback) {
callback = callback || function () {
};
};
if (context.user.workspace !== workspace && context.user.permissions.indexOf('superuser') === -1) {
var err = new Error('Forbidden');
@@ -66,8 +67,19 @@ exports.list = {
joola.dispatch.workspaces.get(context, workspace, function (err, wrk) {
if (err)
return callback(err);
return callback(null, joola.common.obj2array(wrk.canvases));
return async.map(Object.keys(wrk.canvases), function (canvas, cb) {
canvas = wrk.canvases[canvas];
return exports.get.run(context, workspace, canvas.key, function (err, _canvas) {
if (_canvas)
return cb(null, _canvas);
else
return cb(null);
});
}, function (err, result) {
result = joola.common.cleanupArray(result);
return callback(null, result);
});
});
}
};
@@ -105,7 +117,7 @@ exports.get = {
},
run: function (context, workspace, key, callback) {
callback = callback || function () {
};
};
if (context.user.workspace !== workspace && context.user.permissions.indexOf('superuser') === -1) {
var err = new Error('Forbidden');
@@ -124,7 +136,17 @@ exports.get = {
if (!result || typeof result === 'undefined' || result === null || result.length === 0)
return callback(new Error('canvas [' + key + '] does not exist.'));
return callback(null, result[0]);
result = result[0];
var hasRole = false;
if (joola.config.get('authentication:requireroles') === false)
hasRole = ['anonymous'];
else
hasRole = _.intersection(context.user.roles, result.roles);
if (hasRole.length > 0)
return callback(null, result);
else
return callback(null);
});
}
};
@@ -159,15 +181,15 @@ exports.get = {
exports.add = {
name: "/canvases/add",
description: "I add a new canvas",
inputs: ['workspace', 'canvas' ],
inputs: ['workspace', 'canvas'],
_outputExample: {},
_permission: ['canvases:add'],
_dispatch: {
message: 'canvases:add'
},
run: function (context, workspace, canvas, callback) {
callback = callback || function () {
};
};
if (context.user.workspace !== workspace && context.user.permissions.indexOf('superuser') === -1) {
var err = new Error('Forbidden');
@@ -236,7 +258,7 @@ exports.patch = {
},
run: function (context, workspace, canvas, payload, callback) {
callback = callback || function () {
};
};
if (context.user.workspace !== workspace && context.user.permissions.indexOf('superuser') === -1) {
var err = new Error('Forbidden');
@@ -303,7 +325,7 @@ exports.delete = {
},
run: function (context, workspace, canvas, callback) {
callback = callback || function () {
};
};
if (context.user.workspace !== workspace && context.user.permissions.indexOf('superuser') === -1) {
var err = new Error('Forbidden');
View
@@ -61,8 +61,23 @@ exports.list = {
}
callback = callback || function () {
};
var ensureRole = function (dimensions) {
var clean = [];
dimensions.forEach(function (d) {
var hasRole = false;
if (joola.config.get('authentication:requireroles') === false)
hasRole = ['anonymous'];
else
hasRole = _.intersection(context.user.roles, d.roles);
if (hasRole.length > 0)
clean.push(d);
});
return clean;
};
if (context.user.workspace !== workspace && context.user.permissions.indexOf('superuser') === -1) {
var err = new Error('Forbidden');
err.code = 403;
@@ -74,7 +89,7 @@ exports.list = {
if (err)
return callback(err);
return callback(null, joola.common.obj2array(_collection.dimensions));
return callback(null, ensureRole(joola.common.obj2array(_collection.dimensions)));
});
}
else {
@@ -105,7 +120,7 @@ exports.list = {
results.forEach(function (result) {
dimensions = dimensions.concat(result);
});
return callback(null, dimensions);
return callback(null, ensureRole(dimensions));
});
});
}
@@ -145,7 +160,7 @@ exports.get = {
},
run: function (context, workspace, collection, key, callback) {
callback = callback || function () {
};
};
if (context.user.workspace !== workspace && context.user.permissions.indexOf('superuser') === -1) {
var err = new Error('Forbidden');
@@ -164,7 +179,19 @@ exports.get = {
if (!result || typeof result === 'undefined' || result === null || result.length === 0)
return callback(new Error('dimension [' + key + '] does not exist.'));
return callback(null, result[0]);
result = result[0];
var hasRole = false;
if (joola.config.get('authentication:requireroles') === false)
hasRole = ['anonymous'];
else
hasRole = _.intersection(context.user.roles, result.roles);
if (hasRole.length > 0)
return callback(null, result);
else {
var directaccesserr = new Error('Forbidden');
directaccesserr.code = 403;
return callback(directaccesserr );
}
});
}
};
@@ -199,15 +226,15 @@ exports.get = {
exports.add = {
name: "/dimensions/add",
description: "I add a new dimension",
inputs: ['workspace', 'collection', 'dimension' ],
inputs: ['workspace', 'collection', 'dimension'],
_outputExample: {},
_permission: ['dimensions:add'],
_dispatch: {
message: 'dimensions:add'
},
run: function (context, workspace, collection, dimension, callback) {
callback = callback || function () {
};
};
if (context.user.workspace !== workspace && context.user.permissions.indexOf('superuser') === -1) {
var err = new Error('Forbidden');
@@ -276,7 +303,7 @@ exports.patch = {
},
run: function (context, workspace, collection, dimension, payload, callback) {
callback = callback || function () {
};
};
if (context.user.workspace !== workspace && context.user.permissions.indexOf('superuser') === -1) {
var err = new Error('Forbidden');
@@ -343,7 +370,7 @@ exports.delete = {
},
run: function (context, workspace, collection, dimension, callback) {
callback = callback || function () {
};
};
if (context.user.workspace !== workspace && context.user.permissions.indexOf('superuser') === -1) {
var err = new Error('Forbidden');
Oops, something went wrong.

0 comments on commit c4ed606

Please sign in to comment.