net.fckeditor.connector
Interface Connector

All Known Implementing Classes:
AbstractLocalFileSystemConnector, ContextConnector, LocalConnector

public interface Connector

Backend interface of a File Browser connector. A connector serves and manages files and folders accessed through the File Browser on an arbitrary backend system.
The connector will receive a request if, and only if, the request was valid in terms of valid and reasonable parameters up to an abstract point which is independent from a specific connector implementation.

Helpful classes and methods:

  1. If you need to access the request instance itself and/or the context parameters sent from the File Browser, take a look at the ThreadLocalData class.
  2. Use RequestCycleHandler.getUserFilesAbsolutePath, AbstractLocalFileSystemConnector.getRealUserFilesAbsolutePath (if use it) to resolve the real path or simply do it yourself.

Version:
$Id: Connector.java 4785 2009-12-21 20:10:28Z mosipov $

Field Summary
static String KEY_NAME
          Key 'name' for a file's name
static String KEY_SIZE
          Key 'size' for a file's length
 
Method Summary
 void createFolder(ResourceType type, String currentFolder, String newFolder)
          Creates a new folder on the backend.
 String fileUpload(ResourceType type, String currentFolder, String fileName, InputStream inputStream)
          Uploads a new file on to the backend.
 List<Map<String,Object>> getFiles(ResourceType type, String currentFolder)
          Returns a list of file attributes from the backend.
 List<String> getFolders(ResourceType type, String currentFolder)
          Returns a list of folders from the backend.
 void init(ServletContext servletContext)
          Initializes this connector.
 

Field Detail

KEY_NAME

static final String KEY_NAME
Key 'name' for a file's name

See Also:
Constant Field Values

KEY_SIZE

static final String KEY_SIZE
Key 'size' for a file's length

See Also:
Constant Field Values
Method Detail

init

void init(ServletContext servletContext)
          throws Exception
Initializes this connector. Called at dispatcher initialization.

Parameters:
servletContext - reference to the ServletContext in which the caller is running
Throws:
Exception - if the connector initialization fails due to some reason

getFiles

List<Map<String,Object>> getFiles(ResourceType type,
                                  String currentFolder)
                                  throws InvalidCurrentFolderException,
                                         ReadException
Returns a list of file attributes from the backend. Use the pre-defined keys ("name", "size") to put file attributes into the file map. The file length can be any instance of Number, its long value will be taken as the final value.

Parameters:
type - the current resource type
currentFolder - the current folder
Returns:
a list of file attributes
Throws:
InvalidCurrentFolderException - if the current folder name is invalid or does not exist within the underlying backend
ReadException - if the file attributes could not be read due to some reason

getFolders

List<String> getFolders(ResourceType type,
                        String currentFolder)
                        throws InvalidCurrentFolderException,
                               ReadException
Returns a list of folders from the backend.

Parameters:
type - the current resource type
currentFolder - the current folder
Returns:
a list of folder names
Throws:
InvalidCurrentFolderException - if the current folder name is invalid or does not exist within the underlying backend
ReadException - if the folder names could not be read due to some reason

createFolder

void createFolder(ResourceType type,
                  String currentFolder,
                  String newFolder)
                  throws InvalidCurrentFolderException,
                         InvalidNewFolderNameException,
                         FolderAlreadyExistsException,
                         WriteException
Creates a new folder on the backend.

Parameters:
type - the current resource type
currentFolder - the current folder
newFolder - name of the new folder
Throws:
InvalidCurrentFolderException - if the current folder name is invalid or does not exist within the underlying backend
InvalidNewFolderNameException - if the new folder name is invalid due to some reason
FolderAlreadyExistsException - if the new folder already exists
WriteException - if the new folder could not be created due to some reason

fileUpload

String fileUpload(ResourceType type,
                  String currentFolder,
                  String fileName,
                  InputStream inputStream)
                  throws InvalidCurrentFolderException,
                         WriteException
Uploads a new file on to the backend. You are not allowed to overwrite already existing files, rename the new file and return the new filename.

Parameters:
type - the current resource type
currentFolder - the current folder
fileName - the name of the new file
inputStream - input stream of the new file
Returns:
the (eventually renamed) name of the uploaded file
Throws:
InvalidCurrentFolderException - if the current folder name is invalid or does not exist within the underlying backend
WriteException - if the new file could not be created due to some reason


Copyright © 2004-2010 Frederico Caldeira Knabben. All Rights Reserved.