Class WritableStore

All Implemented Interfaces:
AutoCloseable, DirectoryStream.Filter<Path>, UnstructuredAggregate, StoreResource, Aggregate, Resource, WritableAggregate, Localized

final class WritableStore extends Store implements WritableAggregate
Writable version of the store which rely on given datastore provider to create new types. Note 1: this implementation is experimental. Note 2: it has not been tested since we do not have writable feature sets yet.
Since:
1.0
Version:
1.0
  • Field Details

    • isReadOnly

      private boolean isReadOnly
      false if this data store is capable to write FeatureSet. We currently have no easy way to determine that from the provider only, so this flag may be set after the first attempt to add a new resource.
  • Constructor Details

  • Method Details

    • add

      public Resource add(Resource resource) throws DataStoreException
      Create a new file for the given resource. This implementation uses the provider specified at creation time.
      Specified by:
      add in interface WritableAggregate
      Parameters:
      resource - the resource to copy in this Aggregate.
      Returns:
      the effectively added resource. May be resource itself if it has been added verbatim.
      Throws:
      DataStoreException - if the given resource cannot be stored in this Aggregate.
    • remove

      public void remove(Resource resource) throws DataStoreException
      Removes a Resource from this store. The resource must be a part of this Aggregate. For a folder store, this means that the resource must be a direct children of the directory managed by this store. This operation is destructive: the Resource and it's related files will be deleted.
      Specified by:
      remove in interface WritableAggregate
      Parameters:
      resource - child resource to remove from this Aggregate.
      Throws:
      DataStoreException - if the given resource could not be removed.
    • deleteRecursively

      static void deleteRecursively(Path root, boolean deleteRoot) throws IOException
      Deletes all files and sub-directories in the specified directory. This method does nothing if the given root is a file rather than a directory. The root directory is left in place (after being emptied) if deleteRoot is false.
      Parameters:
      root - the directory to delete with all sub-directories.
      deleteRoot - true for deleting also root, or false for leaving it empty.
      Throws:
      IOException