Source
void remove(Map m) {
Path path = Path.getValidPath(m['path']);
if (path == null || !path.isAbsolute) {
closeResponse(m['rid'], error: DSError.INVALID_PATH);
return;
}
int rid = m['rid'];
if (path.isNode) {
closeResponse(m['rid'], error: DSError.INVALID_METHOD);
} else if (path.isConfig) {
LocalNode node;
node = nodeProvider.getOrCreateNode(path.parentPath, false);
int permission = nodeProvider.permissions.getPermission(node.path, this);
if (permission < Permission.CONFIG) {
closeResponse(m['rid'], error: DSError.PERMISSION_DENIED);
} else {
node.removeConfig(
path.name, this, addResponse(new Response(this, rid, 'set'), path));
}
} else if (path.isAttribute) {
LocalNode node;
node = nodeProvider.getOrCreateNode(path.parentPath, false);
int permission = nodeProvider.permissions.getPermission(node.path, this);
if (permission < Permission.WRITE) {
closeResponse(m['rid'], error: DSError.PERMISSION_DENIED);
} else {
node.removeAttribute(
path.name, this, addResponse(new Response(this, rid, 'set'), path));
}
} else {
// shouldn't be possible to reach here
throw 'unexpected case';
}
}