Class CreateHandle

java.lang.Object
nz.org.riskscape.engine.resource.CreateHandle

public abstract class CreateHandle extends Object

A sort of transaction handle for saving resources to allow various housekeeping to be applied by various protocols that allow storage. Overkill for a filesystem API, but will be helpful/necessary for more sophisticated backends and gives us a place to extend the API without requiring the ResourceFactory.create(CreateRequest) method to change.

  • Constructor Details

  • Method Details

    • store

      public URI store(CreateHandle.Callback callback) throws CreateException

      Provide a callback that will store bytes associated with the resource.

      Returns:
      URI a location where the successfully stored data can be accessed
      Throws:
      CreateException - if something unforseen happened when trying to store bytes. Typically this is going to be out of the user's hands here, e.g. no space, connectivity error, etc
    • getOutputStream

      public abstract OutputStream getOutputStream() throws CreateException
      Returns:
      an OutputStream to use for writing data.
      Throws:
      CreateException
    • store

      public abstract URI store() throws CreateException

      Store data written to the handle, returning the URI it is now available at. If getOutputStream hasn't been written too, strange things might happen when you call this (wowoooooo, spooky)

      Throws:
      CreateException
    • getRequest

      public CreateRequest getRequest()

      The original request made to save a resource

    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object