public ResponseEntity update()

in src/inventory/src/main/java/com/google/abmedge/inventory/InventoryController.java [176:191]


  public ResponseEntity<Void> update(@RequestBody List<PurchaseItem> purchaseList) {
    for (PurchaseItem pi : purchaseList) {
      UUID itemId = pi.getItemId();
      Optional<Item> loadedItem = activeConnector.getById(itemId);
      try {
        if (loadedItem.isEmpty() || !updateItem(loadedItem.get(), pi)) {
          LOGGER.warn(String.format("Update attempt with invalid item id: '%s'", itemId));
          throw new Exception();
        }
      } catch (Exception e) {
        LOGGER.error("Failed to update one or more items in the purchase list!", e);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
      }
    }
    return new ResponseEntity<>(HttpStatus.OK);
  }