1 /* 2 * FCKeditor - The text editor for Internet - http://www.fckeditor.net 3 * Copyright (C) 2004-2009 Frederico Caldeira Knabben 4 * 5 * == BEGIN LICENSE == 6 * 7 * Licensed under the terms of any of the following licenses at your 8 * choice: 9 * 10 * - GNU General Public License Version 2 or later (the "GPL") 11 * http://www.gnu.org/licenses/gpl.html 12 * 13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") 14 * http://www.gnu.org/licenses/lgpl.html 15 * 16 * - Mozilla Public License Version 1.1 or later (the "MPL") 17 * http://www.mozilla.org/MPL/MPL-1.1.html 18 * 19 * == END LICENSE == 20 */ 21 package net.fckeditor.tool; 22 23 import net.fckeditor.handlers.ResourceType; 24 25 /** 26 * Static helper methods for the servlet response. 27 * 28 * @version $Id: UtilsResponse.java 3695 2009-06-18 20:18:38Z mosipov $ 29 */ 30 public class UtilsResponse { 31 32 /** 33 * Assembles a URL with omitted filename. 34 * 35 * @see #fileUrl(String, ResourceType, String, String) 36 */ 37 public static String getUrl(String userFilesPath, ResourceType type, 38 String currentFolder) { 39 return fileUrl(userFilesPath, type, currentFolder, null); 40 } 41 42 /** 43 * 44 * Assembles a file URL for the File Browser. Simply appends parameters to a 45 * string buffer with reasonable parameter checking. 46 * 47 * @param userFilesPath 48 * the current userfiles path (may be null) 49 * @param type 50 * the current resource type 51 * @param currentFolder 52 * the selected current folder 53 * @param filename 54 * the current chosen file (may be null) 55 * @return assembled url for the File Browser 56 */ 57 public static String fileUrl(String userFilesPath, ResourceType type, 58 String currentFolder, String filename) { 59 60 StringBuffer sb = new StringBuffer(); 61 if (Utils.isNotEmpty(userFilesPath)) 62 sb.append(userFilesPath); 63 sb.append(type.getPath()); 64 sb.append(currentFolder); 65 if (Utils.isNotEmpty(filename)) 66 sb.append(filename); 67 68 return sb.toString(); 69 } 70 71 }