Interface Layer


public interface Layer
This interface represents a layer in the layered item store. A layer can be in the following states:
#open/closedarchivedstaged?when?
1 open niet archived ja beginsituatie van elke top layer
2 closed niet archived ja (met .closed suffix) op het moment voordat de top layer gearchiveerd wordt
3 closed archived nee archivering gelukt
4 open archived ja reopened
5 closed archived ja (met .closed suffix) close van een heropende layer
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Turns the layer into an archive file.
    void
    Changes the state of the layer to 'closed'.
    void
    Creates a directory at the given path.
    void
    Deletes the directory at the given path, including all its contents.
    void
    Deletes the files pointed to by paths.
    boolean
    Returns whether a file exists at the given path in this layer.
    long
    Returns the id of the layer.
    long
    Returns the size of the layer in bytes.
    boolean
    Returns whether the layer is archived.
    boolean
    Returns whether the layer is open.
    Lists the items in this layer.
    void
    moveDirectoryInternal(String source, String destination)
    Moves the directory at source to destination, where both paths are relative to the root of the layer.
    void
    moveDirectoryInto(Path source, String destination)
    Moves the directory at source into the directory at destination.
    Reads the file at the given path.
    void
    Changes the state of the layer to open.
    void
    writeFile(String filePath, InputStream content)
    Writes the content of the given input stream to the file at the given path.
  • Method Details

    • getId

      long getId()
      Returns the id of the layer.
      Returns:
      the id of the layer
    • close

      void close()
      Changes the state of the layer to 'closed'.
      Throws:
      IllegalStateException - if the layer is already closed
    • reopen

      void reopen() throws IOException
      Changes the state of the layer to open. It also stages the archive file in the staging directory. This operation is not allowed when the layer is not closed or not yet archived.
      Throws:
      IOException
    • isOpen

      boolean isOpen()
      Returns whether the layer is open.
      Returns:
      whether the layer is open
    • archive

      void archive()
      Turns the layer into an archive file.
    • isArchived

      boolean isArchived()
      Returns whether the layer is archived.
      Returns:
      whether the layer is archived
    • createDirectory

      void createDirectory(String path) throws IOException
      Creates a directory at the given path. Not allowed when the layer is closed.
      Parameters:
      path - the path of the directory relative to the storage root
      Throws:
      IOException - if the directory cannot be created
    • deleteDirectory

      void deleteDirectory(String path) throws IOException
      Deletes the directory at the given path, including all its contents. Not allowed when the layer is closed.
      Parameters:
      path - the path of the directory relative to the storage root
      Throws:
      IOException - if the directory cannot be deleted
    • fileExists

      boolean fileExists(String path) throws IOException
      Returns whether a file exists at the given path in this layer.
      Parameters:
      path - the path of the file relative to the storage root
      Returns:
      whether the file exists
      Throws:
      IOException - if the existence of the file cannot be determined
    • readFile

      InputStream readFile(String path) throws IOException
      Reads the file at the given path. Note, that this may take a long time if the layer is archived, especially when the archive is stored on tape.
      Parameters:
      path - the path of the file relative to the storage root
      Returns:
      an input stream for reading the file; the caller is responsible for closing the stream
      Throws:
      IOException - if the file cannot be read
    • writeFile

      void writeFile(String filePath, InputStream content) throws IOException
      Writes the content of the given input stream to the file at the given path. Not allowed when the layer is closed. If the file already exists, it is overwritten.
      Parameters:
      filePath - the path of the file relative to the storage root
      content - the content of the file
      Throws:
      IOException - if the file cannot be written
    • deleteFiles

      void deleteFiles(List<String> paths) throws IOException
      Deletes the files pointed to by paths. Not allowed when the layer is closed.
      Parameters:
      paths - the paths of the files to be deleted
      Throws:
      IOException - if the files cannot be deleted
    • moveDirectoryInto

      void moveDirectoryInto(Path source, String destination) throws IOException
      Moves the directory at source into the directory at destination. Not allowed when the layer is closed.
      Parameters:
      source - the path of the directory to be moved; must be an existing directory
      destination - the path of the directory to move into; the directory is created if it does not exist yet
      Throws:
      IOException - if the directory cannot be moved
    • moveDirectoryInternal

      void moveDirectoryInternal(String source, String destination) throws IOException
      Moves the directory at source to destination, where both paths are relative to the root of the layer.
      Parameters:
      source - the path of the directory to be moved; must be an existing directory
      destination - the path of the destination directory; must not exist yet
      Throws:
      IOException - if the directory cannot be moved
    • getSizeInBytes

      long getSizeInBytes() throws IOException
      Returns the size of the layer in bytes. If the layer is archived, this may take a long time, especially when the archive is stored on tape.
      Returns:
      the size of the layer in bytes
      Throws:
      IOException - if the size cannot be determined
    • listAllItems

      Iterator<Item> listAllItems() throws IOException
      Lists the items in this layer.
      Returns:
      the items in this layer
      Throws:
      IOException - if the items cannot be listed