net.fckeditor.response
Class UploadResponse

java.lang.Object
  extended by net.fckeditor.response.UploadResponse

public class UploadResponse
extends Object

Represents the HTML/JS response for the File Browser POST requests.

This class utilizes varags to reflect the JavaScript callback function in an optimal way. However, varargs can be tricky. You can always omit passed parameters from right to left but any violation may result in an exception or a failed callback.

For example: window.parent.OnUploadCompleted(101,'some/url/file.img','file.img','no error') can be mapped with UploadResponse ur = new UploadResponse(SC_SOME_ERROR,"/some/url/file.img","file.img","no error") .

But window.parent.OnUploadCompleted(101,'some/url/file.img','no error') is an illegal callback and will fail.

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

Field Summary
static int EN_CUSTOM_ERROR
          Error number CUSTOM ERROR
static int EN_CUSTOM_WARNING
          Error number CUSTOM WARNING
static int EN_FILE_RENAMED_WARNING
          Error number FILE RENAMED WARNING
static int EN_INVALID_FILE_TYPE_ERROR
          Error number INVALID FILE TYPE
static int EN_OK
          Error number OK
static int EN_SECURITY_ERROR
          Error number SECURITY ERROR
protected  Object[] parameters
          JavaScript callback parameters
 
Constructor Summary
UploadResponse(Object... arguments)
          Constructs a response with a varying amount of arguments.
 
Method Summary
static UploadResponse getFileRenamedWarning(String fileUrl, String newFileName)
          Creates a FILE RENAMED warning.
static UploadResponse getFileUploadDisabledError()
          Creates a FILE UPLOAD DISABLED error.
static UploadResponse getFileUploadWriteError()
          Creates a FILE UPLOAD WRITE error.
static UploadResponse getInvalidCommandError()
          Creates a INVALID COMMAND error.
static UploadResponse getInvalidCurrentFolderError()
          Creates a INVALID CURRENT FOLDER error.
static UploadResponse getInvalidFileTypeError()
          Creates a INVALID FILE TYPE error.
static UploadResponse getInvalidResourceTypeError()
          Creates a INVALID RESOURCE TYPE error.
static UploadResponse getOK(String fileUrl)
          Creates an OK response.
 void setCustomMessage(String customMassage)
          Sets the custom message of this upload response.
 String toString()
          Creates the HTML/JS representation of this upload response.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parameters

protected Object[] parameters
JavaScript callback parameters


EN_OK

public static final int EN_OK
Error number OK

See Also:
Constant Field Values

EN_CUSTOM_ERROR

public static final int EN_CUSTOM_ERROR
Error number CUSTOM ERROR

See Also:
Constant Field Values

EN_CUSTOM_WARNING

public static final int EN_CUSTOM_WARNING
Error number CUSTOM WARNING

See Also:
Constant Field Values

EN_FILE_RENAMED_WARNING

public static final int EN_FILE_RENAMED_WARNING
Error number FILE RENAMED WARNING

See Also:
Constant Field Values

EN_INVALID_FILE_TYPE_ERROR

public static final int EN_INVALID_FILE_TYPE_ERROR
Error number INVALID FILE TYPE

See Also:
Constant Field Values

EN_SECURITY_ERROR

public static final int EN_SECURITY_ERROR
Error number SECURITY ERROR

See Also:
Constant Field Values
Constructor Detail

UploadResponse

public UploadResponse(Object... arguments)
Constructs a response with a varying amount of arguments.

Use the predefined error numbers or upload responses, if possible. If you need to set error number and message only, use this constructor with the first argument only and call setCustomMessage(String).

Parameters:
arguments - possible argument order: int errorNumber, String fileUrl, String filename, String customMessage . Omit from right to left.
Throws:
IllegalArgumentException - if amount of arguments is less than 1 and above 4
IllegalArgumentException - if the first argument is not an error number (int)
Method Detail

setCustomMessage

public void setCustomMessage(String customMassage)
Sets the custom message of this upload response. Methods automatically determines how many arguments are set and puts the message at the end.

Parameters:
customMassage - the custom message of this upload response

getOK

public static UploadResponse getOK(String fileUrl)
Creates an OK response.


getFileRenamedWarning

public static UploadResponse getFileRenamedWarning(String fileUrl,
                                                   String newFileName)
Creates a FILE RENAMED warning.


getInvalidFileTypeError

public static UploadResponse getInvalidFileTypeError()
Creates a INVALID FILE TYPE error.


getInvalidCommandError

public static UploadResponse getInvalidCommandError()
Creates a INVALID COMMAND error.


getInvalidResourceTypeError

public static UploadResponse getInvalidResourceTypeError()
Creates a INVALID RESOURCE TYPE error.


getInvalidCurrentFolderError

public static UploadResponse getInvalidCurrentFolderError()
Creates a INVALID CURRENT FOLDER error.


getFileUploadDisabledError

public static UploadResponse getFileUploadDisabledError()
Creates a FILE UPLOAD DISABLED error.


getFileUploadWriteError

public static UploadResponse getFileUploadWriteError()
Creates a FILE UPLOAD WRITE error.


toString

public String toString()
Creates the HTML/JS representation of this upload response.

Overrides:
toString in class Object
Returns:
HTML/JS representation of this upload response


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