henning     2003/03/19 01:20:12

  Modified:    src/java/org/apache/turbine/util DynamicURI.java
                        RelativeDynamicURI.java
  Log:
  - Clean up a few more hardcoded values and constants in the DynamicURI class.
  
  - Pull the changes from rev 1.4 (reference support) and post-1.8 into
    RelativeDynamicURI. add an assertInitialized() to the toString() method
    to work like the DynamicURI
  
  Revision  Changes    Path
  1.16      +13 -13    
jakarta-turbine-2/src/java/org/apache/turbine/util/DynamicURI.java
  
  Index: DynamicURI.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/DynamicURI.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DynamicURI.java   19 Mar 2003 05:09:36 -0000      1.15
  +++ DynamicURI.java   19 Mar 2003 09:20:12 -0000      1.16
  @@ -383,9 +383,9 @@
           for( Iterator iter = pp.keySet().iterator(); iter.hasNext(); )
           {
               String key = (String) iter.next();
  -            if (!key.equalsIgnoreCase("action") &&
  -                    !key.equalsIgnoreCase("screen") &&
  -                    !key.equalsIgnoreCase("template"))
  +            if (!key.equalsIgnoreCase(URIConstants.CGI_ACTION_PARAM) &&
  +                    !key.equalsIgnoreCase(URIConstants.CGI_SCREEN_PARAM) &&
  +                    !key.equalsIgnoreCase(URIConstants.CGI_TEMPLATE_PARAM))
               {
                   String[] values = pp.getStrings(key);
                   for (int i = 0; i < values.length; i++)
  @@ -625,7 +625,7 @@
       public int getServerPort()
       {
           int result = getServerData().getServerPort();
  -        return (result==0 ? 80 : result);
  +        return (result==0 ? URIConstants.HTTP_PORT : result);
       }
   
       /**
  @@ -823,7 +823,7 @@
        */
       public DynamicURI setAction(String action)
       {
  -        add(PATH_INFO, "action", action);
  +        add(PATH_INFO, URIConstants.CGI_ACTION_PARAM, action);
           return this;
       }
   
  @@ -854,7 +854,7 @@
        */
       public DynamicURI setScreen(String screen)
       {
  -        add(PATH_INFO, "screen", screen);
  +        add(PATH_INFO, URIConstants.CGI_SCREEN_PARAM, screen);
           return this;
       }
   
  @@ -985,12 +985,12 @@
           assertInitialized();
           StringBuffer output = new StringBuffer();
           output.append(getServerScheme());
  -        output.append("://");
  +        output.append(URIConstants.URI_SCHEME_SEPARATOR);
           output.append(getServerName());
           if ((getServerScheme().equals(URIConstants.HTTP)
  -                    && getServerPort() != 80)
  +                    && getServerPort() != URIConstants.HTTP_PORT)
                   || (getServerScheme().equals(URIConstants.HTTPS)
  -                    && getServerPort() != 443)
  +                    && getServerPort() != URIConstants.HTTPS_PORT)
           )
           {
               output.append(":");
  @@ -1046,13 +1046,13 @@
           HttpServletRequest request = data.getRequest();
   
           output.append(data.getServerScheme());
  -        output.append("://");
  +        output.append(URIConstants.URI_SCHEME_SEPARATOR);
           output.append(data.getServerName());
   
           if ((data.getServerScheme().equals(HTTP) &&
  -                data.getServerPort() != 80) ||
  +                data.getServerPort() != URIConstants.HTTP_PORT) ||
                   (data.getServerScheme().equals(HTTPS) &&
  -                data.getServerPort() != 443))
  +                data.getServerPort() != URIConstants.HTTPS_PORT))
           {
               output.append(":");
               output.append(data.getServerPort());
  
  
  
  1.5       +10 -2     
jakarta-turbine-2/src/java/org/apache/turbine/util/RelativeDynamicURI.java
  
  Index: RelativeDynamicURI.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/RelativeDynamicURI.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RelativeDynamicURI.java   9 Mar 2003 02:54:11 -0000       1.4
  +++ RelativeDynamicURI.java   19 Mar 2003 09:20:12 -0000      1.5
  @@ -257,7 +257,9 @@
        */
       public String toString()
       {
  +        assertInitialized();
           StringBuffer output = new StringBuffer();
  +        output.append(getContextPath());
           output.append(getScriptName());
           if (this.hasPathInfo)
           {
  @@ -269,6 +271,11 @@
               output.append("?");
               output.append(renderQueryString(this.queryData));
           }
  +        if (this.reference != null)
  +        {
  +            output.append("#");
  +            output.append(this.getReference());
  +        }
   
           // There seems to be a bug in Apache JServ 1.0 where the
           // session id is not appended to the end of the url when a
  @@ -277,11 +284,11 @@
           {
               if (this.redirect)
               {
  -                return res.encodeRedirectUrl(output.toString());
  +                return res.encodeRedirectURL(output.toString());
               }
               else
               {
  -                return res.encodeUrl(output.toString());
  +                return res.encodeURL(output.toString());
               }
           }
           else
  @@ -305,6 +312,7 @@
           StringBuffer output = new StringBuffer();
           HttpServletRequest request = data.getRequest();
   
  +        output.append(data.getServerData().getContextPath());
           output.append(data.getServerData().getScriptName());
   
           if (request.getPathInfo() != null)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to