001    package de.deepamehta.plugins.files.service;
002    
003    import de.deepamehta.plugins.files.DirectoryListing;
004    import de.deepamehta.plugins.files.ResourceInfo;
005    import de.deepamehta.plugins.files.StoredFile;
006    import de.deepamehta.plugins.files.UploadedFile;
007    
008    import de.deepamehta.core.Topic;
009    import de.deepamehta.core.service.ClientState;
010    import de.deepamehta.core.service.PluginService;
011    
012    import java.io.File;
013    import java.net.URL;
014    
015    
016    
017    public interface FilesService extends PluginService {
018    
019    
020    
021        // === File System Representation ===
022    
023        /**
024         * Creates a File topic for a given path.
025         * If a File topic for that path exists already that topic is returned.
026         */
027        Topic createFileTopic(String path, ClientState clientState);
028    
029        /**
030         * Creates a Folder topic for a given path.
031         * If a Folder topic for that path exists already that topic is returned.
032         */
033        Topic createFolderTopic(String path, ClientState clientState);
034    
035        // ---
036    
037        Topic createChildFileTopic(long folderTopicId, String path, ClientState clientState);
038    
039        Topic createChildFolderTopic(long folderTopicId, String path, ClientState clientState);
040    
041    
042    
043        // === File Repository ===
044    
045        /**
046         * @param   path    The directory where to store the file. Relative to the file repository root path.
047         *                  Must begin with slash ('/'), no slash at the end.
048         *                  The directory must exist.
049         */
050        StoredFile storeFile(UploadedFile file, String path, ClientState clientState);
051    
052        void createFolder(String folderName, String path);
053    
054        // ---
055    
056        ResourceInfo getResourceInfo(String path);
057    
058        DirectoryListing getDirectoryListing(String path);
059    
060        /**
061         * Checks if the given URL refers to the file repository of this DeepaMehta installation.
062         *
063         * @return  the refered file's/directory's repository path, or <code>null</code> if the URL
064         *          does not refer to the file repository of this DeepaMehta installation.
065         */
066        String getRepositoryPath(URL url);
067    
068        // ---
069    
070        /**
071         * Accesses a file/directory in the file repository by its path.
072         * Note: this method doesn't require the corresponding File/Folder topic to exist.
073         *
074         * @param   path    a file repository path. Must begin with slash ('/'), no slash at the end.
075         */
076        File getFile(String path);
077    
078        /**
079         * Accesses a file/directory in the file repository that is represented by the given File/Folder topic.
080         */
081        File getFile(long fileTopicId);
082    
083        // ---
084    
085        void openFile(long fileTopicId);
086    }