cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/portal/samples sitemap.xmap
Date Fri, 12 Dec 2003 14:42:35 GMT
cziegeler    2003/12/12 06:42:35

  Modified:    src/blocks/portal/java/org/apache/cocoon/portal/transformation
                        CopletTransformer.java
               src/blocks/portal/samples sitemap.xmap
  Log:
  Adding new feature to create a link containing several events
  Start adding auto login
  
  Revision  Changes    Path
  1.12      +74 -5     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
  
  Index: CopletTransformer.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- CopletTransformer.java	11 Dec 2003 15:36:04 -0000	1.11
  +++ CopletTransformer.java	12 Dec 2003 14:42:34 -0000	1.12
  @@ -51,6 +51,8 @@
   package org.apache.cocoon.portal.transformation;
   
   import java.io.IOException;
  +import java.util.ArrayList;
  +import java.util.List;
   
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.cocoon.ProcessingException;
  @@ -111,6 +113,21 @@
        */
       public static final String LINK_ELEM = "link";
   
  +    /** Create a link containing several events */
  +    public static final String LINKS_ELEM = "links";
  +    
  +    /** The content for the links element */
  +    public static final String CONTENT_ELEM = "content";
  +
  +    /** Are we inside a links element? */
  +    protected boolean insideLinks;
  +    
  +    /** The collected list of events */
  +    protected List collectedEvents = new ArrayList();
  +    
  +    /** The content of the links */
  +    protected String content;
  +    
       /**
        * Creates new CopletTransformer.
        */
  @@ -118,6 +135,17 @@
           this.defaultNamespaceURI = NAMESPACE_URI;
       }
       
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.transformation.AbstractSAXTransformer#setupTransforming()
  +     */
  +    public void setupTransforming()
  +    throws IOException, ProcessingException, SAXException {
  +        super.setupTransforming();
  +        this.insideLinks = false;
  +        this.content = null;
  +        this.collectedEvents.clear();
  +    }
  +
       /**
        * Overridden from superclass.
        */
  @@ -180,15 +208,27 @@
                           final CopletInstanceData cid = this.getCopletInstanceData(copletId);
                           event = new CopletJXPathEvent(cid, path, value);
                       }
  -                    final String href = linkService.getLinkURI(event);
  -                    this.output(href, format, newAttrs );
  +                    if ( this.insideLinks ) {
  +                        this.collectedEvents.add(event);
  +                    } else {
  +                        final String href = linkService.getLinkURI(event);
  +                        this.output(href, format, newAttrs );
  +                    }
                   }
               } catch (ServiceException e) {
                   throw new SAXException("Error getting portal service.", e);
               } finally {
                   this.manager.release( portalService );
               }
  -            
  +        } else if (name.equals(LINKS_ELEM) ) {
  +            this.insideLinks = true;
  +            String format = attr.getValue("format");
  +            if ( format == null ) {
  +                format = "html-link";
  +            }
  +            this.stack.push(format);
  +        } else if ( name.equals(CONTENT_ELEM) && this.insideLinks ) {
  +            this.startTextRecording();
           } else {
               super.startTransformingElement(uri, name, raw, attr);
           }
  @@ -199,11 +239,38 @@
        */
       public void endTransformingElement(String uri, String name, String raw) 
       throws ProcessingException, IOException, SAXException {
  -        if ( name.equals(LINK_ELEM) ) {
  +        if ( name.equals(LINK_ELEM) || name.equals(LINKS_ELEM)) {
  +            String elem = (String)this.stack.pop();
  +            if ( elem.length() > 0 ) {
  +                this.sendEndElementEvent(elem);
  +            }
  +        } else if ( name.equals(LINKS_ELEM) ) {
  +            this.insideLinks = false;
  +            final String format = (String)this.stack.pop();
  +            PortalService portalService = null;
  +            try {
  +                portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
  +                final LinkService linkService = portalService.getComponentManager().getLinkService();
  +                
  +                final String href = linkService.getLinkURI(this.collectedEvents);
  +                final AttributesImpl newAttrs = new AttributesImpl();
  +                this.output(href, format, newAttrs );
  +            } catch (ServiceException e) {
  +                throw new SAXException("Error getting portal service.", e);
  +            } finally {
  +                this.manager.release( portalService );
  +            }
  +            this.collectedEvents.clear();
  +            if ( this.content != null ) {
  +                this.sendTextEvent(this.content);
  +                this.content = null;
  +            }
               String elem = (String)this.stack.pop();
               if ( elem.length() > 0 ) {
                   this.sendEndElementEvent(elem);
               }
  +        } else if ( name.equals(CONTENT_ELEM) && this.insideLinks ) {
  +            this.content = this.endTextRecording();
           } else if (!name.equals(COPLET_ELEM)) {
               super.endTransformingElement(uri, name, raw);
           }  
  @@ -230,9 +297,11 @@
               this.stack.push("form");
           } else if ( "text".equals(format) ) {
               this.sendTextEvent(uri);
  +            this.stack.push("");
           } else if ( "parameters".equals(format) ) {
               final String value = uri.substring(uri.indexOf('?')+1);
               this.sendTextEvent(value);
  +            this.stack.push("");
           } else {
               // own format
               newAttrs.addCDATAAttribute("href", uri);
  
  
  
  1.18      +30 -11    cocoon-2.1/src/blocks/portal/samples/sitemap.xmap
  
  Index: sitemap.xmap
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/sitemap.xmap,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- sitemap.xmap	11 Dec 2003 16:05:01 -0000	1.17
  +++ sitemap.xmap	12 Dec 2003 14:42:35 -0000	1.18
  @@ -1,7 +1,6 @@
   <?xml version="1.0"?>
   
   <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  -<!-- =========================== Components ================================ -->
   
    <map:components>
     <map:generators default="file">
  @@ -118,20 +117,39 @@
       
   	<!-- Cascading Stylesheets -->
   	<map:match pattern="css/*.css">
  -    	<map:read mime-type="text/css" src="{global:skin}css/{1}.css"/>
  +         <map:read mime-type="text/css" src="{global:skin}css/{1}.css"/>
      	</map:match>
   
       <map:match pattern="">
  -       <map:redirect-to uri="portal"/>
  +         <map:redirect-to uri="portal"/>
       </map:match>
   
  -   <map:match pattern="news/**">
  -      <map:mount check-reload="yes" src="news/" uri-prefix="news"/>
  +    <map:match pattern="news/**">
  +        <map:mount check-reload="yes" src="news/" uri-prefix="news"/>
       </map:match>
  +
      <map:match pattern="coplets/**">
         <map:mount check-reload="yes" src="coplets/" uri-prefix="coplets"/>
       </map:match>
   
  +    <!-- Do an auto login as guest -->
  +    <!--
  +    <map:act type="auth-loggedIn">
  +        <map:parameter name="handler" value="portalhandler"/> 
  +        <map:parameter name="application" value="portal"/> 
  +        <map:parameter name="negate-result" value="true"/>
  +
  +        <map:act type="auth-login">
  +            <map:parameter name="handler" value="portalhandler"/>
  +            <map:parameter name="application" value="portal"/> 
  +    
  +            <map:parameter name="parameter_name" value="guest"/>
  +            <map:parameter name="parameter_password" value="guest"/>
  +         
  +        </map:act>
  +    </map:act>
  +    -->
  +
       <!-- Test pipeline for layout engine -->
       <map:match pattern="portal">
           <map:act type="auth-protect">
  @@ -201,15 +219,16 @@
   
       <map:match pattern="auth">
           <map:act type="auth-loggedIn">
  -          <map:parameter name="handler" value="portalhandler"/> 
  -          <map:redirect-to uri="loggedin"/>
  +            <map:parameter name="handler" value="portalhandler"/> 
  +            <map:redirect-to uri="loggedin"/>
           </map:act>
           <map:act type="auth-login">
  -          <map:parameter name="handler" value="portalhandler"/>
  -          <map:parameter name="parameter_name" value="{request-param:name}"/>
  -          <map:parameter name="parameter_password" value="{request-param:password}"/>
  +            <map:parameter name="handler" value="portalhandler"/>
  +            <map:parameter name="application" value="portal"/> 
  +            <map:parameter name="parameter_name" value="{request-param:name}"/>
  +            <map:parameter name="parameter_password" value="{request-param:password}"/>
   
  -          <map:redirect-to uri="{request-param:resource}"/>
  +            <map:redirect-to uri="{request-param:resource}"/>
   
           </map:act>
           <map:generate src="resources/login-error.xml"/>
  
  
  

Mime
View raw message