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/java/org/apache/cocoon/portal/layout/renderer/aspect/impl ParameterAspect.java
Date Tue, 29 Jul 2003 06:30:07 GMT
cziegeler    2003/07/28 23:30:07

  Modified:    src/blocks/portal/conf portal.samplesxconf portal.xconf
               src/blocks/portal/samples/profiles/mapping layout.xml
               src/blocks/portal/java/org/apache/cocoon/portal/profile/impl
                        AbstractProfileManager.java
                        StaticProfileManager.java MapProfileLS.java
  Added:       src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl
                        ParameterAspect.java
  Log:
  Bug fixes and improvements from Volker
  
  Revision  Changes    Path
  1.2       +32 -0     cocoon-2.1/src/blocks/portal/conf/portal.samplesxconf
  
  Index: portal.samplesxconf
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/portal.samplesxconf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- portal.samplesxconf	18 Jul 2003 14:41:44 -0000	1.1
  +++ portal.samplesxconf	29 Jul 2003 06:30:06 -0000	1.2
  @@ -65,6 +65,19 @@
            </aspects>
        </renderer>
        <renderer name="link" class="org.apache.cocoon.portal.layout.renderer.impl.DefaultLinkRenderer"
logger="portal"/>
  +     <renderer name="decorated-frame" class="org.apache.cocoon.portal.layout.renderer.impl.AspectRenderer"
logger="portal">
  +         <aspects>
  +            <aspect type="xslt">
  +                <parameter name="style" value="{global:skin}styles/frame.xsl"/>
  +            </aspect>
  +            <aspect type="parameter">
  +                <parameter name="tag-name" value="frame"/>
  +            </aspect>
  +            <aspect type="frame">
  +                <parameter name="store" value="request"/>
  +            </aspect>
  +         </aspects>
  +    </renderer>
    </component>
    
   <!-- Layout factory configuration -->
  @@ -102,6 +115,25 @@
                   <renderer name="window"/>
               </renderers>
           </layout>
  +        <layout name="link"
  +                class="org.apache.cocoon.portal.layout.impl.LinkLayout"
  +                create-id="true">
  +            <renderers default="link">
  +                <renderer name="link"/>
  +            </renderers>
  +            <aspects>
  +               <aspect name="link-layout-key"
  +                       class="java.lang.String"
  +                       store="session"
  +                       auto-create="false">
  +               </aspect>
  +               <aspect name="link-layout-id"
  +                       class="java.lang.String"
  +                       store="session"
  +                       auto-create="false">
  +               </aspect>
  +            </aspects>
  +         </layout>
       </layouts>
   </component>
   
  
  
  
  1.21      +3 -1      cocoon-2.1/src/blocks/portal/conf/portal.xconf
  
  Index: portal.xconf
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/portal.xconf,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- portal.xconf	18 Jul 2003 14:41:44 -0000	1.20
  +++ portal.xconf	29 Jul 2003 06:30:06 -0000	1.21
  @@ -7,13 +7,14 @@
       <aspect name="action-counter" class="org.apache.cocoon.portal.event.aspect.impl.ActionCounterEventAspect"/>
       <aspect name="request-parameter" class="org.apache.cocoon.portal.event.aspect.impl.RequestParameterEventAspect"/>
       <aspect name="frame" class="org.apache.cocoon.portal.event.aspect.impl.FrameEventAspect"/>
  -    <aspect name="full-screen-coplet" class="org.apache.cocoon.portal.event.aspect.impl.FullScreenCopletEventAspect"/>
  +    <aspect name="link"  class="org.apache.cocoon.portal.event.aspect.impl.LinkEventAspect"
/>    <aspect name="full-screen-coplet" class="org.apache.cocoon.portal.event.aspect.impl.FullScreenCopletEventAspect"/>
    </component>
   
    <component class="org.apache.cocoon.portal.event.impl.DefaultEventManager" logger="portal"
