|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.deepamehta.core.osgi.PluginActivator
de.deepamehta.plugins.files.FilesPlugin
public class FilesPlugin
Field Summary | |
---|---|
private static String |
FILE_REPOSITORY_PATH
|
private static String |
FILE_REPOSITORY_URI
|
private Logger |
logger
|
Fields inherited from class de.deepamehta.core.osgi.PluginActivator |
---|
bundle, dms |
Constructor Summary | |
---|---|
FilesPlugin()
|
Method Summary | |
---|---|
private void |
associateChildTopic(long folderTopicId,
long childTopicId)
|
private void |
checkFileExistence(File file)
|
private void |
checkFilePath(File file)
Prerequisite: the file's path is canonical. |
private boolean |
childAssociationExists(long folderTopicId,
long childTopicId)
|
Topic |
createChildFileTopic(long folderTopicId,
String path,
ClientState clientState)
|
Topic |
createChildFolderTopic(long folderTopicId,
String path,
ClientState clientState)
|
Topic |
createFile(InputStream in,
String path)
Creates a file in the file repository, and creates a corresponding File topic. |
private Topic |
createFileTopic(File file,
ClientState clientState)
|
Topic |
createFileTopic(String path,
ClientState clientState)
Creates and returns a File topic representing the file at a given repository path. |
void |
createFolder(String folderName,
String path)
Creates a folder in the file repository. |
private Topic |
createFolderTopic(File file,
ClientState clientState)
|
Topic |
createFolderTopic(String path,
ClientState clientState)
Creates and returns a Folder topic representing the folder at a given repository path. |
private File |
enforeSecurity(String path)
|
private Topic |
fetchFileTopic(File file)
Fetches the File topic representing the file at a given absolute path. |
private Topic |
fetchFolderTopic(File file)
Fetches the Folder topic representing the folder at a given absolute path. |
private Topic |
fetchTopic(File file,
String parentTypeUri)
|
DirectoryListing |
getDirectoryListing(String path)
|
File |
getFile(long fileTopicId)
Accesses a file/directory in the file repository that is represented by the given File/Folder topic. |
File |
getFile(String path)
Accesses a file/directory in the file repository by the given repository path. |
String |
getRepositoryPath(URL url)
Checks if the given URL refers to the file repository of this DeepaMehta installation. |
ResourceInfo |
getResourceInfo(String path)
|
boolean |
handleSecurity(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
void |
init()
|
void |
openFile(long fileTopicId)
|
private File |
repoFile(File directory,
String fileName)
|
private File |
repoFile(File directory,
UploadedFile file)
Calculates the storage location for the uploaded file. |
private File |
repoFile(String path)
Constructs an absolute path from a repository path. |
private String |
repoPath(File file)
Returns the repository path that corresponds to the given absolute path. |
private String |
repoPath(long fileTopicId)
Returns the repository path of the given File/Folder topic. |
StoredFile |
storeFile(UploadedFile file,
String path,
ClientState clientState)
Receives an uploaded file, stores it in the file repository, and creates a corresponding File topic. |
Methods inherited from class de.deepamehta.core.osgi.PluginActivator |
---|
getBundleContext, getUri, postInstall, publishDirectory, serviceArrived, serviceGone, setCoreService, shutdown, start, stop, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final String FILE_REPOSITORY_PATH
private static final String FILE_REPOSITORY_URI
private Logger logger
Constructor Detail |
---|
public FilesPlugin()
Method Detail |
---|
public Topic createFileTopic(String path, @HeaderParam(value="Cookie") ClientState clientState)
FilesService
createFileTopic
in interface FilesService
path
- A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.public Topic createFolderTopic(String path, @HeaderParam(value="Cookie") ClientState clientState)
FilesService
createFolderTopic
in interface FilesService
path
- A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.public Topic createChildFileTopic(long folderTopicId, String path, @HeaderParam(value="Cookie") ClientState clientState)
createChildFileTopic
in interface FilesService
public Topic createChildFolderTopic(long folderTopicId, String path, @HeaderParam(value="Cookie") ClientState clientState)
createChildFolderTopic
in interface FilesService
public StoredFile storeFile(UploadedFile file, String path, @HeaderParam(value="Cookie") ClientState clientState)
FilesService
storeFile
in interface FilesService
path
- The directory where to store the uploaded file.
A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.
The directory must exist.
public Topic createFile(InputStream in, String path)
FilesService
createFile
in interface FilesService
in
- The input stream the file content is read from.path
- The path and filename of the file to be created.
A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.
If that file exists already it is overwritten. ### TODO: rethink overwriting
public void createFolder(String folderName, String path)
FilesService
createFolder
in interface FilesService
path
- 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.public ResourceInfo getResourceInfo(String path)
getResourceInfo
in interface FilesService
public DirectoryListing getDirectoryListing(String path)
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 DeepaMehta installation.public File getFile(String path)
FilesService
getFile
in interface FilesService
path
- A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.public File getFile(long fileTopicId)
FilesService
getFile
in interface FilesService
public void openFile(long fileTopicId)
openFile
in interface FilesService
public boolean handleSecurity(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
handleSecurity
in interface SecurityHandler
public void init()
init
in interface PluginContext
init
in class PluginActivator
private Topic fetchFileTopic(File file)
null
is returned.
file
- An absolute path.private Topic fetchFolderTopic(File file)
null
is returned.
file
- An absolute path.private Topic fetchTopic(File file, String parentTypeUri)
file
- An absolute path.private Topic createFileTopic(File file, ClientState clientState)
private Topic createFolderTopic(File file, ClientState clientState)
private void associateChildTopic(long folderTopicId, long childTopicId)
private boolean childAssociationExists(long folderTopicId, long childTopicId)
private File repoFile(String path)
path
- A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.private File repoFile(File directory, UploadedFile file)
directory
- An absolute path.private File repoFile(File directory, String fileName)
directory
- An absolute path.private String repoPath(File file)
file
- An absolute path.private String repoPath(long fileTopicId)
private File enforeSecurity(String path) throws FileRepositoryException
path
- A repository path. Relative to the repository base path.
Must begin with slash, no slash at the end.
FileRepositoryException
private void checkFilePath(File file) throws FileRepositoryException
FileRepositoryException
private void checkFileExistence(File file) throws FileRepositoryException
FileRepositoryException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |