Interface IReadableRepository

All Known Subinterfaces:
IBuildInformationRepository, IReportsRepository, ISourceRepository

public interface IReadableRepository
Read operations for simple structured file repository.

No assumption about the nature of location revisions can be maintained (whether or not they are repository-wide).

Relative locations are forbidden. Locations with .. path components are forbidden too.

Note that ILocation.getRepositoryName() can be used by underlying implementation.

Version:
$Revision$ $Date$
Author:
Stepan Roh, Polarion Software
See Also:
  • Method Details

    • exists

      boolean exists(ILocation location)
      Whether given location exists (either as a file or as a folder).
      Parameters:
      location - location
      Returns:
      true if given location exists
      Throws:
      IllegalArgumentException - if location is null
      IllegalArgumentException - if location is relative
    • isFolder

      boolean isFolder(ILocation location)
      Whether given location exists as a folder.
      Parameters:
      location - location
      Returns:
      true if given location exists and is a folder
      Throws:
      IllegalArgumentException - if location is null
      IllegalArgumentException - if location is relative
    • isFile

      boolean isFile(ILocation location)
      Whether given location exists as a file.
      Parameters:
      location - location
      Returns:
      true if given location exists and is a file
      Throws:
      IllegalArgumentException - if location is null
      IllegalArgumentException - if location is relative
    • getLastModificationTime

      long getLastModificationTime(ILocation location)
      Return time of last modification if location is file.
      Parameters:
      location - file location
      Returns:
      last modification time in miliseconds or zero if location is not file
      Throws:
      IllegalArgumentException - if location is null
      IllegalArgumentException - if location is relative
    • getFileSize

      long getFileSize(ILocation location)
      Return file size in bytes.

      The return value is unspecified for anything which is not file.

      Parameters:
      location - file location
      Returns:
      file size in bytes or zero if location does not exist
      Throws:
      IllegalArgumentException - if location is null
      IllegalArgumentException - if location is relative
    • readFile

      InputStream readFile(ILocation location) throws IOException
      Read data from given file.

      Returned stream should be closed as soon as possible, however it is ensured that it will work until it is closed.

      Parameters:
      location - location
      Returns:
      file data as InputStream (not null)
      Throws:
      IllegalArgumentException - if location is null
      IllegalArgumentException - if location is relative
      IOException - if error occurs or location is not file
    • listFolder

      List listFolder(ILocation location, boolean recurse) throws IOException
      List folder contents.

      If given location has revision, returned locations have revision corresponding to it.

      Parameters:
      location - location
      recurse - true if listing should be recursive
      Returns:
      List of absolute ILocations (not null)
      Throws:
      IllegalArgumentException - if location is null
      IllegalArgumentException - if location is relative
      IOException - if error occurs or location is not folder
    • copyToLocalFile

      void copyToLocalFile(ILocation location, File file) throws IOException
      Will copy file or folder to given local file or directory.

      If given location is file then file data are written into given local file.

      If given location is folder then File.mkdirs() is called on given local file and folder contents are (recursively) copied under it.

      Note that last modification time of target files will mirror those of source (but might be slightly different due to difference in precision).

      Parameters:
      location - location to copy from
      file - file or directory to copy to
      Throws:
      IllegalArgumentException - if location is null
      IllegalArgumentException - if location is relative
      IllegalArgumentException - if file is null
      IOException - if error occurs