Interface WorkingFileRepository

All Superinterfaces:
StorageUsage
All Known Implementing Classes:
WorkingFileRepositoryImpl, WorkingFileRepositoryRestEndpoint

public interface WorkingFileRepository extends StorageUsage
The Working File Repository is a file storage service that supports the lecture capture system. It may be used by other clients, but is neither intended nor required to be used by other systems.
  • Field Details

  • Method Details

    • getBaseUri

      URI getBaseUri()
      Gets the base URI for this service.
      Returns:
      The base URI
    • put

      URI put(String mediaPackageID, String mediaPackageElementID, String filename, InputStream in) throws IOException, IllegalArgumentException
      Store the data stream under the given media package and element IDs with filename as name of the file.
      Parameters:
      mediaPackageID - the media package identifier
      mediaPackageElementID - the media package element identifier
      filename - the file name to use
      in - the input stream
      Returns:
      The URL to access this file
      Throws:
      IOException - if the input stream cannot be accessed or the element cannot be written to the repository
      IllegalArgumentException - if a URI cannot be created from the arguments
    • get

      InputStream get(String mediaPackageID, String mediaPackageElementID) throws IOException, NotFoundException
      Stream the file stored under the given media package and element IDs.
      Parameters:
      mediaPackageID - the media package identifier
      mediaPackageElementID - the media package element identifier
      Returns:
      the media package element contents
      Throws:
      IOException - if there is a problem reading the data
      NotFoundException - if the media package element can't be found
    • getCollectionURI

      URI getCollectionURI(String collectionID, String fileName) throws IllegalArgumentException
      Get the URL for a file stored under the given collection.
      Parameters:
      collectionID - the collection identifier
      fileName - the file name
      Returns:
      the file's uri
      Throws:
      IllegalArgumentException - if a URI cannot be created from the arguments
    • getURI

      URI getURI(String mediaPackageID, String mediaPackageElementID) throws IllegalArgumentException
      Get the URL for a file stored under the given media package and element IDs. This may be called for mediapackages, elements, or files that have not yet been stored in the repository.
      Parameters:
      mediaPackageID - the media package identifier
      mediaPackageElementID - the media package element identifier
      Returns:
      the URI to this resource
      Throws:
      IllegalArgumentException - if a URI cannot be created from the arguments
    • getURI

      URI getURI(String mediaPackageID, String mediaPackageElementID, String fileName) throws IllegalArgumentException
      Get the URL for a file stored under the given media package and element IDs. This may be called for mediapackages, elements, or files that have not yet been stored in the repository.
      Parameters:
      mediaPackageID - the media package identifier
      mediaPackageElementID - the media package element identifier
      fileName - the file name
      Returns:
      the URI to this resource
      Throws:
      IllegalArgumentException - if a URI cannot be created from the arguments
    • toSafeName

      String toSafeName(String fileName)
    • delete

      boolean delete(String mediaPackageID, String mediaPackageElementID) throws IOException
      Delete the file stored at the given media package and element IDs.
      Parameters:
      mediaPackageID - the media package identifier
      mediaPackageElementID - the media package element identifier
      Throws:
      IOException - if the element cannot be deleted
    • putInCollection

      URI putInCollection(String collectionId, String fileName, InputStream in) throws IOException
      Puts a file into a collection, overwriting the existing file if present.
      Parameters:
      collectionId - The collection identifier
      fileName - The filename to use in storing the input stream
      in - the data to store
      Returns:
      The URI identifying the file
      Throws:
      IOException - if the input stream cannot be accessed or the file cannot be written to the repository
    • getCollectionContents

      URI[] getCollectionContents(String collectionId) throws NotFoundException
      Gets the URIs of the members of this collection
      Parameters:
      collectionId - the collection identifier
      Returns:
      the URIs for each member of the collection
      Throws:
      NotFoundException - if the collectionId does not exist
    • deleteFromCollection

      boolean deleteFromCollection(String collectionId, String fileName) throws IOException
      Removes a file from a collection
      Parameters:
      collectionId - the collection identifier
      fileName - the filename to remove
      Returns:
      true if the file existed and was removed
      Throws:
      IOException
    • deleteFromCollection

      boolean deleteFromCollection(String collectionId, String fileName, boolean removeCollection) throws IOException
      Removes a file from a collection, and the parent folder if empty
      Parameters:
      collectionId - the collection identifier
      fileName - the filename to remove
      removeCollection - remove the parent collection folder if empty
      Returns:
      true if the file existed and was removed
      Throws:
      IOException
    • moveTo

      URI moveTo(String fromCollection, String fromFileName, String toMediaPackage, String toMediaPackageElement, String toFileName) throws NotFoundException, IOException
      Moves a file from a collection into a mediapackage
      Parameters:
      fromCollection - The collection holding the file
      fromFileName - The filename
      toMediaPackage - The media package ID to move the file into
      toMediaPackageElement - the media package element ID of the file
      toFileName - the name of the resulting file
      Returns:
      the URI pointing to the file's new location
      Throws:
      NotFoundException
      IOException
    • getDiskSpace

      String getDiskSpace()
      A textual representation of available and total storage
      Returns:
      Percentage and numeric values of used storage space
    • cleanupOldFilesFromCollection

      boolean cleanupOldFilesFromCollection(String collectionId, long days) throws IOException
      Cleans up collection files older than the number of days passed.
      Parameters:
      collectionId - the collection identifier
      days - files older than that will be deleted
      Throws:
      IOException
    • cleanupOldFilesFromMediaPackage

      boolean cleanupOldFilesFromMediaPackage(long days) throws IOException
      Cleans up media files older than the number of days passed.
      Parameters:
      days - files older than that will be deleted
      Throws:
      IOException