de.deepamehta.plugins.files
Class FilesPlugin

java.lang.Object
  extended by de.deepamehta.core.osgi.PluginActivator
      extended by de.deepamehta.plugins.files.FilesPlugin
All Implemented Interfaces:
de.deepamehta.core.osgi.PluginContext, de.deepamehta.core.service.PluginService, de.deepamehta.core.service.SecurityHandler, FilesService, org.osgi.framework.BundleActivator

public class FilesPlugin
extends de.deepamehta.core.osgi.PluginActivator
implements FilesService, de.deepamehta.core.service.SecurityHandler


Field Summary
 
Fields inherited from class de.deepamehta.core.osgi.PluginActivator
bundle, dms
 
Constructor Summary
FilesPlugin()
           
 
Method Summary
 de.deepamehta.core.Topic createChildFileTopic(long folderTopicId, String path)
           
 de.deepamehta.core.Topic createChildFolderTopic(long folderTopicId, String path)
           
 de.deepamehta.core.Topic createFile(InputStream in, String path)
          Creates a file in the file repository, and creates a corresponding File topic.
 de.deepamehta.core.Topic createFileTopic(String path)
          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.
 de.deepamehta.core.Topic createFolderTopic(String path)
          Creates and returns a Folder topic representing the folder at a given repository path.
 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)
           
 StoredFile storeFile(UploadedFile file, String path)
          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, getPluginName, getStaticResource, 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
 

Constructor Detail

FilesPlugin

public FilesPlugin()
Method Detail

createFileTopic

public de.deepamehta.core.Topic createFileTopic(String path)
Description copied from interface: FilesService
Creates and returns a File topic representing the file at a given repository path. If such a File topic exists already that topic is returned.

Specified by:
createFileTopic in interface FilesService
Parameters:
path - A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.

createFolderTopic

public de.deepamehta.core.Topic createFolderTopic(String path)
Description copied from interface: FilesService
Creates and returns a Folder topic representing the folder at a given repository path. If such a Folder topic exists already that topic is returned.

Specified by:
createFolderTopic in interface FilesService
Parameters:
path - A repository path. Relative to the repository base path. Must begin with slash, no slash at the end.

createChildFileTopic

public de.deepamehta.core.Topic createChildFileTopic(long folderTopicId,
                                                     String path)
Specified by:
createChildFileTopic in interface FilesService

createChildFolderTopic

public de.deepamehta.core.Topic createChildFolderTopic(long folderTopicId,
                                                       String path)
Specified by:
createChildFolderTopic in interface FilesService

storeFile

public StoredFile storeFile(UploadedFile file,
                            String path)
Description copied from interface: FilesService
Receives an uploaded file, stores it in the file repository, and creates a corresponding File topic.

Specified by:
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.
Returns:
a StoredFile object which holds 2 information: the name of the uploaded file, and the ID of the created File topic.

createFile

public de.deepamehta.core.Topic createFile(InputStream in,
                                           String path)
Description copied from interface: FilesService
Creates a file in the file repository, and creates a corresponding File topic.

Specified by:
createFile in interface FilesService
Parameters:
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
Returns:
the File topic that corresponds to the created file.

createFolder

public void createFolder(String folderName,
                         String path)
Description copied from interface: FilesService
Creates a folder in the file repository. Note: to corresponding Folder topic is created.

Specified by:
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.

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 the given repository path. Note: this method doesn't require the corresponding File/Folder topic to exist.

Specified by:
getFile in interface FilesService
Parameters:
path - A repository path. Relative to the repository base 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 de.deepamehta.core.service.SecurityHandler

init

public void init()
Specified by:
init in interface de.deepamehta.core.osgi.PluginContext
Overrides:
init in class de.deepamehta.core.osgi.PluginActivator


Copyright © 2015. All rights reserved.