Class StorageManager
java.lang.Object
it.uniroma2.art.semanticturkey.storage.StorageManager
Manages server-side storage of content
- Author:
- Manuel Fiorelli
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
createDirectory
(Reference dir) Creates a new directorystatic boolean
Creates a new directory, if it does now exist.static void
createFile
(InputStream is, Reference ref, boolean overwrite) Creates a file.static void
deleteDirectory
(Reference dir) Deletes a directorystatic void
deleteFile
(Reference ref) Deletes a filestatic boolean
Returns whether the referenced file existsstatic File
static InputStream
getFileContent
(Reference ref) Returns the content of a filestatic void
getFileContent
(OutputStream os, Reference ref) Returns the content of a filestatic void
getFileContent
(OutputStream os, Reference ref, IntConsumer setContentLength) Returns the content of a filestatic File
getProjectStorageDirectory
(Project project) static File
getPUStorageDirectory
(Project project, STUser user) static File
static File
static File
static Collection<DirectoryEntryInfo>
Lists the entries in a given directory
-
Field Details
-
PATH_VALIDATION_PATTERN
-
-
Constructor Details
-
StorageManager
public StorageManager()
-
-
Method Details
-
getSystemStorageDirectory
-
getProjectStorageDirectory
-
getUserStorageDirectory
-
getPUStorageDirectory
-
getStorageDirectory
-
getFile
-
list
Lists the entries in a given directory- Parameters:
dir
- a reference to the directory- Returns:
-
createDirectory
Creates a new directory- Parameters:
dir
- a reference to the directory
-
createDirectoryIfNotExisting
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
Deletes a directory- Parameters:
dir
- a reference to the directory- Throws:
IOException
-
createFile
Creates a file. Fails if the file already exists, unlessoverwrite
istrue
- Parameters:
is
- an input stream for the content of the fileref
- a reference to the fileoverwrite
-- Throws:
IOException
-
deleteFile
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 toref
- a reference to the filesetContentLength
- an optional (may benull
) consumer that will be invoked to indicate the content size- Throws:
IOException
-
getFileContent
Returns the content of a file- Parameters:
os
- an output stream the which the content of the file will be written toref
- a reference to the file- Throws:
IOException
-
getFileContent
Returns the content of a file- Parameters:
ref
- a reference to the file- Returns:
- Throws:
IOException
-
exists
Returns whether the referenced file exists- Parameters:
ref
-- Returns:
-