com.opensymphony.webwork.components
Class AbstractRichtexteditorConnector

java.lang.Object
  extended by com.opensymphony.xwork.ActionSupport
      extended by com.opensymphony.webwork.components.AbstractRichtexteditorConnector
All Implemented Interfaces:
ServletRequestAware, ServletResponseAware, Action, LocaleProvider, TextProvider, Validateable, ValidationAware, com.uwyn.rife.continuations.ContinuableObject, Serializable, Cloneable
Direct Known Subclasses:
DefaultRichtexteditorConnector

public abstract class AbstractRichtexteditorConnector
extends ActionSupport
implements ServletRequestAware, ServletResponseAware

An abstract class to be extended in order for the Rich text editor to perform server-side browsing and uploading.

 
 
   <package name="richtexteditor-browse" extends="webwork-default" namespace="/webwork/richtexteditor/editor/filemanager/browser/default/connectors/jsp">
        <action name="connector" class="com.opensymphony.webwork.components.DefaultRichtexteditorConnector" method="browse">
                <result name="getFolders" type="richtexteditorGetFolders" />
                <result name="getFoldersAndFiles" type="richtexteditorGetFoldersAndFiles" />
                <result name="createFolder" type="richtexteditorCreateFolder" />
                <result name="fileUpload" type="richtexteditorFileUpload" />
        </action>
   </package>
 
   <package name="richtexteditor-upload" extends="webwork-default" namespace="/webwork/richtexteditor/editor/filemanager/upload">
                <action name="uploader" class="com.opensymphony.webwork.components.DefaultRichtexteditorConnector" method="upload">
                        <result name="richtexteditorFileUpload" />
                </action>    
   </package>
 
 
 

Version:
$Date: 2006-03-09 04:22:35 +0800 (Thu, 09 Mar 2006) $ $Id: AbstractRichtexteditorConnector.java 2338 2006-03-08 20:22:35Z rainerh $
Author:
tm_jee
See Also:
DefaultRichtexteditorConnector, Serialized Form

Nested Class Summary
static class AbstractRichtexteditorConnector.CreateFolderResult
          Represensts the result of a server-side 'CreateFolder' command call.
static class AbstractRichtexteditorConnector.File
          Class represens a File in the server side.
static class AbstractRichtexteditorConnector.FileUploadResult
          Represents the result of a server-side 'FileUpload' command call.
static class AbstractRichtexteditorConnector.Folder
          Class represents a Folder in the server side.
static class AbstractRichtexteditorConnector.FoldersAndFiles
          Represents the files and folders to be returned from the server-side.
 
Field Summary
protected  String _command
           
protected  String _currentFolder
           
protected  File _newFile
           
protected  String _newFileContentType
           
protected  String _newFileFileName
           
protected  String _newFolderName
           
protected  HttpServletRequest _request
           
protected  HttpServletResponse _response
           
protected  String _serverPath
           
protected  String _type
           
static String CREATE_FOLDER
           
static String FILE_UPLOAD
           
static String GET_FOLDERS
           
static String GET_FOLDERS_AND_FILES
           
 
Fields inherited from class com.opensymphony.xwork.ActionSupport
LOG
 
Fields inherited from interface com.opensymphony.xwork.Action
ERROR, INPUT, LOGIN, NONE, SUCCESS
 
Constructor Summary
AbstractRichtexteditorConnector()
           
 
Method Summary
 String browse()
          The method that does the functionality when the richtexteditor 'browse' command is issued.
protected abstract  String calculateServerPath(String serverPath, String folderPath, String type)
          This method should return the url that could be used to access the server-side object.
protected abstract  AbstractRichtexteditorConnector.CreateFolderResult createFolder(String virtualFolderPath, String type, String newFolderName)
          Method that gets called when a 'CreateFolder' command is issued by the rich text editor.
protected abstract  AbstractRichtexteditorConnector.FileUploadResult fileUpload(String virtualFolderPath, String type, String filename, String contentType, File newFile)
          Method that gets called when a 'FileUpload' command is issued by the rich text editor.
 String getCommand()
           
 String getCurrentFolder()
           
protected abstract  AbstractRichtexteditorConnector.Folder[] getFolders(String virtualFolderPath, String type)
          Method that gets called when a 'GetFolders' command is issued by the rich text editor.
