Changeset 2101 for FCKeditor.Java/trunk
- Timestamp:
- 2008-06-23 00:00:48 (5 months ago)
- Location:
- FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor
- Files:
-
- 19 modified
-
connector/ConnectorServlet.java (modified) (5 diffs)
-
FCKeditorConfig.java (modified) (2 diffs)
-
FCKeditor.java (modified) (8 diffs)
-
handlers/CommandHandler.java (modified) (7 diffs)
-
handlers/ConnectorHandler.java (modified) (5 diffs)
-
handlers/ExtensionsHandler.java (modified) (5 diffs)
-
handlers/PropertiesLoader.java (modified) (4 diffs)
-
handlers/RequestCycleHandler.java (modified) (5 diffs)
-
handlers/ResourceTypeHandler.java (modified) (6 diffs)
-
requestcycle/UserAction.java (modified) (2 diffs)
-
requestcycle/UserPathBuilder.java (modified) (2 diffs)
-
response/UploadResponse.java (modified) (2 diffs)
-
tags/CheckTag.java (modified) (2 diffs)
-
tags/ConfigTag.java (modified) (1 diff)
-
tags/EditorTag.java (modified) (3 diffs)
-
tool/Compatibility.java (modified) (2 diffs)
-
tool/UtilsFile.java (modified) (3 diffs)
-
tool/Utils.java (modified) (5 diffs)
-
tool/XHtmlTagTool.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/connector/ConnectorServlet.java
r2028 r2101 51 51 52 52 /** 53 * Servlet to upload and browse files.<br> 54 * 55 * This servlet accepts 4 commands used to retrieve and create files and folders from a server 56 * directory. The allowed commands are: 53 * Servlet to upload and browse files.<br /> 54 * 55 * This servlet accepts 4 commands which interact with the server-side 56 * filesystem.<br /> 57 * The allowed commands are: 57 58 * <ul> 58 * <li>GetFolders: Retrieve the list of directory under the current folder 59 * <li>GetFoldersAndFiles: Retrive the list of files and directory under the current folder 60 * <li>CreateFolder: Create a new directory under the current folder 61 * <li>FileUpload: Send a new file to the server (must be sent with a POST) 59 * <li><code>GetFolders</code>: Retrieves a list of folders in the current 60 * folder</li> 61 * <li><code>GetFoldersAndFiles</code>: Retrives a list of files and folders 62 * in the current folder</li> 63 * <li><code>CreateFolder</code>: Creates a new folder in the current folder</li> 64 * <li><code>FileUpload</code>: Stores an uploaded file into the current 65 * folder. (must be sent with POST)</li> 62 66 * </ul> 63 67 * … … 70 74 71 75 /** 72 * Initialize the servlet.<br> 73 * The default directory for user files will be constructed. 76 * Initialize the servlet: <code>mkdir</code> <DefaultUserFilesPath> 74 77 */ 75 78 public void init() throws ServletException, IllegalArgumentException { 76 // check, if 'baseDir' exists77 79 String realDefaultUserFilesPath = getServletContext().getRealPath( 78 80 ConnectorHandler.getDefaultUserFilesPath()); … … 81 83 UtilsFile.checkDirAndCreate(defaultUserFilesDir); 82 84 83 logger.info("ConnectorServlet successful initialized!");85 logger.info("ConnectorServlet successfully initialized!"); 84 86 } 85 87 86 88 /** 87 * Manage the Get requests (GetFolders, GetFoldersAndFiles, CreateFolder).<br> 89 * Manage the <code>GET</code> requests (<code>GetFolders</code>, 90 * <code>GetFoldersAndFiles</code>, <code>CreateFolder</code>).<br/> 88 91 * 89 * The servlet accepts commands sent in the following format:<br> 90 * connector?Command=CommandName&Type=ResourceType&CurrentFolder=FolderPath<br> 91 * <br> 92 * It executes the commands and then return the results to the client in XML format. 93 * 92 * The servlet accepts commands sent in the following format:<br/> 93 * <code>connector?Command=<CommandName>&Type=<ResourceType>&CurrentFolder=<FolderPath></code> 94 * <p> 95 * It executes the commands and then returns the result to the client in XML 96 * format. 97 * </p> 94 98 */ 95 99 public void doGet(HttpServletRequest request, HttpServletResponse response) … … 174 178 175 179 /** 176 * Manage the Post requests (FileUpload).<br>180 * Manage the <code>POST</code> requests (<code>FileUpload</code>).<br /> 177 181 * 178 * The servlet accepts commands sent in the following format:<br> 179 * connector?Command=FileUpload&Type=ResourceType&CurrentFolder=FolderPath<br> 182 * The servlet accepts commands sent in the following format:<br /> 183 * <code>connector?Command=<FileUpload>&Type=<ResourceType>&CurrentFolder=<FolderPath></code> 184 * with the file in the <code>POST</code> body.<br /> 180 185 * <br> 181 * It store the file (renaming it in case a file with the same name exists) and then return an182 * HTML file with a javascript command in it.186 * It stores an uploaded file (renames a file if another exists with the 187 * same name) and then returns the JavaScript callback. 183 188 */ 184 189 @SuppressWarnings("unchecked") … … 202 207 UploadResponse ur; 203 208 204 // if this is a QuickUpload-Request, 'commandStr' and 'currentFolderStr' are empty 209 // if this is a QuickUpload request, 'commandStr' and 'currentFolderStr' 210 // are empty 205 211 if (Utils.isEmpty(commandStr) && Utils.isEmpty(currentFolderStr)) { 206 212 commandStr = "QuickUpload"; -
FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/FCKeditorConfig.java
r1905 r2101 34 34 /** 35 35 * Contains the configuration settings for the FCKEditor.<br> 36 * Adding element to this collection you can override the settings specified in37 * the config.js file.36 * By adding elements to this collection you can override the settings specified 37 * in the config.js file. 38 38 * 39 39 * @version $Id$ … … 52 52 53 53 /** 54 * Generate the url parameter sequence used to pass this configuration to55 * the editor.54 * Generates the url parameter sequence from this configuration which is 55 * passed to the editor. 56 56 * 57 * @return html en docodesequence of configuration parameters57 * @return html encoded sequence of configuration parameters 58 58 */ 59 59 public String getUrlParams() { -
FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/FCKeditor.java
r1682 r2101 30 30 31 31 /** 32 * FCKeditor control class.<br> 33 * 32 * FCKeditor class.<br /> 34 33 * It creates the html code for the FCKeditor based on the following things: 35 34 * <ul> 36 * <li>browser 'scapabilities</li>35 * <li>browser capabilities</li> 37 36 * <li>different properties settings managed by the {@link PropertiesLoader}</li> 38 * <li>settings from the 'caller', eg. jsp-pages</li>37 * <li>settings from the FCKeditor tag, template engines and other systems</li> 39 38 * </ul> 40 39 * … … 57 56 /** 58 57 * Main constructor.<br> 59 * All important settings are done here and will be preset by the re defaults taken from60 * {@link PropertiesLoader}.58 * All important settings are done here and will be preset by the defaults 59 * taken from {@link PropertiesLoader}. 61 60 * 62 61 * @param request … … 116 115 117 116 /** 118 * Set the initial value to be edited.<br> 119 * In HTML code 117 * Set the initial value to be edited as HTML markup. 120 118 * 121 119 * @param value … … 127 125 128 126 /** 129 * Set the dir where the FCKeditor files reside on the server.<br> 130 * <b>Remarks</b>:<br> 131 * Avoid using relative paths. It is preferable to set the base path starting from the root (/).<br> 132 * Always finish the path with a slash (/). 127 * Sets the directory where the FCKeditor resides on the server.<br /> 128 * <strong>Remarks</strong>: Avoid using relative paths. Use an absolute 129 * path from the context (e.g. /fckeditor). 133 130 * 134 131 * @param value … … 170 167 171 168 /** 172 * Get the advanced configuation set.<br >173 * Adding element to this collection you can override the settings specified in the config.js174 * file.169 * Get the advanced configuation set.<br /> 170 * By adding elements to this collection you can override the settings 171 * specified in the config.js file. 175 172 * 176 173 * @return configuration collection … … 190 187 } 191 188 189 /** 190 * Escape base XML entities as specified <a 191 * href="http://en.wikipedia.org/wiki/Xml#Entity_references">here</a> 192 * 193 * @param txt 194 * Text to escape. 195 * @return Escaped text. 196 */ 192 197 private String escapeXml(String txt) { 193 198 if (Utils.isEmpty(txt)) 194 199 return txt; 200 // TODO Strings are inefficent, use StringBuffer instead 195 201 txt = txt.replaceAll("&", "&"); 196 202 txt = txt.replaceAll("<", "<"); … … 201 207 } 202 208 203 /** 204 * Minimum implementation, see ticket #27 for detailed information. 209 /* 210 * (non-Javadoc) 211 * @see #createHtml() 205 212 */ 206 213 public String create() { 207 214 return createHtml(); 208 215 } 209 216 217 /* 218 * (non-Javadoc) 219 * @see #createHtml() 220 */ 210 221 @Override 211 222 public String toString() { … … 214 225 215 226 /** 216 * Generate the HTML Code for the editor. <br> 217 * Evalute the browser capabilities and generate the editor if compatible, or a simple textarea 218 * otherwise. 219 * 220 * @return html code 227 * Minimum implementation, see ticket #27 for detailed information. Generate 228 * the HTML Code for the editor.<br /> 229 * Evaluate the browser capabilities and generate the editor if compatible, 230 * or a simple textarea otherwise. 231 * 232 * @return FCKeditor html code 221 233 */ 222 234 public String createHtml() { -
FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/handlers/CommandHandler.java
r1905 r2101 25 25 26 26 /** 27 * Handler for the get and postcommands.27 * Handler for <code>GET</code> and <code>POST</code> commands. 28 28 * 29 29 * @version $Id$ … … 60 60 * Getter for the name. 61 61 * 62 * @return name62 * @return The command name 63 63 */ 64 64 public String getName() { … … 70 70 * 71 71 * @param name 72 * @return A {@link CommandHandler} object holding the value represented by the string 73 * argument. 72 * A command to retrieve 73 * @return A {@link CommandHandler} object holding the value represented by 74 * the string argument. 74 75 * @throws IllegalArgumentException 75 * If 'name' is null or can't be parsed.76 * If 'name' is <code>null</code> or does not exist. 76 77 */ 77 78 public static CommandHandler valueOf(final String name) throws IllegalArgumentException { … … 86 87 87 88 /** 88 * Checks, if a specfied string is a valid representation of a get command. 89 * Checks if a specfied string represents a valid <code>GET</code> 90 * command. 89 91 * 90 92 * @param name 91 * @return True, if the string representation is valid, or false. 93 * A command string to check 94 * @return <code>true</code> if the string representation is valid else 95 * <code>false</code>. 92 96 */ 93 97 public static boolean isValidForGet(final String name) { … … 96 100 97 101 /** 98 * Checks, if a specfied string is a valid representation of a post command. 102 * Checks if a specfied string represents a valid <code>POST</code> 103 * command. 99 104 * 100 105 * @param name 101 * @return True, if the string representation is valid, or false. 106 * A command string to check 107 * @return <code>true</code> if the string representation is valid else 108 * <code>false</code>. 102 109 */ 103 110 public static boolean isValidForPost(final String name) { … … 107 114 108 115 /** 109 * A wrapper for {@link #valueOf(String)}. It returns null instead of throwing an exception. 116 * A wrapper for {@link #valueOf(String)}. It returns null instead of 117 * throwing an exception. 110 118 * 111 * @param name 112 * @return A {@link CommandHandler} object holding the value represented by the string113 * argument, or null.119 * @param name A command string to check 120 * @return A {@link CommandHandler} object holding the value represented by 121 * the string argument, or <code>null</code>. 114 122 */ 115 123 public static CommandHandler getCommand(final String name) { … … 128 136 @Override 129 137 public boolean equals(Object obj) { 138 if (obj == null) 139 return false; 130 140 try { 131 141 CommandHandler rt = (CommandHandler) obj; -
FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/handlers/ConnectorHandler.java
r1905 r2101 26 26 27 27 /** 28 * Handler for some base properties.<br>29 * It's a kind of wrapper to some basic properties handled bythe {@link PropertiesLoader}.28 * Handler for Connector-related properties.<br /> 29 * Wraps to the {@link PropertiesLoader}. 30 30 * 31 31 * @version $Id$ … … 34 34 35 35 /** 36 * Getter for the base dir (using for user files). 37 * 38 * @return {@link UserPathBuilder#getUserFilesPath(HttpServletRequest)} or the default base dir, if 39 * {@link UserPathBuilder}} isn't set. 40 */ 41 public static String getUserFilesPath(final HttpServletRequest servletRequest) { 42 String userFilePath = RequestCycleHandler.getUserFilePath(servletRequest); 36 * Getter for the <code>UserFilesPath</code>. 37 * 38 * @return {@link UserPathBuilder#getUserFilesPath(HttpServletRequest)} or 39 * the <code>DefaultUserFilePath</code> if {@link UserPathBuilder} 40 * isn't set. 41 */ 42 public static String getUserFilesPath(final HttpServletRequest request) { 43 String userFilePath = RequestCycleHandler.getUserFilePath(request); 43 44 return (userFilePath != null) ? userFilePath : getDefaultUserFilesPath(); 44 45 } 45 46 46 47 /** 47 * Getter for the default handling of single extensions.48 * Getter for the default handling of files with multiple extensions. 48 49 * 49 * @return the forceSingleExtension 50 * @return <code>true</code> if single extension only should be enforced 51 * else <code>false</code>. 50 52 */ 51 53 public static boolean isForceSingleExtension() { … … 54 56 55 57 /** 56 * Getter for the value to instruct the connector to return the full URL of a file/folder in the57 * XML response rather than the absolute URL.58 * Getter for the value to instruct the connector to return the full URL of 59 * a file/folder in the XML response rather than the absolute URL. 58 60 * 59 * @return Boolean value of the property 'connector.fullUrl'. 61 * @return <code>true</code> if the property <code>connector.fullUrl</code> is 62 * set else <code>false</code>. 60 63 */ 61 64 public static boolean isFullUrl() { … … 64 67 65 68 /** 66 * Getter for the default userFilesPath.69 * Getter for the default <code>UserFilesPath</code>. 67 70 * 68 * @return Default userfiles path(/userfiles)71 * @return <code>DefaultUserFilesPath</code> (/userfiles) 69 72 */ 70 73 public static String getDefaultUserFilesPath() { … … 73 76 74 77 /** 75 * Getter for the value to instruct the Connector to check, if the uploaded image is really one. 78 * Getter for the value to instruct the Connector to check if the uploaded 79 * image is really an image. 76 80 * 77 * @return Boolean value of the property 'connector.secureImageUploads'. 81 * @return Boolean value of the property 82 * <code>connector.secureImageUploads</code>. 78 83 */ 79 84 public static boolean isSecureImageUploads() { -
FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/handlers/ExtensionsHandler.java
r1995 r2101 28 28 29 29 /** 30 * Handler which manages the allowed and denied extensions for each resource type. The 31 * extensions are preset by the properties managed by {@link PropertiesLoader}.<br> 32 * <br> 33 * Hint: It's recommend to use either allowed or denied extensions for one file type. 34 * Never use both at the same time! That's why denied extensions of a file type will be 35 * deleted, if you set the allowed one and vice versa. 30 * This handler manages the allowed and denied extensions for each resource 31 * type. The extensions are preset by the properties managed by 32 * {@link PropertiesLoader}. 33 * <p> 34 * <em>Hint</em>: It's recommend to use either allowed or denied extensions for one file 35 * type. <strong>Never</strong> use both at the same time! That's why denied 36 * extensions of a file type will be deleted if you set the allowed one and vice 37 * versa. 38 * </p> 36 39 * 37 40 * @version $Id$ … … 74 77 75 78 /** 76 * Setter for the allowed extensions of a file type. The denied extensions will be cleared.<br> 77 * If 'extensionsList' is null, allowed extensions kept untouched. 79 * Setter for the allowed extensions of a file type. The denied extensions 80 * will be cleared.<br /> 81 * If <code>extensionsList</code> is <code>null</code>, allowed 82 * extensions are kept untouched. 78 83 * 79 84 * @param type 80 * The file type.85 * The file type. 81 86 * @param extensionsList 82 * Required format: <code>ext1|ext2|ext3</code>87 * Required format: <code>ext1|ext2|ext3</code> 83 88 */ 84 89 public static void setExtensionsAllowed(final ResourceTypeHandler type, final String extensionsList) { … … 93 98 * 94 99 * @param type 95 * The file type.100 * The file type. 96 101 * @return Set of denied extensions or an empty set. 97 102 */ … … 101 106 102 107 /** 103 * Setter for the denied extensions of a file type. The allowed extensions will be cleared.<br> 104 * If 'extensionsList' is null, denied extensions kept untouched. 108 * Setter for the denied extensions of a file type. The allowed extensions 109 * will be cleared.<br /> 110 * If <code>extensionsList</code> is <code>null</code>, denied 111 * extensions are kept untouched. 105 112 * 106 113 * @param type 107 * The file type.114 * The file type. 108 115 * @param extensionsList 109 * Required format: <code>ext1|ext2|ext3</code>116 * Required format: <code>ext1|ext2|ext3</code> 110 117 */ 111 118 public static void setExtensionsDenied(final ResourceTypeHandler type, final String extensionsList) { … … 117 124 118 125 /** 119 * Checks ,if an extension is allowed for a file type.126 * Checks if an extension is allowed for a file type. 120 127 * 121 128 * @param type 129 * The resource type you want to check. 122 130 * @param extension 123 * @return True, false. False is returned too, if 'type' or 'extensions' is null. 131 * The extension you want to check. 132 * @return <code>true</code> is extension is allowed else 133 * <code>false</code>. <em>Attention</em>: <code>false</code> 134 * is always returned if 'type' or 'extensions' is <code>null</code>. 124 135 */ 125 136 public static boolean isAllowed(final ResourceTypeHandler type, final String extension) { -
FCKeditor.Java/trunk/java-core/src/main/java/net/fckeditor/handlers/PropertiesLoader.java
r1685 r2101 26 26 import java.util.Properties; 27 27 28 import net.fckeditor.tool.Utils;29 30 28 import org.slf4j.Logger; 31 29 import org.slf4j.LoggerFactory; 32 30 33 31 /** 34 * Handler to hold the basic properties.<br> 35 * The main default file is 'default.properties' in the deepth of the classpath and should be 36 * untouched. If there is a file named 'fckeditor.properties' in the root of the classpath, it will 37 * be loaded. Values which are loaded before, will be overwritten.<br> 38 * If you won't use an extra properties file to adjust the defaults, you can use 39 * {@link #setProperty(String, String)} instead. 32 * This handler gives you access to properties stored in 33 * <code>/net/fckeditor/handlers/default.properties</code> and 34 * <code>/fckeditor.properties</code>.<br /> 35 * This class loads the properties files as follows: 36 * <ol> 37 * <li>Load <code>default.properties</code></li> 38 * <li>Load <code>fckeditor.properties</code> if present.</li> 39 * </ol> 40 * <em>Attention</em>: Properties specified in 41 * <code>fckeditor.properties</code> will override properties loaded from 42 * <code>default.properties</code>. (intended behavior)<br /> 43 * <em>Hint</em>: You may set properties programmatically with 44 * {@link #setProperty(String, String)} instead or additionally. 40 45 * 41 46 * @version $Id$ … … 47 52 static { 48 53 try { 49 // 1. load systemdefaults54 // 1. load library defaults 50 55 properties.load(new BufferedInputStream(PropertiesLoader.class 51 56 .getResourceAsStream("default.properties"))); … … 54 59 InputStream in = PropertiesLoader.class.getResourceAsStream("/fckeditor.properties"); 55 60 if (in == null)