public class FilesPlugin extends PluginActivator implements FilesService, StaticResourceFilter
Modifier and Type | Field and Description |
---|---|
static DMXEvent |
CHECK_DISK_QUOTA |
bundle, dmx, mf
Constructor and Description |
---|
FilesPlugin() |
Modifier and Type | Method and Description |
---|---|
Topic |
createFile(InputStream in,
String repoPath)
Creates a file in the file repository and a corresponding File topic.
|
RelatedTopic |
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.
|
RelatedTopic |
getChildFileTopic(long folderTopicId,
String repoPath)
Returns the File topic representing the file at a given repository path.
|
RelatedTopic |
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.
|
Topic |
getFileTopic(String repoPath)
Returns the File topic representing the file at a given repository path.
|
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 DMX 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.
|
String |
repoPath(File path)
Maps an absolute path to a repository path.
|
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.
|
getBundleContext, getPluginName, getStaticResource, getUri, preInstall, publishFileSystem, serviceArrived, serviceGone, setCoreService, shutdown, start, stop, toString
public static DMXEvent CHECK_DISK_QUOTA
public Topic getFileTopic(String repoPath)
FilesService
getFileTopic
in interface FilesService
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 (dmx.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 Topic getFolderTopic(String repoPath)
FilesService
getFolderTopic
in interface FilesService
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 (dmx.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 RelatedTopic getChildFileTopic(long folderTopicId, String repoPath)
FilesService
Creates an association (type "Composition") between the File topic (role type "Child") and its parent Folder topic (role type "Parent"), if not exists already.
getChildFileTopic
in interface FilesService
folderTopicId
- 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 (dmx.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 RelatedTopic getChildFolderTopic(long folderTopicId, String repoPath)
FilesService
Creates an association (type "Composition") between the Folder topic (role type "Child") and its parent Folder topic (role type "Parent"), if not exists already.
getChildFolderTopic
in interface FilesService
folderTopicId
- 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 (dmx.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) throws FileRepositoryException
FilesService
storeFile
in interface FilesService
repoPath
- 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 (dmx.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.
FileRepositoryException
public Topic createFile(InputStream in, String repoPath)
FilesService
createFile
in interface FilesService
in
- 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 (dmx.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 RelatedTopic createFolder(String folderName, String repoPath) throws FileRepositoryException
FilesService
createFolder
in interface FilesService
repoPath
- 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 (dmx.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.
FileRepositoryException
public ResourceInfo getResourceInfo(String repoPath)
getResourceInfo
in interface FilesService
public DirectoryListing getDirectoryListing(String repoPath)
getDirectoryListing
in interface FilesService
public String getRepositoryPath(URL url)
FilesService
getRepositoryPath
in interface FilesService
null
if the URL
does not refer to the file repository of this DMX installation.public File getFile(String repoPath)
FilesService
Note: this method does not require the corresponding File/Folder topic to exist.
getFile
in interface FilesService
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 (dmx.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)
FilesService
getFile
in interface FilesService
fileTopicId
- ID of a File/Folder topic.public boolean fileExists(String repoPath)
FilesService
fileExists
in interface FilesService
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 (dmx.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()
FilesService
dmx.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 FilesService
public String pathPrefix(long workspaceId)
FilesService
dmx.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 FilesService
public int openFile(long fileTopicId)
openFile
in interface FilesService
public void init()
init
in interface PluginContext
init
in class PluginActivator
public void staticResourceFilter(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
staticResourceFilter
in interface StaticResourceFilter
Copyright © 2023. All Rights Reserved.