protected abstract  AbstractRichtexteditorConnector.FoldersAndFiles getFoldersAndFiles(String virtualFolderPath, String type)
          Method that gets called when a 'GetFoldersAndFiles' command is issued by the rich text editor.
 File getNewFile()
           
 String getNewFileContentType()
           
 String getNewFileFileName()
           
 String getNewFolderName()
           
 String getServerPath()
           
 String getType()
           
 void setCommand(String command)
           
 void setCurrentFolder(String currentFolder)
           
 void setNewFile(File newFile)
           
 void setNewFileContentType(String newFileContentType)
           
 void setNewFileFileName(String newFileFileName)
           
 void setNewFolderName(String newFolderName)
           
 void setServerPath(String serverPath)
           
 void setServletRequest(HttpServletRequest request)
          Sets the HTTP request object in implementing classes.
 void setServletResponse(HttpServletResponse response)
          Sets the HTTP response object in implementing classes.
 void setType(String type)
           
protected abstract  void unknownCommand(String command, String virtualFolderPath, String type, String filename, String contentType, File newFile)
          Methods that get called when an unrecognized command is issued.
 String upload()
          The method that does the functionality when the richtexteditor 'upload' command is '/webwork/richtexteditor/data/' issued.
 
Methods inherited from class com.opensymphony.xwork.ActionSupport
addActionError, addActionMessage, addFieldError, clearErrorsAndMessages, clone, doDefault, doInput, execute, getActionErrors, getActionMessages, getErrorMessages, getErrors, getFieldErrors, getLocale, getText, getText, getText, getText, getText, getText, getText, getText, getText, getTexts, getTexts, hasActionErrors, hasActionMessages, hasErrors, hasFieldErrors, hasKey, pause, setActionErrors, setActionMessages, setFieldErrors, validate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GET_FOLDERS

public static String GET_FOLDERS

GET_FOLDERS_AND_FILES

public static String GET_FOLDERS_AND_FILES

CREATE_FOLDER

public static String CREATE_FOLDER

FILE_UPLOAD

public static String FILE_UPLOAD

_request

protected HttpServletRequest _request

_response

protected HttpServletResponse _response

_newFile

protected File _newFile

_newFileFileName

protected String _newFileFileName

_newFileContentType

protected String _newFileContentType

_type

protected String _type

_command

protected String _command

_currentFolder

protected String _currentFolder

_serverPath

protected String _serverPath

_newFolderName

protected String _newFolderName
Constructor Detail

AbstractRichtexteditorConnector

public AbstractRichtexteditorConnector()
Method Detail

browse

public String browse()
              throws Exception
The method that does the functionality when the richtexteditor 'browse' command is issued.

Following are the result name that gets returned depending on the actual 'browse' command.

Browse Command Result Name
GetFolders getFolders
GetFoldersAndFiles getFoldersAndFiles
CreateFolder createFolder
FileUpload fileUpload

Returns:
result name
Throws:
Exception

upload

public String upload()
              throws Exception
The method that does the functionality when the richtexteditor 'upload' command is '/webwork/richtexteditor/data/' issued.

It return a result name of 'fileUpload'.

Returns:
result name
Throws:
Exception

calculateServerPath

protected abstract String calculateServerPath(String serverPath,
                                              String folderPath,
                                              String type)
                                       throws Exception
This method should return the url that could be used to access the server-side object. For example, if this methods return '/aaa/bbb/ccc', the say, server-side image selected is myImage.gif, then the image tag generated might be something like
   <img src='/aaa/bbb/ccc/myImage.gif' .... /<
 
For example, if the folderPath is '/folder1' and the type is 'Image', the calculated server path might be '/aaa/bbb/ccc/Image/folder1/' such that if the image is 'myImage.gif' the src attribute of the image tag might be '/aaa/bbb/ccc/Image/folder1/myImage.gif'.

