cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: rev 37252 - in cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon: components/persistence portal/coplet portal/profile portal/profile/impl
Date Tue, 31 Aug 2004 12:25:00 GMT
Author: cziegeler
Date: Tue Aug 31 05:24:59 2004
New Revision: 37252

Added:
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
  (contents, props changed)
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfo.java
  (contents, props changed)
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserProfile.java
  (contents, props changed)
Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/components/persistence/CastorSourceConverter.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletData.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletdata.xml
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileLS.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
Log:
Improving group based profile manager

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/components/persistence/CastorSourceConverter.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/components/persistence/CastorSourceConverter.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/components/persistence/CastorSourceConverter.java
Tue Aug 31 05:24:59 2004
@@ -51,13 +51,13 @@
  * In order to work properly the methods provided by this interface require some 
  * parameters:
  * objectmap : containing a map of objects for resolving references during load
- * profiletype: specifying the mapping (this is one of layout, copletinstancedata, copletdata
or copletbasedate
+ * profiletype: specifying the mapping (this is one of layout, copletinstancedata, copletdata
or copletbasedata
  * 
  * @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&ouml;rn L&uuml;tkemeier</a>
  * 
- * @version CVS $Id: CastorSourceConverter.java,v 1.4 2004/03/05 13:02:07 bdelacretaz Exp
$
+ * @version CVS $Id$
  */
 public class CastorSourceConverter
     extends AbstractLogEnabled
@@ -65,19 +65,22 @@
         
     public static final String ROLE = CastorSourceConverter.class.getName();
 
+    public static final String PARAMETER_OBJECTMAP = "objectmap";
+    public static final String PARAMETER_PROFILETYPE = "profiletype";
+    
     private Map mappingSources = new HashMap();
     private ServiceManager manager;
     private Map mappings = new HashMap();
 
     public Object getObject(InputStream stream, Map parameters) throws ConverterException
{
         try {
-            ReferenceFieldHandler.setObjectMap((Map)parameters.get("objectmap"));
-            Unmarshaller unmarshaller = new Unmarshaller((Mapping)this.mappings.get(parameters.get("profiletype")));
+            ReferenceFieldHandler.setObjectMap((Map)parameters.get(PARAMETER_OBJECTMAP));
+            Unmarshaller unmarshaller = new Unmarshaller((Mapping)this.mappings.get(parameters.get(PARAMETER_PROFILETYPE)));
             Object result = unmarshaller.unmarshal(new InputSource(stream));
             stream.close();
             return result;
         } catch (MappingException e) {
-            throw new ConverterException("can't create Unmarshaller", e);
+            throw new ConverterException("Can't create Unmarshaller", e);
         } catch (Exception e) {
             throw new ConverterException(e.getMessage(), e);
         }
@@ -87,11 +90,11 @@
         Writer writer = new OutputStreamWriter(stream);
 		try {
 			Marshaller marshaller = new Marshaller( writer );
-			marshaller.setMapping((Mapping)this.mappings.get(parameters.get("profiletype")));
+			marshaller.setMapping((Mapping)this.mappings.get(parameters.get(PARAMETER_PROFILETYPE)));
 			marshaller.marshal(object);
 			writer.close();
 		} catch (MappingException e) {
-			throw new ConverterException("can't create Unmarshaller", e);
+			throw new ConverterException("Can't create Unmarshaller", e);
 		} catch (Exception e) {
 			throw new ConverterException(e.getMessage(), e);
 		}

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletData.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletData.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/CopletData.java
Tue Aug 31 05:24:59 2004
@@ -46,12 +46,8 @@
 
     protected String allowedRoles;
     
-    protected String deniedRoles;
-    
     protected transient List allowedRolesList;
     
-    protected transient List deniedRolesList;
-    
 	/**
 	 * Signals whether a delta has been applied.
 	 */
@@ -182,20 +178,6 @@
     }
     
     /**
-     * @return Returns the denied roles.
-     */
-    public String getDeniedRoles() {
-        return this.deniedRoles;
-    }
-    /**
-     * @param roles The allowed roles to set.
-     */
-    public void setDeniedRoles(String roles) {
-        this.deniedRoles = roles;
-        this.deniedRolesList = null;
-    }
-
-    /**
      * Return the list of roles that are allowed to access this coplet
      * @return A list of roles or null if everyone is allowed.
      */
@@ -218,29 +200,6 @@
         return this.allowedRolesList;
     }
     
-    /**
-     * Return the list of roles that are denied to access this coplet
-     * @return A list of roles or null if everyone is allowed.
-     */
-    public List getDeniedRolesList() {
-        if ( StringUtils.isBlank(this.deniedRoles) ) {
-            return null;
-        }
-        if ( this.deniedRolesList == null ) {
-            this.deniedRolesList = new ArrayList();
-            final StringTokenizer tokenizer = new StringTokenizer(this.deniedRoles, ",");
-            while ( tokenizer.hasMoreElements() ) {
-                String token = (String)tokenizer.nextElement();
-                this.deniedRolesList.add(token);
-            }
-            if ( this.deniedRolesList.size() == 0 ) {
-                this.deniedRoles = null;
-                this.deniedRolesList = null;
-            }
-        }
-        return this.deniedRolesList;
-    }
-
     public void addToAllowedRoles(String role) {
         List l = this.getAllowedRolesList();
         if ( l == null ) {
@@ -251,7 +210,7 @@
                 l.add(role);
             }
         }
-        this.buildRolesString(l, true);
+        this.buildRolesString(l);
     }
     
     public void removeFromAllowedRoles(String role) {
@@ -262,43 +221,13 @@
                 this.allowedRoles = null;
                 this.allowedRolesList = null;
             } else {
-                this.buildRolesString(l, true);
+                this.buildRolesString(l);
             }
         }
     }
     
