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/resources save-user-profile.xml
Date Thu, 22 May 2003 15:19:49 GMT
cziegeler    2003/05/22 08:19:49

  Modified:    src/blocks/portal/java/org/apache/cocoon/portal/source
                        CopletSourceFactory.java CopletSource.java
               src/blocks/portal/samples/profiles/mapping layout.xml
                        copletinstancedata.xml
               src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl
                        CompositeContentAspect.java TabContentAspect.java
                        WindowAspect.java
               src/blocks/portal/java/org/apache/cocoon/portal/profile/impl
                        CopletDataManager.java MapSourceAdapter.java
                        SimpleProfileManager.java
               src/blocks/portal/java/org/apache/cocoon/portal/layout
                        Item.java CompositeLayout.java
               src/blocks/portal/java/org/apache/cocoon/portal/event/impl
                        DefaultEventManager.java
               src/blocks/portal/java/org/apache/cocoon/portal/profile
                        ProfileLS.java
               src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter
                        CopletAdapter.java
               src/blocks/portal/java/org/apache/cocoon/portal/aspect
                        Aspectalizable.java
               src/blocks/portal/java/org/apache/cocoon/portal/util
                        DeltaApplicable.java
               src/blocks/portal/java/org/apache/cocoon/portal/coplet
                        CopletData.java CopletFactory.java
               src/blocks/portal/samples sitemap.xmap
               src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl
                        AbstractAspectalizable.java
               src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl
                        DefaultCopletFactory.java
               src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl
                        URICopletAdapter.java
               src/blocks/portal/java/org/apache/cocoon/components/persistance
                        CastorSourceConverter.java
  Added:       src/blocks/portal/java/org/apache/cocoon/portal/event/impl
                        DefaultEventAspectContext.java
                        EventAspectChain.java
               src/blocks/portal/java/org/apache/cocoon/portal/layout/impl
                        ParameterFieldHandler.java
               src/blocks/portal/java/org/apache/cocoon/portal/util
                        DeltaApplicableReferencesAdjustable.java
               src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl
                        MapItem.java AspectDataFieldHandler.java
               src/blocks/portal/samples/resources save-user-profile.xml
  Removed:     src/blocks/portal/java/org/apache/cocoon/portal/event/aspect
                        DefaultEventAspectContext.java
                        EventAspectChain.java
               src/blocks/portal/java/org/apache/cocoon/portal/layout/impl
                        Parameter.java
  Log:
  Updating and refactoring
  
  Revision  Changes    Path
  1.2       +13 -8     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/source/CopletSourceFactory.java
  
  Index: CopletSourceFactory.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/source/CopletSourceFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CopletSourceFactory.java	7 May 2003 06:22:21 -0000	1.1
  +++ CopletSourceFactory.java	22 May 2003 15:19:38 -0000	1.2
  @@ -66,6 +66,7 @@
   import org.apache.excalibur.source.SourceFactory;
   
   /**
  + * The source factory for the coplet sources
    *
    * @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>
  @@ -76,14 +77,14 @@
       extends AbstractLogEnabled
       implements SourceFactory, Composable, ThreadSafe {
   
  -    private ComponentManager componentManager;
  +    protected ComponentManager manager;
       
       /**
        * @see org.apache.avalon.framework.component.Composable#compose(ComponentManager)
        */
       public void compose(ComponentManager componentManager)
           throws ComponentException {
  -        this.componentManager = componentManager;
  +        this.manager = componentManager;
       }
   
   	/**
  @@ -91,26 +92,30 @@
   	 */
   	public Source getSource(String location, Map parameters)
   		throws MalformedURLException, IOException {
  -            
  +        
  +        String uri = location;
  +        String protocol = null;
  +        
           // remove the protocol
           int position = location.indexOf(':') + 1;
           if (position != 0) {
               location = location.substring(position+2);
  +            protocol = location.substring(0, position);
           }
           ProfileManager profileManager = null;
           CopletInstanceData coplet = null;
           try {
  -            profileManager = (ProfileManager)this.componentManager.lookup(ProfileManager.ROLE);
  +            profileManager = (ProfileManager)this.manager.lookup(ProfileManager.ROLE);
               coplet = profileManager.getCopletInstanceData(location);
               CopletSource copletSource =
  -                new CopletSource(coplet.getCopletData().getCopletBaseData().getCopletAdapterName(),
  +                new CopletSource(uri, protocol,
                                    coplet);
  -            copletSource.compose(this.componentManager);
  +            copletSource.compose(this.manager);
               return copletSource;
           } catch (ComponentException ce) {
               throw new SourceException("Unable to lookup profile manager.", ce);
           } finally {
  -            this.componentManager.release(profileManager);
  +            this.manager.release(profileManager);
           }
   	}
   
  
  
  
  1.2       +19 -16    cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/source/CopletSource.java
  
  Index: CopletSource.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/source/CopletSource.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CopletSource.java	7 May 2003 06:22:21 -0000	1.1
  +++ CopletSource.java	22 May 2003 15:19:38 -0000	1.2
  @@ -67,27 +67,31 @@
   import org.xml.sax.SAXException;
   
   /**
  - *
  + * This is the source implementation of the coplet source
  + * 
    * @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$
    */
  -public final class CopletSource 
  +public class CopletSource 
       implements Source, XMLizable, Composable {
   
  -    private ComponentManager componentManager;
  +    protected ComponentManager manager;
       
  -    private String copletControllerName;
  -    private CopletInstanceData copletInstanceData;
  +    protected String uri;
  +    protected String copletControllerName;
  +    protected CopletInstanceData copletInstanceData;
       
       /** The used protocol */
  -    private String scheme = "coplet";
  +    protected String scheme;
       
  -    public CopletSource(String copletControllerName,
  +    public CopletSource(String location, String protocol,
                            CopletInstanceData coplet) {
  -         this.copletInstanceData = coplet;
  -         this.copletControllerName = copletControllerName;
  +        this.uri = location;
  +        this.scheme = (protocol == null ? "coplet" : protocol);
  +        this.copletInstanceData = coplet;
  +        this.copletControllerName = this.copletInstanceData.getCopletData().getCopletBaseData().getCopletAdapterName();
       }
       
   	/**
  @@ -101,8 +105,7 @@
   	 * @see org.apache.excalibur.source.Source#getURI()
   	 */
   	public String getURI() {
  -        // FIXME
  -		return "hallo";
  +		return this.uri;
   	}
   
   	/**
  @@ -147,7 +150,7 @@
           ComponentSelector copletAdapterSelector = null;
           CopletAdapter copletAdapter = null;
           try {
  -            copletAdapterSelector = (ComponentSelector)this.componentManager.lookup(CopletAdapter.ROLE+"Selector");
  +            copletAdapterSelector = (ComponentSelector)this.manager.lookup(CopletAdapter.ROLE+"Selector");
               copletAdapter = (CopletAdapter)copletAdapterSelector.select(this.copletControllerName);
               
               copletAdapter.toSAX(this.copletInstanceData, handler);
  @@ -157,7 +160,7 @@
               if ( null != copletAdapter ) {
                    copletAdapterSelector.release( copletAdapter );
               }
  -            this.componentManager.release(copletAdapterSelector);
  +            this.manager.release(copletAdapterSelector);
           }
               
   	}
  @@ -167,7 +170,7 @@
   	 */
   	public void compose(ComponentManager componentManager)
   		throws ComponentException {
  -        this.componentManager = componentManager;
  +        this.manager = componentManager;
   	}
   
       /**
  @@ -181,7 +184,7 @@
        * @see org.apache.excalibur.source.Source#getScheme()
        */
       public String getScheme() {
  -        return scheme;
  +        return this.scheme;
       }
   
   }
  
  
  
  1.9       +27 -14    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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- layout.xml	22 May 2003 07:00:23 -0000	1.8
  +++ layout.xml	22 May 2003 15:19:38 -0000	1.9
  @@ -4,6 +4,9 @@
   
   
   	<class name="org.apache.cocoon.portal.aspect.impl.AbstractAspectalizable">
  +        <field name="persistentAspectData" type="org.apache.cocoon.portal.aspect.impl.MapItem" collection="map" handler="org.apache.cocoon.portal.aspect.impl.AspectDataFieldHandler">
  +            <bind-xml name="aspect"/>
  +        </field>
       </class>
   
   	<class name="org.apache.cocoon.portal.factory.impl.AbstractProducible"
  @@ -17,19 +20,19 @@
       </class>
   
   	<class name="org.apache.cocoon.portal.layout.AbstractParameters">
  -        <field name="parameters" type="org.apache.cocoon.portal.layout.impl.Parameter" collection="map">
  -            <bind-xml auto-naming="deriveByClass" />
  +        <field name="parameters" type="org.exolab.castor.mapping.MapItem" collection="map" handler="org.apache.cocoon.portal.layout.impl.ParameterFieldHandler">
  +            <bind-xml name="parameter" />
           </field>
       </class>
       
       <class name="org.apache.cocoon.portal.layout.AbstractLayout"
              extends="org.apache.cocoon.portal.factory.impl.AbstractProducible">
  -        <field name="parameters" type="org.apache.cocoon.portal.layout.impl.Parameter" collection="map">
  -            <bind-xml auto-naming="deriveByClass" />
  -        </field>
           <field name="layoutRendererName" type="java.lang.String">
               <bind-xml name="layout-renderer-name" node="attribute" />
           </field>
  +        <field name="parameters" type="org.exolab.castor.mapping.MapItem" collection="map" handler="org.apache.cocoon.portal.layout.impl.ParameterFieldHandler">
  +            <bind-xml name="parameter" />
  +        </field>
           <field name="static" type="boolean">
               <bind-xml name="static" node="attribute" />
           </field>
  @@ -71,15 +74,25 @@
           </field>
       </class>
   
  -    <class name="org.apache.cocoon.portal.layout.impl.Parameter">
  -        <map-to xml="parameter" />
  -        <field name="name" type="string">
  -            <bind-xml name="name" node="attribute" />
  -        </field>
  -        <field name="value" type="string">
  -            <bind-xml name="value" node="attribute" />
  -        </field>
  -    </class>
  +	<class name="org.exolab.castor.mapping.MapItem">
  +		<field name="key" type="java.lang.String">
  +			<bind-xml name="name" node="attribute"/>
  +		</field>
  +
  +		<field name="value" type="java.lang.String">
  +			<bind-xml name="value" node="attribute"/>
  +		</field>
  +	</class>
  +
  +	<class name="org.apache.cocoon.portal.aspect.impl.MapItem">
  +		<field name="key" type="java.lang.String">
  +			<bind-xml name="name"/>
  +		</field>
  +
  +		<field name="value">
  +			<bind-xml name="value"/>
  +		</field>
  +	</class>
   
       <class name="org.apache.cocoon.portal.layout.impl.CopletLayout" auto-complete="false"
              extends="org.apache.cocoon.portal.layout.AbstractLayout">
  
  
  
  1.5       +14 -1     cocoon-2.1/src/blocks/portal/samples/profiles/mapping/copletinstancedata.xml
  
  Index: copletinstancedata.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/profiles/mapping/copletinstancedata.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- copletinstancedata.xml	21 May 2003 13:24:01 -0000	1.4
  +++ copletinstancedata.xml	22 May 2003 15:19:38 -0000	1.5
  @@ -3,6 +3,9 @@
   	<description>Coplet instance data mapping file</description>
   
   	<class name="org.apache.cocoon.portal.aspect.impl.AbstractAspectalizable">
  +        <field name="persistentAspectDatas" type="org.apache.cocoon.portal.aspect.impl.MapItem" collection="map" handler="org.apache.cocoon.portal.aspect.impl.AspectDataFieldHandler">
  +            <bind-xml name="aspect"/>
  +        </field>
       </class>
   
   	<class name="org.apache.cocoon.portal.factory.impl.AbstractProducible"
  @@ -24,7 +27,7 @@
   	</class>
   
   	<class name="org.apache.cocoon.portal.coplet.CopletInstanceData"
  -	    extends="org.apache.cocoon.portal.factory.impl.AbstractProducible">
  +		   extends="org.apache.cocoon.portal.factory.impl.AbstractProducible">
   		<map-to xml="coplet-instance-data" />
   
   		<field name="status" type="java.lang.Integer">
  @@ -32,6 +35,16 @@
   		</field>
   
   		<field name="copletData" type="java.lang.String" handler="org.apache.cocoon.portal.profile.impl.CopletDataReferenceFieldHandler"/>
  +	</class>
  +
  +	<class name="org.apache.cocoon.portal.aspect.impl.MapItem">
  +		<field name="key" type="java.lang.String">
  +			<bind-xml name="name"/>
  +		</field>
  +
  +		<field name="value">
  +			<bind-xml name="value"/>
  +		</field>
   	</class>
   </mapping>
   
  
  
  
  1.2       +10 -9     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/CompositeContentAspect.java
  
  Index: CompositeContentAspect.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/CompositeContentAspect.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CompositeContentAspect.java	7 May 2003 06:22:22 -0000	1.1
  +++ CompositeContentAspect.java	22 May 2003 15:19:38 -0000	1.2
  @@ -56,7 +56,6 @@
   import org.apache.cocoon.portal.PortalService;
   import org.apache.cocoon.portal.layout.Item;
   import org.apache.cocoon.portal.layout.Layout;
  -import org.apache.cocoon.portal.layout.impl.Parameter;
   import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
   import org.apache.cocoon.xml.AttributesImpl;
   import org.apache.cocoon.xml.XMLUtils;
  @@ -89,9 +88,10 @@
   
           AttributesImpl attributes = new AttributesImpl();
           Map parameter = layout.getParameters();
  -        for (Iterator iter = parameter.values().iterator(); iter.hasNext();) {
  -            Parameter param = (Parameter) iter.next();
  -            attributes.addCDATAAttribute(param.getName(), param.getValue());
  +        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(handler, this.getTagName(context), attributes);
           super.toSAX(context, layout, service, handler);
  @@ -114,10 +114,11 @@
           } else {
               AttributesImpl attributes = new AttributesImpl();
   
  -            for (Iterator iter = parameters.values().iterator(); iter.hasNext();) {
  -                Parameter param = (Parameter) iter.next();
  -                attributes.addCDATAAttribute(param.getName(), param.getValue());
  -            }
  +			Map.Entry entry;
  +			for (Iterator iter = parameters.entrySet().iterator(); iter.hasNext();) {
  +				entry = (Map.Entry) iter.next();
  +				attributes.addCDATAAttribute((String)entry.getKey(), (String)entry.getValue());
  +			}
               XMLUtils.startElement(handler, ITEM_STRING, attributes);
           }
           processLayout(layout, service, handler);
  
  
  
  1.5       +6 -6      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java
  
  Index: TabContentAspect.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TabContentAspect.java	19 May 2003 14:10:13 -0000	1.4
  +++ TabContentAspect.java	22 May 2003 15:19:38 -0000	1.5
  @@ -59,7 +59,6 @@
   import org.apache.cocoon.portal.layout.CompositeLayout;
   import org.apache.cocoon.portal.layout.Layout;
   import org.apache.cocoon.portal.layout.NamedItem;
  -import org.apache.cocoon.portal.layout.impl.Parameter;
   import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
   import org.apache.cocoon.xml.AttributesImpl;
   import org.apache.cocoon.xml.XMLUtils;
  @@ -86,10 +85,11 @@
           if (layout instanceof CompositeLayout) {
               AttributesImpl attributes = new AttributesImpl();
               Map parameter = layout.getParameters();
  -            for (Iterator iter = parameter.values().iterator(); iter.hasNext();) {
  -                Parameter param = (Parameter) iter.next();
  -                attributes.addCDATAAttribute(param.getName(), param.getValue());
  -            }
  +			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(handler, this.getTagName(context), attributes);
   
               PortalService portalService = null;
  
  
  
  1.2       +6 -6      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/WindowAspect.java
  
  Index: WindowAspect.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/WindowAspect.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WindowAspect.java	7 May 2003 06:22:22 -0000	1.1
  +++ WindowAspect.java	22 May 2003 15:19:38 -0000	1.2
  @@ -57,7 +57,6 @@
   import org.apache.cocoon.portal.coplet.CopletInstanceData;
   import org.apache.cocoon.portal.layout.Layout;
   import org.apache.cocoon.portal.layout.impl.CopletLayout;
  -import org.apache.cocoon.portal.layout.impl.Parameter;
   import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
   import org.apache.cocoon.xml.AttributesImpl;
   import org.apache.cocoon.xml.XMLUtils;
  @@ -88,10 +87,11 @@
           final CopletInstanceData copletInstanceData = ((CopletLayout)layout).getCopletInstanceData();
           AttributesImpl attributes = new AttributesImpl();
           Map parameter = layout.getParameters();
  -        for (Iterator iter = parameter.values().iterator(); iter.hasNext();) {
  -            Parameter param = (Parameter) iter.next();
  -            attributes.addCDATAAttribute(param.getName(), param.getValue());
  -        }
  +		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, this.getTagName(context), attributes);
           int status = copletInstanceData.getStatus();
           XMLUtils.createElement(contenthandler, "title", copletInstanceData.getCopletData().getTitle());
  
  
  
  1.3       +30 -7     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/CopletDataManager.java
  
  Index: CopletDataManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/CopletDataManager.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CopletDataManager.java	20 May 2003 14:32:36 -0000	1.2
  +++ CopletDataManager.java	22 May 2003 15:19:42 -0000	1.3
  @@ -55,7 +55,7 @@
   import java.util.Map;
   
   import org.apache.cocoon.portal.coplet.CopletData;
  -import org.apache.cocoon.portal.util.DeltaApplicable;
  +import org.apache.cocoon.portal.util.DeltaApplicableReferencesAdjustable;
   
   /**
    * Holds instances of CopletData.
  @@ -65,7 +65,7 @@
    * @version CVS $Id$
    */
   public class CopletDataManager 
  -implements DeltaApplicable {
  +implements DeltaApplicableReferencesAdjustable {
   
   	/**
   	 * The coplet data instances.
  @@ -73,6 +73,11 @@
   	private Map copletData = new HashMap();
   	
   	/**
  +	 * Signals whether a delta has been applied.
  +	 */
  +	private boolean deltaApplied = false;
  +	
  +	/**
   	 * Gets all coplet data.
   	 */
   	public Map getCopletData() {
  @@ -100,6 +105,8 @@
   	public boolean applyDelta(Object object) {
   		CopletDataManager manager = (CopletDataManager)object;
   		
  +		this.deltaApplied = true;
  +
   		Iterator iterator = manager.getCopletData().values().iterator();
   		CopletData data, delta;
   		while (iterator.hasNext()) {
  @@ -116,14 +123,30 @@
   	}
   	
   	/**
  -	 * Updates the references to the coplet base data to the ones stored in the manager.
  +	 * Checks if a delta has been applied.
  +	 */
  +	public boolean deltaApplied() {
  +		return this.deltaApplied;
  +	}
  +
  +	/**
  +	 * Updates the references to contained DeltaApplicable objects  
  +	 * if no delta has been applied to them.
  +	 * @throws ClassCastException If the object is not of the expected type.
   	 */
  -	public void update(CopletBaseDataManager manager) {
  +	public void adjustReferences(Object object) {
  +		CopletDataManager manager = (CopletDataManager)object;
  +		
   		Iterator iterator = this.copletData.values().iterator();
  -		CopletData data;
  +		CopletData data, other;
   		while (iterator.hasNext()) {
   			data = (CopletData)iterator.next();
  -			data.setCopletBaseData(manager.getCopletBaseData(data.getCopletBaseData().getId()));
  +			if (!data.deltaApplied()) {
  +				other = manager.getCopletData(data.getId());
  +				if (other != null) {
  +					this.putCopletData(other);
  +				}
  +			}
   		}
   	}
   }
  
  
  
  1.2       +139 -98   cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapSourceAdapter.java
  
  Index: MapSourceAdapter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapSourceAdapter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MapSourceAdapter.java	19 May 2003 09:14:09 -0000	1.1
  +++ MapSourceAdapter.java	22 May 2003 15:19:42 -0000	1.2
  @@ -50,6 +50,9 @@
   */
   package org.apache.cocoon.portal.profile.impl;
   
  +import java.io.IOException;
  +import java.io.InputStreamReader;
  +import java.io.StringWriter;
   import java.util.Map;
   
   import org.apache.avalon.framework.component.Component;
  @@ -63,10 +66,12 @@
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.components.persistance.CastorSourceConverter;
   import org.apache.cocoon.portal.profile.ProfileLS;
  -import org.apache.excalibur.source.ModifiableSource;
  +import org.apache.cocoon.xml.dom.DOMUtil;
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceResolver;
   import org.apache.excalibur.source.SourceValidity;
  +import org.apache.excalibur.xml.sax.SAXParser;
  +import org.w3c.dom.Element;
   
   /**
    *
  @@ -86,87 +91,114 @@
       /* (non-Javadoc)
        * @see org.apache.cocoon.portal.profile.ProfileLS#loadProfile(java.lang.Object)
        */
  -    public Object loadProfile(Object key) throws Exception {
  -        Map mapKey = (Map) key;
  -		String profile = (String)mapKey.get("profile");
  -
  -        // TODO
  -        //String sourceURI = "context://samples/portal/profiles/layout/" + paramKey.getParameter("portalname") + ".xml";
  +    public Object loadProfile(Object key, Map map) throws Exception {
  +		Map mapKey = (Map) key;
   		StringBuffer buffer = new StringBuffer();
  -		buffer.append("profiles/");
  -		buffer.append(profile);
  -		buffer.append("/");
  -		buffer.append(mapKey.get("portalname"));
  -		Object type = mapKey.get("type");
  -		if (type != null) {
  -			buffer.append("-");
  -			buffer.append(type);
  -			if (type.equals("role")) {
  -				buffer.append("-");
  -				buffer.append(mapKey.get("role"));
  -			} else if (type.equals("user")) {
  -				buffer.append("-");
  -				buffer.append(mapKey.get("user"));
  -			}
  +
  +		String profile = (String)map.get("profile");
  +
  +		Configuration config = ((Configuration)mapKey.get("config")).getChild("profiles");
  +		Object type = map.get("type");
  +		String uri = null;
  +		if (type == null) {
  +			uri = config.getChild(profile+"-load").getAttribute("uri");
  +		} else if (type.equals("global")) {
  +			uri = config.getChild(profile+"-global-load").getAttribute("uri");
  +		} else if (type.equals("role")) {
  +			uri = config.getChild(profile+"-role-load").getAttribute("uri");
  +		} else if (type.equals("user")) {
  +			uri = config.getChild(profile+"-user-load").getAttribute("uri");
   		}
  -		buffer.append(".xml");
  +		buffer.append(uri);
  +
  +		if (uri.indexOf("?") == -1) {
  +			buffer.append("?portal=");
  +		} else {
  +			buffer.append("&portal=");
  +		}
  +		buffer.append(map.get("portalname"));
  +
  +		buffer.append("&role=");
  +		buffer.append(mapKey.get("role"));
           
  +		buffer.append("&user=");
  +		buffer.append(mapKey.get("user"));
  +
   		String sourceURI = buffer.toString();
  -        SourceResolver resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
  -        Source source = null;
  -        CastorSourceConverter converter = null;
  -        try {
  -            source = resolver.resolveURI(sourceURI);
  -            converter = (CastorSourceConverter) this.manager.lookup(CastorSourceConverter.ROLE);
  -
  -			ReferenceFieldHandler.setObjectMap((Map)mapKey.get("objectmap"));
  -            return converter.getObject(source, profile);
  -        } finally {
  -            resolver.release(source);
  -            manager.release(converter);
  -            manager.release(resolver);
  -        }
  +		SourceResolver resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
  +		Source source = null;
  +		CastorSourceConverter converter = null;
  +		try {
  +			source = resolver.resolveURI(sourceURI);
  +			converter = (CastorSourceConverter) this.manager.lookup(CastorSourceConverter.ROLE);
  +
  +			ReferenceFieldHandler.setObjectMap((Map)map.get("objectmap"));
  +			return converter.getObject(source.getInputStream(), profile);
  +		} finally {
  +			resolver.release(source);
  +			manager.release(converter);
  +			manager.release(resolver);
  +		}
       }
   
       /* (non-Javadoc)
        * @see org.apache.cocoon.portal.profile.ProfileLS#saveProfile(java.lang.Object, java.lang.Object)
        */
  -    public void saveProfile(Object key, Object profile) throws Exception {
  +    public void saveProfile(Object key, Map map, Object profile) throws Exception {
   		Map mapKey = (Map) key;
  -		String profileName = (String)mapKey.get("profile");
  -
  -		// TODO
  -		//String sourceURI = "context://samples/portal/profiles/layout/" + paramKey.getParameter("portalname") + ".xml";
   		StringBuffer buffer = new StringBuffer();
  -		buffer.append("profiles/");
  -		buffer.append(profileName);
  -		buffer.append("/");
  -		buffer.append(mapKey.get("portalname"));
  -		Object type = mapKey.get("type");
  -		if (type != null) {
  -			buffer.append("-");
  -			buffer.append(type);
  -			if (type.equals("role")) {
  -				buffer.append("-");
  -				buffer.append(mapKey.get("role"));
  -			} else if (type.equals("user")) {
  -				buffer.append("-");
  -				buffer.append(mapKey.get("user"));
  -			}
  +
  +		String profileName = (String)map.get("profile");
  +
  +		Configuration config = ((Configuration)mapKey.get("config")).getChild("profiles");
  +		Object type = map.get("type");
  +		String uri = null;
  +		if (type == null) {
  +			uri = config.getChild(profileName+"-save").getAttribute("uri");
  +		} else if (type.equals("global")) {
  +			uri = config.getChild(profileName+"-global-save").getAttribute("uri");
  +		} else if (type.equals("role")) {
  +			uri = config.getChild(profileName+"-role-save").getAttribute("uri");
  +		} else if (type.equals("user")) {
  +			uri = config.getChild(profileName+"-user-save").getAttribute("uri");
   		}
  -		buffer.append(".xml");
  +		buffer.append(uri);
  +
  +		if (uri.indexOf("?") == -1) {
  +			buffer.append("?portal=");
  +		} else {
  +			buffer.append("&portal=");
  +		}
  +		buffer.append(map.get("portalname"));
  +
  +		buffer.append("&role=");
  +		buffer.append(mapKey.get("role"));
           
  -		String sourceURI = buffer.toString();
  +		buffer.append("&user=");
  +		buffer.append(mapKey.get("user"));
  +
   		SourceResolver resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
  -		ModifiableSource source = null;
  +		Source source = null;
   		CastorSourceConverter converter = null;
  +		SAXParser parser = null;
   		try {
  -			source = (ModifiableSource)resolver.resolveURI(sourceURI);
  +			StringWriter writer = new StringWriter();
  +			
   			converter = (CastorSourceConverter) this.manager.lookup(CastorSourceConverter.ROLE);
  +			converter.storeObject(writer, profileName, profile);
  +
  +			buffer.append("&content=");
  +			buffer.append(writer.toString());
   
  -			converter.storeObject(source, profileName, profile);
  +			source = resolver.resolveURI(buffer.toString());
  +			parser = (SAXParser)this.manager.lookup(SAXParser.ROLE);
  +			Element element = DOMUtil.getDocumentFragment(parser, new InputStreamReader(source.getInputStream())).getOwnerDocument().getDocumentElement();
  +			if (!DOMUtil.getValueOf(element, "descendant::sourceResult/execution").trim().equals("success")) {
  +				throw new IOException("Could not save profile: "+DOMUtil.getValueOf(element, "descendant::sourceResult/message"));
  +			}
   		} finally {
   			resolver.release(source);
  +			manager.release((Component)parser);
   			manager.release(converter);
   			manager.release(resolver);
   		}
  @@ -175,45 +207,54 @@
       /* (non-Javadoc)
        * @see org.apache.cocoon.portal.profile.ProfileLS#getValidity(java.lang.Object)
        */
  -    public SourceValidity getValidity(Object key) {
  -        SourceResolver resolver = null;
  -        Source source = null;
  -        try {
  -            Map mapKey = (Map) key;
  -            // TODO
  -//            String sourceURI =
  -//                "context://samples/portal/profiles/layout/" + paramKey.getParameter("portalname") + ".xml";
  +    public SourceValidity getValidity(Object key, Map map) {
  +		SourceResolver resolver = null;
  +		Source source = null;
  +		try {
  +			Map mapKey = (Map) key;
   			StringBuffer buffer = new StringBuffer();
  -			buffer.append("profiles/");
  -			buffer.append(mapKey.get("profile"));
  -			buffer.append("/");
  -			buffer.append(mapKey.get("portalname"));
  -			Object type = mapKey.get("type");
  -			if (type != null) {
  -				buffer.append("-");
  -				buffer.append(type);
  -				if (type.equals("role")) {
  -					buffer.append("-");
  -					buffer.append(mapKey.get("role"));
  -				} else if (type.equals("user")) {
  -					buffer.append("-");
  -					buffer.append(mapKey.get("user"));
  -				}
  +
  +			String profile = (String)map.get("profile");
  +
  +			Configuration config = ((Configuration)mapKey.get("config")).getChild("profiles");
  +			Object type = map.get("type");
  +			String uri = null;
  +			if (type == null) {
  +				uri = config.getChild(profile+"-load").getAttribute("uri");
  +			} else if (type.equals("global")) {
  +				uri = config.getChild(profile+"-global-load").getAttribute("uri");
  +			} else if (type.equals("role")) {
  +				uri = config.getChild(profile+"-role-load").getAttribute("uri");
  +			} else if (type.equals("user")) {
  +				uri = config.getChild(profile+"-user-load").getAttribute("uri");
  +			}
  +			buffer.append(uri);
  +
  +			if (uri.indexOf("?") == -1) {
  +				buffer.append("?portal=");
  +			} else {
  +				buffer.append("&portal=");
   			}
  -			buffer.append(".xml");
  +			buffer.append(map.get("portalname"));
  +
  +			buffer.append("&role=");
  +			buffer.append(mapKey.get("role"));
           
  +			buffer.append("&user=");
  +			buffer.append(mapKey.get("user"));
  +
   			String sourceURI = buffer.toString();
  -            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
  -            source = resolver.resolveURI(sourceURI);
  -            return source.getValidity();
  -        } catch (Exception e) {
  -            getLogger().warn(e.getMessage(), e);
  -            return null;
  -        } finally {
  -            if (source != null)
  -                resolver.release(source);
  -            manager.release(resolver);
  -        }
  +			resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
  +			source = resolver.resolveURI(sourceURI);
  +			return source.getValidity();
  +		} catch (Exception e) {
  +			getLogger().warn(e.getMessage(), e);
  +			return null;
  +		} finally {
  +			if (source != null)
  +				resolver.release(source);
  +			manager.release(resolver);
  +		}
       }
   
       /* (non-Javadoc)
  
  
  
  1.7       +179 -209  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/SimpleProfileManager.java
  
  Index: SimpleProfileManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/SimpleProfileManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SimpleProfileManager.java	22 May 2003 12:32:48 -0000	1.6
  +++ SimpleProfileManager.java	22 May 2003 15:19:42 -0000	1.7
  @@ -72,7 +72,7 @@
   import org.apache.cocoon.portal.layout.LayoutFactory;
   import org.apache.cocoon.portal.layout.impl.CopletLayout;
   import org.apache.cocoon.portal.profile.ProfileManager;
  -import org.apache.cocoon.portal.util.DeltaApplicable;
  +import org.apache.cocoon.portal.util.DeltaApplicableReferencesAdjustable;
   import org.apache.cocoon.webapps.authentication.user.RequestState;
   import org.apache.cocoon.webapps.authentication.user.UserHandler;
   import org.apache.excalibur.source.SourceNotFoundException;
  @@ -97,6 +97,8 @@
   
       private Map layoutStati = new HashMap(100);
       
  +    private Map attributes = new HashMap();
  +    
       /**
        * @see org.apache.avalon.framework.component.Composable#compose(ComponentManager)
        */
  @@ -124,75 +126,79 @@
                   }
               }
               
  -            String portalPrefix = "/"+service.getPortalName();
  -
  -			// TODO Change to KeyManager usage
  -			UserHandler handler = RequestState.getState().getHandler();
  -			HashMap map = new HashMap();
  -			map.put("portalname", service.getPortalName());
  -			map.put("user", handler.getUserId());
  -			map.put("role", handler.getContext().getContextInfo().get("role"));
  -
  -			// load coplet base data
  -			map.put("profile", "copletbasedata");
  -			map.put("objectmap", null);
  -			Object[] result = this.getProfile(map, portalPrefix+"/CopletBaseData", service);
  -			if (result[0] == null) {
  -				throw new SourceNotFoundException("Could not find coplet base data profile.");
  -			}
  -			CopletBaseDataManager copletBaseDataManager = (CopletBaseDataManager)result[0];
  -			boolean lastLoaded = ((Boolean)result[1]).booleanValue();
  +            String portalPrefix = SimpleProfileManager.class.getName()+"/"+service.getPortalName();
   
  -			// load coplet data
  -			map.put("profile", "copletdata");
  -			map.put("objectmap", copletBaseDataManager.getCopletBaseData());
  -			result = this.getDeltaProfile(map, portalPrefix+"/CopletData", service);
  -			if (result[0] == null) {
  -				throw new SourceNotFoundException("Could not find coplet data profile.");
  -			}
  -			CopletDataManager copletDataManager = (CopletDataManager)result[0];
  -			boolean loaded = ((Boolean)result[1]).booleanValue();
  -			if (lastLoaded && !loaded) {
  -				copletDataManager.update(copletBaseDataManager);
  -			}
  -			lastLoaded = loaded;
  -            // updating
  -            Iterator i = copletDataManager.getCopletData().values().iterator();
  -            while ( i.hasNext()) {
  -                CopletData cd = (CopletData)i.next();
  -                copletFactory.prepare(cd);
  -            }
  -
  -			// load coplet instance data
  -			map.put("profile", "copletinstancedata");
  -			map.put("objectmap", copletDataManager.getCopletData());
  -			result = this.getOrCreateProfile(map, portalPrefix+"/CopletInstanceData", service);
  -			CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager)result[0];
  -			loaded = ((Boolean)result[1]).booleanValue();
  -			if (lastLoaded && !loaded) {
  -				copletInstanceDataManager.update(copletDataManager);
  +			Layout layout = null;
  +			Object[] objects = (Object[])service.getAttribute(portalPrefix+"/Layout");
  +			if (objects != null)
  +				layout = (Layout)objects[0];
  +				
  +			if (layout == null) {
  +				HashMap map = new HashMap();
  +				map.put("portalname", service.getPortalName());
  +				
  +				// TODO Change to KeyManager usage
  +				UserHandler handler = RequestState.getState().getHandler();
  +				HashMap keyMap = new HashMap();
  +				keyMap.put("user", handler.getUserId());
  +				keyMap.put("role", handler.getContext().getContextInfo().get("role"));
  +				keyMap.put("config", RequestState.getState().getApplicationConfiguration().getConfiguration("portal"));
  +	
  +				// load coplet base data
  +				map.put("profile", "copletbasedata");
  +				map.put("objectmap", null);
  +				Object[] result = this.getProfile(keyMap, map, portalPrefix+"/CopletBaseData", null);
  +				if (result[0] == null) {
  +					throw new SourceNotFoundException("Could not find coplet base data profile.");
  +				}
  +				CopletBaseDataManager copletBaseDataManager = (CopletBaseDataManager)result[0];
  +				boolean lastLoaded = ((Boolean)result[1]).booleanValue();
  +	
  +				// load coplet data
  +				map.put("profile", "copletdata");
  +				map.put("objectmap", copletBaseDataManager.getCopletBaseData());
  +				result = this.getDeltaProfile(keyMap, map, portalPrefix+"/CopletData", service, lastLoaded);
  +				if (result[0] == null) {
  +					throw new SourceNotFoundException("Could not find coplet data profile.");
  +				}
  +				CopletDataManager copletDataManager = (CopletDataManager)result[0];
  +				lastLoaded = ((Boolean)result[1]).booleanValue();
  +				// updating
  +				Iterator i = copletDataManager.getCopletData().values().iterator();
  +				while ( i.hasNext()) {
  +					CopletData cd = (CopletData)i.next();
  +					copletFactory.prepare(cd);
  +				}
  +	
  +				// load coplet instance data
  +				map.put("profile", "copletinstancedata");
  +				map.put("objectmap", copletDataManager.getCopletData());
  +				result = this.getOrCreateProfile(keyMap, map, portalPrefix+"/CopletInstanceData", service);
  +				CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager)result[0];
  +				boolean loaded = ((Boolean)result[1]).booleanValue();
  +				if (lastLoaded && !loaded) {
  +					copletInstanceDataManager.update(copletDataManager);
  +				}
  +				lastLoaded = loaded;
  +				// updating
  +				i = copletInstanceDataManager.getCopletInstanceData().values().iterator();
  +				while ( i.hasNext()) {
  +					CopletInstanceData cid = (CopletInstanceData)i.next();
  +					copletFactory.prepare(cid);
  +				}
  +	
  +				// load layout
  +				map.put("profile", "layout");
  +				map.put("objectmap", ((CopletInstanceDataManager)result[0]).getCopletInstanceData());
  +				result = this.getOrCreateProfile(keyMap, map, portalPrefix+"/Layout", service);
  +				layout = (Layout)result[0];
  +				loaded = ((Boolean)result[1]).booleanValue();
  +				if (lastLoaded && !loaded) {
  +					updateLayout(layout, copletInstanceDataManager);
  +				}
  +	            factory.prepareLayout( layout );
   			}
  -			lastLoaded = loaded;
  -            // updating
  -            i = copletInstanceDataManager.getCopletInstanceData().values().iterator();
  -            while ( i.hasNext()) {
  -                CopletInstanceData cid = (CopletInstanceData)i.next();
  -                copletFactory.prepare(cid);
  -            }
   
  -			// load layout
  -			map.put("profile", "layout");
  -			map.put("objectmap", ((CopletInstanceDataManager)result[0]).getCopletInstanceData());
  -			result = this.getOrCreateProfile(map, portalPrefix+"/Layout", service);
  -			Layout layout = (Layout)result[0];
  -			loaded = ((Boolean)result[1]).booleanValue();
  -			if (lastLoaded && !loaded) {
  -				resolveParents(layout, null, copletInstanceDataManager);
  -			} else {
  -				resolveParents(layout, null, null);
  -			}
  -            factory.prepareLayout( layout );
  -             
               return layout;
           } catch (Exception ce) {
               // TODO
  @@ -209,58 +215,53 @@
        * @return result[0] is the profile, result[1] is a Boolean, 
        * which signals whether the profile has been loaded or reused.
        */
  -    private Object[] getDeltaProfile(Object key, String location, PortalService service) 
  +    private Object[] getDeltaProfile(Object key, Map map, String location, PortalService service, boolean forcedLoad) 
       throws Exception {
       	Object[] result;
       	
  -		// TODO Change key access to KeyManager usage
  -		Map map = (Map)key;
  -		
  +		// TODO Change to KeyManager usage
  +		Map keyMap = (Map)key;
  +
   		// check validities
  -		map.remove("type");
  -		Object[] globalValidity = this.getValidity(map, location+"-global", service);
  +		map.put("type", "global");
  +		Object[] globalValidity = this.getValidity(key, map, location, null);
   		map.put("type", "role");
  -		Object[] roleValidity = this.getValidity(map, location+"-role-"+map.get("role"), service);
  +		Object[] roleValidity = this.getValidity(key, map, location+"-role-"+keyMap.get("role"), null);
   		map.put("type", "user");
  -		Object[] userValidity = this.getValidity(map, location+"-user-"+map.get("user"), service);
  +		Object[] userValidity = this.getValidity(key, map, location+"-user", service);
   		boolean isValid
   			= ((Boolean)globalValidity[0]).booleanValue()
   			  &&((Boolean)roleValidity[0]).booleanValue()
   			  &&((Boolean)userValidity[0]).booleanValue();
   			  
  -		if (isValid) {
  -			/* The objects of the global profile have been modified by deltas
  -			   during the last load and therefore represent the current profile. 
  -			   So reuse them. */
  -			Object[] objects = (Object[]) service.getAttribute(SimpleProfileManager.class.getName()+location+"-global");
  -
  +		if (isValid && !forcedLoad) {
  +			Object[] objects = (Object[]) this.attributes.get(location);
   			result = new Object[] {objects[0], Boolean.FALSE};
   		} else {
   			// load global profile
  -			map.remove("type");
  -			/* It must be loaded and cannot be reused since the objects are modified by deltas
  -			   so they do NOT represent the global profile any more. */
  -			DeltaApplicable object = (DeltaApplicable)this.loadProfile(map, location+"-global", (SourceValidity)globalValidity[1], service);
  +			map.put("type", "global");
  +			Object global = this.getProfile(key, map, location, globalValidity, null, forcedLoad)[0];
  +			DeltaApplicableReferencesAdjustable object = (DeltaApplicableReferencesAdjustable)this.loadProfile(key, map, location, (SourceValidity)globalValidity[1], service);
   			result = new Object[] {object, Boolean.TRUE};
   		
   			// load role delta
   			map.put("type", "role");
  -			result = this.getProfile(map, location+"-role-"+map.get("role"), roleValidity, service);
  +			result = this.getProfile(key, map, location+"-role-"+keyMap.get("role"), roleValidity, null, forcedLoad);
   			if (((Boolean)result[1]).booleanValue())
   				object.applyDelta(result[0]); 		
   
   			// load user delta
   			map.put("type", "user");
  -			result = this.getProfile(map, location+"-user-"+map.get("user"), userValidity, service);
  +			result = this.getProfile(key, map, location+"-user", userValidity, service, forcedLoad);
   			if (((Boolean)result[1]).booleanValue())
   				object.applyDelta(result[0]);
  +				
  +			// change references to objects where no delta has been applied
  +			object.adjustReferences(global);
   			
   			result = new Object[] {object, Boolean.TRUE}; 		
   		}
   
  -		// clean up for reuse
  -		map.remove("type");
  -
       	return result;
       }
   
  @@ -269,26 +270,26 @@
   	 * @return result[0] is the profile, result[1] is a Boolean, 
   	 * which signals whether the profile has been loaded or reused.
   	 */
  -	private Object[] getOrCreateProfile(Object key, String location, PortalService service) 
  +	private Object[] getOrCreateProfile(Object key, Map map, String location, PortalService service) 
   	throws Exception {
   		Object[] result;
       	
  -		// TODO Change key access to KeyManager usage
  -		Map map = (Map)key;
  -		
  +		// TODO Change to KeyManager usage
  +		Map keyMap = (Map)key;
  +
   		// load user profile
   		map.put("type", "user");
  -		result = this.getProfile(key, location+"-user-"+map.get("user"), service);
  +		result = this.getProfile(key, map, location, service);
   
   		if (result[0] == null) {
   			// load role profile
   			map.put("type", "role");
  -			result = this.getProfile(key, location+"-role-"+map.get("role"), service);
  +			result = this.getProfile(key, map, location+"-role-"+keyMap.get("role"), null);
   
   			if (result[0] == null) {
   				// load global profile
  -				map.remove("type");
  -				result = this.getProfile(key, location+"-global", service);
  +				map.put("type", "global");
  +				result = this.getProfile(key, map, location, null);
   
   				if (result[0] == null) {
   					throw new SourceNotFoundException("Could not find global or role profile to create user profile.");
  @@ -298,30 +299,26 @@
   			// save profile as user profile
   			MapSourceAdapter adapter = null;
   			try {
  -				// TODO could one perhaps simply copy the file to increase performance??
   				adapter = (MapSourceAdapter) this.manager.lookup(MapSourceAdapter.ROLE);
   				map.put("type", "user");
   				
                   // FIXME - disabled saving for testing
  -                // adapter.saveProfile(key, result[0]);
  +                // adapter.saveProfile(key, map, result[0]);
   
   				// set validity for created user profile
  -				SourceValidity newValidity = adapter.getValidity(key);
  +				SourceValidity newValidity = adapter.getValidity(key, map);
   				if (newValidity != null) {
   					Object[] objects = new Object[] { result[0], newValidity };
  -					service.setAttribute(SimpleProfileManager.class.getName()+location+"-user-"+map.get("user"), objects);
  +					this.setAttribute(location, objects, service);
   				} else {
                       Object[] objects = new Object[] { result[0], null };
  -                    service.setAttribute(SimpleProfileManager.class.getName()+location+"-user-"+map.get("user"), objects);
  +                    this.setAttribute(location, objects, service);
   				}
   			} finally {
   				this.manager.release(adapter);
   			}
   		}
   		
  -		// clean up for reuse
  -		map.remove("type");
  -
   		return result;
   	}
   
  @@ -330,19 +327,19 @@
   	 * @return result[0] is the profile, result[1] is a Boolean, 
   	 * which signals whether the profile has been loaded or reused.
   	 */
  -	private Object[] getProfile(Object key, String location, PortalService service) 
  +	private Object[] getProfile(Object key, Map map, String location, PortalService service) 
   	throws Exception {
   		MapSourceAdapter adapter = null;
   		try {
   			adapter = (MapSourceAdapter) this.manager.lookup(MapSourceAdapter.ROLE);
   
  -			Object[] objects = (Object[]) service.getAttribute(SimpleProfileManager.class.getName() + location);
  +			Object[] objects = (Object[]) this.getAttribute(location, service);
   			
   			// check whether still valid
   			SourceValidity sourceValidity = null;
   			if (objects != null)
   				sourceValidity = (SourceValidity)objects[1];
  -			Object[] validity = this.getValidity(key, location, sourceValidity, adapter);
  +			Object[] validity = this.getValidity(key, map, location, sourceValidity, adapter);
   			if (((Boolean)validity[0]).booleanValue()) {
   				if (objects == null) {
   					return new Object[]{null, Boolean.FALSE};
  @@ -353,10 +350,10 @@
   			
   			// load profile
   			SourceValidity newValidity = (SourceValidity)validity[1];
  -			Object object = adapter.loadProfile(key);
  +			Object object = adapter.loadProfile(key, map);
   			if (newValidity != null) {
   				objects = new Object[] { object, newValidity };
  -				service.setAttribute(SimpleProfileManager.class.getName() + location, objects);
  +				this.setAttribute(location, objects, service);
   			}
   
   			return new Object[]{object, Boolean.TRUE};
  @@ -370,51 +367,59 @@
   	 * @return result[0] is the profile, result[1] is a Boolean, 
   	 * which signals whether the profile has been loaded or reused.
   	 */
  -	private Object[] getProfile(Object key, String location, Object[] validity, PortalService service) 
  +	private Object[] getProfile(Object key, Map map, String location, Object[] validity, PortalService service, boolean forcedLoad) 
   	throws Exception {
  -		MapSourceAdapter adapter = null;
  -		try {
  -			adapter = (MapSourceAdapter) this.manager.lookup(MapSourceAdapter.ROLE);
  +		if (forcedLoad) {
  +			try {
  +				return new Object[] {this.loadProfile(key, map, location, (SourceValidity)validity[1], service), Boolean.TRUE};
  +			} catch (SourceNotFoundException e) {
  +				return new Object[] {null, Boolean.FALSE};
  +			}
  +		} else {
  +			MapSourceAdapter adapter = null;
  +			try {
  +				adapter = (MapSourceAdapter) this.manager.lookup(MapSourceAdapter.ROLE);
   
  -			// check whether still valid
  -			Object[] objects = (Object[]) service.getAttribute(SimpleProfileManager.class.getName() + location);
  -			if (((Boolean)validity[0]).booleanValue()) {
  -				if (objects == null) {
  -					return new Object[]{null, Boolean.FALSE};
  -				} else {
  -					return new Object[]{objects[0], Boolean.FALSE};
  +				// check whether still valid
  +				Object[] objects = (Object[]) this.getAttribute(location, service);
  +				if (((Boolean)validity[0]).booleanValue()) {
  +					if (objects == null) {
  +						return new Object[]{null, Boolean.FALSE};
  +					} else {
  +						return new Object[]{objects[0], Boolean.FALSE};
  +					}
   				}
  -			}
   
  -			// load profile
  -			SourceValidity newValidity = (SourceValidity)validity[1];
  -			Object object = adapter.loadProfile(key);
  -			if (newValidity != null) {
  -				objects = new Object[] { object, newValidity };
  -				service.setAttribute(SimpleProfileManager.class.getName() + location, objects);
  -			}
  +				// load profile
  +				SourceValidity newValidity = (SourceValidity)validity[1];
  +				Object object = adapter.loadProfile(key, map);
  +				if (newValidity != null) {
  +					objects = new Object[] { object, newValidity };
  +					this.setAttribute(location, objects, service);
  +				}
   
  -			return new Object[]{object, Boolean.TRUE};
  -		} finally {
  -			this.manager.release(adapter);
  +				return new Object[]{object, Boolean.TRUE};
  +			} finally {
  +				this.manager.release(adapter);
  +			}
   		}
   	}
   
   	/**
   	 * Loads a profile and reuses the specified validity for storing if it is not null.
   	 */
  -	private Object loadProfile(Object key, String location, SourceValidity newValidity, PortalService service) 
  +	private Object loadProfile(Object key, Map map, String location, SourceValidity newValidity, PortalService service) 
   	throws Exception {
   		MapSourceAdapter adapter = null;
   		try {
   			adapter = (MapSourceAdapter) this.manager.lookup(MapSourceAdapter.ROLE);
   
   			if (newValidity == null)
  -				newValidity = adapter.getValidity(key);
  -			Object object = adapter.loadProfile(key);
  +				newValidity = adapter.getValidity(key, map);
  +			Object object = adapter.loadProfile(key, map);
   			if (newValidity != null) {
   				Object[] objects = new Object[] { object, newValidity };
  -				service.setAttribute(SimpleProfileManager.class.getName() + location, objects);
  +				this.setAttribute(location, objects, service);
   			}
   
   			return object;
  @@ -428,18 +433,18 @@
   	 * @return result[0] is a Boolean, which signals whether it is valid, 
   	 * result[1] may contain a newly created validity or be null if it could be reused.
   	 */
  -	private Object[] getValidity(Object key, String location, PortalService service)
  +	private Object[] getValidity(Object key, Map map, String location, PortalService service)
   	throws Exception { 
   		MapSourceAdapter adapter = null;
   		try {
   			adapter = (MapSourceAdapter) this.manager.lookup(MapSourceAdapter.ROLE);
   
  -			Object[] objects = (Object[]) service.getAttribute(SimpleProfileManager.class.getName() + location);
  +			Object[] objects = (Object[]) this.getAttribute(location, service);
   			SourceValidity sourceValidity = null;
   			if (objects != null)
   				sourceValidity = (SourceValidity)objects[1];
   			
  -			return this.getValidity(key, location, sourceValidity, adapter);
  +			return this.getValidity(key, map, location, sourceValidity, adapter);
   		} finally {
   			this.manager.release(adapter);
   		}
  @@ -450,7 +455,7 @@
   	 * @return result[0] is a Boolean, which signals whether it is valid, 
   	 * result[1] may contain a newly created validity or be null if it could be reused.
   	 */
  -	private Object[] getValidity(Object key, String location, SourceValidity sourceValidity, MapSourceAdapter adapter) 
  +	private Object[] getValidity(Object key, Map map, String location, SourceValidity sourceValidity, MapSourceAdapter adapter) 
   	throws Exception {
   		int valid = SourceValidity.INVALID;
   
  @@ -460,7 +465,7 @@
   				return new Object[]{Boolean.TRUE, null};
   		}
   
  -		SourceValidity newValidity = adapter.getValidity(key);
  +		SourceValidity newValidity = adapter.getValidity(key, map);
   		
   		// source does not exist so it is valid
   		if (newValidity == null)
  @@ -474,53 +479,38 @@
   		return new Object[]{Boolean.FALSE, newValidity};
   	}
   	
  +	/**
  +	 * If service is null the value is stored in this.attributes otherwise it is stored via the service.
  +	 */
  +	private void setAttribute(String key, Object value, PortalService service) {
  +		if (service == null) {
  +			this.attributes.put(key, value);
  +		} else {
  +			service.setAttribute(key, value);
  +		}
  +	}
  +	
  +	/**
  +	 * If service is null the value is requested from this.attributes otherwise it is stored via the service.
  +	 */
  +	private Object getAttribute(String key, PortalService service) {
  +		if (service == null) {
  +			return this.attributes.get(key);
  +		} else {
  +			return service.getAttribute(key);
  +		}
  +	}
  +
       public CopletInstanceData getCopletInstanceData(String copletID) {
           PortalService service = null;
           String attribute = null;
           try {
               service = (PortalService) this.manager.lookup(PortalService.ROLE);
   
  -			// TODO Change to KeyManager usage
  -			UserHandler handler = RequestState.getState().getHandler();
  -			attribute = SimpleProfileManager.class.getName()+"/"+service.getPortalName()+"/CopletInstanceData-user-"+handler.getUserId();
  -
  -/* 			TODO Must be changed for dynamic coplet creation.           
  - 
  - 			if (null == coplets) {
  -                coplets = new HashMap();
  -                service.setAttribute(attribute, coplets);
  -            }*/
  -			CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager)((Object[])service.getAttribute(attribute))[0];
  -
  -            CopletInstanceData cid = copletInstanceDataManager.getCopletInstanceData(copletID);
  -            if (null == cid) {
  -/* 				TODO Must be changed for dynamic coplet creation. 
  -
  -                CopletBaseData base = new CopletBaseData();
  -                base.setName("URICoplet");
  -                base.setCopletAdapterName("uri");
  -                base.setDefaultRendererName("window");
  -                cid = new CopletInstanceData();
  -                CopletData cd = new CopletData();
  -                cd.setName(copletID);
  -                cid.setCopletData(cd);
  -                cid.setCopletId(copletID); // TODO generate unique copletID
  -                cid.getCopletData().setCopletBaseData(base);
  -                cid.getCopletData().setAttribute("uri", copletID);
  -                cid.getCopletData().setTitle(copletID);
  -                coplets.put(key, cid);
  -
  -                Marshaller marshaller;
  -                try {
  -                    marshaller = new Marshaller(new PrintWriter(System.out));
  -                    marshaller.setSuppressXSIType(true);
  -                    marshaller.setMapping(layoutMapping);
  -                    marshaller.marshal(cid);
  -                } catch (Exception e) {
  -                    //e.printStackTrace();
  -                }*/
  -            }
  -            return cid;
  +			attribute = SimpleProfileManager.class.getName()+"/"+service.getPortalName()+"/CopletInstanceData";
  +			CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager)((Object[])this.attributes.get(attribute))[0];
  +
  +            return copletInstanceDataManager.getCopletInstanceData(copletID);
           } catch (ComponentException e) {
               // TODO Auto-generated catch block
               e.printStackTrace();
  @@ -542,41 +532,21 @@
           }
       }
   
  -    private void resolveParents(final Layout layout, final Item item, CopletInstanceDataManager manager)
  +    private void updateLayout(final Layout layout, final CopletInstanceDataManager manager)
       throws ProcessingException {
  -        String id = layout.getId();
  -        if ( id == null ) {
  -            throw new ProcessingException("Layout has no id " + layout.getName());
  -        }
  -
           if (layout instanceof CompositeLayout) {
  -
  -            final CompositeLayout compositeLayout = (CompositeLayout) layout;
  -
  +            final CompositeLayout compositeLayout = (CompositeLayout)layout;
               for (int j = 0; j < compositeLayout.getSize(); j++) {
                   final Item layoutItem = (Item) compositeLayout.getItem(j);
  -                layoutItem.setParent(compositeLayout);
  -                this.resolveParents(layoutItem.getLayout(), layoutItem, manager);
  +                this.updateLayout(layoutItem.getLayout(), manager);
               }
  -        }
  -        if (layout instanceof CopletLayout) {
  -			CopletLayout copletLayout = (CopletLayout)layout;
  -
  +        } else if (layout instanceof CopletLayout) {
  +			final CopletLayout copletLayout = (CopletLayout)layout;
   			if (manager != null) {
   				String copletId = copletLayout.getCopletInstanceData().getId();
   				copletLayout.setCopletInstanceData(manager.getCopletInstanceData(copletId)); 
   			}
  -
  -            // FIXME - move this simple test at a better place
  -            if ( copletLayout.getCopletInstanceData() == null ) {
  -                throw new ProcessingException("Layout " + copletLayout.getId() + " has no coplet instance data.");
  -            } else {
  -                if ( copletLayout.getCopletInstanceData().getCopletData() == null ) {
  -                    throw new ProcessingException("CopletInstanceData " + copletLayout.getCopletInstanceData().getId() + " has no coplet data.");
  -                }
  -            }
           }
  -        layout.setParent(item);
       }
   
   }
  
  
  
  1.3       +2 -1      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/Item.java
  
  Index: Item.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/Item.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Item.java	19 May 2003 12:50:59 -0000	1.2
  +++ Item.java	22 May 2003 15:19:43 -0000	1.3
  @@ -78,6 +78,7 @@
   	 */
   	public final void setLayout(Layout layout) {
   		this.layout = layout;
  +		layout.setParent(this);
   	}
       
       public final CompositeLayout getParent() {
  
  
  
  1.3       +3 -1      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/CompositeLayout.java
  
  Index: CompositeLayout.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/CompositeLayout.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CompositeLayout.java	19 May 2003 13:06:06 -0000	1.2
  +++ CompositeLayout.java	22 May 2003 15:19:43 -0000	1.3
  @@ -86,6 +86,7 @@
   	 */
   	public final void addItem(Item item) {
   		items.add(item);
  +		item.setParent(this);
   	}
   
   	/**
  @@ -114,6 +115,7 @@
       
       public final void removeItem(Item item) {
           this.items.remove(item);
  +        item.setParent(null);
       }
       
   }
  
  
  
  1.4       +1 -3      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
  
  Index: DefaultEventManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultEventManager.java	19 May 2003 14:10:12 -0000	1.3
  +++ DefaultEventManager.java	22 May 2003 15:19:43 -0000	1.4
  @@ -74,9 +74,7 @@
   import org.apache.cocoon.portal.event.Publisher;
   import org.apache.cocoon.portal.event.Register;
   import org.apache.cocoon.portal.event.Subscriber;
  -import org.apache.cocoon.portal.event.aspect.DefaultEventAspectContext;
   import org.apache.cocoon.portal.event.aspect.EventAspect;
  -import org.apache.cocoon.portal.event.aspect.EventAspectChain;
   import org.apache.cocoon.portal.event.aspect.impl.SizingEventSubscriber;
   import org.apache.cocoon.portal.event.subscriber.impl.DefaultLayoutAspectDataEventSubscriber;
   import org.apache.cocoon.portal.event.subscriber.impl.DefaultLayoutEventSubscriber;
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventAspectContext.java
  
  Index: DefaultEventAspectContext.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.event.impl;
  
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.avalon.framework.parameters.Parameters;
  import org.apache.cocoon.portal.PortalService;
  import org.apache.cocoon.portal.event.EventConverter;
  import org.apache.cocoon.portal.event.Publisher;
  import org.apache.cocoon.portal.event.aspect.EventAspect;
  import org.apache.cocoon.portal.event.aspect.EventAspectContext;
  
  /**
   *
   * @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: DefaultEventAspectContext.java,v 1.1 2003/05/22 15:19:43 cziegeler Exp $
   */
  public final class DefaultEventAspectContext 
      implements EventAspectContext {
  
      private EventAspectChain chain;
      
      private Iterator iterator;
      private Iterator configIterator;
      private Parameters config;
      
      private Publisher publisher;
      private Map objectModel;
      private EventConverter converter;
  
      public DefaultEventAspectContext(EventAspectChain chain) {
          this.chain = chain;
          this.iterator = chain.getIterator();
          this.configIterator = chain.getConfigIterator();
      }
      
  	/* (non-Javadoc)
  	 * @see org.apache.cocoon.portal.layout.renderer.RendererAspectContext#invokeNext(org.apache.cocoon.portal.layout.Layout, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler)
  	 */
  	public void invokeNext(PortalService service) {
  		if (iterator.hasNext()) {
              this.config = (Parameters) this.configIterator.next();
              final EventAspect aspect = (EventAspect) iterator.next();
              aspect.process( this, service );
  		}
  
  	}
  
  	/* (non-Javadoc)
  	 * @see org.apache.cocoon.portal.layout.renderer.RendererAspectContext#getConfiguration()
  	 */
  	public Parameters getAspectParameters() {
  		return this.config;
  	}
  
      /**
       * Get the encoder
       */
      public EventConverter getEventConverter(){
          return this.converter;
      }
      
      /**
       * Get the publisher
       */
      public Publisher getEventPublisher(){
          return this.publisher;
      }
      
      /**
       * Get the object model
       */
      public Map getObjectModel() {
          return this.objectModel;
      }
  
  	/**
  	 * @param converter
  	 */
  	public void setEventConverter(EventConverter converter) {
  		this.converter = converter;
  	}
  
  	/**
  	 * @param map
  	 */
  	public void setObjectModel(Map map) {
  		objectModel = map;
  	}
  
  	/**
  	 * @param publisher
  	 */
  	public void setEventPublisher(Publisher publisher) {
  		this.publisher = publisher;
  	}
  
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/EventAspectChain.java
  
  Index: EventAspectChain.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.event.impl;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentSelector;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.parameters.Parameters;
  
  /**
   *
   * @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: EventAspectChain.java,v 1.1 2003/05/22 15:19:43 cziegeler Exp $
   */
  public final class EventAspectChain {
      
      private List aspects = new ArrayList();
      
      private List configs = new ArrayList();
      
      public void configure(ComponentSelector selector, Configuration conf) 
      throws ConfigurationException {
          if ( conf != null ) {
              Configuration[] aspects = conf.getChildren("aspect");
              if ( aspects != null ) {
                  for(int i=0; i < aspects.length; i++) {
                      final Configuration current = aspects[i];
                      final String role = current.getAttribute("type");
                      try {
                          this.aspects.add(selector.select(role));
                          this.configs.add(Parameters.fromConfiguration(current));
                      } catch (ComponentException se) {
                          throw new ConfigurationException("Unable to lookup aspect " + role, se);
                      }
                  }
              }
          } else {
              throw new ConfigurationException("No aspects configured");
          }
      }
      
      public Iterator getIterator() {
          return this.aspects.iterator();
      }
      
      public Iterator getConfigIterator() {
          return this.configs.iterator();
      }
      
      public void dispose(ComponentSelector selector) {
          Iterator i = this.aspects.iterator();
          while (i.hasNext()) {
              selector.release((Component)i.next()); 
          }
          this.aspects.clear();
      }
  }
  
  
  
  1.3       +7 -4      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileLS.java
  
  Index: ProfileLS.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileLS.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ProfileLS.java	19 May 2003 09:14:10 -0000	1.2
  +++ ProfileLS.java	22 May 2003 15:19:43 -0000	1.3
  @@ -50,17 +50,20 @@
   */
   package org.apache.cocoon.portal.profile;
   
  +import java.util.Map;
  +
   import org.apache.excalibur.source.SourceValidity;
   
   /**
    *
    * @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>
  + * @author <a href="mailto:bluetkemeier@s-und-n.de">Björn Lütkemeier</a>
    * 
    * @version CVS $Id$
    */
   public interface ProfileLS {
  -    Object loadProfile(Object key) throws Exception;  //TODO define ExceptionType later
  -    void saveProfile(Object key, Object profile) throws Exception;  //TODO define ExceptionType later
  -    SourceValidity getValidity(Object key);
  +    Object loadProfile(Object key, Map map) throws Exception;  //TODO define ExceptionType later
  +    void saveProfile(Object key, Map map, Object profile) throws Exception;  //TODO define ExceptionType later
  +    SourceValidity getValidity(Object key, Map map);
   }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/ParameterFieldHandler.java
  
  Index: ParameterFieldHandler.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.impl;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.cocoon.portal.layout.Parameters;
  import org.exolab.castor.mapping.FieldHandler;
  import org.exolab.castor.mapping.MapItem;
  
  /**
   * Field handler for parameters.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Björn Lütkemeier</a>
   * 
   * @version CVS $Id: ParameterFieldHandler.java,v 1.1 2003/05/22 15:19:43 cziegeler Exp $
   */
  public class ParameterFieldHandler
  implements FieldHandler
  {
  	public void checkValidity(Object object)
  	{
  	}
  
  	public Object getValue(Object object) 
  	{
  		HashMap map = new HashMap();
  		Iterator iterator = ((Parameters)object).getParameters().entrySet().iterator();
  		Map.Entry entry;
  		Object key;
  		while (iterator.hasNext()) {
  			entry = (Map.Entry)iterator.next();
  			key = entry.getKey();
  			map.put(key, new MapItem(key, entry.getValue()));
  		}
  		return map;
  	}
  
  	public Object newInstance(Object parent)
  	{
  		return new MapItem();
  	}
  
  	public void resetValue(Object object)
  	{
  		((Parameters)object).getParameters().clear();
  	}
  
  	public void setValue(Object object, Object value)
  	{
  		MapItem item = (MapItem)value;
  		((Parameters)object).getParameters().put(item.getKey(), item.getValue());
  	}
  }
  
  
  
  1.2       +8 -2      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/CopletAdapter.java
  
  Index: CopletAdapter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/CopletAdapter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CopletAdapter.java	7 May 2003 06:22:29 -0000	1.1
  +++ CopletAdapter.java	22 May 2003 15:19:43 -0000	1.2
  @@ -56,7 +56,13 @@
   import org.xml.sax.SAXException;
   
   /**
  - *
  + * This is the "portlet" implementation.
  + * A coplet adapter is the interface between the portal engine and
  + * the implementation of a coplet.
  + * Usually there is only one instance of an adapter (= singleton). 
  + * Whenever an instance of this coplet is rendered, the
  + * adapter is invoked to render the coplet.
  + * 
    * @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>
    * 
  
  
  
  1.7       +3 -3      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/Aspectalizable.java
  
  Index: Aspectalizable.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/Aspectalizable.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Aspectalizable.java	22 May 2003 06:54:52 -0000	1.6
  +++ Aspectalizable.java	22 May 2003 15:19:44 -0000	1.7
  @@ -89,9 +89,9 @@
        * Return all persistent aspect datas 
        * @return A map of data objects, the keys are built by the aspect names
        */
  -    Map getPersistentAspectDatas();
  +    Map getPersistentAspectData();
   
  -    void addPersistenAspectData(String aspectName, Object data);
  +    void addPersistentAspectData(String aspectName, Object data);
       
       /**
        * Is this aspect supported
  
  
  
  1.2       +6 -1      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/util/DeltaApplicable.java
  
  Index: DeltaApplicable.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/util/DeltaApplicable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeltaApplicable.java	19 May 2003 09:14:11 -0000	1.1
  +++ DeltaApplicable.java	22 May 2003 15:19:44 -0000	1.2
  @@ -66,4 +66,9 @@
   	 * @throws ClassCastException If the object is not of the expected type.
   	 */
   	public boolean applyDelta(Object object);
  +	
  +	/**
  +	 * Checks if a delta has been applied.
  +	 */
  +	public boolean deltaApplied();
   }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/util/DeltaApplicableReferencesAdjustable.java
  
  Index: DeltaApplicableReferencesAdjustable.java
  ===================================================================
  /*
  
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
  
   Copyright (C) 1999-2003 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.util;
  
  /**
   * Interface for functionality of objects to be updated by a delta object 
   * and where references to contained DeltaApplicable objects can be adjusted 
   * if no delta has been applied to them.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Björn Lütkemeier</a>
   * 
   * @version CVS $Id: DeltaApplicableReferencesAdjustable.java,v 1.1 2003/05/22 15:19:44 cziegeler Exp $
   */
  public interface DeltaApplicableReferencesAdjustable 
  extends DeltaApplicable {
  	/**
  	 * Updates the references to contained DeltaApplicable objects  
       * if no delta has been applied to them.
  	 * @throws ClassCastException If the object is not of the expected type.
  	 */
  	public void adjustReferences(Object object);
  }
  
  
  
  1.6       +15 -1     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletData.java
  
  Index: CopletData.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletData.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CopletData.java	22 May 2003 12:32:47 -0000	1.5
  +++ CopletData.java	22 May 2003 15:19:45 -0000	1.6
  @@ -77,6 +77,11 @@
   
       protected Map attributes = new HashMap();
   
  +	/**
  +	 * Signals whether a delta has been applied.
  +	 */
  +	private boolean deltaApplied = false;
  +
       /**
        * Constructor
        */
  @@ -162,6 +167,8 @@
   	public boolean applyDelta(Object object) {
   		CopletData data = (CopletData)object;
   		
  +		this.deltaApplied = true;
  +		
   		Boolean maxpageable = data.maxpageable;
   		if (maxpageable != null)
   			this.maxpageable = maxpageable;
  @@ -202,5 +209,12 @@
   		}
   		
   		return true;
  +	}
  +	
  +	/**
  +	 * Checks if a delta has been applied.
  +	 */
  +	public boolean deltaApplied() {
  +		return this.deltaApplied;
   	}
   }
  
  
  
  1.2       +2 -2      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletFactory.java
  
  Index: CopletFactory.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CopletFactory.java	22 May 2003 12:32:47 -0000	1.1
  +++ CopletFactory.java	22 May 2003 15:19:45 -0000	1.2
  @@ -70,7 +70,7 @@
       void prepare(CopletInstanceData copletInstanceData)
       throws ProcessingException;
       
  -    CopletInstanceData newInstance(String name)
  +    CopletInstanceData newInstance(CopletData copletData)
       throws ProcessingException;
       
   }
  
  
  
  1.4       +53 -7     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- sitemap.xmap	19 May 2003 09:14:11 -0000	1.3
  +++ sitemap.xmap	22 May 2003 15:19:47 -0000	1.4
  @@ -30,13 +30,33 @@
    <map:pipelines>
    
     <map:component-configurations>
  -    <authentication-manager>
  -      <handlers>
  -        <handler name="portalhandler">
  -          <redirect-to uri="cocoon:/login"/>
  -          <authentication uri="cocoon:raw:/sunrise-authuser"/>
  -        </handler>
  -      </handlers>
  +	<authentication-manager>
  +		<handlers>
  +			<handler name="portalhandler">
  +				<redirect-to uri="cocoon:/login"/>
  +				<authentication uri="cocoon:raw:/sunrise-authuser"/>
  +				<applications>
  +					<application loadondemand="true" name="portal">
  +                		<configuration name="portal">
  +                			<profiles>
  +                				<copletbasedata-load uri="cocoon:raw:/load-global-profile?profile=copletbasedata"/>
  +	                			<copletdata-global-load uri="cocoon:raw:/load-global-profile?profile=copletdata"/>
  +    	            			<copletdata-role-load uri="cocoon:raw:/load-role-profile?profile=copletdata"/>
  +        	        			<copletdata-user-load uri="cocoon:raw:/load-user-profile?profile=copletdata"/>
  +            	    			<copletinstancedata-global-load uri="cocoon:raw:/load-global-profile?profile=copletinstancedata"/>
  +                				<copletinstancedata-role-load uri="cocoon:raw:/load-role-profile?profile=copletinstancedata"/>
  +                				<copletinstancedata-user-load uri="cocoon:raw:/load-user-profile?profile=copletinstancedata"/>
  +                				<copletinstancedata-user-save uri="cocoon:raw:/save-user-profile?profile=copletinstancedata"/>
  +                				<layout-global-load uri="cocoon:raw:/load-global-profile?profile=layout"/>
  +	                			<layout-role-load uri="cocoon:raw:/load-role-profile?profile=layout"/>
  +    	            			<layout-user-load uri="cocoon:raw:/load-user-profile?profile=layout"/>
  +        	        			<layout-user-save uri="cocoon:raw:/save-user-profile?profile=layout"/>
  +            	    		</profiles>
  +	            	    </configuration>
  +	            	</application>
  +	            </applications>
  +	        </handler>
  +		</handlers>
       </authentication-manager>
     </map:component-configurations>
     
  @@ -54,6 +74,7 @@
       <map:match pattern="portal">
           <map:act type="auth-protect">
             <map:parameter name="handler" value="portalhandler"/> 
  +          <map:parameter name="application" value="portal"/> 
   
             <map:generate type="portal" label="content">
           	<map:parameter name="portal-name" value="portal" />
  @@ -109,6 +130,7 @@
       <map:match pattern="loggedin">
   		<map:act type="auth-protect">
   		  <map:parameter name="handler" value="portalhandler"/> 
  +          <map:parameter name="application" value="portal"/> 
   		  
             <map:generate src="resources/logged-in.xml"/>
             <map:transform src="styles/header.xsl"/>
  @@ -121,6 +143,8 @@
       <map:match pattern="logout">
   		<map:act type="auth-protect">
   		  <map:parameter name="handler" value="portalhandler"/> 
  +          <map:parameter name="application" value="portal"/> 
  +
   		  <map:act type="auth-logout"/>
           </map:act>
   <!-- TODO logout??? -->
  @@ -136,6 +160,28 @@
           <map:parameter name="use-request-parameters" value="true"/>
         </map:transform>
         <map:serialize type="xml"/>
  +    </map:match>
  +
  +    <map:match pattern="load-global-profile">
  +    	<map:generate src="profiles/{request-param:profile}/{request-param:portal}.xml"/>
  +    	<map:serialize type="xml"/>
  +    </map:match>
  +
  +    <map:match pattern="load-role-profile">
  +    	<map:generate src="profiles/{request-param:profile}/{request-param:portal}-role-{request-param:role}.xml"/>
  +    	<map:serialize type="xml"/>
  +    </map:match>
  +
  +    <map:match pattern="load-user-profile">
  +    	<map:generate src="profiles/{request-param:profile}/{request-param:portal}-user-{request-param:user}.xml"/>
  +    	<map:serialize type="xml"/>
  +    </map:match>
  +
  +    <map:match pattern="save-user-profile">
  +    	<map:generate src="resources/save-user-profile.xml"/>
  +        <map:transform type="session"/>
  +        <map:transform type="write-source"/>
  +    	<map:serialize type="xml"/>
       </map:match>
     </map:pipeline>
   
  
  
  
  1.5       +16 -12    cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/AbstractAspectalizable.java
  
  Index: AbstractAspectalizable.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/AbstractAspectalizable.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractAspectalizable.java	22 May 2003 06:54:52 -0000	1.4
  +++ AbstractAspectalizable.java	22 May 2003 15:19:48 -0000	1.5
  @@ -50,9 +50,8 @@
   */
   package org.apache.cocoon.portal.aspect.impl;
   
  -import java.util.ArrayList;
  +import java.util.HashMap;
   import java.util.Iterator;
  -import java.util.List;
   import java.util.Map;
   
   import org.apache.cocoon.portal.aspect.AspectDataHandler;
  @@ -70,7 +69,7 @@
   
       transient protected AspectDataHandler aspectDataHandler;
       
  -    transient protected List persistentDatas;
  +    transient protected Map persistentDatas;
       
       /**
        * Is this aspect supported
  @@ -91,8 +90,12 @@
           return this.aspectDataHandler.getAspectDatas(this);
       }
       
  -    public Map getPersistentAspectDatas(){
  -        return this.aspectDataHandler.getPersistentAspectDatas(this);
  +    public Map getPersistentAspectData(){
  +    	if (this.aspectDataHandler == null) {
  +	    	return this.persistentDatas;
  +    	} else {
  +			return this.aspectDataHandler.getPersistentAspectDatas(this);
  +    	}
       }
   
       /**
  @@ -101,20 +104,21 @@
       public void setAspectDataHandler(AspectDataHandler handler) {
           this.aspectDataHandler = handler;
           if ( this.persistentDatas != null ) {
  -            Iterator iter = this.persistentDatas.iterator();
  +            Iterator iter = this.persistentDatas.entrySet().iterator();
  +            Map.Entry entry;
               while (iter.hasNext()) {
  -                Object[] o = (Object[])iter.next();
  -                handler.setAspectData(this, (String)o[0], o[1]);
  +                entry = (Map.Entry)iter.next();
  +                handler.setAspectData(this, (String)entry.getKey(), entry.getValue());
               }
               this.persistentDatas = null;
           }
       }
   
  -    public void addPersistenAspectData(String aspectName, Object data) {
  +    public void addPersistentAspectData(String aspectName, Object data) {
           if ( this.persistentDatas == null ) {
  -            this.persistentDatas = new ArrayList();
  +            this.persistentDatas = new HashMap();
           }
  -        this.persistentDatas.add(new Object[] {aspectName, data});
  +        this.persistentDatas.put(aspectName, data);
       }
   
   }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/MapItem.java
  
  Index: MapItem.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.aspect.impl;
  
  
  /**
   * Used by the AspectDataFieldHandler for Castor.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Björn Lütkemeier</a>
   * 
   * @version CVS $Id: MapItem.java,v 1.1 2003/05/22 15:19:47 cziegeler Exp $
   */
  public class MapItem
  extends org.exolab.castor.mapping.MapItem {
  
  	public MapItem() {
  		super();
  	}
  
  	public MapItem(Object key, Object value) {
  		super(key, value);
  	}
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/AspectDataFieldHandler.java
  
  Index: AspectDataFieldHandler.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.aspect.impl;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.cocoon.portal.aspect.Aspectalizable;
  import org.exolab.castor.mapping.FieldHandler;
  
  /**
   * Field handler for aspects of an Aspectizable object.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Björn Lütkemeier</a>
   * 
   * @version CVS $Id: AspectDataFieldHandler.java,v 1.1 2003/05/22 15:19:48 cziegeler Exp $
   */
  public class AspectDataFieldHandler
  implements FieldHandler
  {
  	public void checkValidity(Object object)
  	{
  	}
  
  	public Object getValue(Object object) 
  	{
  		HashMap map = new HashMap();
  		Iterator iterator;
  
  		Map data = ((Aspectalizable) object).getPersistentAspectData();
  		if (data == null)
  			return map;
  
  		iterator = data.entrySet().iterator();
  		Map.Entry entry;
  		Object key;
  		while (iterator.hasNext()) {
  			entry = (Map.Entry)iterator.next();
  			key = entry.getKey();
  			map.put(key, new MapItem(key, entry.getValue()));
  		}
  		return map;
  	}
  
  	public Object newInstance(Object parent)
  	{
  		return new MapItem();
  	}
  
  	public void resetValue(Object object)
  	{
  		// impossible
  	}
  
  	public void setValue(Object object, Object value)
  	{
  		MapItem item = (MapItem)value;
  		((Aspectalizable)object).addPersistentAspectData((String)item.getKey(), item.getValue());
  	}
  }
  
  
  
  1.2       +22 -3     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl/DefaultCopletFactory.java
  
  Index: DefaultCopletFactory.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/impl/DefaultCopletFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultCopletFactory.java	22 May 2003 12:32:47 -0000	1.1
  +++ DefaultCopletFactory.java	22 May 2003 15:19:48 -0000	1.2
  @@ -74,6 +74,7 @@
   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.coplet.adapter.CopletAdapter;
   
   /**
    * This factory is for creating and managing coplet objects
  @@ -137,8 +138,9 @@
       }
   
       
  -    public CopletInstanceData newInstance(String name)
  +    public CopletInstanceData newInstance(CopletData copletData)
       throws ProcessingException {
  +        String name = copletData.getName();
           Object[] o = (Object[]) this.coplets.get( name );
               
           if ( o == null ) {
  @@ -153,7 +155,24 @@
           instance.initialize( name, id );
           instance.setDescription( copletDescription );
           instance.setAspectDataHandler((AspectDataHandler)o[2]);
  -
  +        instance.setCopletData(copletData);
  +        
  +        // now lookup the adapter
  +        final String adapterName = copletData.getCopletBaseData().getCopletAdapterName();
  +        CopletAdapter adapter = null;
  +        ComponentSelector adapterSelector = null;
  +        try {
  +            adapterSelector = (ComponentSelector) this.manager.lookup( CopletAdapter.ROLE + "Selector");
  +            adapter = (CopletAdapter)adapterSelector.select( adapterName );
  +            adapter.init( instance );
  +        } catch (ComponentException ce) {
  +            throw new ProcessingException("Unable to lookup coplet adapter selector or adaptor.", ce);
  +        } finally {
  +            if ( adapterSelector != null) {
  +                adapterSelector.release( adapter );
  +            }
  +            this.manager.release( adapterSelector );
  +        }
           return instance;
       }
       
  
  
  
  1.4       +2 -1      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/URICopletAdapter.java
  
  Index: URICopletAdapter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/adapter/impl/URICopletAdapter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- URICopletAdapter.java	20 May 2003 14:32:37 -0000	1.3
  +++ URICopletAdapter.java	22 May 2003 15:19:48 -0000	1.4
  @@ -87,6 +87,7 @@
   
       /** The source resolver */
       protected SourceResolver resolver;
  +    
       /**
        * @see org.apache.avalon.framework.component.Composable#compose(ComponentManager)
        */
  
  
  
  1.3       +5 -8      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/components/persistance/CastorSourceConverter.java
  
  Index: CastorSourceConverter.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/components/persistance/CastorSourceConverter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CastorSourceConverter.java	19 May 2003 09:14:11 -0000	1.2
  +++ CastorSourceConverter.java	22 May 2003 15:19:48 -0000	1.3
  @@ -50,8 +50,8 @@
   */
   package org.apache.cocoon.components.persistance;
   
  +import java.io.BufferedWriter;
   import java.io.InputStream;
  -import java.io.OutputStreamWriter;
   import java.io.Writer;
   import java.util.HashMap;
   import java.util.Iterator;
  @@ -69,7 +69,6 @@
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.components.source.SourceUtil;
  -import org.apache.excalibur.source.ModifiableSource;
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceResolver;
   import org.exolab.castor.mapping.Mapping;
  @@ -96,9 +95,8 @@
       private ComponentManager manager;
       private Map mappings = new HashMap();
   
  -    public Object getObject(Source source, String name) throws ConverterException {
  +    public Object getObject(InputStream stream, String name) throws ConverterException {
           try {
  -			InputStream stream = source.getInputStream();
               Unmarshaller unmarshaller = new Unmarshaller((Mapping)this.mappings.get(name));
               Object result = unmarshaller.unmarshal(new InputSource(stream));
               stream.close();
  @@ -110,10 +108,9 @@
           }
       }
   
  -	public void storeObject(ModifiableSource source, String name, Object object) throws ConverterException {
  +	public void storeObject(Writer writer, String name, Object object) throws ConverterException {
   		try {
  -			Writer writer = new OutputStreamWriter(source.getOutputStream());
  -			Marshaller marshaller = new Marshaller(writer);
  +			Marshaller marshaller = new Marshaller(new BufferedWriter(writer));
   			Mapping mapping = new Mapping();
   			marshaller.setMapping((Mapping)this.mappings.get(name));
   			marshaller.marshal(object);
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/resources/save-user-profile.xml
  
  Index: save-user-profile.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- $Id: save-user-profile.xml,v 1.1 2003/05/22 15:19:48 cziegeler Exp $ 
   Description: This resource save the user profile to a file.
  
  -->
  
  <user xmlns:source="http://apache.org/cocoon/source/1.0" xmlns:session="http://apache.org/cocoon/session/1.0">
      <source:insert>
      	<source:source>profiles/<session:getxml context="request" path="/parameter/profile"/>/<session:getxml context="request" path="/parameter/portal"/>-user-<session:getxml context="request" path="/parameter/user"/>.xml</source:source>
          <source:path>/</source:path>
          <source:fragment><session:getxml context="request" path="/parameter/content"/></source:fragment>
          <source:replace>*</source:replace>
      </source:insert>
  </user>
  
  
  

Mime
View raw message