Coverage Report - net.fckeditor.tool.UtilsResponse
 
Classes in this File Line Coverage Branch Coverage Complexity
UtilsResponse
0%
0/13
0%
0/8
2.5
 
 1  
 /*
 2  
  * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 3  
  * Copyright (C) 2003-2008 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 javax.servlet.http.HttpServletRequest;
 24  
 
 25  
 import net.fckeditor.handlers.ConnectorHandler;
 26  
 import net.fckeditor.handlers.ResourceTypeHandler;
 27  
 
 28  
 /**
 29  
  * Some static helper methods in conjunction with the servlet response.
 30  
  *
 31  
  * @version $Id: UtilsResponse.java 1881 2008-04-02 15:48:23Z mosipov $
 32  
  */
 33  0
 public class UtilsResponse {
 34  
 
 35  
         /**
 36  
          * TODO - document me!
 37  
      * 
 38  
      * @param request
 39  
      * @param resourceType
 40  
      * @param urlPath TODO
 41  
      * @param prependContextPath
 42  
      * @param fullUrl
 43  
      * @return constructed url
 44  
      */
 45  
     public static String constructResponseUrl(HttpServletRequest request,
 46  
                     ResourceTypeHandler resourceType, String urlPath,
 47  
                     boolean prependContextPath, boolean fullUrl) {
 48  
                     
 49  0
             StringBuffer sb = new StringBuffer();
 50  
             
 51  0
             if (fullUrl) {
 52  0
                     String address = request.getRequestURL().toString();
 53  0
                     sb.append(address.substring(0, address.indexOf('/', 8))
 54  
                                     + request.getContextPath());
 55  
             }
 56  
             
 57  0
             if (prependContextPath && !fullUrl)
 58  0
                     sb.append(request.getContextPath());
 59  
             
 60  0
             sb.append(ConnectorHandler.getUserFilesPath(request));
 61  0
             sb.append(resourceType.getPath());
 62  
             
 63  0
             if (Utils.isNotEmpty(urlPath))
 64  0
                     sb.append(urlPath);
 65  
             
 66  0
             return sb.toString();
 67  
     }
 68  
 
 69  
         /**
 70  
          * TODO - document me!
 71  
          * 
 72  
          * @param request
 73  
          * @param resourceType
 74  
          * @param prependContextPath
 75  
          * @param fullUrl
 76  
          * @return constructed url
 77  
          */
 78  
         public static String constructResponseUrl(HttpServletRequest request,
 79  
                     ResourceTypeHandler resourceType, boolean prependContextPath, 
 80  
                     boolean fullUrl) {
 81  0
             return constructResponseUrl(request, resourceType, null, 
 82  
                             prependContextPath, fullUrl);
 83  
     }
 84  
 
 85  
 }