Class StorageManager

java.lang.Object
it.uniroma2.art.semanticturkey.storage.StorageManager

public abstract class StorageManager extends Object
Manages server-side storage of content
Author:
Manuel Fiorelli
  • Field Details

    • PATH_VALIDATION_PATTERN

      public static final Pattern PATH_VALIDATION_PATTERN
  • Constructor Details

    • StorageManager

      public StorageManager()
  • Method Details

    • getSystemStorageDirectory

      public static File getSystemStorageDirectory()
    • getProjectStorageDirectory

      public static File getProjectStorageDirectory(Project project)
    • getUserStorageDirectory

      public static File getUserStorageDirectory(STUser user)
    • getPUStorageDirectory

      public static File getPUStorageDirectory(Project project, STUser user)
    • getStorageDirectory

      public static File getStorageDirectory(Reference ref)
    • getFile

      public static File getFile(Reference ref)
    • list

      public static Collection<DirectoryEntryInfo> list(Reference dir)
      Lists the entries in a given directory
      Parameters:
      dir - a reference to the directory
      Returns:
    • createDirectory

      public static void createDirectory(Reference dir)
      Creates a new directory
      Parameters:
      dir - a reference to the directory
    • createDirectoryIfNotExisting

      public static boolean createDirectoryIfNotExisting(Reference dir)
      Creates a new directory, if it does now exist. Returns true if the directory was created, false otherwise
      Parameters:
      dir - a reference to the directory
      Returns:
      true if the directory was created, false otherwise
    • deleteDirectory

      public static void deleteDirectory(Reference dir) throws IOException
      Deletes a directory
      Parameters:
      dir - a reference to the directory
      Throws:
      IOException
    • createFile

      public static void createFile(InputStream is, Reference ref, boolean overwrite) throws IOException
      Creates a file. Fails if the file already exists, unless overwrite is true
      Parameters:
      is - an input stream for the content of the file
      ref - a reference to the file
      overwrite -
      Throws:
      IOException
    • deleteFile

      public static void deleteFile(Reference ref) throws IOException
      Deletes a file
      Parameters:
      ref - a reference to the file
      Throws:
      IOException
    • getFileContent

      public static void getFileContent(OutputStream os, Reference ref, IntConsumer setContentLength) throws IOException
      Returns the content of a file
      Parameters:
      os - an output stream the which the content of the file will be written to
      ref - a reference to the file
      setContentLength - an optional (may be null) consumer that will be invoked to indicate the content size
      Throws:
      IOException
    • getFileContent

      public static void getFileContent(OutputStream os, Reference ref) throws IOException
      Returns the content of a file
      Parameters:
      os - an output stream the which the content of the file will be written to
      ref - a reference to the file
      Throws:
      IOException
    • getFileContent

      public static InputStream getFileContent(Reference ref) throws IOException
      Returns the content of a file
      Parameters:
      ref - a reference to the file
      Returns:
      Throws:
      IOException
    • exists

      public static boolean exists(Reference ref)
      Returns whether the referenced file exists
      Parameters:
      ref -
      Returns: