Class ItemStoreUtils

java.lang.Object
org.tasktide.itemstore.utils.ItemStoreUtils

public class ItemStoreUtils extends Object
Collection of useful methods supporting the ItemStore
  • Constructor Details

    • ItemStoreUtils

      public ItemStoreUtils()
  • Method Details

    • fetchNewProtoTypeLabel

      public static String fetchNewProtoTypeLabel()
      Fetch random label for prototype
      Returns:
      String
    • verifyDirectory

      public static boolean verifyDirectory(Path dbDirectory)
      Checks whether configured directory is writable
      Returns:
      boolean
    • verifyDirectories

      public static boolean verifyDirectories(Path dbDirectory, Path masterDB, Path prototype)
    • getStore

      public static ItemStore getStore(ItemStoreType storeType, String storeName)
      Create required ItemStore
      Parameters:
      storeType -
      storeName -
      Returns:
      ItemStore
    • makeMockItem

      public static Item<String> makeMockItem()
      Create a mock Item, Id field is random UUID
      Returns:
      Item-String
    • makeMockItem

      public static Item<String> makeMockItem(String label)
      Create a mock Item, Id field is random UUID
      Parameters:
      label -
      Returns:
      Item-String
    • makeMockItemCollection

      public static List<Item> makeMockItemCollection(int amount)
      Make a collection of mock Item of required size
      Parameters:
      amount -
      Returns:
      List-Item-String
    • makeMockItemCollection

      public static List<Item> makeMockItemCollection(int amount, String label)
      Make a collection of mock Item of required size
      Parameters:
      amount -
      label -
      Returns:
      List-Item-String
    • deleteRecursively

      public static void deleteRecursively(Path path) throws IOException
      Recursively delete all contents of folder and it
      Parameters:
      path -
      Throws:
      IOException
    • makeTargetLockFile

      public static boolean makeTargetLockFile(Path targetLock)
      Creates target lock file
      Returns:
      boolean
    • serializeItemToByteArray

      public static byte[] serializeItemToByteArray(com.fasterxml.jackson.databind.ObjectMapper MAPPER, Item item) throws ItemStoreCheckedException
      Serializes Item to byte array with provided ObjectMapper
      Parameters:
      MAPPER -
      item -
      Returns:
      Throws:
      ItemStoreCheckedException
    • writeBatch

      public static void writeBatch(org.rocksdb.RocksDB db, org.rocksdb.WriteBatch batch, org.rocksdb.WriteOptions writeOptions) throws ItemStoreCheckedException
      Batch write records
      Parameters:
      db -
      batch -
      writeOptions -
      Throws:
      ItemStoreCheckedException
    • getId

      public static byte[] getId(org.rocksdb.RocksDB db, String id) throws ItemStoreCheckedException
      Fetch record for Id
      Parameters:
      db -
      id -
      Returns:
      byte[]
      Throws:
      ItemStoreCheckedException
    • marshallItemFromByteArray

      public static Item marshallItemFromByteArray(com.fasterxml.jackson.databind.ObjectMapper mapper, byte[] data) throws ItemStoreCheckedException
      Marshall Item from byte array
      Parameters:
      mapper -
      data -
      Returns:
      Item
      Throws:
      ItemStoreCheckedException
    • delete

      public static void delete(org.rocksdb.RocksDB db, Item item) throws ItemStoreCheckedException
      Delete Item from RocksDB encasing
      Parameters:
      db -
      item -
      Throws:
      ItemStoreCheckedException