public class FilesPlugin extends de.deepamehta.core.osgi.PluginActivator implements FilesService, de.deepamehta.core.service.event.StaticResourceFilterListener
| Modifier and Type | Field and Description |
|---|---|
static de.deepamehta.core.service.DeepaMehtaEvent |
CHECK_DISK_QUOTA |
static int |
DISK_QUOTA_MB |
static String |
FILE_REPOSITORY_PATH |
static boolean |
FILE_REPOSITORY_PER_WORKSPACE |
| Constructor and Description |
|---|
FilesPlugin() |
| Modifier and Type | Method and Description |
|---|---|
de.deepamehta.core.Topic |
createFile(InputStream in,
String repoPath)
Creates a file in the file repository and a corresponding File topic.
|
void |
createFolder(String folderName,
String repoPath)
Creates a folder in the file repository.
|
boolean |
fileExists(String repoPath)
Checks if a file/directory with the given repository path exists in the file repository.
|
de.deepamehta.core.Topic |
getChildFileTopic(long folderTopicId,
String repoPath)
Returns the File topic representing the file at a given repository path.
|
de.deepamehta.core.Topic |
getChildFolderTopic(long folderTopicId,
String repoPath)
Returns the Folder topic representing the folder at a given repository path.
|
DirectoryListing |
getDirectoryListing(String repoPath) |
File |
getFile(long fileTopicId)
Convenience method to access the file/directory in the file repository that is represented by the given
File/Folder topic.
|
File |
getFile(String repoPath)
Accesses a file/directory in the file repository by the given repository path.
|
de.deepamehta.core.Topic |
getFileTopic(String repoPath)
Returns the File topic representing the file at a given repository path.
|
de.deepamehta.core.Topic |
getFolderTopic(String repoPath)
Returns the Folder topic representing the folder at a given repository path.
|
String |
getRepositoryPath(URL url)
Checks if the given URL refers to the file repository of this DeepaMehta installation.
|
ResourceInfo |
getResourceInfo(String repoPath) |
void |
init() |
int |
openFile(long fileTopicId) |
String |
pathPrefix()
Returns a prefix that can be used for constructing a repository path.
|
String |
pathPrefix(long workspaceId)
Returns a prefix that can be used for constructing a repository path.
|
void |
preInstall() |
String |
repoPath(File path)
Maps an absolute path to a repository path.
|
void |
shutdown() |
void |
staticResourceFilter(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) |
StoredFile |
storeFile(UploadedFile file,
String repoPath)
Receives an uploaded file, stores it in the file repository, and creates a corresponding File topic.
|
public static final String FILE_REPOSITORY_PATH
public static final boolean FILE_REPOSITORY_PER_WORKSPACE
public static final int DISK_QUOTA_MB
public static de.deepamehta.core.service.DeepaMehtaEvent CHECK_DISK_QUOTA
public de.deepamehta.core.Topic getFileTopic(String repoPath)
FilesServicegetFileTopic in interface FilesServicerepoPath - A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.
If per-workspace file repos are active (dm4.filerepo.per_workspace=true)
the repository path must contain the workspace prefix as the first path segment,
e.g. "/workspace-1234" where 1234 is the workspace ID.
However there is one exception to that rule: if and only if "/" is passed
as the repository path the workspace prefix is determined automatically with the
semantics of current workspace, based on the request's workspace cookie.
For support with constructing a repository path see the pathPrefix methods.
public de.deepamehta.core.Topic getFolderTopic(String repoPath)
FilesServicegetFolderTopic in interface FilesServicerepoPath - A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.
If per-workspace file repos are active (dm4.filerepo.per_workspace=true)
the repository path must contain the workspace prefix as the first path segment,
e.g. "/workspace-1234" where 1234 is the workspace ID.
However there is one exception to that rule: if and only if "/" is passed
as the repository path the workspace prefix is determined automatically with the
semantics of current workspace, based on the request's workspace cookie.
For support with constructing a repository path see the pathPrefix methods.
public de.deepamehta.core.Topic getChildFileTopic(long folderTopicId,
String repoPath)
FilesServiceCreates an association (type "Aggregation") between the File topic (role type "Child") and its parent Folder topic (role type "Parent"), if not exists already.
getChildFileTopic in interface FilesServicefolderTopicId - ID of the parent Folder topic.repoPath - A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.
If per-workspace file repos are active (dm4.filerepo.per_workspace=true)
the repository path must contain the workspace prefix as the first path segment,
e.g. "/workspace-1234" where 1234 is the workspace ID.
However there is one exception to that rule: if and only if "/" is passed
as the repository path the workspace prefix is determined automatically with the
semantics of current workspace, based on the request's workspace cookie.
For support with constructing a repository path see the pathPrefix methods.
public de.deepamehta.core.Topic getChildFolderTopic(long folderTopicId,
String repoPath)
FilesServiceCreates an association (type "Aggregation") between the Folder topic (role type "Child") and its parent Folder topic (role type "Parent"), if not exists already.
getChildFolderTopic in interface FilesServicefolderTopicId - ID of the parent Folder topic.repoPath - A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.
If per-workspace file repos are active (dm4.filerepo.per_workspace=true)
the repository path must contain the workspace prefix as the first path segment,
e.g. "/workspace-1234" where 1234 is the workspace ID.
However there is one exception to that rule: if and only if "/" is passed
as the repository path the workspace prefix is determined automatically with the
semantics of current workspace, based on the request's workspace cookie.
For support with constructing a repository path see the pathPrefix methods.
public StoredFile storeFile(UploadedFile file, String repoPath)
FilesServicestoreFile in interface FilesServicerepoPath - The directory where to store the uploaded file.
The directory must exist.
A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.
If per-workspace file repos are active (dm4.filerepo.per_workspace=true)
the repository path must contain the workspace prefix as the first path segment,
e.g. "/workspace-1234" where 1234 is the workspace ID.
However there is one exception to that rule: if and only if "/" is passed
as the repository path the workspace prefix is determined automatically with the
semantics of current workspace, based on the request's workspace cookie.
For support with constructing a repository path see the pathPrefix methods.
public de.deepamehta.core.Topic createFile(InputStream in, String repoPath)
FilesServicecreateFile in interface FilesServicein - The input stream the file content is read from.repoPath - The path and filename of the file to be created.
If that file exists already it is overwritten. ### TODO: rethink overwriting
A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.
If per-workspace file repos are active (dm4.filerepo.per_workspace=true)
the repository path must contain the workspace prefix as the first path segment,
e.g. "/workspace-1234" where 1234 is the workspace ID.
However there is one exception to that rule: if and only if "/" is passed
as the repository path the workspace prefix is determined automatically with the
semantics of current workspace, based on the request's workspace cookie.
For support with constructing a repository path see the pathPrefix methods.
public void createFolder(String folderName, String repoPath)
FilesServicecreateFolder in interface FilesServicerepoPath - The directory where to create the folder.
A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.
If per-workspace file repos are active (dm4.filerepo.per_workspace=true)
the repository path must contain the workspace prefix as the first path segment,
e.g. "/workspace-1234" where 1234 is the workspace ID.
However there is one exception to that rule: if and only if "/" is passed
as the repository path the workspace prefix is determined automatically with the
semantics of current workspace, based on the request's workspace cookie.
For support with constructing a repository path see the pathPrefix methods.
public ResourceInfo getResourceInfo(String repoPath)
getResourceInfo in interface FilesServicepublic DirectoryListing getDirectoryListing(String repoPath)
getDirectoryListing in interface FilesServicepublic String getRepositoryPath(URL url)
FilesServicegetRepositoryPath in interface FilesServicenull if the URL
does not refer to the file repository of this DeepaMehta installation.public File getFile(String repoPath)
FilesServiceNote: this method does not require the corresponding File/Folder topic to exist.
getFile in interface FilesServicerepoPath - A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.
If per-workspace file repos are active (dm4.filerepo.per_workspace=true)
the repository path must contain the workspace prefix as the first path segment,
e.g. "/workspace-1234" where 1234 is the workspace ID.
However there is one exception to that rule: if and only if "/" is passed
as the repository path the workspace prefix is determined automatically with the
semantics of current workspace, based on the request's workspace cookie.
For support with constructing a repository path see the pathPrefix methods.
public File getFile(long fileTopicId)
FilesServicegetFile in interface FilesServicefileTopicId - ID of a File/Folder topic.public boolean fileExists(String repoPath)
FilesServicefileExists in interface FilesServicerepoPath - A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.
If per-workspace file repos are active (dm4.filerepo.per_workspace=true)
the repository path must contain the workspace prefix as the first path segment,
e.g. "/workspace-1234" where 1234 is the workspace ID.
However there is one exception to that rule: if and only if "/" is passed
as the repository path the workspace prefix is determined automatically with the
semantics of current workspace, based on the request's workspace cookie.
For support with constructing a repository path see the pathPrefix methods.
true if the file exists, false otherwise.public String pathPrefix()
FilesServicedm4.filerepo.per_workspace=true) the prefix
represents the current workspace (e.g. "/workspace-1234"), based on the workspace cookie.
In case of per-workspace file repos are not active an empty string is returned.pathPrefix in interface FilesServicepublic String pathPrefix(long workspaceId)
FilesServicedm4.filerepo.per_workspace=true) the prefix
represents the given workspace (e.g. "/workspace-1234").
In case of per-workspace file repos are not active an empty string is returned.pathPrefix in interface FilesServicepublic int openFile(long fileTopicId)
openFile in interface FilesServicepublic void preInstall()
preInstall in interface de.deepamehta.core.osgi.PluginContextpreInstall in class de.deepamehta.core.osgi.PluginActivatorpublic void init()
init in interface de.deepamehta.core.osgi.PluginContextinit in class de.deepamehta.core.osgi.PluginActivatorpublic void shutdown()
shutdown in interface de.deepamehta.core.osgi.PluginContextshutdown in class de.deepamehta.core.osgi.PluginActivatorpublic void staticResourceFilter(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
staticResourceFilter in interface de.deepamehta.core.service.event.StaticResourceFilterListenerCopyright © 2017. All rights reserved.