Source
void invoke(Map m) {
Path path = Path.getValidNodePath(m['path']);
if (path != null && path.isAbsolute) {
int rid = m['rid'];
LocalNode parentNode;
parentNode = nodeProvider.getOrCreateNode(path.parentPath, false);
doInvoke([LocalNode overriden]) {
LocalNode node = overriden == null ?
nodeProvider.getNode(path.path) :
overriden;
if (node == null) {
if (overriden == null) {
node = parentNode.getChild(path.name);
if (node == null) {
closeResponse(m['rid'], error: DSError.PERMISSION_DENIED);
return;
}
if (node is WaitForMe) {
(node as WaitForMe).onLoaded.then((_) => doInvoke(node));
return;
} else {
doInvoke(node);
return;
}
} else {
closeResponse(m['rid'], error: DSError.PERMISSION_DENIED);
return;
}
}
int permission = nodeProvider.permissions.getPermission(path.path, this);
int maxPermit = Permission.parse(m['permit']);
if (maxPermit < permission) {
permission = maxPermit;
}
Map<String, dynamic> params;
if (m["params"] is Map<String, dynamic>) {
params = m["params"] as Map<String, dynamic>;
}
if (params == null) {
params = {};
}
if (node.getInvokePermission() <= permission) {
node.invoke(
params,
this,
addResponse(
new InvokeResponse(this, rid, parentNode, node, path.name),
path,
params
),
parentNode,
permission
);
} else {
closeResponse(m['rid'], error: DSError.PERMISSION_DENIED);
}
}
if (parentNode is WaitForMe) {
(parentNode as WaitForMe).onLoaded.then((_) {
doInvoke();
}).catchError((e, stack) {
var err = new DSError(
"nodeError",
msg: e.toString(),
detail: stack.toString()
);
closeResponse(
m['rid'],
error: err
);
});
} else {
doInvoke();
}
} else {
closeResponse(m['rid'], error: DSError.INVALID_PATH);
}
}