Interface Store

All Known Implementing Classes:

public interface Store
An interface representing an abstract store, eg a FileSystem, which is used to store and retrieve files
  • Field Details

  • Method Details

    • setServiceEngine

      void setServiceEngine(ServiceEngine engine)
      Set the ServiceEngine on this store. Called immediately after the constructor
    • configure

      void configure(Json json)
    • put

      OutputStream put(String path, Json props, Authorization auth) throws IOException
      Save a file to the store. Return an OutputStream to write to. Props may contain: - content_type - expiry - if not null, the number of ms after the last access to delete the file. - panding - if false, the file is flushed on each write and any get should return an InputStream for what we have. Otherwise the returned stream is opened on the first write, and until that any "get" call returns PENDING. Props is live, and can be modified up until the point the returned OutputStream is closed. Any modifications to props before closing will be reflected in any subsequent "get" operations for object, and will be written to the store when the stream is finally closed. Props should be updated synchronized. Props should be set with "ok" to boolean indicating ok or not before error
      folder - the folder (required)
      path - the path (required)
      an OutputStream which is opened on the first write.
      IOException - if the path already exists
    • get

      InputStream get(String path, Json props, Authorization auth) throws IOException
      Retrieve a file from the store. Return an InputStream to read from, or null if it doesn't exist. Props may contain anything: and will be updated (ie set or the fields removed) with - name - the name of the path - ok - whether completion was ok - content_type - last_modified - length If no files in that folder can be read, an IOException("Unauthorized") will be thrown. It's a list containing items with at least name, and possibly contentType and length.
      folder - the folder (required)
      path - the path (may be null);
    • del

      boolean del(String path, Authorization auth) throws IOException
      Delete from the store. Props may contain anything The path may be null, if it is any files in that folder will be deleted with permission. If an OutputStreaam is currently open for that writer, any further writes to it will fail. If any files cannot be deleted, an IOException("Unauthorized") will be thrown.
      folder - the folder (required)
      path - the path (may be null)
      true if a file was deleted, false otherwise
      IOException - if something went wrong
    • clear

      void clear()
      Clear the store of all data
    • shutdown

      void shutdown()
      Prepare the Store for the ServiceEngine being shutdown
    • newFolderName

      default String newFolderName()
      Return a random folder name that doesn't exist
    • copyStream

      default void copyStream(InputStream in, OutputStream out) throws IOException