Parameters:
serverPath - the server path provided through setServerPath (by default it is
folderPath - the current folder path requested
type - the type (Image, Link or Flash)
Returns:
calculated server path
Throws:
Exception

getFolders

protected abstract AbstractRichtexteditorConnector.Folder[] getFolders(String virtualFolderPath,
                                                                       String type)
                                                                throws Exception
Method that gets called when a 'GetFolders' command is issued by the rich text editor. This method should search the server-side and return an Folder[] that the server side has.

The folder path queried by the rich text editor is folderPath. While the type of could be one of 'Image', 'Link' or 'Flash'.

Parameters:
virtualFolderPath -
type -
Returns:
An array of Folders
Throws:
Exception

getFoldersAndFiles

protected abstract AbstractRichtexteditorConnector.FoldersAndFiles getFoldersAndFiles(String virtualFolderPath,
                                                                                      String type)
                                                                               throws Exception
Method that gets called when a 'GetFoldersAndFiles' command is issued by the rich text editor. This method should typically search the server-side for files and folders under the provided virtualFolderPath and return a FoldersAndFiles object.

The folder path queried by the richtexted editor is virtualFolderPath. While the type could be one of 'Image', 'Link' or 'Flash'.

Parameters:
virtualFolderPath -
type -
Returns:
FoldersAndFiles
Throws:
Exception

createFolder

protected abstract AbstractRichtexteditorConnector.CreateFolderResult createFolder(String virtualFolderPath,
                                                                                   String type,
                                                                                   String newFolderName)
                                                                            throws Exception
Method that gets called when a 'CreateFolder' command is issued by the rich text editor. This method would typically create a folder in the server-side if it is allowed to do so and return the result through CreateFolderResult object. CreateFolderResult contains static methods to return the available results.

The folder path queried by the richtexted editor is virtualFolderPath. While the type could be one of 'Image', 'Link' or 'Flash'. The new folder name to be created is newFolderName.

Parameters:
virtualFolderPath -
type -
newFolderName -
Returns:
CreateFolderResult
Throws:
Exception

fileUpload

protected abstract AbstractRichtexteditorConnector.FileUploadResult fileUpload(String virtualFolderPath,
                                                                               String type,
                                                                               String filename,
                                                                               String contentType,
                                                                               File newFile)
                                                                        throws Exception
Method that gets called when a 'FileUpload' command is issued by the rich text editor. This method would typically handle the file upload and return a FileUploadResult object. FileUploadResult contains only static methods that could create the available results.

The folder path queried by the richtexted editor is virtualFolderPath. While the type could be one of 'Image', 'Link' or 'Flash'. The upload file name is filename while its content type is conetnType and its content could be read off the newFile object.

Parameters:
virtualFolderPath -
type -
filename -
contentType -
newFile -
Returns:
FileUploadResult
Throws:
Exception

unknownCommand

protected abstract void unknownCommand(String command,
                                       String virtualFolderPath,
                                       String type,
                                       String filename,
                                       String contentType,
                                       File newFile)
                                throws Exception
Methods that get called when an unrecognized command is issued. Typical usage would be to log an error message.

Parameters:
command -
virtualFolderPath -
type -
filename -
contentType -
newFile -
Throws:
Exception

getNewFile

public File getNewFile()

setNewFile

public void setNewFile(File newFile)

getNewFileFileName

public String getNewFileFileName()

setNewFileFileName

public void setNewFileFileName(String newFileFileName)

getNewFileContentType

public String getNewFileContentType()

setNewFileContentType

public void setNewFileContentType(String newFileContentType)

getCommand

public String getCommand()

setCommand

public void setCommand(String command)

getType

public String getType()

setType

public void setType(String type)

getCurrentFolder

public String getCurrentFolder()

setCurrentFolder

public void setCurrentFolder(String currentFolder)

getNewFolderName

public String getNewFolderName()

setNewFolderName

public void setNewFolderName(String newFolderName)

getServerPath

public String getServerPath()

setServerPath

public void setServerPath(String serverPath)

setServletRequest

public void setServletRequest(HttpServletRequest request)
Description copied from interface: ServletRequestAware
Sets the HTTP request object in implementing classes.

Specified by:
setServletRequest in interface ServletRequestAware
Parameters:
request - the HTTP request.

setServletResponse

public void setServletResponse(HttpServletResponse response)
Description copied from interface: ServletResponseAware
Sets the HTTP response object in implementing classes.

Specified by:
setServletResponse in interface ServletResponseAware
Parameters:
response - the HTTP response.

WebWork Project Page