Changeset 1699
- Timestamp:
- 2008-03-15 17:23:28 (8 months ago)
- Location:
- FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor
- Files:
-
- 3 modified
-
connector/ConnectorServlet.java (modified) (5 diffs)
-
response/XmlResponse.java (modified) (3 diffs)
-
tool/Utils.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/connector/ConnectorServlet.java
r1697 r1699 129 129 .getDefaultResourceType(typeStr); 130 130 131 String typePath = constructResourceTypeUrl(resourceType, request); 131 String typePath = Utils.constructResponseUrl(request, resourceType, 132 currentFolderStr, false, false); 132 133 String typeDirPath = getServletContext().getRealPath(typePath); 133 String currentPath = typePath + currentFolderStr;134 134 135 135 File typeDir = new File(typeDirPath); … … 143 143 144 144 xr = new XmlResponse(command, resourceType, currentFolderStr, 145 currentPath, request); 145 Utils.constructResponseUrl(request, resourceType, 146 currentFolderStr, true, 147 ConnectorHandler.isFullUrl())); 146 148 147 149 if (command.equals(CommandHandler.GET_FOLDERS)) … … 228 230 ResourceTypeHandler resourceType = ResourceTypeHandler.getDefaultResourceType(typeStr); 229 231 230 String typePath = constructResourceTypeUrl(resourceType, request); 232 String typePath = Utils.constructResponseUrl(request, resourceType, 233 currentFolderStr, false, false); 231 234 String typeDirPath = getServletContext().getRealPath(typePath); 232 String currentPath = typePath + currentFolderStr;233 235 234 236 File typeDir = new File(typeDirPath); … … 273 275 if (Utils.isEmpty(newFilename)) 274 276 ur = new UploadResponse(UploadResponse.EN_OK, Utils 275 .constructServerAddress(request, 276 currentPath).concat(filename)); 277 .constructResponseUrl(request, 278 resourceType, currentFolderStr, 279 true, ConnectorHandler.isFullUrl()) 280 .concat(filename)); 277 281 else 278 282 ur = new UploadResponse(UploadResponse.EN_RENAMED, 279 Utils.constructServerAddress(request, 280 currentPath).concat(newFilename), 281 newFilename); 283 Utils.constructResponseUrl(request, 284 resourceType, currentFolderStr, 285 true, ConnectorHandler.isFullUrl()) 286 .concat(newFilename), newFilename); 282 287 283 288 // secure image check … … 309 314 } 310 315 311 private String constructResponseUrl(final ResourceTypeHandler fileType,312 final String currentFolderString, final HttpServletRequest request) {313 StringBuffer sb = new StringBuffer();314 sb.append(ConnectorHandler.getUserFilesPath(request));315 sb.append(fileType.getPath());316 if (Utils.isNotEmpty(currentFolderString))317 sb.append(currentFolderString);318 return Utils.replaceAll(sb.toString(), "//", "/");319 }320 321 /**322 * TODO document me!323 * @param resourceType324 * @param request325 * @return326 */327 private String constructResourceTypeUrl(final ResourceTypeHandler resourceType,328 final HttpServletRequest request) {329 return constructResponseUrl(resourceType, null, request);330 }331 332 316 } -
FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/response/XmlResponse.java
r1690 r1699 25 25 import java.io.StringWriter; 26 26 27 import javax.servlet.http.HttpServletRequest;28 27 import javax.xml.parsers.DocumentBuilder; 29 28 import javax.xml.parsers.DocumentBuilderFactory; … … 78 77 79 78 /** 79 * 80 80 * @param command 81 * file browser 81 * @param resourceType 82 * @param currentFolder 82 83 * @param constructedUrl 83 * TODO84 84 */ 85 public XmlResponse(CommandHandler command, ResourceTypeHandler type, String currentFolder,86 String c onstructedUrl, HttpServletRequest request) {85 public XmlResponse(CommandHandler command, ResourceTypeHandler resourceType, 86 String currentFolder, String constructedUrl) { 87 87 88 88 try { … … 98 98 document.appendChild(root); 99 99 root.setAttribute("command", command.toString()); 100 root.setAttribute("resourceType", type.toString());100 root.setAttribute("resourceType", resourceType.toString()); 101 101 102 102 Element currentFolderElement = document.createElement("CurrentFolder"); 103 103 currentFolderElement.setAttribute("path", currentFolder); 104 104 105 currentFolderElement.setAttribute("url", Utils.constructServerAddress( 106 request, constructedUrl)); 105 currentFolderElement.setAttribute("url", constructedUrl); 107 106 root.appendChild(currentFolderElement); 108 107 -
FCKeditor.Java/branches/2.4/src/main/java/net/fckeditor/tool/Utils.java
r1644 r1699 28 28 29 29 import net.fckeditor.handlers.ConnectorHandler; 30 import net.fckeditor.handlers.ResourceTypeHandler; 30 31 31 32 … … 146 147 else 147 148 return request.getContextPath() + url; 148 } 149 } 150 151 /** 152 * 153 * @param request 154 * @param resourceType 155 * @param urlPath TODO 156 * @param prependContextPath 157 * @param fullUrl 158 * @return 159 */ 160 public static String constructResponseUrl(HttpServletRequest request, 161 ResourceTypeHandler resourceType, String urlPath, 162 boolean prependContextPath, boolean fullUrl) { 163 164 StringBuffer sb = new StringBuffer(); 165 166 if (fullUrl) { 167 String address = request.getRequestURL().toString(); 168 sb.append(address.substring(0, address.indexOf('/', 8)) 169 + request.getContextPath()); 170 } 171 172 if (prependContextPath && !fullUrl) 173 sb.append(request.getContextPath()); 174 175 sb.append(ConnectorHandler.getUserFilesPath(request)); 176 sb.append(resourceType.getPath()); 177 178 if (isNotEmpty(urlPath)) 179 sb.append(urlPath); 180 181 return sb.toString(); 182 } 183 184 public static String constructResponseUrl(HttpServletRequest request, 185 ResourceTypeHandler resourceType, boolean prependContextPath, 186 boolean fullUrl) { 187 return constructResponseUrl(request, resourceType, null, 188 prependContextPath, fullUrl); 189 } 149 190 }