de.deepamehta.plugins.files
Class FilesPlugin

Show UML class diagram
java.lang.Object
  extended by de.deepamehta.core.osgi.PluginActivator
      extended by de.deepamehta.plugins.files.FilesPlugin
All Implemented Interfaces:
PluginContext, PluginService, SecurityHandler, FilesService, BundleActivator

public class FilesPlugin
extends PluginActivator
implements FilesService, SecurityHandler


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)
           
private  Topic createFileTopic(File file, ClientState clientState)
           
 Topic createFileTopic(String path, ClientState clientState)
          Creates a File topic for a given path.
 void createFolder(String folderName, String path)
           
private  Topic createFolderTopic(File file, ClientState clientState)
           
 Topic createFolderTopic(String path, ClientState clientState)
          Creates a Folder topic for a given path.
private  File enforeSecurity(String path)
           
private  Topic fetchFileTopic(File file)
           
private  Topic fetchFolderTopic(File file)
           
 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 its 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)
          Maps a repository path to a repository file.
private  String repoPath(File file)
          Maps a repository file to a repository path.
private  String repoPath(long fileTopicId)
           
 StoredFile storeFile(UploadedFile file, String path, ClientState clientState)
           
 
Methods inherited from class de.deepamehta.core.osgi.PluginActivator
getBundleContext, postInstall, publishDirectory, serviceArrived, serviceGone, setCoreService, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FILE_REPOSITORY_PATH

private static final String FILE_REPOSITORY_PATH

FILE_REPOSITORY_URI

private static final String FILE_REPOSITORY_URI
See Also:
Constant Field Values

logger

private Logger logger
Constructor Detail

FilesPlugin

public FilesPlugin()
Method Detail

createFileTopic

public Topic createFileTopic(String path,
                             @HeaderParam(value="Cookie")
                             ClientState clientState)
Description copied from interface: FilesService
Creates a File topic for a given path. If a File topic for that path exists already that topic is returned.

Specified by:
createFileTopic in interface FilesService

createFolderTopic

public Topic createFolderTopic(String path,
                               @HeaderParam(value="Cookie")
                               ClientState clientState)
Description copied from interface: FilesService
Creates a Folder topic for a given path. If a Folder topic for that path exists already that topic is returned.

Specified by:
createFolderTopic in interface FilesService

createChildFileTopic

public Topic createChildFileTopic(long folderTopicId,
                                  String path,
                                  @HeaderParam(value="Cookie")
                                  ClientState clientState)
Specified by:
createChildFileTopic in interface FilesService

createChildFolderTopic

public Topic createChildFolderTopic(long folderTopicId,
                                    String path,
                                    @HeaderParam(value="Cookie")
                                    ClientState clientState)
Specified by:
createChildFolderTopic in interface FilesService

storeFile

public StoredFile storeFile(UploadedFile file,
                            String path,
                            @HeaderParam(value="Cookie")
                            ClientState clientState)
Specified by:
storeFile in interface FilesService
path - The directory where to store the file. Relative to the file repository root path. Must begin with slash ('/'), no slash at the end. The directory must exist.

createFolder

public void createFolder(String folderName,
                         String path)
Specified by:
createFolder in interface FilesService

getResourceInfo

public ResourceInfo getResourceInfo(String path)
Specified by:
getResourceInfo in interface FilesService

getDirectoryListing

public DirectoryListing getDirectoryListing(String path)
Specified by:
getDirectoryListing in interface FilesService

getRepositoryPath

public String getRepositoryPath(URL url)
Description copied from interface: FilesService
Checks if the given URL refers to the file repository of this DeepaMehta installation.

Specified by:
getRepositoryPath in interface FilesService
Returns:
the refered file's/directory's repository path, or null if the URL does not refer to the file repository of this DeepaMehta installation.

getFile

public File getFile(String path)
Description copied from interface: FilesService
Accesses a file/directory in the file repository by its path. Note: this method doesn't require the corresponding File/Folder topic to exist.

Specified by:
getFile in interface FilesService
Parameters:
path - a file repository path. Must begin with slash ('/'), no slash at the end.

getFile

public File getFile(long fileTopicId)
Description copied from interface: FilesService
Accesses a file/directory in the file repository that is represented by the given File/Folder topic.

Specified by:
getFile in interface FilesService

openFile

public void openFile(long fileTopicId)
Specified by:
openFile in interface FilesService

handleSecurity

public boolean handleSecurity(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response)
Specified by:
handleSecurity in interface SecurityHandler

init

public void init()
Specified by:
init in interface PluginContext
Overrides:
init in class PluginActivator

fetchFileTopic

private Topic fetchFileTopic(File file)

fetchFolderTopic

private Topic fetchFolderTopic(File file)

createFileTopic

private Topic createFileTopic(File file,
                              ClientState clientState)

createFolderTopic

private Topic createFolderTopic(File file,
                                ClientState clientState)

associateChildTopic

private void associateChildTopic(long folderTopicId,
                                 long childTopicId)

childAssociationExists

private boolean childAssociationExists(long folderTopicId,
                                       long childTopicId)

repoFile

private File repoFile(String path)
Maps a repository path to a repository file.


repoFile

private File repoFile(File directory,
                      UploadedFile file)
Calculates the storage location for the uploaded file.


repoFile

private File repoFile(File directory,
                      String fileName)

repoPath

private String repoPath(File file)
Maps a repository file to a repository path.


repoPath

private String repoPath(long fileTopicId)

enforeSecurity

private File enforeSecurity(String path)
                     throws FileRepositoryException
Throws:
FileRepositoryException

checkFilePath

private void checkFilePath(File file)
                    throws FileRepositoryException
Prerequisite: the file's path is canonical.

Throws:
FileRepositoryException

checkFileExistence

private void checkFileExistence(File file)
                         throws FileRepositoryException
Throws:
FileRepositoryException


Copyright © 2013. All Rights Reserved.