Skip to content

Add storage bulk update API request models

Hong Yan requested to merge add-storage-bulk-models into master

Add new apis, models and validators for storage bulk update API request

From SLB GA storage to os-core-common (models and validators and interface methods)

  • Merged PR 156139: placeholder for the bulk update API
  • Merged PR 162923: add optimistic lock for bulk update API
  • Merged PR 172654: Change Bulk Update API to use JSONPatch request body

This API allows the update of records metadata in batch.

1. Models and validators

Add new storage request body: RecordBulkUpdateParam and its fields

An example of this request body

{
  "query": {
    "ids": [
      "common:welldb:123456:version",
      "common:welldb:345678:version",
      "common:welldb:567890:version"
    ]
  },
  "ops": [
    {
      "op": "replace",
      "path": "/acl/viewers",
      "value": [
        "data.default.viewers@<DataPartition>.<Domain>.com",
        "test1.viewers@<DataPartition>.<Domain>.com"
      ]
    },
    {
      "op": "replace",
      "path": "/legal/legaltags",
      "value": [
        "DataPartition-legaltag-1",
        "DataPartition-legaltag-2"
      ]
    },
    {
      "op": "replace",
      "path": "/acl/owners",
      "value": [
        "data.default.owners@<DataPartition>.<Domain>.com",
        "test1.viewers@<DataPartition>.<Domain>.com"
      ]
    }
  ]
}

In this case, the RecordBulkUpdateParam contains a RecordQuery field query and a List<PatchOperation> field ops. With this response body we can then implement a storage bulk update api for data in Storage service.

2. New interface methods

In package org.opengroup.osdu.core.common.storage.IPersistenceService add method

/**
 * This interface method do the actual update of the metadata
 * of records in the Record Repository and Cloud Storage and 
 * revert the metadata back in case there is an error.
 *
 * @param recordMetadata The list of new record metadata
 * @param recordsId      The list of ids of the records that need to be updated
 * @param recordsIdMap   A map of each record id to their version

 * @return A list of locked records (idWithVersion) in case they are found locked during the updating.
 */
List<String> updateMetadata(List<RecordMetadata> recordMetadata, List<String> recordsId, Map<String, String> recordsIdMap);
Edited by Chad Leong

Merge request reports

Loading