rogerrut    2004/12/01 23:14:01

  Modified:    components/jetspeed/src/java/org/apache/jetspeed/rewriter
                        WebContentRewriter.java
  Log:
  WebContentPortlet: Added state and Portlet action handling
  
  Revision  Changes    Path
  1.3       +60 -8     
jakarta-jetspeed-2/components/jetspeed/src/java/org/apache/jetspeed/rewriter/WebContentRewriter.java
  
  Index: WebContentRewriter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-jetspeed-2/components/jetspeed/src/java/org/apache/jetspeed/rewriter/WebContentRewriter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebContentRewriter.java   2 Dec 2004 03:13:53 -0000       1.2
  +++ WebContentRewriter.java   2 Dec 2004 07:14:01 -0000       1.3
  @@ -14,6 +14,8 @@
   */
   package org.apache.jetspeed.rewriter;
   
  +import java.net.URL;
  +
   import javax.portlet.PortletURL;
   
   /**
  @@ -32,6 +34,11 @@
        */
       private PortletURL actionURL = null;
       
  +    /*
  +     * Base URL
  +     */
  +    private String baseURL = null;
  +    
       /**
        * Setters/getters for members
        */
  @@ -45,6 +52,16 @@
           return this.actionURL;
       }
       
  +    public void setBaseURL(String url)
  +    {
  +        this.baseURL = url;
  +    }
  +    
  +    public String getBaseURL()
  +    {
  +        return this.baseURL;
  +    }
  +    
        /** rewriteURL
         * @param url
         * @param tag
  @@ -59,14 +76,49 @@
             * TODO: no default. Use default Jetspeed JIRA to make sure that 
the method was called
             */
            String modifiedURL = 
"http://nagoya.apache.org/jira/secure/BrowseProject.jspa?id=10492";;
  -         if ( this.actionURL != null)
  -         {
  -             // create Action URL
  -                     actionURL.setParameter(this.ACTION_PARAMETER_URL, url);
  -                     
  -                     modifiedURL = actionURL.toString();
  +         
  +         //  Check if it's a relative or full URL
  +        if ( url.startsWith("/") || url.indexOf("http") == -1)
  +        {
  +            try
  +            {
  +                 if (baseURL != null)
  +                 {
  +                     URL full = new URL(new URL(baseURL), url);
  +                     modifiedURL = full.toString();
  +                 }
  +                 else
  +                 {
  +                     modifiedURL = url; // leave as is
  +                 }
  +            }
  +            catch(Exception e)
  +            {
  +                modifiedURL = url;
  +            }
  +        }
  +        else
  +        {
  +            // Apply action URL's not to images
  +            if (url.indexOf(".gif") == -1 && url.indexOf(".jpg") == -1)
  +            {
  +                         if ( this.actionURL != null)
  +                         {
  +                             // create Action URL
  +                                     
actionURL.setParameter(ACTION_PARAMETER_URL, url);
  +                                     
  +                                     modifiedURL = actionURL.toString();
  +                     }
  +                     else
  +                     {
  +                         modifiedURL = url;
  +                     }
  +            }
  +            else
  +            {
  +                modifiedURL = url;
  +            }
            }
  -             
                return modifiedURL;
        }
   
  
  
  

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

Reply via email to