You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2003/05/19 11:14:12 UTC

cvs commit: cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/components/persistance CastorSourceConverter.java

cziegeler    2003/05/19 02:14:11

  Modified:    src/blocks/portal/samples/profiles/mapping layout.xml
               src/blocks/portal/java/org/apache/cocoon/portal/coplet
                        CopletInstanceData.java CopletData.java
                        CopletBaseData.java
               src/blocks/portal/java/org/apache/cocoon/portal/profile/impl
                        SimpleProfileManager.java
               src/blocks/portal/java/org/apache/cocoon/portal/profile
                        ProfileLS.java
               src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl
                        AbstractCIncludeAspect.java
               src/blocks/portal/conf portal.xconf
               src/blocks/portal/samples/profiles/layout portal.xml
               src/blocks/portal/samples sitemap.xmap
               src/blocks/portal/java/org/apache/cocoon/components/persistance
                        CastorSourceConverter.java
  Added:       src/blocks/portal/samples/profiles/mapping
                        copletbasedata.xml copletdata.xml
                        copletinstancedata.xml
               src/blocks/portal/samples/resources sunrise-user.xml
                        login-error.xml login.xml logged-in.xml
               src/blocks/portal/java/org/apache/cocoon/portal/profile/impl
                        CopletInstanceDataReferenceFieldHandler.java
                        CopletDataManager.java
                        CopletBaseDataReferenceFieldHandler.java
                        CopletDataReferenceFieldHandler.java
                        ReferenceFieldHandler.java MapSourceAdapter.java
                        CopletInstanceDataManager.java
                        ConfigurationFieldHandler.java
                        CopletBaseDataManager.java
                        AttributesFieldHandler.java
               src/blocks/portal/samples/styles login-html.xsl
                        sunrise-user.xsl
               src/blocks/portal/samples/profiles/copletbasedata portal.xml
               src/blocks/portal/java/org/apache/cocoon/portal/util
                        DeltaApplicable.java
               src/blocks/portal/samples/profiles/copletinstancedata
                        portal.xml
               src/blocks/portal/samples/profiles/copletdata portal.xml
  Removed:     src/blocks/portal/java/org/apache/cocoon/portal/profile/impl
                        ParameterSourceAdapter.java
  Log:
  Updating portal framework
  
  Revision  Changes    Path
  1.2       +8 -6      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- layout.xml	7 May 2003 06:22:21 -0000	1.1
  +++ layout.xml	19 May 2003 09:14:05 -0000	1.2
  @@ -39,12 +39,7 @@
           <map-to xml="column-layout" />
       </class>
   
  -    <class name="org.apache.cocoon.portal.layout.impl.CopletLayout" auto-complete="false"
  -           extends="org.apache.cocoon.portal.layout.AbstractLayout">
  -        <map-to xml="coplet-layout" />
  -    </class>
  -    
  -    <class name="org.apache.cocoon.portal.layout.impl.FrameLayout"
  +   <class name="org.apache.cocoon.portal.layout.impl.FrameLayout"
              extends="org.apache.cocoon.portal.layout.AbstractLayout">
           <map-to xml="frame-layout" />
           <field name="source" type="java.lang.String" />
  @@ -78,6 +73,13 @@
       <class name="org.apache.cocoon.portal.layout.impl.RowLayout"
              extends="org.apache.cocoon.portal.layout.impl.CompositeLayout">
           <map-to xml="row-layout" />
  +    </class>
  +
  +    <class name="org.apache.cocoon.portal.layout.impl.CopletLayout" auto-complete="false"
  +           extends="org.apache.cocoon.portal.layout.AbstractLayout">
  +        <map-to xml="coplet-layout" />
  +
  +		<field name="copletInstanceData" type="java.lang.String" handler="org.apache.cocoon.portal.profile.impl.CopletInstanceDataReferenceFieldHandler"/>
       </class>
   
       <class name="org.apache.cocoon.portal.layout.impl.TabLayout"
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/profiles/mapping/copletbasedata.xml
  
  Index: copletbasedata.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <mapping>
  	<description>Coplet base data mapping file</description>
  
  	<class name="org.apache.cocoon.portal.profile.impl.CopletBaseDataManager">
  		<map-to xml="coplets" />
  
  		<field name="copletBaseData" type="org.apache.cocoon.portal.coplet.CopletBaseData" collection="map">
  			<bind-xml auto-naming="deriveByClass" />
  		</field>
  	</class>
  
  	<class name="org.apache.cocoon.portal.coplet.CopletBaseData">
  		<map-to xml="coplet-base-data" />
  
  		<field name="name" type="java.lang.String">
  			<bind-xml name="name" node="attribute" />
  		</field>
  
  		<field name="copletAdapterName" type="java.lang.String">
  			<bind-xml name="coplet-adapter" />
  		</field>
  
  		<field name="defaultRendererName" type="java.lang.String">
  			<bind-xml name="default-renderer" />
  		</field>
  
  		<field name="copletConfig" type="org.exolab.castor.mapping.MapItem" collection="map" handler="org.apache.cocoon.portal.profile.impl.ConfigurationFieldHandler">
  			<bind-xml name="configuration"/>
  		</field>
  	</class>
     
  	<class name="org.exolab.castor.mapping.MapItem">
  		<field name="key" type="java.lang.String">
  			<bind-xml name="name"/>
  		</field>
  
  		<field name="value">
  			<bind-xml name="value"/>
  		</field>
  	</class>
  </mapping>
  
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/profiles/mapping/copletdata.xml
  
  Index: copletdata.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <mapping>
  	<description>Coplet data mapping file</description>
  
  	<class name="org.apache.cocoon.portal.profile.impl.CopletDataManager">
  		<map-to xml="coplets" />
  
  		<field name="copletData" type="org.apache.cocoon.portal.coplet.CopletData" collection="map">
  			<bind-xml auto-naming="deriveByClass"/>
  		</field>
  	</class>
  
  	<class name="org.apache.cocoon.portal.coplet.CopletData">
  		<map-to xml="coplet-data" />
  
  		<field name="name" type="java.lang.String">
  			<bind-xml name="name" node="attribute" />
  		</field>
  
  		<field name="title" type="java.lang.String">
  			<bind-xml name="title"/>
  		</field>
  
  		<field name="maxpageable" type="java.lang.Boolean">
  			<bind-xml name="maxpageable" />
  		</field>
  
  		<field name="removable" type="java.lang.Boolean">
  			<bind-xml name="removable" />
  		</field>
  
  		<field name="attributes" type="org.exolab.castor.mapping.MapItem" collection="map" handler="org.apache.cocoon.portal.profile.impl.AttributesFieldHandler">
  			<bind-xml name="attribute"/>
  		</field>
  
  		<field name="copletBaseData" type="java.lang.String" handler="org.apache.cocoon.portal.profile.impl.CopletBaseDataReferenceFieldHandler"/>
  	</class>
     
  	<class name="org.exolab.castor.mapping.MapItem">
  		<field name="key" type="java.lang.String">
  			<bind-xml name="name"/>
  		</field>
  
  		<field name="value">
  			<bind-xml name="value"/>
  		</field>
  	</class>
  </mapping>
  
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/profiles/mapping/copletinstancedata.xml
  
  Index: copletinstancedata.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <mapping>
  	<description>Coplet instance data mapping file</description>
  
  	<class name="org.apache.cocoon.portal.profile.impl.CopletInstanceDataManager">
  		<map-to xml="coplets" />
  
  		<field name="copletInstanceData" type="org.apache.cocoon.portal.coplet.CopletInstanceData" collection="map">
  			<bind-xml auto-naming="deriveByClass"/>
  		</field>
  	</class>
  
  	<class name="org.apache.cocoon.portal.coplet.CopletInstanceData">
  		<map-to xml="coplet-instance-data" />
  
  		<field name="copletId" type="java.lang.String">
  			<bind-xml name="id" node="attribute" />
  		</field>
  
  		<field name="status" type="java.lang.Integer">
  			<bind-xml name="status"/>
  		</field>
  
  		<field name="copletData" type="java.lang.String" handler="org.apache.cocoon.portal.profile.impl.CopletDataReferenceFieldHandler"/>
  	</class>
  </mapping>
  
  
  
  
  1.2       +13 -4     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
  
  Index: CopletInstanceData.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CopletInstanceData.java	7 May 2003 06:22:29 -0000	1.1
  +++ CopletInstanceData.java	19 May 2003 09:14:06 -0000	1.2
  @@ -50,14 +50,19 @@
   */
   package org.apache.cocoon.portal.coplet;
   
  +import org.exolab.castor.mapping.MapItem;
  +
   /**
    *
    * @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 final class CopletInstanceData {
  +public final class CopletInstanceData
  +//	extending MapItem used for Castor map workaround 
  +extends MapItem {
   
   	public final static int STATUS_MINIMIZED = 0;
   	public final static int STATUS_MAXIMIZED = 1;
  @@ -66,13 +71,14 @@
       
   	private CopletData copletData;
   
  -	protected int status;
  +	protected int status = STATUS_MAXIMIZED;
   
   	/**
   	 * Constructor
   	 */
   	public CopletInstanceData() {
  -		this.status = STATUS_MAXIMIZED;
  +		// used for Castor map workaround
  +		this.setValue(this);
   	}
   
   	/**
  @@ -89,6 +95,9 @@
   	 */
   	public void setCopletId(String copletId) {
   		this.copletId = copletId;
  +
  +		// used for Castor map workaround
  +		this.setKey(copletId);
   	}
   
   	/**
  
  
  
  1.2       +105 -13   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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CopletData.java	7 May 2003 06:22:29 -0000	1.1
  +++ CopletData.java	19 May 2003 09:14:07 -0000	1.2
  @@ -51,24 +51,32 @@
   package org.apache.cocoon.portal.coplet;
   
   import java.util.HashMap;
  +import java.util.Iterator;
   import java.util.Map;
   
  +import org.apache.cocoon.portal.util.DeltaApplicable;
  +import org.exolab.castor.mapping.MapItem;
  +
   /**
    *
    * @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 class CopletData {
  +public class CopletData 
  +//extending MapItem used for Castor map workaround 
  +extends MapItem 
  +implements DeltaApplicable {
   
       protected String name;
   
       protected String title;
   
  -    protected boolean maxpageable;
  +    protected Boolean maxpageable;
       
  -    protected boolean removable;
  +    protected Boolean removable;
   
       protected CopletBaseData copletBaseData;
   
  @@ -78,8 +86,8 @@
        * Constructor
        */
       public CopletData() {
  -        this.maxpageable = true;
  -        this.removable = true;
  +		// used for Castor map workaround
  +		this.setValue(this);
       }
   
       public String getName() {
  @@ -88,30 +96,57 @@
   
       public void setName(String name) {
           this.name = name;
  +
  +		// used for Castor map workaround
  +		this.setKey(name);
       }
   
       /**
  -      * Returns the maxpageable.
  +      * Returns the maxpageable as boolean. If it has not been set "true" is returned.
         * @return boolean
         */
       public boolean isMaxpageable() {
  -        return maxpageable;
  +    	if (this.maxpageable == null) {
  +			return true;
  +    	} else {
  +			return this.maxpageable.booleanValue();
  +    	}
       }
   
       /**
  -     * Returns the removable.
  +     * Returns the removable as boolean. If it has not been set "true" is returned.
        * @return boolean
        */
       public boolean isRemovable() {
  -        return removable;
  -    }
  +		if (this.removable == null) {
  +			return true;
  +		} else {
  +			return this.removable.booleanValue();
  +		}
  +    }
  +
  +	/**
  +	  * Returns the maxpageable as Boolean.
  +	  * @return boolean
  +	  */
  +	public Boolean getMaxpageable() {
  +		return this.maxpageable;
  +	}
  +
  +	/**
  +	 * Returns the removable as Boolean.
  +	 * @return boolean
  +	 */
  +	public Boolean getRemovable() {
  +		return this.removable;
  +	}
   
       /**
        * Sets the maxpageable.
        * @param maxpageable The maxpageable to set
        */
       public void setMaxpageable(boolean maxpageable) {
  -        this.maxpageable = maxpageable;
  +        this.maxpageable = new Boolean(maxpageable);
       }
   
       /**
  @@ -119,7 +154,7 @@
        * @param removable The removable to set
        */
       public void setRemovable(boolean removable) {
  -        this.removable = removable;
  +        this.removable = new Boolean(removable);
       }
   
       /**
  @@ -161,4 +196,61 @@
       public void setAttribute(String key, Object value) {
           this.attributes.put(key, value);
       }
  +    
  +    public Map getAttributes() {
  +    	return this.attributes;
  +    }
  +	
  +	/**
  +	 * Applies the specified delta.
  +	 * @throws ClassCastException If the object is not of the expected type.
  +	 */
  +	public boolean applyDelta(Object object) {
  +		CopletData data = (CopletData)object;
  +		
  +		Boolean maxpageable = data.maxpageable;
  +		if (maxpageable != null)
  +			this.maxpageable = maxpageable;
  +		
  +		Boolean removable = data.removable;
  +		if (removable != null)
  +			this.removable = removable;
  +
  +		String title = data.getTitle();
  +		if (title != null)
  +			this.setTitle(title);
  +			
  +		CopletBaseData copletBaseData = data.getCopletBaseData();
  +		if (copletBaseData != null)	{
  +			this.setCopletBaseData(copletBaseData);
  +		}
  +			
  +		Iterator iterator = data.getAttributes().entrySet().iterator();
  +		Object attribute, delta;
  +		String key;
  +		Map.Entry entry;
  +		while (iterator.hasNext()) {
  +			entry = (Map.Entry)iterator.next();
  +			key = (String)entry.getKey();
  +			delta = entry.getValue();
  +
  +			attribute = this.getAttribute(key);
  +			if (attribute == null) {
  +				// add new attribute
  +				this.setAttribute(key, delta);
  +			} else if (attribute instanceof DeltaApplicable) {
  +				// apply delta
  +				boolean success = ((DeltaApplicable)attribute).applyDelta(delta);
  +				if (!success) {
  +					// replace attribute
  +					this.setAttribute(key, delta);
  +				}
  +			} else {
  +				// replace attribute
  +				this.setAttribute(key, delta);
  +			}
  +		}
  +		
  +		return true;
  +	}
   }
  
  
  
  1.2       +15 -6     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletBaseData.java
  
  Index: CopletBaseData.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletBaseData.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CopletBaseData.java	7 May 2003 06:22:29 -0000	1.1
  +++ CopletBaseData.java	19 May 2003 09:14:07 -0000	1.2
  @@ -53,25 +53,31 @@
   import java.util.HashMap;
   import java.util.Map;
   
  +import org.exolab.castor.mapping.MapItem;
  +
   /**
    *
    * @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 final class CopletBaseData {
  +public final class CopletBaseData
  +// extending MapItem used for Castor map workaround 
  +extends MapItem { 
   
  -	private Map copletConfig;
  +	private Map copletConfig = new HashMap();
   
   	private String name;
   
  -	private String copletAdapterName;
  +	private String copletAdapterName = null;
   
  -	private String defaultRendererName;
  +	private String defaultRendererName = null;
   
   	public CopletBaseData() {
  -		this.copletConfig = new HashMap();
  +		// used for Castor map workaround
  +		this.setValue(this);
   	}
   
   	public String getName() {
  @@ -80,6 +86,9 @@
   
   	public void setName(String name) {
   		this.name = name;
  +
  +		// used for Castor map workaround
  +		this.setKey(name);
   	}
   
   	public String getCopletAdapterName() {
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/resources/sunrise-user.xml
  
  Index: sunrise-user.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  
  <!-- $Id: sunrise-user.xml,v 1.1 2003/05/19 09:14:07 cziegeler Exp $ 
   Description: All portal users
  
  -->
  
  <authentication>
  	<users>
  		<user>
  			<name>cocoon</name>
  			<password>cocoon</password>
  			<role>admin</role>
              <title>Mr.</title>
  			<firstname>Walter</firstname>
              <lastname>Cocoon</lastname>
  			<company/>
              <street/>
  			<zipcode/>
              <city/>
  			<country/>
              <phone/>
              <fax/>
  			<email/>
              <bankid/>
  			<bankname/>
              <accountid/>
  		</user>
  		<user>
  			<name>guest</name>
              <password>guest</password>
  			<role>guest</role>
              <title>Mrs.</title>
  			<firstname>G.</firstname>
              <lastname>Guest</lastname>
  			<company>Cocoon</company>
              <street>Cocoon Street</street>
  			<zipcode>33100</zipcode>
              <city>Cocooncity</city>
  			<country>Somewhere</country>
              <phone/>
              <fax/>
  			<email>guest</email>
              <bankid/>
  			<bankname/>
              <accountid/>
  		</user>
  	</users>
  </authentication>
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/resources/login-error.xml
  
  Index: login-error.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- $Id: login-error.xml,v 1.1 2003/05/19 09:14:07 cziegeler Exp $ 
  
  -->
  
  <table width="100%" border="0" cellpadding="0" cellspacing="0"><tbody>
  	<tr align="center"> 
  		<td>
  			<br/>
  			<font face="Arial, Helvetica, sans-serif" size="2">
  				<b>The Login was not successful.</b>
  			</font>
  			<br/><br/>
  	      	<font face="Arial, Helvetica, sans-serif" size="2">
  				<a href="login" target="_top"><b>Please try it again.</b></a>
  			</font>
  		</td>
  	</tr>
  </tbody></table>
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/resources/login.xml
  
  Index: login.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- $Id: login.xml,v 1.1 2003/05/19 09:14:09 cziegeler Exp $ 
   Description: The login form for the portal
  
  -->
  
  <content>
  	<form>
  		<url>auth?resource=portal</url>
  		<field name="name" type="text" length="24" description="User"/>
  		<field name="password" type="password" length="10" description="Password"/>
  	</form>
  </content>
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/resources/logged-in.xml
  
  Index: logged-in.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- $Id: logged-in.xml,v 1.1 2003/05/19 09:14:09 cziegeler Exp $ 
  
  -->
  
  <table width="100%" border="0" cellpadding="0" cellspacing="0"><tbody>
  	<tr align="center"> 
  		<td>
  	      	<font face="Arial, Helvetica, sans-serif" size="2"><b>
  			<p>
  				<center>You are already logged in.</center>
  			</p>
  			<p>
  				<center>
  					Please <a target="_top" href="logout">log out first</a>
  				</center>
  			</p>
  			<p><center> or </center></p>
  			<p>
  				<center>
  					<a target="_top" href="portal">use your current login.</a>
  				</center>
  			</p>
  	      	</b></font>
  		</td>
  	</tr>
  </tbody></table>
  
  
  
  
  1.2       +366 -46   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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SimpleProfileManager.java	7 May 2003 06:22:24 -0000	1.1
  +++ SimpleProfileManager.java	19 May 2003 09:14:09 -0000	1.2
  @@ -50,7 +50,6 @@
   */
   package org.apache.cocoon.portal.profile.impl;
   
  -import java.io.PrintWriter;
   import java.util.HashMap;
   import java.util.Map;
   
  @@ -59,12 +58,10 @@
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.avalon.framework.component.Composable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.thread.ThreadSafe;
  +import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.portal.PortalService;
   import org.apache.cocoon.portal.aspect.AspectStatus;
  -import org.apache.cocoon.portal.coplet.CopletBaseData;
  -import org.apache.cocoon.portal.coplet.CopletData;
   import org.apache.cocoon.portal.coplet.CopletInstanceData;
   import org.apache.cocoon.portal.coplet.status.SizeableStatus;
   import org.apache.cocoon.portal.layout.AbstractLayout;
  @@ -73,14 +70,18 @@
   import org.apache.cocoon.portal.layout.impl.CompositeLayout;
   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.webapps.authentication.user.RequestState;
  +import org.apache.cocoon.webapps.authentication.user.UserHandler;
  +import org.apache.excalibur.source.SourceNotFoundException;
   import org.apache.excalibur.source.SourceValidity;
   import org.exolab.castor.mapping.Mapping;
  -import org.exolab.castor.xml.Marshaller;
   
   /**
    *
    * @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$
    */
  @@ -106,7 +107,6 @@
        */
       public Layout getPortalLayout(String key) {
           PortalService service = null;
  -        ParameterSourceAdapter adapter = null;
           try {
               service = (PortalService) this.componentManager.lookup(PortalService.ROLE);
               
  @@ -116,57 +116,364 @@
                       return l;
                   }
               }
  +            
  +            String portalPrefix = "/"+service.getPortalName();
   
  -            Object[] objects = (Object[]) service.getAttribute(SimpleProfileManager.class.getName() + "/Layout");
  +			// 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();
  +
  +			// 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;
  +
  +			// 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);
  +			}
  +			lastLoaded = loaded;
  +
  +			// 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);
  +			}
   
  -            int valid = SourceValidity.INVALID;
  -            SourceValidity sourceValidity = null;
  -            if (objects != null) {
  -                sourceValidity = (SourceValidity) objects[1];
  -                valid = sourceValidity.isValid();
  -                if (valid == SourceValidity.VALID)
  -                    return (Layout) objects[0];
  -            }
  -            adapter = (ParameterSourceAdapter) this.componentManager.lookup(ParameterSourceAdapter.ROLE);
  -            Parameters param = new Parameters();
  -            param.setParameter("portalname", service.getPortalName());
  -            SourceValidity newValidity = adapter.getValidity(param);
  -            if (valid == SourceValidity.UNKNWON) {
  -                if (sourceValidity.isValid(newValidity) == SourceValidity.VALID)
  -                    return (Layout) objects[0];
  -            }
  -            Layout layout = (Layout) adapter.loadProfile(param);
  -            if (newValidity != null) {
  -                objects = new Object[] { layout, newValidity };
  -                service.setAttribute(SimpleProfileManager.class.getName() + "/Layout", objects);
  -            }
  -            // resolve parents
  -            resolveParents(layout, null);
               return layout;
           } catch (Exception ce) {
               // TODO
               throw new CascadingRuntimeException("Arg", ce);
           } finally {
               this.componentManager.release(service);
  -            this.componentManager.release(adapter);
           }
       }
  +    
  +    /**
  +     * Gets a profile and applies possible user and role deltas to it.
  +     * @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) 
  +    throws Exception {
  +    	Object[] result;
  +    	
  +		// TODO Change key access to KeyManager usage
  +		Map map = (Map)key;
  +		
  +		// check validities
  +		map.remove("type");
  +		Object[] globalValidity = this.getValidity(map, location+"-global", service);
  +		map.put("type", "role");
  +		Object[] roleValidity = this.getValidity(map, location+"-role-"+map.get("role"), service);
  +		map.put("type", "user");
  +		Object[] userValidity = this.getValidity(map, location+"-user-"+map.get("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");
  +
  +			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);
  +			result = new Object[] {object, Boolean.TRUE};
  +		
  +			// load role delta
  +			map.put("type", "role");
  +			result = this.getProfile(map, location+"-role-"+map.get("role"), roleValidity, service);
  +			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);
  +			if (((Boolean)result[1]).booleanValue())
  +				object.applyDelta(result[0]);
  +			
  +			result = new Object[] {object, Boolean.TRUE}; 		
  +		}
  +
  +		// clean up for reuse
  +		map.remove("type");
  +
  +    	return result;
  +    }
   
  +	/**
  +	 * Gets a user profile and creates it by copying the role or the global profile.
  +	 * @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) 
  +	throws Exception {
  +		Object[] result;
  +    	
  +		// TODO Change key access to KeyManager usage
  +		Map map = (Map)key;
  +		
  +		// load user profile
  +		map.put("type", "user");
  +		result = this.getProfile(key, location+"-user-"+map.get("user"), service);
  +
  +		if (result[0] == null) {
  +			// load role profile
  +			map.put("type", "role");
  +			result = this.getProfile(key, location+"-role-"+map.get("role"), service);
  +
  +			if (result[0] == null) {
  +				// load global profile
  +				map.remove("type");
  +				result = this.getProfile(key, location+"-global", service);
  +
  +				if (result[0] == null) {
  +					throw new SourceNotFoundException("Could not find global or role profile to create user profile.");
  +				}
  +			}
  +			
  +			// save profile as user profile
  +			MapSourceAdapter adapter = null;
  +			try {
  +				// TODO could one perhaps simply copy the file to increase performance??
  +				adapter = (MapSourceAdapter) this.componentManager.lookup(MapSourceAdapter.ROLE);
  +				map.put("type", "user");
  +				
  +                // FIXME - disabled saving for testing
  +                // adapter.saveProfile(key, result[0]);
  +
  +				// set validity for created user profile
  +				SourceValidity newValidity = adapter.getValidity(key);
  +				if (newValidity != null) {
  +					Object[] objects = new Object[] { result[0], newValidity };
  +					service.setAttribute(SimpleProfileManager.class.getName()+location+"-user-"+map.get("user"), objects);
  +				} else {
  +                    Object[] objects = new Object[] { result[0], null };
  +                    service.setAttribute(SimpleProfileManager.class.getName()+location+"-user-"+map.get("user"), objects);
  +				}
  +			} finally {
  +				this.componentManager.release(adapter);
  +			}
  +		}
  +		
  +		// clean up for reuse
  +		map.remove("type");
  +
  +		return result;
  +	}
  +
  +	/**
  +	 * Gets a profile.
  +	 * @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) 
  +	throws Exception {
  +		MapSourceAdapter adapter = null;
  +		try {
  +			adapter = (MapSourceAdapter) this.componentManager.lookup(MapSourceAdapter.ROLE);
  +
  +			Object[] objects = (Object[]) service.getAttribute(SimpleProfileManager.class.getName() + location);
  +			
  +			// check whether still valid
  +			SourceValidity sourceValidity = null;
  +			if (objects != null)
  +				sourceValidity = (SourceValidity)objects[1];
  +			Object[] validity = this.getValidity(key, location, sourceValidity, adapter);
  +			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);
  +			}
  +
  +			return new Object[]{object, Boolean.TRUE};
  +		} finally {
  +			this.componentManager.release(adapter);
  +		}
  +	}
  +	
  +	/**
  +	 * Gets a profile by using the specified validity information.
  +	 * @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) 
  +	throws Exception {
  +		MapSourceAdapter adapter = null;
  +		try {
  +			adapter = (MapSourceAdapter) this.componentManager.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};
  +				}
  +			}
  +
  +			// 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);
  +			}
  +
  +			return new Object[]{object, Boolean.TRUE};
  +		} finally {
  +			this.componentManager.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) 
  +	throws Exception {
  +		MapSourceAdapter adapter = null;
  +		try {
  +			adapter = (MapSourceAdapter) this.componentManager.lookup(MapSourceAdapter.ROLE);
  +
  +			if (newValidity == null)
  +				newValidity = adapter.getValidity(key);
  +			Object object = adapter.loadProfile(key);
  +			if (newValidity != null) {
  +				Object[] objects = new Object[] { object, newValidity };
  +				service.setAttribute(SimpleProfileManager.class.getName() + location, objects);
  +			}
  +
  +			return object;
  +		} finally {
  +			this.componentManager.release(adapter);
  +		}
  +	}
  +
  +	/**
  +	 * Checks the validity.
  +	 * @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)
  +	throws Exception { 
  +		MapSourceAdapter adapter = null;
  +		try {
  +			adapter = (MapSourceAdapter) this.componentManager.lookup(MapSourceAdapter.ROLE);
  +
  +			Object[] objects = (Object[]) service.getAttribute(SimpleProfileManager.class.getName() + location);
  +			SourceValidity sourceValidity = null;
  +			if (objects != null)
  +				sourceValidity = (SourceValidity)objects[1];
  +			
  +			return this.getValidity(key, location, sourceValidity, adapter);
  +		} finally {
  +			this.componentManager.release(adapter);
  +		}
  +	}
  +
  +	/**
  +	 * Checks the specified validity.
  +	 * @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) 
  +	throws Exception {
  +		int valid = SourceValidity.INVALID;
  +
  +		if (sourceValidity != null) {
  +			valid = sourceValidity.isValid();
  +			if (valid == SourceValidity.VALID)
  +				return new Object[]{Boolean.TRUE, null};
  +		}
  +
  +		SourceValidity newValidity = adapter.getValidity(key);
  +		
  +		// source does not exist so it is valid
  +		if (newValidity == null)
  +			return new Object[]{Boolean.TRUE, null};
  +		
  +		if (valid == SourceValidity.UNKNWON) {
  +			if (sourceValidity.isValid(newValidity) == SourceValidity.VALID)
  +				return new Object[]{Boolean.TRUE, newValidity};
  +		}
  +
  +		return new Object[]{Boolean.FALSE, newValidity};
  +	}
  +	
       public CopletInstanceData getCopletInstanceData(String copletID) {
           PortalService service = null;
  -        String key = null;
  +        String attribute = null;
           try {
               service = (PortalService) this.componentManager.lookup(PortalService.ROLE);
  -            key = service.getPortalName() + ":" + copletID;
   
  -            Map coplets = (Map) service.getAttribute(SimpleProfileManager.class.getName() + "/Coplets");
  -            if (null == coplets) {
  +			// 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(SimpleProfileManager.class.getName() + "/Coplets", coplets);
  -            }
  +                service.setAttribute(attribute, coplets);
  +            }*/
  +			CopletInstanceDataManager copletInstanceDataManager = (CopletInstanceDataManager)((Object[])service.getAttribute(attribute))[0];
   
  -            CopletInstanceData cid = (CopletInstanceData) coplets.get(key);
  +            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");
  @@ -189,7 +496,7 @@
                       marshaller.marshal(cid);
                   } catch (Exception e) {
                       //e.printStackTrace();
  -                }
  +                }*/
               }
               return cid;
           } catch (ComponentException e) {
  @@ -213,7 +520,8 @@
           }
       }
   
  -    private void resolveParents(final Layout layout, final Item item) {
  +    private void resolveParents(final Layout layout, final Item item, CopletInstanceDataManager manager)
  +    throws ProcessingException {
           String id = layout.getId();
           if ( id == null ) {
               id = Integer.toString(layout.hashCode());
  @@ -226,14 +534,26 @@
               for (int j = 0; j < compositeLayout.getSize(); j++) {
                   final Item layoutItem = (Item) compositeLayout.getItem(j);
                   layoutItem.setParent(compositeLayout);
  -                this.resolveParents(layoutItem.getLayout(), layoutItem);
  +                this.resolveParents(layoutItem.getLayout(), layoutItem, manager);
               }
           }
           if (layout instanceof CopletLayout) {
  -            final CopletLayout cl = (CopletLayout)layout;
  -            final CopletInstanceData cid = this.getCopletInstanceData(cl.getId());
  -            cl.setCopletInstanceData(cid);
  -            this.setAspectStatus(ProfileManager.SESSION_STATUS, cid.getCopletData().getName(), new SizeableStatus());
  +			CopletLayout copletLayout = (CopletLayout)layout;
  +
  +			if (manager != null) {
  +				String copletId = copletLayout.getCopletInstanceData().getCopletId();
  +				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().getCopletId() + " has no coplet data.");
  +                }
  +            }
  +            this.setAspectStatus(ProfileManager.SESSION_STATUS, copletLayout.getCopletInstanceData().getCopletData().getName(), new SizeableStatus());
           }
           layout.setParent(item);
       }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/CopletInstanceDataReferenceFieldHandler.java
  
  Index: CopletInstanceDataReferenceFieldHandler.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  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.profile.impl;
  
  import org.apache.cocoon.portal.coplet.CopletInstanceData;
  import org.apache.cocoon.portal.layout.impl.CopletLayout;
  
  /**
   * Field handler for external CopletInstanceData references.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj�rn L�tkemeier</a>
   * 
   * @version CVS $Id: CopletInstanceDataReferenceFieldHandler.java,v 1.1 2003/05/19 09:14:09 cziegeler Exp $
   */
  public class CopletInstanceDataReferenceFieldHandler
  extends ReferenceFieldHandler {
  
  	public void checkValidity(Object object) {
  	}
  
  	public Object getValue(Object object) {
  		CopletInstanceData copletInstanceData = ((CopletLayout)object).getCopletInstanceData();
  		if (copletInstanceData != null) {
  			return copletInstanceData.getCopletId();
  		} else {
  			return null;
  		}
  	}
  
  	public Object newInstance(Object parent) {
  		return new CopletInstanceData();
  	}
  
  	public void resetValue(Object object) {
  		((CopletLayout)object).setCopletInstanceData(null);
  	}
  
  	public void setValue(Object object, Object value) {
  		CopletInstanceData copletInstanceData = (CopletInstanceData)getObjectMap().get(value);
  		((CopletLayout)object).setCopletInstanceData(copletInstanceData);
  	}
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/CopletDataManager.java
  
  Index: CopletDataManager.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  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.profile.impl;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.cocoon.portal.coplet.CopletData;
  import org.apache.cocoon.portal.util.DeltaApplicable;
  
  /**
   * Holds instances of CopletData.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj�rn L�tkemeier</a>
   * 
   * @version CVS $Id: CopletDataManager.java,v 1.1 2003/05/19 09:14:09 cziegeler Exp $
   */
  public class CopletDataManager 
  implements DeltaApplicable {
  
  	/**
  	 * The coplet data instances.
  	 */
  	private Map copletData = new HashMap();
  	
  	/**
  	 * Gets all coplet data.
  	 */
  	public Map getCopletData() {
  		return this.copletData;
  	}
  
  	/**
  	 * Gets the specified coplet data. 
  	 */
  	public CopletData getCopletData(String name) {
  		return (CopletData)this.copletData.get(name);
  	}
  	
  	/**
  	 * Puts the specified coplet data to the manager.
  	 */
  	public void putCopletData(CopletData data) {
  		this.copletData.put(data.getName(), data);
  	}
  	
  	/**
  	 * Applies the specified delta.
  	 * @throws ClassCastException If the object is not of the expected type.
  	 */
  	public boolean applyDelta(Object object) {
  		CopletDataManager manager = (CopletDataManager)object;
  		
  		Iterator iterator = manager.getCopletData().values().iterator();
  		CopletData data, delta;
  		while (iterator.hasNext()) {
  			delta = (CopletData)iterator.next();
  			data = this.getCopletData(delta.getName());
  			if (data == null) {
  				this.putCopletData(delta);
  			} else {
  				data.applyDelta(delta); 
  			}
  		}
  		
  		return true;
  	}
  	
  	/**
  	 * Updates the references to the coplet base data to the ones stored in the manager.
  	 */
  	public void update(CopletBaseDataManager manager) {
  		Iterator iterator = this.copletData.values().iterator();
  		CopletData data;
  		while (iterator.hasNext()) {
  			data = (CopletData)iterator.next();
  			data.setCopletBaseData(manager.getCopletBaseData(data.getCopletBaseData().getName()));
  		}
  	}
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/CopletBaseDataReferenceFieldHandler.java
  
  Index: CopletBaseDataReferenceFieldHandler.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  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.profile.impl;
  
  import org.apache.cocoon.portal.coplet.CopletBaseData;
  import org.apache.cocoon.portal.coplet.CopletData;
  
  
  /**
   * Field handler for external CopletBaseData references.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj�rn L�tkemeier</a>
   * 
   * @version CVS $Id: CopletBaseDataReferenceFieldHandler.java,v 1.1 2003/05/19 09:14:09 cziegeler Exp $
   */
  public class CopletBaseDataReferenceFieldHandler 
  extends ReferenceFieldHandler {
  
  	public void checkValidity(Object object)
  	{
  	}
  
  	public Object getValue(Object object) 
  	{
  		CopletBaseData copletBaseData = ((CopletData)object).getCopletBaseData();
  		if (copletBaseData != null) {
  			return copletBaseData.getName();
  		} else {
  			return null;
  		}
  	}
  
  	public Object newInstance(Object parent)
  	{
  		return new CopletBaseData();
  	}
  
  	public void resetValue(Object object)
  	{
  		((CopletData)object).setCopletBaseData(null);
  	}
  
  	public void setValue(Object object, Object value)
  	{
  		CopletBaseData copletBaseData = (CopletBaseData)getObjectMap().get(value);
  		((CopletData)object).setCopletBaseData(copletBaseData);
  	}
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/CopletDataReferenceFieldHandler.java
  
  Index: CopletDataReferenceFieldHandler.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  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.profile.impl;
  
  import org.apache.cocoon.portal.coplet.CopletData;
  import org.apache.cocoon.portal.coplet.CopletInstanceData;
  
  /**
   * Field handler for external CopletData references.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj�rn L�tkemeier</a>
   * 
   * @version CVS $Id: CopletDataReferenceFieldHandler.java,v 1.1 2003/05/19 09:14:09 cziegeler Exp $
   */
  public class CopletDataReferenceFieldHandler 
  extends ReferenceFieldHandler {
  
  	public void checkValidity(Object object)
  	{
  	}
  
  	public Object getValue(Object object) 
  	{
  		CopletData copletData = ((CopletInstanceData)object).getCopletData();
  		if (copletData != null) {
  			return copletData.getName();
  		} else {
  			return null;
  		}
  	}
  
  	public Object newInstance(Object parent)
  	{
  		return new CopletData();
  	}
  
  	public void resetValue(Object object)
  	{
  		((CopletInstanceData)object).setCopletData(null);
  	}
  
  	public void setValue(Object object, Object value)
  	{
  		CopletData copletData = (CopletData)getObjectMap().get(value);
  		((CopletInstanceData)object).setCopletData(copletData);
  	}
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/ReferenceFieldHandler.java
  
  Index: ReferenceFieldHandler.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  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.profile.impl;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import org.exolab.castor.mapping.FieldHandler;
  
  /**
   * Field handler superclass for external references.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj�rn L�tkemeier</a>
   * 
   * @version CVS $Id: ReferenceFieldHandler.java,v 1.1 2003/05/19 09:14:09 cziegeler Exp $
   */
  public abstract class ReferenceFieldHandler
  implements FieldHandler
  {
  	/**
  	 * Used to pass resolvable objects to the field handler.
  	 */
  	private static ThreadLocal threadLocalMap = new InheritableThreadLocal();
  	
  	/**
  	 * Gets the map used to pass resolvable objects to the field handler.
  	 */
  	public static Map getObjectMap() {
  		Map map = (Map)threadLocalMap.get();
  
  		if (map == null) {
  			map = new HashMap();
  			threadLocalMap.set(map);
  		}
  
  		return map;
  	}
  
  	/**
  	 * Sets the map used to pass resolvable objects to the field handler.
  	 */
  	public static void setObjectMap(Map objectMap) {
  		if (objectMap == null) {
  			threadLocalMap.set(new HashMap());
  		} else {
  			threadLocalMap.set(objectMap);
  		}
  	}
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapSourceAdapter.java
  
  Index: MapSourceAdapter.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  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.profile.impl;
  
  import java.util.Map;
  
  import org.apache.avalon.framework.component.Component;
  import org.apache.avalon.framework.component.ComponentException;
  import org.apache.avalon.framework.component.ComponentManager;
  import org.apache.avalon.framework.component.Composable;
  import org.apache.avalon.framework.configuration.Configurable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.thread.ThreadSafe;
  import org.apache.cocoon.components.persistance.CastorSourceConverter;
  import org.apache.cocoon.portal.profile.ProfileLS;
  import org.apache.excalibur.source.ModifiableSource;
  import org.apache.excalibur.source.Source;
  import org.apache.excalibur.source.SourceResolver;
  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: MapSourceAdapter.java,v 1.1 2003/05/19 09:14:09 cziegeler Exp $
   */
  public class MapSourceAdapter
      extends AbstractLogEnabled
      implements Component, Composable, Configurable, ProfileLS, ThreadSafe {
  
      public static final String ROLE = MapSourceAdapter.class.getName();
      private ComponentManager manager;
  
      /* (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";
  		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"));
  			}
  		}
  		buffer.append(".xml");
          
  		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);
          }
      }
  
      /* (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 {
  		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"));
  			}
  		}
  		buffer.append(".xml");
          
  		String sourceURI = buffer.toString();
  		SourceResolver resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
  		ModifiableSource source = null;
  		CastorSourceConverter converter = null;
  		try {
  			source = (ModifiableSource)resolver.resolveURI(sourceURI);
  			converter = (CastorSourceConverter) this.manager.lookup(CastorSourceConverter.ROLE);
  
  			converter.storeObject(source, profileName, profile);
  		} finally {
  			resolver.release(source);
  			manager.release(converter);
  			manager.release(resolver);
  		}
      }
  
      /* (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";
  			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"));
  				}
  			}
  			buffer.append(".xml");
          
  			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);
          }
      }
  
      /* (non-Javadoc)
       * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
       */
      public void configure(Configuration config) throws ConfigurationException {
          // TODO Auto-generated method stub
  
      }
  
      /* (non-Javadoc)
       * @see org.apache.avalon.framework.component.Composable#compose(org.apache.avalon.framework.component.ComponentManager)
       */
      public void compose(ComponentManager manager) throws ComponentException {
          this.manager = manager;
      }
  
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/CopletInstanceDataManager.java
  
  Index: CopletInstanceDataManager.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  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.profile.impl;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.cocoon.portal.coplet.CopletInstanceData;
  
  /**
   * Holds instances of CopletInstanceData.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj�rn L�tkemeier</a>
   * 
   * @version CVS $Id: CopletInstanceDataManager.java,v 1.1 2003/05/19 09:14:09 cziegeler Exp $
   */
  public class CopletInstanceDataManager {
  	
  	/**
  	 * The coplet instance data instances.
  	 */
  	private Map copletInstanceData = new HashMap();
  	
  	/**
  	 * Gets all coplet instance data.
  	 */
  	public Map getCopletInstanceData() {
  		return this.copletInstanceData;
  	}
  
  	/**
  	 * Gets the specified coplet instance data. 
  	 */
  	public CopletInstanceData getCopletInstanceData(String copletId) {
  		return (CopletInstanceData)this.copletInstanceData.get(copletId);
  	}
  	
  	/**
  	 * Puts the specified coplet instance data to the manager.
  	 */
  	public void putCopletInstanceData(CopletInstanceData data) {
  		this.copletInstanceData.put(data.getCopletId(), data);
  	}
  	
  	/**
  	 * Updates the references to the coplet data to the ones stored in the manager.
  	 */
  	public void update(CopletDataManager manager) {
  		Iterator iterator = this.copletInstanceData.values().iterator();
  		CopletInstanceData data;
  		while (iterator.hasNext()) {
  			data = (CopletInstanceData)iterator.next();
  			data.setCopletData(manager.getCopletData(data.getCopletData().getName()));
  		}
  	}
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/ConfigurationFieldHandler.java
  
  Index: ConfigurationFieldHandler.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  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.profile.impl;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.cocoon.portal.coplet.CopletBaseData;
  import org.exolab.castor.mapping.FieldHandler;
  import org.exolab.castor.mapping.MapItem;
  
  /**
   * Field handler for attributes of a CopletBaseData object.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj�rn L�tkemeier</a>
   * 
   * @version CVS $Id: ConfigurationFieldHandler.java,v 1.1 2003/05/19 09:14:09 cziegeler Exp $
   */
  public class ConfigurationFieldHandler
  implements FieldHandler
  {
  	public void checkValidity(Object object)
  	{
  	}
  
  	public Object getValue(Object object) 
  	{
  		HashMap map = new HashMap();
  		Iterator iterator = ((CopletBaseData)object).getCopletConfig().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)
  	{
  		((CopletBaseData)object).getCopletConfig().clear();
  	}
  
  	public void setValue(Object object, Object value)
  	{
  		MapItem item = (MapItem)value;
  		((CopletBaseData)object).setCopletConfig((String)item.getKey(), item.getValue());
  	}
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/CopletBaseDataManager.java
  
  Index: CopletBaseDataManager.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  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.profile.impl;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.cocoon.portal.coplet.CopletBaseData;
  
  /**
   * Holds instances of CopletBaseData.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj�rn L�tkemeier</a>
   * 
   * @version CVS $Id: CopletBaseDataManager.java,v 1.1 2003/05/19 09:14:09 cziegeler Exp $
   */
  public class CopletBaseDataManager {
  
  	/**
  	 * The coplet base data instances.
  	 */
  	private Map copletBaseData = new HashMap();
  	
  	/**
  	 * Gets all coplet base data.
  	 */
  	public Map getCopletBaseData() {
  		return this.copletBaseData;
  	}
  
  	/**
  	 * Gets the specified coplet base data. 
  	 */
  	public CopletBaseData getCopletBaseData(String name) {
  		return (CopletBaseData)this.copletBaseData.get(name);
  	}
  	
  	/**
  	 * Puts the specified coplet base data to the manager.
  	 */
  	public void putCopletBaseData(CopletBaseData data) {
  		this.copletBaseData.put(data.getName(), data);
  	}
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AttributesFieldHandler.java
  
  Index: AttributesFieldHandler.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  <st...@apache.org>. For more  information on the Apache
   Software Foundation, please see <http://www.apache.org/>.
  
  */
  package org.apache.cocoon.portal.profile.impl;
  
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.cocoon.portal.coplet.CopletData;
  import org.exolab.castor.mapping.FieldHandler;
  import org.exolab.castor.mapping.MapItem;
  
  /**
   * Field handler for attributes of a CopletData object.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj�rn L�tkemeier</a>
   * 
   * @version CVS $Id: AttributesFieldHandler.java,v 1.1 2003/05/19 09:14:09 cziegeler Exp $
   */
  public class AttributesFieldHandler
  implements FieldHandler
  {
  	public void checkValidity(Object object)
  	{
  	}
  
  	public Object getValue(Object object) 
  	{
  		HashMap map = new HashMap();
  		Iterator iterator = ((CopletData)object).getAttributes().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)
  	{
  		((CopletData)object).getAttributes().clear();
  	}
  
  	public void setValue(Object object, Object value)
  	{
  		MapItem item = (MapItem)value;
  		((CopletData)object).setAttribute((String)item.getKey(), item.getValue());
  	}
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/styles/login-html.xsl
  
  Index: login-html.xsl
  ===================================================================
  <?xml version="1.0"?>
  
  <!--+ $Id: login-html.xsl,v 1.1 2003/05/19 09:14:10 cziegeler Exp $ 
      |
      | Description: Login page to HTML
      |
      +-->
  
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  <xsl:template match="content">
  <!--	<table bgColor="#ffffff" border="0" cellPadding="0" cellSpacing="0" width="305"><tbody>
  		<tr>
  			<td>-->
  				<table bgColor="#ffffff" border="0" cellPadding="0" cellSpacing="2" width="100%"><tbody>
  					<tr>
  						<td bgColor="#46627a" vAlign="middle" width="15">
                      						<img height="1" src="sunspotdemoimg-space.gif" width="15"/>
                    					</td>
                    					<td bgColor="#46627a" align="center">
                      						<font color="#ffffff" face="Verdana, Arial, Helvetica, sans-serif" size="2">
                        							<b>
                          							<center>Cocoon Portal Login</center>
                        							</b>
                      						</font>
                    					</td>
                  				</tr>
                  				<tr>
                    					<td bgColor="#cccccc" width="15">
  				  			<IMG height="1" src="sunspotdemoimg-space.gif" width="15"/>
                    					</td>
                    					<td bgColor="#cccccc" align="center">
  				  			<br/>
                          					<font face="Arial, Helvetica, sans-serif" size="2">
                            						<xsl:apply-templates/>
  							</font>
  							<br/>
                    					</td>
                  				</tr>
                  				<tr>
  					            <td bgColor="#cccccc" width="15">
  							<img height="1" src="sunspotdemoimg-space.gif" width="15"/>
                    					</td>
                    					<td bgColor="#cccccc" align="center">
  				  			<br/>
                          					<font face="Verdana, Arial, Helvetica, sans-serif" size="2">
                            						If you are not already registered, use this guest login:
  								<br/><br/>
  								User:	<b>guest</b>
  								Password:
  								<b>guest</b>
  								<br/><br/>Or use this administrator login:<br/>
  								User:
  								<b>cocoon</b>
  								Password:
  								<b>cocoon</b>
  							</font>
  							<br/><br/>
                    					</td>
                  				</tr>
                			</tbody></table>
  <!--	          </td>
          </tr>
  	</tbody></table>-->
  </xsl:template>
  
  <xsl:template match="form">
  	<form method="post" target="_top">
  		<xsl:attribute name="action"><xsl:value-of select="normalize-space(url)"/></xsl:attribute>
  		<table>
  		        <xsl:apply-templates select="field"/><br/>
  		</table>
  		<input type="submit" value="Login"></input>
  	</form>
  </xsl:template>
  
  <xsl:template match="field">
  	<tr>
  		<td>
  			<font face="Arial, Helvetica, sans-serif" size="2"><xsl:value-of select="@description"/>:</font>
  		</td>
  		<td>
  			<input>
  				<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
  				<xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute>
  				<xsl:attribute name="size"><xsl:value-of select="@length"/></xsl:attribute>
  			</input>
  		</td>
  	</tr>
  </xsl:template>
  
  <!-- Copy all and apply templates -->
  <xsl:template match="@*|node()">
  	<xsl:copy>
  		<xsl:apply-templates select="@*|node()" />
  	</xsl:copy>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/styles/sunrise-user.xsl
  
  Index: sunrise-user.xsl
  ===================================================================
  <?xml version="1.0"?>
  <!-- $Id: sunrise-user.xsl,v 1.1 2003/05/19 09:14:10 cziegeler Exp $ 
  
  -->
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  <xsl:param name="password"/>
  <xsl:param name="name"/>
  
  <xsl:template match="authentication">
  	<authentication>
  		<xsl:apply-templates select="users"/>
  	</authentication>
  </xsl:template>
  
  <xsl:template match="users">
  	<xsl:apply-templates select="user"/>
  </xsl:template>
  
  <xsl:template match="user">
  	<xsl:if test="normalize-space(name) = $name and normalize-space(password) = $password">
  		<ID><xsl:value-of select="name"/></ID>
  		<role><xsl:value-of select="role"/></role>
  		<data>
  			<name><xsl:value-of select="name"/></name>
  			<role><xsl:value-of select="role"/></role>
  			<ID><xsl:value-of select="name"/></ID>
  			<user><xsl:value-of select="name"/></user>
  			<title><xsl:value-of select="title"/></title>
  			<firstname><xsl:value-of select="firstname"/></firstname>
  			<lastname><xsl:value-of select="lastname"/></lastname>
  			<company><xsl:value-of select="company"/></company>
  			<street><xsl:value-of select="street"/></street>
  			<zipcode><xsl:value-of select="zipcode"/></zipcode>
  			<city><xsl:value-of select="city"/></city>
  			<country><xsl:value-of select="country"/></country>
  			<phone><xsl:value-of select="phone"/></phone>
  			<fax><xsl:value-of select="fax"/></fax>
  			<email><xsl:value-of select="email"/></email>
  			<bankid><xsl:value-of select="bankid"/></bankid>
  			<bankname><xsl:value-of select="bankname"/></bankname>
  			<accountid><xsl:value-of select="accountid"/></accountid>
  		</data>
  	</xsl:if>
  </xsl:template>
  
  </xsl:stylesheet>
  
  
  
  1.2       +2 -2      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProfileLS.java	7 May 2003 06:22:28 -0000	1.1
  +++ ProfileLS.java	19 May 2003 09:14:10 -0000	1.2
  @@ -61,6 +61,6 @@
    */
   public interface ProfileLS {
       Object loadProfile(Object key) throws Exception;  //TODO define ExceptionType later
  -    void saveProfile(Object key, Object profile);
  +    void saveProfile(Object key, Object profile) throws Exception;  //TODO define ExceptionType later
       SourceValidity getValidity(Object key);
   }
  
  
  
  1.2       +2 -2      cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractCIncludeAspect.java
  
  Index: AbstractCIncludeAspect.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractCIncludeAspect.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractCIncludeAspect.java	7 May 2003 20:24:02 -0000	1.1
  +++ AbstractCIncludeAspect.java	19 May 2003 09:14:10 -0000	1.2
  @@ -81,7 +81,7 @@
           attributes.addCDATAAttribute("src", source);
           handler.startElement(NAMESPACE, ELEMENT, QELEMENT, attributes);
           handler.endElement(NAMESPACE, ELEMENT, QELEMENT);
  -        handler.endPrefixMapping(NAMESPACE);
  +        handler.endPrefixMapping(PREFIX);
       }
   
   }
  
  
  
  1.2       +5 -2      cocoon-2.1/src/blocks/portal/conf/portal.xconf
  
  Index: portal.xconf
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/portal.xconf,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- portal.xconf	7 May 2003 06:22:28 -0000	1.1
  +++ portal.xconf	19 May 2003 09:14:10 -0000	1.2
  @@ -123,7 +123,10 @@
    </component>
    
    <component class="org.apache.cocoon.components.persistance.CastorSourceConverter" role="org.apache.cocoon.components.persistance.CastorSourceConverter">
  - 	<mapping-source>context://samples/portal/profiles/mapping/layout.xml</mapping-source>
  + 	<mapping-source source="layout">context://samples/portal/profiles/mapping/layout.xml</mapping-source>
  + 	<mapping-source source="copletbasedata">context://samples/portal/profiles/mapping/copletbasedata.xml</mapping-source>
  + 	<mapping-source source="copletdata">context://samples/portal/profiles/mapping/copletdata.xml</mapping-source>
  + 	<mapping-source source="copletinstancedata">context://samples/portal/profiles/mapping/copletinstancedata.xml</mapping-source>
    </component>
  - <component class="org.apache.cocoon.portal.profile.impl.ParameterSourceAdapter" role="org.apache.cocoon.portal.profile.impl.ParameterSourceAdapter" />
  + <component class="org.apache.cocoon.portal.profile.impl.MapSourceAdapter" role="org.apache.cocoon.portal.profile.impl.MapSourceAdapter" />
   </xconf>
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/profiles/copletbasedata/portal.xml
  
  Index: portal.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <coplets>
     <coplet-base-data name="URICoplet">
        <coplet-adapter>uri</coplet-adapter>
        <default-renderer>window</default-renderer>
     </coplet-base-data>
  </coplets>
  
  
  
  
  1.2       +27 -15    cocoon-2.1/src/blocks/portal/samples/profiles/layout/portal.xml
  
  Index: portal.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/profiles/layout/portal.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- portal.xml	7 May 2003 06:22:25 -0000	1.1
  +++ portal.xml	19 May 2003 09:14:10 -0000	1.2
  @@ -7,14 +7,16 @@
                   <row-layout renderer-name="row" static="true">
                       <item>
   		                <coplet-layout renderer-name="window" static="true">
  -		                    <id>cocoon://samples/portal/news/newsweek.rss</id>
  -		                    <parameter name="title" value="Newsweek" />
  +		                    <id>1</id>
  +		                    <parameter name="title" value="Newsweek"/>
  +		                    <coplet-instance-data>Newsweek-1</coplet-instance-data>
   		                </coplet-layout>
                       </item>
                       <item>
   		                <coplet-layout renderer-name="window">
  -		                    <id>cocoon://samples/portal/news/NYTBusiness.rss</id>
  -		                    <parameter name="title" value="NYT Business" />
  +		                    <id>2</id>
  +		                    <parameter name="title" value="NYT Business"/> 
  +		                    <coplet-instance-data>NYTBusiness-1</coplet-instance-data>
   		                </coplet-layout>
                       </item>
                   </row-layout>
  @@ -23,8 +25,9 @@
                   <row-layout renderer-name="row" static="false">
                       <item>
   		                <coplet-layout renderer-name="window">
  -		                    <id>cocoon://samples/portal/news/BBCNews.rss</id>
  -		                    <parameter name="title" value="BBC News" />
  +		                    <id>3</id>
  +		                    <parameter name="title" value="BBC News"/>
  +		                    <coplet-instance-data>BBCNews-1</coplet-instance-data>
   		                </coplet-layout>
                       </item>
                       <item>
  @@ -37,8 +40,9 @@
                               </item>
                               <item>
                                   <coplet-layout renderer-name="window">
  -				                    <id>cocoon://samples/portal/news/CNET_news.rss</id>
  +				                    <id>4</id>
   				                    <parameter name="title" value="CNET News" />
  +				                    <coplet-instance-data>CNET News-1</coplet-instance-data>
                                   </coplet-layout>
                               </item>
                           </column-layout>
  @@ -47,8 +51,9 @@
                           <column-layout renderer-name="column">
                               <item>
                                   <coplet-layout renderer-name="window">
  -				                    <id>cocoon://samples/portal/news/CNET_business.rss</id>
  +				                    <id>5</id>
   				                    <parameter name="title" value="CNET Business News" />
  +				                    <coplet-instance-data>CNET Business-1</coplet-instance-data>
                                   </coplet-layout>
                               </item>
                               <item>
  @@ -66,14 +71,16 @@
                   <row-layout renderer-name="row" static="false">
                       <item>
   		                <coplet-layout renderer-name="window">
  -		                    <id>cocoon://samples/portal/news/CSTNews.rss</id>
  +		                    <id>6</id>
   		                    <parameter name="title" value="Chicago Sunday Times" />
  +		                    <coplet-instance-data>CSTNews-1</coplet-instance-data>
   		                </coplet-layout>
                       </item>
                       <item>
   		                <coplet-layout renderer-name="window">
  -		                    <id>cocoon://samples/portal/news/CNNEurope.rss</id>
  +		                    <id>7</id>
   		                    <parameter name="title" value="CNN Europe" />
  +		                    <coplet-instance-data>CNNEurope-1</coplet-instance-data>
   		                </coplet-layout>
                       </item>
                   </row-layout>
  @@ -86,16 +93,18 @@
                   <row-layout renderer-name="row">
                       <item>
   		                <coplet-layout renderer-name="window">
  -		                    <id>cocoon://samples/portal/news/ML_weblog.rss</id>
  +		                    <id>8</id>
   		                    <parameter name="title" value="ML's Weblog" />
   		                    <parameter name="bgcolor" value="#ffff00" />
  +		                    <coplet-instance-data>ML Weblog-1</coplet-instance-data>
   		                </coplet-layout>
                       </item>
                       <item>
   		                <coplet-layout renderer-name="window">
  -		                    <id>cocoon://samples/portal/news/CZ_weblog.rss</id>
  +		                    <id>9</id>
   		                    <parameter name="title" value="CZ's Weblog" />
   		                    <parameter name="bgcolor" value="#ffff00" />
  +		                    <coplet-instance-data>CZ Weblog-1</coplet-instance-data>
   		                </coplet-layout>
                       </item>
                   </row-layout>
  @@ -104,9 +113,10 @@
                   <row-layout renderer-name="row">
                       <item>
   		                <coplet-layout renderer-name="window">
  -		                    <id>cocoon://samples/portal/news/weblog.rss</id>
  +		                    <id>10</id>
   		                    <parameter name="title" value="Another Weblog" />
   		                    <parameter name="bgcolor" value="#ffff00" />
  +		                    <coplet-instance-data>Weblog-1</coplet-instance-data>
   		                </coplet-layout>
                       </item>
                   </row-layout>
  @@ -119,14 +129,16 @@
                   <column-layout renderer-name="column">
                       <item>
   		                <coplet-layout renderer-name="window">
  -		                    <id>cocoon://samples/portal/news/introduction.html</id>
  +		                    <id>11</id>
   		                    <parameter name="title" value="Cocoon Introduction" />
  +		                    <coplet-instance-data>Introduction-1</coplet-instance-data>
   		                </coplet-layout>
                       </item>
                       <item>
   		                <coplet-layout renderer-name="window">
  -		                    <id>cocoon://samples/portal/news/overview.html</id>
  +		                    <id>12</id>
   		                    <parameter name="title" value="Cocoon Overview" />
  +		                    <coplet-instance-data>Overview-1</coplet-instance-data>
   		                </coplet-layout>
                       </item>
   	            </column-layout>
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/util/DeltaApplicable.java
  
  Index: DeltaApplicable.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  <st...@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.
   *
   * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj�rn L�tkemeier</a>
   * 
   * @version CVS $Id: DeltaApplicable.java,v 1.1 2003/05/19 09:14:11 cziegeler Exp $
   */
  public interface DeltaApplicable {
  	/**
  	 * Applies the specified delta.
  	 * @return true if the delta could be successfully applied, false otherwise.
  	 * false can be used if object references stored in maps must be replaced 
  	 * by the caller instead of a delta being applied.
  	 * @throws ClassCastException If the object is not of the expected type.
  	 */
  	public boolean applyDelta(Object object);
  }
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/profiles/copletinstancedata/portal.xml
  
  Index: portal.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <coplets>
     <coplet-instance-data id="Newsweek-1">
        <coplet-data>Newsweek</coplet-data>
        <status>1</status>
     </coplet-instance-data>
  
     <coplet-instance-data id="NYTBusiness-1">
        <coplet-data>NYTBusiness</coplet-data>
        <status>1</status>
     </coplet-instance-data>
  
     <coplet-instance-data id="BBCNews-1">
        <coplet-data>BBCNews</coplet-data>
        <status>1</status>
     </coplet-instance-data>
  
     <coplet-instance-data id="CNET News-1">
        <coplet-data>CNET News</coplet-data>
        <status>1</status>
     </coplet-instance-data>
  
     <coplet-instance-data id="CNET Business-1">
        <coplet-data>CNET Business</coplet-data>
        <status>1</status>
     </coplet-instance-data>
  
     <coplet-instance-data id="CSTNews-1">
        <coplet-data>CSTNews</coplet-data>
        <status>1</status>
     </coplet-instance-data>
  
     <coplet-instance-data id="CNNEurope-1">
        <coplet-data>CNNEurope</coplet-data>
        <status>1</status>
     </coplet-instance-data>
  
     <coplet-instance-data id="ML Weblog-1">
        <coplet-data>ML Weblog</coplet-data>
        <status>1</status>
     </coplet-instance-data>
  
     <coplet-instance-data id="CZ Weblog-1">
        <coplet-data>CZ Weblog</coplet-data>
        <status>1</status>
     </coplet-instance-data>
  
     <coplet-instance-data id="Weblog-1">
        <coplet-data>Weblog</coplet-data>
        <status>1</status>
     </coplet-instance-data>
  
     <coplet-instance-data id="Introduction-1">
        <coplet-data>Introduction</coplet-data>
        <status>1</status>
     </coplet-instance-data>
  
     <coplet-instance-data id="Overview-1">
        <coplet-data>Overview</coplet-data>
        <status>1</status>
     </coplet-instance-data>
  </coplets>
  
  
  1.3       +87 -6     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- sitemap.xmap	7 May 2003 06:51:59 -0000	1.2
  +++ sitemap.xmap	19 May 2003 09:14:11 -0000	1.3
  @@ -28,6 +28,18 @@
   <!-- =========================== Pipelines ================================= -->
   
    <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>
  +  </map:component-configurations>
  +  
     <map:pipeline>
   
       <map:match pattern="">
  @@ -40,13 +52,18 @@
   
       <!-- Test pipeline for layout engine -->
       <map:match pattern="portal">
  -        <map:generate type="portal" label="content">
  +        <map:act type="auth-protect">
  +          <map:parameter name="handler" value="portalhandler"/> 
  +
  +          <map:generate type="portal" label="content">
           	<map:parameter name="portal-name" value="portal" />
  -        </map:generate>
  -        <map:transform type="cinclude"/> 
  -        <map:transform src="styles/header.xsl"/>
  -        <map:transform type="htmlroot" />
  -        <map:serialize type="html"/> 
  +          </map:generate>
  +          <map:transform type="cinclude"/> 
  +          <map:transform src="styles/header.xsl"/>
  +          <map:transform type="htmlroot" />
  +          <map:serialize type="html"/> 
  +        </map:act>
  +        <map:redirect-to uri="login"/>
       </map:match>
       
       <!-- images -->
  @@ -57,7 +74,71 @@
       	<map:read mime-type="image/jpg" src="images/{1}.jpg"/>
      	</map:match>
       
  +    <!-- authentication stuff -->
  +
  +    <map:match pattern="login">
  +        <map:act type="auth-loggedIn">
  +          <map:parameter name="handler" value="portalhandler"/> 
  +          <map:redirect-to uri="portal"/>
  +        </map:act>
  +        <map:generate src="resources/login.xml"/>
  +        <map:transform src="styles/login-html.xsl"/>
  +        <map:transform src="styles/header.xsl"/>
  +        <map:transform type="htmlroot" />
  +        <map:transform type="encodeURL"/>
  +        <map:serialize/>
  +    </map:match>
  +
  +    <map:match pattern="auth">
  +        <map:act type="auth-loggedIn">
  +          <map:parameter name="handler" value="portalhandler"/> 
  +          <map:redirect-to uri="loggedin"/>
  +        </map:act>
  +        <map:act type="auth-login">
  +          <map:parameter name="handler" value="portalhandler"/>
  +          <map:parameter name="parameter_name" value="{request-param:name}"/>
  +          <map:parameter name="parameter_password" value="{request-param:password}"/>
  +          <map:redirect-to uri="portal"/>
  +        </map:act>
  +        <map:generate src="resources/login-error.xml"/>
  +        <map:transform src="styles/header.xsl"/>
  +        <map:transform type="encodeURL"/>
  +        <map:serialize/>
  +    </map:match>
  +
  +    <map:match pattern="loggedin">
  +		<map:act type="auth-protect">
  +		  <map:parameter name="handler" value="portalhandler"/> 
  +		  
  +          <map:generate src="resources/logged-in.xml"/>
  +          <map:transform src="styles/header.xsl"/>
  +          <map:transform type="encodeURL"/>
  +          <map:serialize/>
  +        </map:act>
  +        <map:redirect-to uri="login"/>
  +    </map:match>
  +
  +    <map:match pattern="logout">
  +		<map:act type="auth-protect">
  +		  <map:parameter name="handler" value="portalhandler"/> 
  +		  <map:act type="auth-logout"/>
  +        </map:act>
  +<!-- TODO logout??? -->
  +        <map:redirect-to uri="login"/>
  +    </map:match>
  +
     </map:pipeline>
  +
  +  <map:pipeline internal-only="true">
  +    <map:match pattern="sunrise-authuser">
  +      <map:generate src="resources/sunrise-user.xml"/>
  +      <map:transform src="styles/sunrise-user.xsl">
  +        <map:parameter name="use-request-parameters" value="true"/>
  +      </map:transform>
  +      <map:serialize type="xml"/>
  +    </map:match>
  +  </map:pipeline>
  +
    </map:pipelines>
   
   </map:sitemap>
  
  
  
  1.1                  cocoon-2.1/src/blocks/portal/samples/profiles/copletdata/portal.xml
  
  Index: portal.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <coplets>
     <coplet-data name="Newsweek">
        <title>Newsweek</title>
        <maxpageable>true</maxpageable>
        <removable>true</removable>
        <coplet-base-data>URICoplet</coplet-base-data>
        <attribute>
        	<name>uri</name>
        	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon://samples/portal/news/newsweek.rss</value>
        </attribute>
     </coplet-data>
  
     <coplet-data name="NYTBusiness">
        <title>NYT Business</title>
        <maxpageable>true</maxpageable>
        <removable>true</removable>
        <coplet-base-data>URICoplet</coplet-base-data>
        <attribute>
        	<name>uri</name>
        	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon://samples/portal/news/NYTBusiness.rss</value>
        </attribute>
     </coplet-data>
  
     <coplet-data name="BBCNews">
        <title>BBC News</title>
        <maxpageable>true</maxpageable>
        <removable>true</removable>
        <coplet-base-data>URICoplet</coplet-base-data>
        <attribute>
        	<name>uri</name>
        	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon://samples/portal/news/BBCNews.rss</value>
        </attribute>
     </coplet-data>
  
     <coplet-data name="CNET News">
        <title>CNET News</title>
        <maxpageable>true</maxpageable>
        <removable>true</removable>
        <coplet-base-data>URICoplet</coplet-base-data>
        <attribute>
        	<name>uri</name>
        	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon://samples/portal/news/CNET_news.rss</value>
        </attribute>
     </coplet-data>
  
     <coplet-data name="CNET Business">
        <title>CNET Business News</title>
        <maxpageable>true</maxpageable>
        <removable>true</removable>
        <coplet-base-data>URICoplet</coplet-base-data>
        <attribute>
        	<name>uri</name>
        	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon://samples/portal/news/CNET_business.rss</value>
        </attribute>
     </coplet-data>
  
     <coplet-data name="CSTNews">
        <title>Chicago Sunday Times</title>
        <maxpageable>true</maxpageable>
        <removable>true</removable>
        <coplet-base-data>URICoplet</coplet-base-data>
        <attribute>
        	<name>uri</name>
        	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon://samples/portal/news/CSTNews.rss</value>
        </attribute>
     </coplet-data>
  
     <coplet-data name="CNNEurope">
        <title>CNN Europe</title>
        <maxpageable>true</maxpageable>
        <removable>true</removable>
        <coplet-base-data>URICoplet</coplet-base-data>
        <attribute>
        	<name>uri</name>
        	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon://samples/portal/news/CNNEurope.rss</value>
        </attribute>
     </coplet-data>
  
     <coplet-data name="ML Weblog">
        <title>ML's Weblog</title>
        <maxpageable>true</maxpageable>
        <removable>true</removable>
        <coplet-base-data>URICoplet</coplet-base-data>
        <attribute>
        	<name>uri</name>
        	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon://samples/portal/news/ML_weblog.rss</value>
        </attribute>
     </coplet-data>
  
     <coplet-data name="CZ Weblog">
        <title>CZ's Weblog</title>
        <maxpageable>true</maxpageable>
        <removable>true</removable>
        <coplet-base-data>URICoplet</coplet-base-data>
        <attribute>
        	<name>uri</name>
        	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon://samples/portal/news/CZ_weblog.rss</value>
        </attribute>
     </coplet-data>
  
     <coplet-data name="Weblog">
        <title>Another Weblog</title>
        <maxpageable>true</maxpageable>
        <removable>true</removable>
        <coplet-base-data>URICoplet</coplet-base-data>
        <attribute>
        	<name>uri</name>
        	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon://samples/portal/news/weblog.rss</value>
        </attribute>
     </coplet-data>
  
     <coplet-data name="Introduction">
        <title>Cocoon Introduction</title>
        <maxpageable>true</maxpageable>
        <removable>true</removable>
        <coplet-base-data>URICoplet</coplet-base-data>
        <attribute>
        	<name>uri</name>
        	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon://samples/portal/news/introduction.html</value>
        </attribute>
     </coplet-data>
  
     <coplet-data name="Overview">
        <title>Cocoon Overview</title>
        <maxpageable>true</maxpageable>
        <removable>true</removable>
        <coplet-base-data>URICoplet</coplet-base-data>
        <attribute>
        	<name>uri</name>
        	<value xsi:type="java:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">cocoon://samples/portal/news/overview.html</value>
        </attribute>
     </coplet-data>
  </coplets>
  
  
  
  
  1.2       +56 -14    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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CastorSourceConverter.java	7 May 2003 06:22:30 -0000	1.1
  +++ CastorSourceConverter.java	19 May 2003 09:14:11 -0000	1.2
  @@ -50,6 +50,14 @@
   */
   package org.apache.cocoon.components.persistance;
   
  +import java.io.InputStream;
  +import java.io.OutputStreamWriter;
  +import java.io.Writer;
  +import java.util.HashMap;
  +import java.util.Iterator;
  +import java.util.Map;
  +import java.util.Map.Entry;
  +
   import org.apache.avalon.framework.activity.Initializable;
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentException;
  @@ -61,17 +69,20 @@
   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;
   import org.exolab.castor.mapping.MappingException;
  -import org.exolab.castor.xml.UnmarshalHandler;
  +import org.exolab.castor.xml.Marshaller;
   import org.exolab.castor.xml.Unmarshaller;
  +import org.xml.sax.InputSource;
   
   /**
    *
    * @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$
    */
  @@ -81,17 +92,17 @@
           
       public static final String ROLE = CastorSourceConverter.class.getName();
   
  -    private String mappingSource;
  +    private Map mappingSources = new HashMap();
       private ComponentManager manager;
  -    private Mapping mapping;
  +    private Map mappings = new HashMap();
   
  -    public Object getObject(Source source) throws ConverterException {
  +    public Object getObject(Source source, String name) throws ConverterException {
           try {
  -            Unmarshaller unmarshaller = new Unmarshaller(mapping);
  -            UnmarshalHandler handler = unmarshaller.createHandler();
  -
  -            SourceUtil.toSAX(source, Unmarshaller.getContentHandler(handler));
  -            return handler.getObject();
  +			InputStream stream = source.getInputStream();
  +            Unmarshaller unmarshaller = new Unmarshaller((Mapping)this.mappings.get(name));
  +            Object result = unmarshaller.unmarshal(new InputSource(stream));
  +            stream.close();
  +            return result;
           } catch (MappingException e) {
               throw new ConverterException("can't create Unmarshaller", e);
           } catch (Exception e) {
  @@ -99,6 +110,21 @@
           }
       }
   
  +	public void storeObject(ModifiableSource source, String name, Object object) throws ConverterException {
  +		try {
  +			Writer writer = new OutputStreamWriter(source.getOutputStream());
  +			Marshaller marshaller = new Marshaller(writer);
  +			Mapping mapping = new Mapping();
  +			marshaller.setMapping((Mapping)this.mappings.get(name));
  +			marshaller.marshal(object);
  +			writer.close();
  +		} catch (MappingException e) {
  +			throw new ConverterException("can't create Unmarshaller", e);
  +		} catch (Exception e) {
  +			throw new ConverterException(e.getMessage(), e);
  +		}
  +	}
  +
       /* (non-Javadoc)
        * @see org.apache.avalon.framework.component.Composable#compose(org.apache.avalon.framework.component.ComponentManager)
        */
  @@ -110,7 +136,11 @@
        * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
        */
       public void configure(Configuration config) throws ConfigurationException {
  -        mappingSource = config.getChild("mapping-source").getValue();
  +    	Configuration[] children = config.getChildren("mapping-source");
  +    	for (int i=0; i<children.length; i++) {
  +    		Configuration mappingSource = children[i];
  +    		this.mappingSources.put(mappingSource.getAttribute("source"), mappingSource.getValue());
  +    	}
       }
   
       /* (non-Javadoc)
  @@ -120,9 +150,21 @@
           SourceResolver resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
           Source source = null;
           try {
  -            source = resolver.resolveURI(mappingSource);
  -            mapping = new Mapping();
  -            mapping.loadMapping(SourceUtil.getInputSource(source));
  +			Entry entry;
  +			String name;
  +			String mappingSource;
  +			Mapping mapping;
  +			Iterator iterator = this.mappingSources.entrySet().iterator();
  +        	while (iterator.hasNext()) {
  +        		entry = (Map.Entry)iterator.next(); 
  +        		name = (String)entry.getKey();
  +        		mappingSource = (String)entry.getValue();
  +        		
  +				source = resolver.resolveURI(mappingSource);
  +				mapping = new Mapping();
  +				mapping.loadMapping(SourceUtil.getInputSource(source));
  +				this.mappings.put(name, mapping);
  +        	}
           } finally {
               if (source != null) {
                   resolver.release(source);