iipRequestLinkTemplates method
void
iipRequestLinkTemplates(
- int callback,
- String resourceLink
)
Implementation
void iipRequestLinkTemplates(int callback, String resourceLink) {
var queryCallback = (List<IResource>? r) {
if (r == null)
sendError(ErrorType.Management, callback,
ExceptionCode.ResourceNotFound.index);
else {
var list = r.where((x) =>
x.instance?.applicable(
_session as Session, ActionType.ViewTemplate, null) !=
Ruling.Denied);
if (list.length == 0)
sendError(ErrorType.Management, callback,
ExceptionCode.ResourceNotFound.index);
else {
// get all templates related to this resource
var msg = new BinaryList();
List<TypeTemplate> templates = [];
list.forEach((resource) {
templates.addAll(TypeTemplate.getDependencies(
resource.instance?.template as TypeTemplate)
.where((x) => !templates.contains(x)));
});
templates.forEach((t) {
msg
..addInt32(t.content.length)
..addDC(t.content);
});
// digggg
sendReply(IIPPacketAction.LinkTemplates, callback)
..addInt32(msg.length)
..addUint8Array(msg.toArray())
..done();
}
}
};
if (_server?.entryPoint != null)
_server?.entryPoint?.query(resourceLink, this).then(queryCallback);
else
Warehouse.query(resourceLink).then(queryCallback);
}