iipRequestClearAttributes method

void iipRequestClearAttributes(
  1. int callback,
  2. int resourceId,
  3. DC attributes, [
  4. bool all = false,
])

Implementation

void iipRequestClearAttributes(int callback, int resourceId, DC attributes,
    [bool all = false]) {
  Warehouse.getById(resourceId).then((r) {
    if (r == null) {
      sendError(ErrorType.Management, callback,
          ExceptionCode.ResourceNotFound.index);
      return;
    }

    if (r.instance?.store?.instance?.applicable(
            _session as Session, ActionType.UpdateAttributes, null) !=
        Ruling.Allowed) {
      sendError(ErrorType.Management, callback,
          ExceptionCode.UpdateAttributeDenied.index);
      return;
    }

    List<String>? attrs = null;

    if (!all) attrs = attributes.getStringArray(0, attributes.length);

    if (r.instance?.removeAttributes(attrs) == true)
      sendReply(
              all
                  ? IIPPacketAction.ClearAllAttributes
                  : IIPPacketAction.ClearAttributes,
              callback)
          .done();
    else
      sendError(ErrorType.Management, callback,
          ExceptionCode.UpdateAttributeFailed.index);
  });
}