role="org.apache.cocoon.portal.event.EventManager">
       <event-aspects>
           <aspect type="action-counter"/>
           <aspect type="frame"/>
  +        <aspect type="link"/>
           <aspect type="full-screen-coplet"/>
           <aspect type="request-parameter"/>
       </event-aspects>
  @@ -61,6 +62,7 @@
       <aspect name="coplet" class="org.apache.cocoon.portal.layout.renderer.aspect.impl.DefaultCopletAspect"/>
       <aspect name="frame" class="org.apache.cocoon.portal.layout.renderer.aspect.impl.FrameAspect"/>
       <aspect name="xslt" class="org.apache.cocoon.portal.layout.renderer.aspect.impl.XSLTAspect"/>
  +    <aspect class="org.apache.cocoon.portal.layout.renderer.aspect.impl.ParameterAspect"
name="parameter"/>
    </component>
   
    <!-- Aspect Storage configuration -->
  
  
  
  1.13      +3 -0      cocoon-2.1/src/blocks/portal/samples/profiles/mapping/layout.xml
  
  Index: layout.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/profiles/mapping/layout.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- layout.xml	27 May 2003 14:07:16 -0000	1.12
  +++ layout.xml	29 Jul 2003 06:30:06 -0000	1.13
  @@ -41,6 +41,9 @@
       <class name="org.apache.cocoon.portal.layout.impl.LinkLayout"
              extends="org.apache.cocoon.portal.layout.AbstractLayout">
           <map-to xml="link-layout" />
  +        <field name="layoutKey" type="java.lang.String">
  +            <bind-xml name="layout-key" node="attribute" />
  +        </field>
           <field name="layoutId" type="java.lang.String">
               <bind-xml name="layout-id" node="attribute" />
           </field>
  
  
  
  1.3       +14 -7     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
  
  Index: AbstractProfileManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractProfileManager.java	18 Jul 2003 14:41:45 -0000	1.2
  +++ AbstractProfileManager.java	29 Jul 2003 06:30:07 -0000	1.3
  @@ -54,6 +54,9 @@
   import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
  +import org.apache.avalon.framework.configuration.Configurable;
  +import org.apache.avalon.framework.configuration.Configuration;
  +import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.portal.PortalService;
  @@ -69,10 +72,10 @@
    */
   public abstract class AbstractProfileManager 
       extends AbstractLogEnabled 
  -    implements Composable, ProfileManager, ThreadSafe {
  +    implements Composable, Configurable, ProfileManager, ThreadSafe {
  +
  +    protected String defaultLayoutKey;
   
  -    public static final String DEFAULT_LAYOUT_KEY = "portal";
  -    
       protected ComponentManager manager;
   
       /**
  @@ -111,7 +114,7 @@
               service = (PortalService)this.manager.lookup(PortalService.ROLE);
               String defaultLayoutKey = (String)service.getAttribute("default-layout-key");
               if ( defaultLayoutKey == null ) {
  -                return DEFAULT_LAYOUT_KEY;
  +                return this.defaultLayoutKey;
               }
               return defaultLayoutKey;
           } catch (ComponentException ce) {
  @@ -155,5 +158,9 @@
           }
       }
   
  -    
  -}
  \ No newline at end of file
  +    public void configure(Configuration configuration) throws ConfigurationException {
  +        Configuration child = configuration.getChild("default-layout-key");
  +        // get configured default LayoutKey
  +        this.defaultLayoutKey = child.getValue("portal");
  +    }
  +}
  
  
  
  1.7       +167 -130  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
  
  Index: StaticProfileManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StaticProfileManager.java	18 Jul 2003 14:41:45 -0000	1.6
  +++ StaticProfileManager.java	29 Jul 2003 06:30:07 -0000	1.7
  @@ -58,12 +58,12 @@
   
   import org.apache.avalon.framework.CascadingRuntimeException;
   import org.apache.avalon.framework.component.Component;
  -import org.apache.avalon.framework.component.ComponentException;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.cocoon.portal.PortalService;
   import org.apache.cocoon.portal.coplet.CopletData;
  +import org.apache.cocoon.portal.coplet.CopletFactory;
   import org.apache.cocoon.portal.coplet.CopletInstanceData;
   import org.apache.cocoon.portal.layout.CompositeLayout;
   import org.apache.cocoon.portal.layout.Item;
  @@ -71,6 +71,7 @@
   import org.apache.cocoon.portal.layout.LayoutFactory;
   import org.apache.cocoon.portal.profile.ProfileLS;
   import org.apache.commons.collections.SequencedHashMap;
  +import org.apache.commons.collections.StaticBucketMap;
   import org.apache.excalibur.source.SourceValidity;
   
   /**
  @@ -81,53 +82,43 @@
    * 
    * @version CVS $Id$
    */
  -public class StaticProfileManager
  -    extends AbstractProfileManager
  -    implements Configurable {
  -
  +public class StaticProfileManager extends AbstractProfileManager implements Configurable
  +{
       protected String profilesPath;
   
  -    protected String defaultLayoutGroup = null;
  +    protected StaticBucketMap copletInstanceDataManagers = new StaticBucketMap();
   
  -    protected static final String LAYOUTKEY_PREFIX =
  -        StaticProfileManager.class.getName() + "/Layout/";
  +    protected static final String LAYOUTKEY_PREFIX = StaticProfileManager.class.getName()
+ "/Layout/";
   
       /**
        * @see org.apache.cocoon.portal.profile.ProfileManager#getPortalLayout(String, String)
        */
  -    public Layout getPortalLayout(String layoutKey, String layoutID) {
  +    public Layout getPortalLayout(String layoutKey, String layoutID)
  +    {
           PortalService service = null;
           ProfileLS adapter = null;
  -        try {
  +        try
  +        {
               service = (PortalService) this.manager.lookup(PortalService.ROLE);
   
  -            if (null == layoutID) {
  -                Layout l =
  -                    (Layout) service.getTemporaryAttribute("DEFAULT_LAYOUT");
  -                if (null != l) {
  +            if (layoutKey == null)
  +            {
  +                Layout l = getEntryLayout();
  +                if (null != l)
  +                {
                       return l;
                   }
  +                layoutKey = getDefaultLayoutKey();
               }
   
  -            String serviceKey = null;
  -            if (layoutKey == null) {
  -                layoutKey = defaultLayoutGroup; // Default group to load
  -            }
  -            serviceKey =
  -                LAYOUTKEY_PREFIX + service.getPortalName() + "/" + layoutKey;
  -            if (layoutID == null) {
  -                // look for the default key
  -                // it is set with the id of the root layoutId of a layoutGroup
  -                layoutID =
  -                    (String) service.getAttribute(serviceKey + "defaultKey");
  -            }
  -
  +            String serviceKey = LAYOUTKEY_PREFIX + layoutKey;
               Object[] objects = (Object[]) service.getAttribute(serviceKey);
   
               // check if the layout is already cached and still valid
               int valid = SourceValidity.INVALID;
               SourceValidity sourceValidity = null;
  -            if (objects != null) {
  +            if (objects != null)
  +            {
                   sourceValidity = (SourceValidity) objects[1];
                   valid = sourceValidity.isValid();
                   Layout layout = null;
  @@ -136,60 +127,56 @@
                   if (layout != null)
                       return layout;
               }
  -            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
  +
  +            CopletInstanceDataManager copletInstanceDataManager = getCopletInstanceDataManager(service);
   
               Map parameters = new HashMap();
               parameters.put("profiletype", "layout");
  -            
  +            parameters.put("objectmap", copletInstanceDataManager.getCopletInstanceData());
  +
               Map map = new SequencedHashMap();
               map.put("base", this.profilesPath);
               map.put("portalname", service.getPortalName());
               map.put("profile", "layout");
               map.put("groupKey", layoutKey);
   
  +            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
               SourceValidity newValidity = adapter.getValidity(map, parameters);
  -            if (valid == SourceValidity.UNKNOWN) {
  -                if (sourceValidity.isValid(newValidity)
  -                    == SourceValidity.VALID) {
  -                    // XXX what if objects is null ? Could it be ?
  +            if (valid == SourceValidity.UNKNOWN)
  +            {
  +                if (sourceValidity.isValid(newValidity) == SourceValidity.VALID)
  +                {
                       return (Layout) ((Map) objects[0]).get(layoutID);
                   }
               }
   
               // get Layout specified in the map
               Layout layout = (Layout) adapter.loadProfile(map, parameters);
  -            Map layouts = null;
  -            if (objects != null) {
  -                layouts = (Map) objects[0];
  -            } else {
  -                layouts = new HashMap();
  -            }
  -            // save the root layout as default of an group if no key is given
  -            service.setAttribute(serviceKey + "defaultKey", layout.getId());
  +            Map layouts = new HashMap();
  +
  +            layouts.put(null, layout); //save root with null as key
               cacheLayouts(layouts, layout);
   
               LayoutFactory factory = service.getComponentManager().getLayoutFactory();
               factory.prepareLayout(layout);
   
               // store the new values in the service
  -            if (newValidity != null) {
  +            if (newValidity != null)
  +            {
                   objects = new Object[] { layouts, newValidity };
                   service.setAttribute(serviceKey, objects);
               }
   
  -            // is the default layout wanted ?
  -            if ((layout.getId().equals(layoutID)) || layoutID == null) {
  -                return layout;
  -            }
  -
  -            // or a layout in the group ?
               return (Layout) layouts.get(layoutID);
  -
  -        } catch (Exception ce) {
  +        }
  +        catch (Exception ce)
  +        {
               throw new CascadingRuntimeException("Unable to get layout.", ce);
  -        } finally {
  +        }
  +        finally
  +        {
               this.manager.release(service);
  -            this.manager.release((Component)adapter);
  +            this.manager.release((Component) adapter);
           }
       }
   
  @@ -197,17 +184,22 @@
        * @param layoutMap
        * @param layout
        */
  -    private void cacheLayouts(Map layoutMap, Layout layout) {
  -        if (layout != null) {
  -            if (layout.getId() != null) {
  +    private void cacheLayouts(Map layoutMap, Layout layout)
  +    {
  +        if (layout != null)
  +        {
  +            if (layout.getId() != null)
  +            {
                   String layoutId = layout.getId();
                   layoutMap.put(layoutId, layout);
               }
  -            if (layout instanceof CompositeLayout) {
  +            if (layout instanceof CompositeLayout)
  +            {
                   // step through all it's child layouts and cache them too
                   CompositeLayout cl = (CompositeLayout) layout;
                   Iterator i = cl.getItems().iterator();
  -                while (i.hasNext()) {
  +                while (i.hasNext())
  +                {
                       Item current = (Item) i.next();
                       this.cacheLayouts(layoutMap, current.getLayout());
                   }
  @@ -216,104 +208,149 @@
   
       }
   
  -    public CopletInstanceData getCopletInstanceData(String copletID) {
  +    private CopletInstanceDataManager getCopletInstanceDataManager(PortalService service)
throws Exception
  +    {
  +        String portalName = service.getPortalName();
  +        CopletInstanceDataManager copletInstanceDataManager =
  +            (CopletInstanceDataManager) this.copletInstanceDataManagers.get(portalName);
  +        if (copletInstanceDataManager != null)
  +            return copletInstanceDataManager;
  +
  +        ProfileLS adapter = null;
  +        try
  +        {
  +            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
  +
  +            Map parameters = new HashMap();
  +            parameters.put("profiletype", "copletbasedata");
  +            parameters.put("objectmap", null);
  +
  +            Map map = new SequencedHashMap();
  +            map.put("base", this.profilesPath);
  +            map.put("portalname", service.getPortalName());
  +            map.put("profile", "coplet");
  +            map.put("name", "basedata");
  +            CopletBaseDataManager copletBaseDataManager = (CopletBaseDataManager) adapter.loadProfile(map,
parameters);
  +
  +            //CopletData
  +            parameters.clear();
  +            parameters.put("profiletype", "copletdata");
  +            parameters.put("objectmap", copletBaseDataManager.getCopletBaseData());
  +
  +            map.clear();
  +            map.put("base", this.profilesPath);
  +            map.put("portalname", service.getPortalName());
  +            map.put("profile", "coplet");
  +            map.put("name", "data");
  +            CopletDataManager copletDataManager = (CopletDataManager) adapter.loadProfile(map,
parameters);
  +
  +            //CopletInstanceData
  +            parameters.clear();
  +            parameters.put("profiletype", "copletinstancedata");
  +            parameters.put("objectmap", copletDataManager.getCopletData());
  +
  +            map.clear();
  +            map.put("base", this.profilesPath);
  +            map.put("portalname", service.getPortalName());
  +            map.put("profile", "coplet");
  +            map.put("name", "instancedata");
  +            copletInstanceDataManager = (CopletInstanceDataManager) adapter.loadProfile(map,
parameters);
  +
  +            CopletFactory copletFactory = service.getComponentManager().getCopletFactory();
  +            Iterator iterator = copletDataManager.getCopletData().values().iterator();
  +            while (iterator.hasNext())
  +            {
  +                CopletData cd = (CopletData) iterator.next();
  +                copletFactory.prepare(cd);
  +            }
  +            iterator = copletInstanceDataManager.getCopletInstanceData().values().iterator();
  +            while (iterator.hasNext())
  +            {
  +                CopletInstanceData cid = (CopletInstanceData) iterator.next();
  +                copletFactory.prepare(cid);
  +            }
  +
  +            this.copletInstanceDataManagers.put(portalName, copletInstanceDataManager);
  +            return copletInstanceDataManager;
  +        }
  +        finally
  +        {
  +            this.manager.release(service);
  +            this.manager.release((Component) adapter);
  +        }
  +    }
  +
  +    public CopletInstanceData getCopletInstanceData(String copletID)
  +    {
           PortalService service = null;
  -        String attribute = null;
  -        try {
  +        try
  +        {
               service = (PortalService) this.manager.lookup(PortalService.ROLE);
  -
  -            attribute =
  -                StaticProfileManager.class.getName()
  -                    + "/"
  -                    + service.getPortalName()
  -                    + "/CopletInstanceData";
  -            CopletInstanceDataManager copletInstanceDataManager =
  -                (CopletInstanceDataManager) service.getAttribute(attribute);
  -
  -            return copletInstanceDataManager.getCopletInstanceData(copletID);
  -        } catch (ComponentException e) {
  -            throw new CascadingRuntimeException(
  -                "Unable to lookup portal service.",
  -                e);
  -        } finally {
  +            return getCopletInstanceDataManager(service).getCopletInstanceData(copletID);
  +        }
  +        catch (Exception e)
  +        {
  +            throw new CascadingRuntimeException("Error in getCopletInstanceData", e);
  +        }
  +        finally
  +        {
               this.manager.release(service);
           }
       }
   
  -    public List getCopletInstanceData(CopletData data) {
  +    public List getCopletInstanceData(CopletData data)
  +    {
           List coplets = new ArrayList();
           PortalService service = null;
  -        String attribute = null;
  -        try {
  +        try
  +        {
               service = (PortalService) this.manager.lookup(PortalService.ROLE);
  -
  -            attribute =
  -                StaticProfileManager.class.getName()
  -                    + "/"
  -                    + service.getPortalName()
  -                    + "/CopletInstanceData";
  -            CopletInstanceDataManager copletInstanceDataManager =
  -                (CopletInstanceDataManager) service.getAttribute(attribute);
  -
  -            Iterator iter =
  -                copletInstanceDataManager
  -                    .getCopletInstanceData()
  -                    .values()
  -                    .iterator();
  -            while (iter.hasNext()) {
  +            Iterator iter = getCopletInstanceDataManager(service).getCopletInstanceData().values().iterator();
  +            while (iter.hasNext())
  +            {
                   CopletInstanceData current = (CopletInstanceData) iter.next();
  -                if (current.getCopletData().equals(data)) {
  +                if (current.getCopletData().equals(data))
  +                {
                       coplets.add(current);
                   }
               }
               return coplets;
  -        } catch (ComponentException e) {
  -            throw new CascadingRuntimeException(
  -                "Unable to lookup portal service.",
  -                e);
  -        } finally {
  +        }
  +        catch (Exception e)
  +        {
  +            throw new CascadingRuntimeException("Error in getCopletInstanceData", e);
  +        }
  +        finally
  +        {
               this.manager.release(service);
           }
       }
   
  -    public void register(CopletInstanceData coplet) {
  -    }
  -
  -    public void unregister(CopletInstanceData coplet) {
  +    public void register(CopletInstanceData coplet)
  +    {
       }
   
  -    public void register(Layout layout) {
  +    public void unregister(CopletInstanceData coplet)
  +    {
       }
   
  -    public void unregister(Layout layout) {
  +    public void register(Layout layout)
  +    {
       }
   
  -    public void saveUserProfiles() {
  +    public void unregister(Layout layout)
  +    {
       }
   
  -    public void configure(Configuration configuration)
  -        throws ConfigurationException {
  -        Configuration child = configuration.getChild("default-layout-group");
  -        if (child != null) {
  -            // get configured default LayoutGroup
  -            defaultLayoutGroup = child.getValue();
  -        }
  -
  -        if (this.defaultLayoutGroup == null) {
  -            // if none is configured set it to "portal"
  -            this.defaultLayoutGroup = "portal";
  -        }
  -        child = configuration.getChild("profiles-path");
  -        if (child != null) {
  -            this.profilesPath = child.getValue();
  -        }
  -        if ( this.profilesPath == null ) {
  -            this.profilesPath = "context://samples/simple-portal/profiles";
  -        }
  +    public void saveUserProfiles()
  +    {
       }
   
  -    public Layout getPortalLayout(String key) {
  -        return getPortalLayout(null, key);
  +    public void configure(Configuration configuration) throws ConfigurationException
  +    {
  +        super.configure(configuration);
  +        Configuration child = configuration.getChild("profiles-path");
  +        this.profilesPath = child.getValue("cocoon:/profiles");
  +        //this.profilesPath = "context://samples/simple-portal/profiles";
       }
  -
   }
  
  
  
  1.2       +2 -2      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java
  
  Index: MapProfileLS.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MapProfileLS.java	10 Jul 2003 13:16:59 -0000	1.1
  +++ MapProfileLS.java	29 Jul 2003 06:30:07 -0000	1.2
  @@ -112,7 +112,7 @@
                   if ( !first) {
                       buffer.append('/');
                   }
  -                first = true;
  +                first = false;
               }
               String append = entry.getValue().toString();
               if ( "?".equals(append) ) {
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/ParameterAspect.java
  
  Index: ParameterAspect.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
  
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
  
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
  
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
  
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
  
   4. The names "Apache Cocoon" and  "Apache Software Foundation" must  not  be
      used to  endorse or promote  products derived from  this software without
      prior written permission. For written permission, please contact
      apache@apache.org.
  
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
  
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <stefano@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.layout.renderer.aspect.impl;
  
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.avalon.framework.parameters.ParameterException;
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.cocoon.portal.PortalService;
  import org.apache.cocoon.portal.layout.Layout;
  import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
  import org.apache.cocoon.xml.AttributesImpl;
  import org.apache.cocoon.xml.XMLUtils;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.SAXException;
  
  /**
   *
   * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
   * 
   * @version CVS $Id: ParameterAspect.java,v 1.1 2003/07/29 06:30:07 cziegeler Exp $
   */
  public final class ParameterAspect extends AbstractAspect {
  
      /* (non-Javadoc)
       * @see org.apache.cocoon.portal.layout.renderer.RendererAspect#toSAX(org.apache.cocoon.portal.layout.renderer.RendererAspectContext,
org.apache.cocoon.portal.layout.Layout, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler)
       */
      public void toSAX(RendererAspectContext context,
                          Layout layout,
                          PortalService service,
                          ContentHandler contenthandler)
      throws SAXException {
          
          final PreparedConfiguration config = (PreparedConfiguration)context.getAspectConfiguration();
  
          Map parameter = layout.getParameters();
          if (parameter.size() > 0) {
              AttributesImpl attributes = new AttributesImpl();
              Map.Entry entry;
              for (Iterator iter = parameter.entrySet().iterator(); iter.hasNext();) {
                  entry = (Map.Entry) iter.next();
                  attributes.addCDATAAttribute((String)entry.getKey(), (String)entry.getValue());
              }
              XMLUtils.startElement(contenthandler, config.tagName, attributes);
          } else {
              XMLUtils.startElement(contenthandler, config.tagName);
          }
  
          context.invokeNext( layout, service, contenthandler );
  
          XMLUtils.endElement(contenthandler, config.tagName);
      }
  
      protected class PreparedConfiguration {
          public String tagName;
          
          public void takeValues(PreparedConfiguration from) {
              this.tagName = from.tagName;
          }
      }
      
      /* (non-Javadoc)
       * @see org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect#prepareConfiguration(org.apache.avalon.framework.parameters.Parameters)
       */
      public Object prepareConfiguration(Parameters configuration) 
      throws ParameterException {
          PreparedConfiguration pc = new PreparedConfiguration();
          pc.tagName = configuration.getParameter("tag-name", "parameter");
          return pc;
      }
  }
  
  
  

Mime
View raw message