iipRequestQueryResources method

void iipRequestQueryResources(
  1. int callback,
  2. String resourceLink
)

Implementation

void iipRequestQueryResources(int callback, String resourceLink) {
  Warehouse.query(resourceLink).then((r) {
    if (r == null) {
      sendError(ErrorType.Management, callback,
          ExceptionCode.ResourceNotFound.index);
    } else {
      var list = r
          .where((x) =>
              x.instance?.applicable(
                  _session as Session, ActionType.Attach, null) !=
              Ruling.Denied)
          .toList();

      if (list.length == 0)
        sendError(ErrorType.Management, callback,
            ExceptionCode.ResourceNotFound.index);
      else
        sendReply(IIPPacketAction.QueryLink, callback)
          ..addDC(Codec.composeResourceArray(list, this, true))
          ..done();
    }
  });
}