-    public void addToDeniedRoles(String role) {
-        List l = this.getDeniedRolesList();
-        if ( l == null ) {
-            l = new ArrayList();
-            l.add(role);
-        } else {
-            if ( !l.contains(role) ) {
-                l.add(role);
-            }
-        }
-        this.buildRolesString(l, false);
-    }
-    
-    public void removeFromDeniedRoles(String role) {
-        List l = this.getDeniedRolesList();
-        if ( l != null && l.contains(role) ) {
-            l.remove(role);
-            if ( l.size() == 0 ) {
-                this.deniedRoles = null;
-                this.deniedRolesList = null;
-            } else {
-                this.buildRolesString(l, false);
-            }
-        }
-    }
-
-    protected void buildRolesString(List fromList, boolean allow) {
-        if ( allow ) {
-            this.allowedRolesList = fromList;
-        } else {
-            this.deniedRolesList = fromList;
-        }
+    protected void buildRolesString(List fromList) {
+        this.allowedRolesList = fromList;
         StringBuffer buffer = new StringBuffer();
         boolean first = true;
         Iterator i = fromList.iterator();
@@ -310,10 +239,6 @@
             first = false;
             buffer.append(role);
         }
-        if ( allow ) {
-            this.allowedRoles = buffer.toString();
-        } else {
-            this.deniedRoles = buffer.toString();
-        }
+        this.allowedRoles = buffer.toString();
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletdata.xml
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletdata.xml
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/coplet/copletdata.xml
Tue Aug 31 05:24:59 2004
@@ -50,11 +50,7 @@
 		</field>
 
 		<field name="allowedRoles" type="java.lang.String">
-			<bind-xml name="allowed-roles"/>
-		</field>
-
-		<field name="deniedRoles" type="java.lang.String">
-			<bind-xml name="denied-roles"/>
+			<bind-xml name="roles"/>
 		</field>
 
 		<field name="attributes" type="org.exolab.castor.mapping.MapItem" collection="map" handler="org.apache.cocoon.portal.util.AttributesFieldHandler">

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileLS.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileLS.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/ProfileLS.java
Tue Aug 31 05:24:59 2004
@@ -20,21 +20,20 @@
 import org.apache.excalibur.source.SourceValidity;
 
 /**
+ * This component is used for loading/saving of a profile.
  *
  * @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&ouml;rn L&uuml;tkemeier</a>
  * 
- * @version CVS $Id: ProfileLS.java,v 1.5 2004/03/05 13:02:16 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public interface ProfileLS {
     
     String ROLE = ProfileLS.class.getName();
     
-    //  TODO define ExceptionType later
     Object loadProfile(Object key, Map parameters) throws Exception;  
     
-    //TODO define ExceptionType later
     void saveProfile(Object key, Map parameters, Object profile) throws Exception;  
     
     SourceValidity getValidity(Object key, Map parameters);

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
Tue Aug 31 05:24:59 2004
@@ -55,34 +55,39 @@
      * @see org.apache.cocoon.portal.profile.ProfileManager#register(org.apache.cocoon.portal.coplet.CopletInstanceData)
      */
     public void register(CopletInstanceData coplet) {
+        // overwrite in subclass
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#register(org.apache.cocoon.portal.layout.Layout)
      */
     public void register(Layout layout) {
+        // overwrite in subclass
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserProfiles()
      */
     public void saveUserProfiles() {
+        // overwrite in subclass
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#unregister(org.apache.cocoon.portal.coplet.CopletInstanceData)
      */
     public void unregister(CopletInstanceData coplet) {
+        // overwrite in subclass
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#unregister(org.apache.cocoon.portal.layout.Layout)
      */
     public void unregister(Layout layout) {
+        // overwrite in subclass
     }
 
-    /**
-     * Change the default layout key for most functions
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#setDefaultLayoutKey(java.lang.String)
      */
     public void setDefaultLayoutKey(String layoutKey) {
         PortalService service = null;
@@ -101,8 +106,8 @@
         }
     }
     
-    /**
-     * Get the default layout key
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#getDefaultLayoutKey()
      */
     public String getDefaultLayoutKey() {
         PortalService service = null;
@@ -126,12 +131,14 @@
      * @see org.apache.cocoon.portal.profile.ProfileManager#login()
      */
     public void login() {
+        // overwrite in subclass
     }
     
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#logout()
      */
     public void logout() {
+        // overwrite in subclass
     }
 
     /* (non-Javadoc)

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
Tue Aug 31 05:24:59 2004
@@ -0,0 +1,288 @@
+/*
+ * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.profile.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.avalon.framework.CascadingRuntimeException;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.coplet.CopletData;
+import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
+import org.apache.cocoon.portal.layout.Layout;
+import org.apache.cocoon.webapps.authentication.AuthenticationManager;
+
+/**
+ * The profile manager using the authentication framework
+ * 
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * 
+ * @version CVS $Id: AbstractUserProfileManager.java 37123 2004-08-27 12:11:53Z cziegeler
$
+ */
+public class GroupBasedProfileManager 
+    extends AbstractProfileManager { 
+
+    protected static final String KEY_PREFIX = GroupBasedProfileManager.class.getName() +
':';
+    
+    protected UserProfile getUserProfile(String layoutKey) {
+        if ( layoutKey == null ) {
+            layoutKey = this.getDefaultLayoutKey();
+        }
+        PortalService service = null;
+        try {
+            service = (PortalService)this.manager.lookup(PortalService.ROLE);
+
+            return (UserProfile)service.getAttribute(KEY_PREFIX + layoutKey);
+        } catch (ServiceException e) {
+            // this should never happen
+            throw new CascadingRuntimeException("Unable to lookup portal service.", e);
+        } finally {
+            this.manager.release(service);
+        }
+    }
+    
+    protected void removeUserProfiles() {
+        // TODO: remove all profiles - we have to rememember all used layout keys
+        String layoutKey = this.getDefaultLayoutKey();
+        PortalService service = null;
+        try {
+            service = (PortalService)this.manager.lookup(PortalService.ROLE);
+
+            service.removeAttribute(KEY_PREFIX + layoutKey);
+        } catch (ServiceException e) {
+            // this should never happen
+            throw new CascadingRuntimeException("Unable to lookup portal service.", e);
+        } finally {
+            this.manager.release(service);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#login()
+     */
+    public void login() {
+        super.login();
+        // TODO - we should move most of the stuff from getPortalLayout to here
+        // for now we use a hack :)
+        this.getPortalLayout(null, null);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#logout()
+     */
+    public void logout() {
+        final UserProfile profile = this.getUserProfile(null);
+        if ( profile != null ) {
+            ServiceSelector adapterSelector = null;
+            try {
+                adapterSelector = (ServiceSelector)this.manager.lookup(CopletAdapter.ROLE+"Selector");
+
+                Iterator iter = profile.getCopletInstanceDatas().values().iterator();
+                while ( iter.hasNext() ) {
+                    CopletInstanceData cid = (CopletInstanceData) iter.next();
+                    CopletAdapter adapter = null;
+                    try {
+                        adapter = (CopletAdapter)adapterSelector.select(cid.getCopletData().getCopletBaseData().getCopletAdapterName());
+                        adapter.logout( cid );
+                    } finally {
+                        adapterSelector.release( adapter );
+                    }
+                }
+
+            } catch (ServiceException e) {
+                throw new CascadingRuntimeException("Unable to lookup portal service.", e);
+            } finally {
+                this.manager.release(adapterSelector);
+            }
+            this.removeUserProfiles();
+        }
+        super.logout();
+    }
+       
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceData(java.lang.String)
+     */
+    public CopletInstanceData getCopletInstanceData(String copletID) {
+        final UserProfile profile = this.getUserProfile(null);
+        if ( profile != null ) {
+            return (CopletInstanceData)profile.getCopletInstanceDatas().get(copletID);
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletData(java.lang.String)
+     */
+    public CopletData getCopletData(String copletDataId) {
+        final UserProfile profile = this.getUserProfile(null);
+        if ( profile != null ) {
+            return (CopletData)profile.getCopletDatas().get(copletDataId);
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceData(org.apache.cocoon.portal.coplet.CopletData)
+     */
+    public List getCopletInstanceData(CopletData data) {
+        final UserProfile profile = this.getUserProfile(null);
+        final List coplets = new ArrayList();
+        if ( profile != null ) {
+            final Iterator iter = profile.getCopletInstanceDatas().values().iterator();
+            while ( iter.hasNext() ) {
+                final CopletInstanceData current = (CopletInstanceData)iter.next();
+                if ( current.getCopletData().equals(data) ) {
+                    coplets.add( current );
+                }
+            }
+        }
+        return coplets;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#register(org.apache.cocoon.portal.coplet.CopletInstanceData)
+     */
+    public void register(CopletInstanceData coplet) {
+        final UserProfile profile = this.getUserProfile(null);
+        profile.getCopletInstanceDatas().put(coplet.getId(), coplet);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#unregister(org.apache.cocoon.portal.coplet.CopletInstanceData)
+     */
+    public void unregister(CopletInstanceData coplet) {
+        final UserProfile profile = this.getUserProfile(null);
+        profile.getCopletInstanceDatas().remove(coplet.getId());
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#register(org.apache.cocoon.portal.layout.Layout)
+     */
+    public void register(Layout layout) {
+        if ( layout != null && layout.getId() != null ) {
+            final UserProfile profile = this.getUserProfile(null);    
+            profile.getLayouts().put(layout.getId(), layout);
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#unregister(org.apache.cocoon.portal.layout.Layout)
+     */
+    public void unregister(Layout layout) {
+        if ( layout != null && layout.getId() != null ) {
+            final UserProfile profile = this.getUserProfile(null);
+            profile.getLayouts().remove(layout.getId());
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#getPortalLayout(java.lang.String,
java.lang.String)
+     */
+    public Layout getPortalLayout(String layoutKey, String layoutId) {
+        PortalService service = null;
+
+        try {
+            service = (PortalService) this.manager.lookup(PortalService.ROLE);
+            if ( null == layoutKey ) {
+                layoutKey = this.getDefaultLayoutKey();
+            }
+            // FIXME actually this is a hack for full screen
+            Layout l = (Layout) service.getTemporaryAttribute("DEFAULT_LAYOUT:" + layoutKey);
+            if ( null != l) {
+                return l;
+            }
+            
+            UserProfile profile = this.getUserProfile(layoutKey);
+            if ( profile == null ) {
+                profile = this.loadProfile(layoutKey, service);
+            }
+            if ( profile == null ) {
+                throw new RuntimeException("Unable to load profile: " + layoutKey);
+            }
+            if ( layoutId != null ) {
+                return (Layout)profile.getLayouts().get(layoutId);
+            }
+            return profile.getRootLayout();
+        } catch (Exception ce) {
+            throw new CascadingRuntimeException("Exception during loading of profile.", ce);
+        } finally {
+            this.manager.release(service);
+        }
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletDatas()
+     */
+    public Collection getCopletDatas() {
+        final UserProfile profile = this.getUserProfile(null);
+        if ( profile != null ) {
+            return profile.getCopletDatas().values();
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceDatas()
+     */
+    public Collection getCopletInstanceDatas() {
+        final UserProfile profile = this.getUserProfile(null);
+        if ( profile != null ) {
+            return profile.getCopletInstanceDatas().values();
+        }
+        return null;
+    }
+
+    /**
+     * Return the user info about the current user.
+     * This implementation uses the authentication framework - if you
+     * want to use a different authentication method just overwrite this
+     * method.
+     */
+    protected UserInfo getUserInfo() {
+        AuthenticationManager authManager = null;
+        try {
+            authManager = (AuthenticationManager)this.manager.lookup(AuthenticationManager.ROLE);
+            final UserInfo info = new UserInfo();
+            info.setUserName(authManager.getState().getHandler().getUserId());
+            try {
+                info.setGroup((String)authManager.getState().getHandler().getContext().getContextInfo().get("group"));
+            } catch (ProcessingException pe) {
+                // ignore this
+            }
+            return info;    
+        } catch (ServiceException ce) {
+            // ignore this here
+            return null;
+        } finally {
+            this.manager.release( authManager );
+        }
+    }
+        
+    /**
+     * Load the profile
+     */
+    protected UserProfile loadProfile(final String layoutKey, final PortalService service)
{
+        final UserProfile profile = new UserProfile();
+        
+        return profile;
+    }
+}

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java
Tue Aug 31 05:24:59 2004
@@ -42,9 +42,11 @@
 import org.w3c.dom.Element;
 
 /**
+ * This implementation uses Castor to load/save the profiles.
+ * 
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * 
- * @version CVS $Id: MapProfileLS.java,v 1.7 2004/03/05 13:02:16 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public class MapProfileLS
     extends AbstractLogEnabled

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
Tue Aug 31 05:24:59 2004
@@ -304,30 +304,35 @@
      * @see org.apache.cocoon.portal.profile.ProfileManager#register(org.apache.cocoon.portal.coplet.CopletInstanceData)
      */
     public void register(CopletInstanceData coplet) {
+        // nothing to do
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#unregister(org.apache.cocoon.portal.coplet.CopletInstanceData)
      */
     public void unregister(CopletInstanceData coplet) {
+        // nothing to do
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#register(org.apache.cocoon.portal.layout.Layout)
      */
     public void register(Layout layout) {
+        // nothing to do
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#unregister(org.apache.cocoon.portal.layout.Layout)
      */
     public void unregister(Layout layout) {
+        // nothing to do
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserProfiles()
      */
     public void saveUserProfiles() {
+        // nothing to do
     }
 
     /* (non-Javadoc)
@@ -338,7 +343,6 @@
         super.configure(configuration);
         Configuration child = configuration.getChild("profiles-path");
         this.profilesPath = child.getValue("cocoon:/profiles");
-        //this.profilesPath = "context://samples/simple-portal/profiles";
     }
         
     /* (non-Javadoc)

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfo.java
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserInfo.java
Tue Aug 31 05:24:59 2004
@@ -0,0 +1,59 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.profile.impl;
+
+/**
+ * Information about the current user.
+ * This data object is used for loading the profile. It decouples the
+ * portal from the used authentication method.
+ * 
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @version CVS $Id: MapProfileLS.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class UserInfo {
+    
+    protected String userName;
+    
+    protected String group;
+    
+    /**
+     * @return Returns the group.
+     */
+    public String getGroup() {
+        return group;
+    }
+
+    /**
+     * @param group The group to set.
+     */
+    public void setGroup(String group) {
+        this.group = group;
+    }
+    
+    /**
+     * @return Returns the userName.
+     */
+    public String getUserName() {
+        return userName;
+    }
+    
+    /**
+     * @param userName The userName to set.
+     */
+    public void setUserName(String userName) {
+        this.userName = userName;
+    }
+}

Added: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserProfile.java
==============================================================================
--- (empty file)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/UserProfile.java
Tue Aug 31 05:24:59 2004
@@ -0,0 +1,112 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.profile.impl;
+
+import java.util.Map;
+
+import org.apache.cocoon.portal.layout.Layout;
+
+/**
+ * This data object holds all information about the current user:
+ * - references to the configuration
+ * - all selected coplets (coplet instance datas)
+ * - layout objects
+ * 
+ * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
+ * @version CVS $Id: MapProfileLS.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+public class UserProfile {
+    
+    protected Map copletBaseDatas;
+    
+    protected Map copletDatas;
+    
+    protected Map copletInstanceDatas;
+    
+    protected Map layouts;
+    
+    protected Layout rootLayout;
+    
+    /**
+     * @return Returns the copletBaseDatas.
+     */
+    public Map getCopletBaseDatas() {
+        return copletBaseDatas;
+    }
+    
+    /**
+     * @param copletBaseDatas The copletBaseDatas to set.
+     */
+    public void setCopletBaseDatas(Map copletBaseDatas) {
+        this.copletBaseDatas = copletBaseDatas;
+    }
+    
+    /**
+     * @return Returns the copletDatas.
+     */
+    public Map getCopletDatas() {
+        return copletDatas;
+    }
+    
+    /**
+     * @param copletDatas The copletDatas to set.
+     */
+    public void setCopletDatas(Map copletDatas) {
+        this.copletDatas = copletDatas;
+    }
+    
+    /**
+     * @return Returns the copletInstanceDatas.
+     */
+    public Map getCopletInstanceDatas() {
+        return copletInstanceDatas;
+    }
+    
+    /**
+     * @param copletInstanceDatas The copletInstanceDatas to set.
+     */
+    public void setCopletInstanceDatas(Map copletInstanceDatas) {
+        this.copletInstanceDatas = copletInstanceDatas;
+    }
+    
+    /**
+     * @return Returns the layouts.
+     */
+    public Map getLayouts() {
+        return layouts;
+    }
+    
+    /**
+     * @param layouts The layouts to set.
+     */
+    public void setLayouts(Map layouts) {
+        this.layouts = layouts;
+    }
+    
+    /**
+     * @return Returns the rootLayout.
+     */
+    public Layout getRootLayout() {
+        return rootLayout;
+    }
+    
+    /**
+     * @param rootLayout The rootLayout to set.
+     */
+    public void setRootLayout(Layout rootLayout) {
+        this.rootLayout = rootLayout;
+    }
+}

Mime
View raw message