cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: rev 55597 - in cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal: components/modules/input coplet/adapter/impl transformation
Date Tue, 26 Oct 2004 10:15:35 GMT
Author: cziegeler
Date: Tue Oct 26 03:15:33 2004
New Revision: 55597

Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/components/modules/input/CopletModule.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/components/modules/input/LayoutModule.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/URICopletAdapter.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
Log:
Add alternate href to coplet transformer

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/components/modules/input/CopletModule.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/components/modules/input/CopletModule.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/components/modules/input/CopletModule.java
Tue Oct 26 03:15:33 2004
@@ -61,7 +61,7 @@
  * 
  * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
  * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: CopletModule.java,v 1.11 2004/03/05 13:02:10 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public class CopletModule 
 implements InputModule, Serviceable, ThreadSafe {
@@ -120,7 +120,7 @@
             return value.toString();
             
         } catch (ServiceException e) {
-            throw new ConfigurationException("ComponentException ", e);
+            throw new ConfigurationException("ServiceException ", e);
         } finally {
             this.manager.release(portalService);
         }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/components/modules/input/LayoutModule.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/components/modules/input/LayoutModule.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/components/modules/input/LayoutModule.java
Tue Oct 26 03:15:33 2004
@@ -37,7 +37,7 @@
  * The syntax to use is LAYOUT_ID/PATH or LAYOUT_KEY:LAYOUT_ID/PATH
  *
  * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
- * @version CVS $Id: LayoutModule.java,v 1.2 2004/03/05 13:02:10 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public class LayoutModule 
 implements InputModule, Serviceable, ThreadSafe {
@@ -98,7 +98,7 @@
             return value;
             
         } catch (ServiceException e) {
-            throw new ConfigurationException("ComponentException ", e);
+            throw new ConfigurationException("ServiceException ", e);
         } finally {
             this.manager.release(portalService);
         }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/URICopletAdapter.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/URICopletAdapter.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/URICopletAdapter.java
Tue Oct 26 03:15:33 2004
@@ -53,7 +53,7 @@
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
  * 
- * @version CVS $Id: URICopletAdapter.java,v 1.14 2004/03/05 13:02:10 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public class URICopletAdapter 
     extends AbstractCopletAdapter
@@ -132,7 +132,7 @@
 		} catch (ProcessingException pe) {
 			throw new SAXException("ProcessingException", pe);
 		} catch (ServiceException ce) {
-			throw new SAXException("ComponentException", ce);
+			throw new SAXException("ServiceException", ce);
 		} finally {
 			this.resolver.release(copletSource);
 			this.manager.release(portalService);

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
Tue Oct 26 03:15:33 2004
@@ -82,6 +82,9 @@
     /** Create a link containing several events */
     public static final String LINKS_ELEM = "links";
     
+    /** Create a link containing several events */
+    public static final String PARAMETER_ELEM = "parameter";
+
     /** The content for the links element */
     public static final String CONTENT_ELEM = "content";
 
@@ -184,8 +187,24 @@
                     this.output(href, format, newAttrs );
                 }
             }
+        } else if (name.equals(PARAMETER_ELEM)) {
+            if (this.insideLinks) {
+                String href = attr.getValue("href");
+                if ( href != null ) {
+                    final int pos = href.indexOf('?');
+                    if ( pos != -1 ) {
+                        href = href.substring(pos+1);
+                    }
+                    this.collectedEvents.add(new LinkService.ParameterDescription(href));
+                }
+            }
         } else if (name.equals(LINKS_ELEM) ) {
             this.insideLinks = true;
+            final AttributesImpl newAttrs = new AttributesImpl();
+            newAttrs.setAttributes(attr);
+            newAttrs.removeAttribute("format");
+            this.stack.push(newAttrs);
+            
             String format = attr.getValue("format");
             if ( format == null ) {
                 format = "html-link";
@@ -214,9 +233,23 @@
             this.insideLinks = false;
             final String format = (String)this.stack.pop();
             final LinkService linkService = this.getPortalService().getComponentManager().getLinkService();
+            String href = linkService.getLinkURI(this.collectedEvents);
             
-            final String href = linkService.getLinkURI(this.collectedEvents);
-            final AttributesImpl newAttrs = new AttributesImpl();
+            AttributesImpl newAttrs = (AttributesImpl)this.stack.pop();
+            // test for alternate base url
+            final String baseURL = newAttrs.getValue("base-url");
+            if ( baseURL != null ) {
+                newAttrs.removeAttribute("base-url");
+                int pos = href.indexOf('?') + 1;
+                final char separator;
+                if ( baseURL.indexOf('?') == -1 ) {
+                    separator = '?';
+                } else {
+                    separator = '&';
+                }
+                href = baseURL + separator + href.substring(pos);
+                
+            }
             this.output(href, format, newAttrs );
 
             this.collectedEvents.clear();
@@ -230,7 +263,7 @@
             }
         } else if ( name.equals(CONTENT_ELEM) && this.insideLinks ) {
             this.content = this.endSAXRecording();
-        } else if (!name.equals(COPLET_ELEM)) {
+        } else if (!name.equals(COPLET_ELEM) && !name.equals(PARAMETER_ELEM)) {
             super.endTransformingElement(uri, name, raw);
         }  
     }

Mime
View raw message