cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r293160 - in /cocoon: blocks/portal/trunk/java/org/apache/cocoon/portal/profile/ blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/ blocks/portal/trunk/java/org/apache/cocoon/portal/scratchpad/ trunk/legal/ trunk/lib/ trunk/lib...
Date Sun, 02 Oct 2005 20:22:18 GMT
Author: cziegeler
Date: Sun Oct  2 13:21:13 2005
New Revision: 293160

URL: http://svn.apache.org/viewcvs?rev=293160&view=rev
Log:
Start improving profile handling

Added:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUserInfoProvider.java   (with props)
    cocoon/trunk/legal/cowarp-0.5-dev-20051002.jar.license.txt
      - copied unchanged from r293137, cocoon/trunk/legal/cowarp-0.4.jar.license.txt
    cocoon/trunk/lib/optional/cowarp-0.5-dev-20051002.jar   (with props)
Removed:
    cocoon/trunk/legal/cowarp-0.4.jar.license.txt
    cocoon/trunk/lib/optional/cowarp-0.4.jar
Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AuthenticationFWUserInfoProvider.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfoProvider.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/scratchpad/Profile.java
    cocoon/trunk/lib/jars.xml

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUserInfoProvider.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUserInfoProvider.java?rev=293160&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUserInfoProvider.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUserInfoProvider.java Sun Oct  2 13:21:13 2005
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2005 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;
+
+import java.util.Map;
+
+/**
+ * Get the information about the current user and the configuration for
+ * the portal.
+ * This interface is the connection between the used authentication method
+ * and the portal.
+ *
+ * @version $Id$
+ */
+public interface PortalUserInfoProvider {
+    
+    /**
+     * Return the user for a portal.
+     */
+    PortalUser getPortalUser(String portalName);
+
+    /**
+     * Return the user for a portal.
+     */
+    Map getConfiguration(String portalName);
+}
\ No newline at end of file

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUserInfoProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUserInfoProvider.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java?rev=293160&r1=293159&r2=293160&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java Sun Oct  2 13:21:13 2005
@@ -1,12 +1,12 @@
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
- * 
+ * Copyright 1999-2002,2004-2005 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.
@@ -15,50 +15,68 @@
  */
 package org.apache.cocoon.portal.profile.impl;
 
+import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.layout.Layout;
 import org.apache.cocoon.portal.profile.ProfileManager;
 
 /**
- * Base class for all profile managers
- * 
+ * Base class for all profile managers.
+ *
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
- * 
+ *
  * @version CVS $Id$
  */
 public abstract class AbstractProfileManager 
     extends AbstractLogEnabled 
-    implements Serviceable, ProfileManager, ThreadSafe {
+    implements Serviceable, Disposable, ProfileManager, ThreadSafe {
 
+    /** The service manager of the portal application. */
     protected ServiceManager manager;
 
-    /* (non-Javadoc)
+    /** The corresponding portal service. */
+    protected PortalService portalService;
+
+    /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager manager) throws ServiceException {
         this.manager = manager;
+        this.portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        if ( this.manager != null ) {
+            this.manager.release(this.portalService);
+            this.portalService = null;
+            this.manager = null;
+        }
     }
 
-    /* (non-Javadoc)
+    /**
      * @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(String)
      */
     public void saveUserProfiles(String layoutKey) {
@@ -66,46 +84,45 @@
         this.saveUserLayout(layoutKey);
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserCopletInstanceDatas(java.lang.String)
      */
     public void saveUserCopletInstanceDatas(String layoutKey) {
         // override in subclass
     }
 
-    /* (non-Javadoc)
-    * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserLayout(String)
-    */
+    /**
+     * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserLayout(String)
+     */
     public void saveUserLayout(String layoutKey) {
         // override 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
     }
 
-    /* (non-Javadoc)
+    /**
      * @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
     }
-
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AuthenticationFWUserInfoProvider.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AuthenticationFWUserInfoProvider.java?rev=293160&r1=293159&r2=293160&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AuthenticationFWUserInfoProvider.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AuthenticationFWUserInfoProvider.java Sun Oct  2 13:21:13 2005
@@ -1,12 +1,12 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ * Copyright 1999-2005 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.
@@ -18,11 +18,15 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.portal.profile.PortalUser;
+import org.apache.cocoon.portal.profile.PortalUserInfoProvider;
 import org.apache.cocoon.webapps.authentication.AuthenticationManager;
 import org.apache.cocoon.webapps.authentication.configuration.ApplicationConfiguration;
 import org.apache.cocoon.webapps.authentication.user.RequestState;
@@ -31,36 +35,33 @@
 /**
  * Get the information about the current user.
  * This implementation uses the authentication-fw block
- * 
+ *
  * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  * @version CVS $Id: MapProfileLS.java 30941 2004-07-29 19:56:58Z vgritsenko $
  */
 public class AuthenticationFWUserInfoProvider 
-implements UserInfoProvider, Serviceable {
-    
+implements PortalUserInfoProvider, Serviceable {
+
     protected ServiceManager manager;
-    
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
     public void service(ServiceManager manager) throws ServiceException {
         this.manager = manager;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.profile.impl.UserInfoProvider#getUserInfo(java.lang.String, java.lang.String)
+    /**
+     * @see org.apache.cocoon.portal.profile.PortalUserInfoProvider#getPortalUser(java.lang.String)
      */
-    public UserInfo getUserInfo(String portalName, String layoutKey) 
-    throws Exception {
+    public PortalUser getPortalUser(String portalName) {
         AuthenticationManager authManager = null;
         try {
             authManager = (AuthenticationManager)this.manager.lookup(AuthenticationManager.ROLE);
             final RequestState state = authManager.getState();
             final UserHandler handler = state.getHandler();
 
-            final UserInfo info = new AFWUserInfo(portalName, layoutKey, handler);
-
+            final UserInfo info = new AFWUserInfo(portalName, handler);
 
             info.setUserName(handler.getUserId());
             try {
@@ -69,13 +70,29 @@
                 // ignore this
             }
 
+            return info;
+        } catch (ServiceException se) {
+            throw new CascadingRuntimeException("Unable to lookup authentication manager.", se);
+        } finally {
+            this.manager.release( authManager );
+        }
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.profile.PortalUserInfoProvider#getConfiguration(java.lang.String)
+     */
+    public Map getConfiguration(String portalName) {
+        AuthenticationManager authManager = null;
+        try {
+            authManager = (AuthenticationManager)this.manager.lookup(AuthenticationManager.ROLE);
+            final RequestState state = authManager.getState();
             final ApplicationConfiguration ac = state.getApplicationConfiguration();        
             if ( ac == null ) {
-                throw new ProcessingException("Configuration for portal not found in application configuration.");
+                throw new RuntimeException("Configuration for portal not found in application configuration.");
             }
             final Configuration appConf = ac.getConfiguration("portal");
             if ( appConf == null ) {
-                throw new ProcessingException("Configuration for portal not found in application configuration.");
+                throw new RuntimeException("Configuration for portal not found in application configuration.");
             }
             final Configuration config = appConf.getChild("profiles");
             final Configuration[] children = config.getChildren();
@@ -85,26 +102,29 @@
                     configs.put(children[i].getName(), children[i].getAttribute("uri"));
                 }
             }
-            info.setConfigurations(configs);
-            return info;    
+            return configs;
+        } catch (ServiceException se) {
+            throw new CascadingRuntimeException("Unable to lookup authentication manager.", se);
+        } catch (ConfigurationException ce) {
+            throw new CascadingRuntimeException("Unable to get required configuration.", ce);
         } finally {
             this.manager.release( authManager );
         }
     }
-    
+
     public static final class AFWUserInfo extends UserInfo {
-        
+
         protected final UserHandler handler;
         /**
          * @param portalName
          * @param layoutKey
          */
-        public AFWUserInfo(String portalName, String layoutKey, UserHandler handler) {
-            super(portalName, layoutKey);
+        public AFWUserInfo(String portalName, UserHandler handler) {
+            super(portalName, null);
             this.handler = handler;
         }
-    
-        /* (non-Javadoc)
+
+        /**
          * @see org.apache.cocoon.portal.profile.PortalUser#isUserInRole(java.lang.String)
          */
         public boolean isUserInRole(String role) {

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java?rev=293160&r1=293159&r2=293160&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java Sun Oct  2 13:21:13 2005
@@ -1,12 +1,12 @@
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
- * 
+ * Copyright 1999-2002,2004-2005 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.
@@ -17,6 +17,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -35,13 +36,13 @@
 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.CopletFactory;
 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.portal.profile.PortalUser;
+import org.apache.cocoon.portal.profile.PortalUserInfoProvider;
 import org.apache.cocoon.portal.profile.ProfileLS;
 import org.apache.cocoon.util.ClassUtils;
 import org.apache.commons.collections.map.LinkedMap;
@@ -53,7 +54,7 @@
  * This profile manager uses a group based approach:
  * The coplet-base-data and the coplet-data are global, these are shared
  * between all users.
- * If the user has is own set of coplet-instance-datas/layouts these are
+ * If the user has his own set of coplet-instance-datas/layouts these are
  * loaded.
  * If the user has not an own set, the group set is loaded - therefore
  * each user has belong to exactly one group.
@@ -77,117 +78,104 @@
     public static final String CATEGORY_GLOBAL = "global";
     public static final String CATEGORY_GROUP  = "group";
     public static final String CATEGORY_USER   = "user";
-    
+
+    protected static final Map MAP_FOR_BASE_DATA = Collections.singletonMap(ProfileLS.PARAMETER_PROFILETYPE,
+                                                                            ProfileLS.PROFILETYPE_COPLETBASEDATA);
+
     protected static final String KEY_PREFIX = GroupBasedProfileManager.class.getName() + ':';
-    
+
     protected static final class ProfileInfo {
         public Map            objects;
         public SourceValidity validity;
     }
-    
-    protected ProfileInfo copletBaseDatas;
-    protected ProfileInfo copletDatas;
-    
+
+    final protected ProfileInfo copletBaseDatas = new ProfileInfo();
+    final protected ProfileInfo copletDatas = new ProfileInfo();
+
     /** The userinfo provider - the connection to the authentication mechanism */
-    protected UserInfoProvider provider;
-    
+    protected PortalUserInfoProvider provider;
+
     /** The class name of the userinfo provider */
-    protected String userInfoProviderClassName;
-    
+    protected String portalUserInfoProviderClassName;
+
     /** The component context */
     protected Context context;
-    
-    /* (non-Javadoc)
+
+    /** Check for changes? */
+    protected boolean checkForChanges = true;
+
+    /**
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      */
     public void contextualize(Context context) throws ContextException {
         this.context = context;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
      */
     public void parameterize(Parameters params) throws ParameterException {
-        this.userInfoProviderClassName = params.getParameter("userinfo-provider");
+        this.portalUserInfoProviderClassName = params.getParameter("userinfo-provider");
+        this.checkForChanges = params.getParameterAsBoolean("check-for-changes", this.checkForChanges);
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.avalon.framework.activity.Initializable#initialize()
      */
     public void initialize() throws Exception {
-        this.provider = (UserInfoProvider)ClassUtils.newInstance(this.userInfoProviderClassName);
+        this.provider = (PortalUserInfoProvider)ClassUtils.newInstance(this.portalUserInfoProviderClassName);
         ContainerUtil.enableLogging(this.provider, this.getLogger());
         ContainerUtil.contextualize(this.provider, this.context);
         ContainerUtil.service(this.provider, this.manager);
         ContainerUtil.initialize(this.provider);
-        this.copletBaseDatas = new ProfileInfo();
-        this.copletDatas = new ProfileInfo();
     }
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.avalon.framework.activity.Disposable#dispose()
      */
     public void dispose() {
         ContainerUtil.dispose(this.provider);
         this.provider = null;
-        this.manager = null;
+        super.dispose();
     }
-    
-    protected UserProfile getUserProfile(String layoutKey) {
-        PortalService service = null;
-        try {
-            service = (PortalService)this.manager.lookup(PortalService.ROLE);
-            if ( layoutKey == null ) {
-                layoutKey = service.getDefaultLayoutKey();
-            }
 
-            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 UserProfile getUserProfile(String layoutKey) {
+        if ( layoutKey == null ) {
+            layoutKey = this.portalService.getDefaultLayoutKey();
         }
+
+        return (UserProfile)this.portalService.getAttribute(KEY_PREFIX + layoutKey);
     }
-    
+
     protected void removeUserProfiles() {
         // TODO: remove all profiles - we have to rememember all used layout keys
-        PortalService service = null;
-        try {
-            service = (PortalService)this.manager.lookup(PortalService.ROLE);
-            final String layoutKey = service.getDefaultLayoutKey();
+        final String layoutKey = this.portalService.getDefaultLayoutKey();
 
-            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);
-        }
+        this.portalService.removeAttribute(KEY_PREFIX + layoutKey);
     }
 
-    protected void storeUserProfile(String layoutKey, PortalService service, UserProfile profile) {
+    protected void storeUserProfile(String layoutKey, UserProfile profile) {
         if ( layoutKey == null ) {
-            layoutKey = service.getDefaultLayoutKey();
+            layoutKey = this.portalService.getDefaultLayoutKey();
         }
-        service.setAttribute(KEY_PREFIX + layoutKey, profile);
+        this.portalService.setAttribute(KEY_PREFIX + layoutKey, profile);
     }
     
     /**
      * Prepares the object by using the specified factory.
      */
-    protected void prepareObject(Object object, PortalService service)
+    protected void prepareObject(Object object)
     throws ProcessingException {
         if ( object != null ) {
             if ( object instanceof Map ) {
                 object = ((Map)object).values();
             }
             if (object instanceof Layout) {
-                service.getComponentManager().getLayoutFactory().prepareLayout((Layout)object);
+                this.portalService.getComponentManager().getLayoutFactory().prepareLayout((Layout)object);
             } else if (object instanceof Collection) {
                 ServiceSelector adapterSelector = null;
                 try {
-                    final CopletFactory copletFactory = service.getComponentManager().getCopletFactory();
+                    final CopletFactory copletFactory = this.portalService.getComponentManager().getCopletFactory();
                     final Iterator iterator = ((Collection)object).iterator();
                     while (iterator.hasNext()) {
                         final Object o = iterator.next();
@@ -219,7 +207,7 @@
         }
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.portal.profile.ProfileManager#login()
      */
     public void login() {
@@ -229,7 +217,7 @@
         this.getPortalLayout(null, null);
     }
     
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.portal.profile.ProfileManager#logout()
      */
     public void logout() {
@@ -260,8 +248,8 @@
         }
         super.logout();
     }
-       
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceData(java.lang.String)
      */
     public CopletInstanceData getCopletInstanceData(String copletID) {
@@ -272,7 +260,7 @@
         return null;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletData(java.lang.String)
      */
     public CopletData getCopletData(String copletDataId) {
@@ -283,7 +271,7 @@
         return null;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceData(org.apache.cocoon.portal.coplet.CopletData)
      */
     public List getCopletInstanceData(CopletData data) {
@@ -301,15 +289,15 @@
         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) {
@@ -317,7 +305,7 @@
         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) {
@@ -326,8 +314,8 @@
             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) {
@@ -337,37 +325,32 @@
         }
     }
 
-    /* (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;
+        if ( null == layoutKey ) {
+            layoutKey = this.portalService.getDefaultLayoutKey();
+        }
 
-        try {
-            service = (PortalService) this.manager.lookup(PortalService.ROLE);
-            if ( null == layoutKey ) {
-                layoutKey = service.getDefaultLayoutKey();
-            }
-            
-            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);
+        UserProfile profile = this.getUserProfile(layoutKey);
+        if ( profile == null ) {
+            try {
+                profile = this.loadProfile(layoutKey);
+            } catch (Exception e) {
+                throw new CascadingRuntimeException("Unable to load profile: " + layoutKey, e);
+            }
         }
+        if ( profile == null ) {
+            throw new RuntimeException("Unable to load profile: " + layoutKey);
+        }
+        if ( layoutId != null ) {
+            return (Layout)profile.getLayouts().get(layoutId);
+        }
+        return profile.getRootLayout();
     }
     
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletDatas()
      */
     public Collection getCopletDatas() {
@@ -378,7 +361,7 @@
         return null;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletInstanceDatas()
      */
     public Collection getCopletInstanceDatas() {
@@ -392,31 +375,31 @@
     /**
      * Load the profile
      */
-    protected UserProfile loadProfile(final String layoutKey, final PortalService service) 
+    protected UserProfile loadProfile(final String layoutKey) 
     throws Exception {
-        final UserInfo info = this.provider.getUserInfo(service.getPortalName(), layoutKey);
+        final PortalUser info = this.provider.getPortalUser(this.portalService.getPortalName());
         ProfileLS loader = null;
         try {
             loader = (ProfileLS)this.manager.lookup( ProfileLS.ROLE );
             final UserProfile profile = new UserProfile();
-            this.storeUserProfile(layoutKey, service, profile);
-            
+            this.storeUserProfile(layoutKey, profile);
+
             // first "load" the global data
-            profile.setCopletBaseDatas( this.getGlobalBaseDatas(loader, info, service) );
-            profile.setCopletDatas( this.getGlobalDatas(loader, info, service, profile) );
-            
+            profile.setCopletBaseDatas( this.getGlobalBaseDatas(loader, info, layoutKey) );
+            profile.setCopletDatas( this.getGlobalDatas(loader, info, profile, layoutKey) );
+
             // now load the user/group specific data
-            if ( !this.getCopletInstanceDatas(loader, profile, info, service, CATEGORY_USER) ) {
-                if ( info.getGroup() == null || !this.getCopletInstanceDatas(loader, profile, info, service, CATEGORY_GROUP)) {
-                    if ( !this.getCopletInstanceDatas(loader, profile, info, service, CATEGORY_GLOBAL) ) {
+            if ( !this.getCopletInstanceDatas(loader, profile, info, CATEGORY_USER, layoutKey) ) {
+                if ( info.getGroup() == null || !this.getCopletInstanceDatas(loader, profile, info, CATEGORY_GROUP, layoutKey)) {
+                    if ( !this.getCopletInstanceDatas(loader, profile, info, CATEGORY_GLOBAL, layoutKey) ) {
                         throw new ProcessingException("No profile for copletinstancedatas found.");
                     }
                 }
             }
 
-            if ( !this.getLayout(loader, profile, info, service, CATEGORY_USER) ) {
-                if ( info.getGroup() == null || !this.getLayout(loader, profile, info, service, CATEGORY_GROUP)) {
-                    if ( !this.getLayout(loader, profile, info, service, CATEGORY_GLOBAL) ) {
+            if ( !this.getLayout(loader, profile, info, CATEGORY_USER, layoutKey) ) {
+                if ( info.getGroup() == null || !this.getLayout(loader, profile, info, CATEGORY_GROUP, layoutKey)) {
+                    if ( !this.getLayout(loader, profile, info, CATEGORY_GLOBAL, layoutKey) ) {
                         throw new ProcessingException("No profile for layout found.");
                     }
                 }
@@ -429,68 +412,98 @@
             this.manager.release( loader );
         }
     }
-    
-    protected Map getGlobalBaseDatas(final ProfileLS     loader,
-                                     final UserInfo      info,
-                                     final PortalService service) 
+
+    protected Map getGlobalBaseDatas(final ProfileLS  loader,
+                                     final PortalUser info,
+                                     final String     layoutKey) 
     throws Exception {
-        synchronized ( this ) {
-            final Map key = this.buildKey(CATEGORY_GLOBAL, 
-                    ProfileLS.PROFILETYPE_COPLETBASEDATA, 
-                    info, 
-                    true);
-            final Map parameters = new HashMap();
-            parameters.put(ProfileLS.PARAMETER_PROFILETYPE, 
-                           ProfileLS.PROFILETYPE_COPLETBASEDATA);
-            
-            if ( this.copletBaseDatas.validity != null
-                 && this.copletBaseDatas.validity.isValid() == SourceValidity.VALID) {
+        // if we already have loaded the profile and don't check
+        // for changes, just return the profile
+        if ( this.copletBaseDatas.objects != null && !this.checkForChanges ) {
+            return this.copletBaseDatas.objects;
+        }
+
+        final Map key = this.buildKey(CATEGORY_GLOBAL, 
+                ProfileLS.PROFILETYPE_COPLETBASEDATA, 
+                info, 
+                true,
+                layoutKey);
+
+        SourceValidity newValidity = null;
+        // if we have a profile, check for reloading
+        if ( this.copletBaseDatas.validity != null ) {
+            // if it's still valid just return the profile
+            final int validity = this.copletBaseDatas.validity.isValid();
+            if ( validity == SourceValidity.VALID) {
                 return this.copletBaseDatas.objects;
+            } else if ( validity == SourceValidity.UNKNOWN ) {
+                newValidity = loader.getValidity(key, MAP_FOR_BASE_DATA);
+                if ( newValidity != null
+                     && this.copletBaseDatas.validity.isValid(newValidity) == SourceValidity.VALID) {
+                    return this.copletBaseDatas.objects;
+                }
             }
-            final SourceValidity newValidity = loader.getValidity(key, parameters);
-            if ( this.copletBaseDatas.validity != null 
-                 && newValidity != null
-                 && this.copletBaseDatas.validity.isValid(newValidity) == SourceValidity.VALID) {
-                return this.copletBaseDatas.objects;
+        }
+
+        // we have to load/reload
+        synchronized ( this ) {
+            this.copletBaseDatas.objects = ((CopletBaseDataManager)loader.loadProfile(key, MAP_FOR_BASE_DATA)).getCopletBaseData();
+            if ( newValidity == null ) {
+                newValidity = loader.getValidity(key, MAP_FOR_BASE_DATA);
             }
-            this.copletBaseDatas.objects = ((CopletBaseDataManager)loader.loadProfile(key, parameters)).getCopletBaseData();
             this.copletBaseDatas.validity = newValidity;
             this.copletDatas.objects = null;
             this.copletDatas.validity = null;
-            this.prepareObject(this.copletBaseDatas.objects, service);
+            this.prepareObject(this.copletBaseDatas.objects);
             return this.copletBaseDatas.objects;
         }
     }
-    
-    protected Map getGlobalDatas(final ProfileLS     loader,
-                                 final UserInfo      info,
-                                 final PortalService service,
-                                 final UserProfile   profile) 
+
+    protected Map getGlobalDatas(final ProfileLS   loader,
+                                 final PortalUser  info,
+                                 final UserProfile profile,
+                                 final String      layoutKey) 
     throws Exception {
-        synchronized ( this ) {
-            final Map key = this.buildKey(CATEGORY_GLOBAL, 
-                    ProfileLS.PROFILETYPE_COPLETDATA, 
-                    info, 
-                    true);
-            final Map parameters = new HashMap();
-            parameters.put(ProfileLS.PARAMETER_PROFILETYPE, 
-                           ProfileLS.PROFILETYPE_COPLETDATA);
-            parameters.put(ProfileLS.PARAMETER_OBJECTMAP,
-                           profile.getCopletBaseDatas());
-            
-            if ( this.copletDatas.validity != null
-                 && this.copletDatas.validity.isValid() == SourceValidity.VALID) {
-                return this.copletDatas.objects;
-            }
-            final SourceValidity newValidity = loader.getValidity(key, parameters);
-            if ( this.copletDatas.validity != null 
-                 && newValidity != null
-                 && this.copletDatas.validity.isValid(newValidity) == SourceValidity.VALID) {
+        // if we already have loaded the profile and don't check
+        // for changes, just return the profile
+        if ( this.copletDatas.objects != null && !this.checkForChanges ) {
+            return this.copletDatas.objects;
+        }
+
+        final Map key = this.buildKey(CATEGORY_GLOBAL, 
+                ProfileLS.PROFILETYPE_COPLETDATA, 
+                info, 
+                true,
+                layoutKey);
+        final Map parameters = new HashMap();
+        parameters.put(ProfileLS.PARAMETER_PROFILETYPE, 
+                       ProfileLS.PROFILETYPE_COPLETDATA);
+        parameters.put(ProfileLS.PARAMETER_OBJECTMAP,
+                       profile.getCopletBaseDatas());
+
+        SourceValidity newValidity = null;
+        // if we have a profile, check for reloading
+        if ( this.copletDatas.validity != null ) {
+            // if it's still valid just return the profile
+            final int validity = this.copletDatas.validity.isValid();
+            if ( validity == SourceValidity.VALID) {
                 return this.copletDatas.objects;
+            } else if ( validity == SourceValidity.UNKNOWN ) {
+                newValidity = loader.getValidity(key,parameters);
+                if ( newValidity != null
+                     && this.copletDatas.validity.isValid(newValidity) == SourceValidity.VALID) {
+                    return this.copletDatas.objects;
+                }
             }
+        }
+
+        synchronized ( this ) {
             this.copletDatas.objects = ((CopletDataManager)loader.loadProfile(key, parameters)).getCopletData();
+            if ( newValidity == null ) {
+                newValidity = loader.getValidity(key, parameters);
+            }
             this.copletDatas.validity = newValidity;
-            this.prepareObject(this.copletDatas.objects, service);
+            this.prepareObject(this.copletDatas.objects);
             return this.copletDatas.objects;
         }
     }
@@ -505,16 +518,17 @@
         return false;
     }
 
-    protected boolean getCopletInstanceDatas(final ProfileLS     loader,
-                                             final UserProfile   profile,
-                                             final UserInfo      info,
-                                             final PortalService service,
-                                             final String        category) 
+    protected boolean getCopletInstanceDatas(final ProfileLS   loader,
+                                             final UserProfile profile,
+                                             final PortalUser  info,
+                                             final String      category,
+                                             final String      layoutKey) 
     throws Exception {
         Map key = this.buildKey(category, 
                                 ProfileLS.PROFILETYPE_COPLETINSTANCEDATA, 
                                 info, 
-                                true);
+                                true,
+                                layoutKey);
         Map parameters = new HashMap();
         parameters.put(ProfileLS.PARAMETER_PROFILETYPE, 
                        ProfileLS.PROFILETYPE_COPLETINSTANCEDATA);        
@@ -524,8 +538,8 @@
         try {
             CopletInstanceDataManager cidm = (CopletInstanceDataManager)loader.loadProfile(key, parameters);
             profile.setCopletInstanceDatas(cidm.getCopletInstanceData());
-            this.prepareObject(profile.getCopletInstanceDatas(), service);
-            
+            this.prepareObject(profile.getCopletInstanceDatas());
+
             return true;
         } catch (Exception e) {
             if (!isSourceNotFoundException(e)) {
@@ -535,16 +549,17 @@
         }
     }
 
-    protected boolean getLayout(final ProfileLS     loader,
-                                final UserProfile   profile,
-                                final UserInfo      info,
-                                final PortalService service,
-                                final String        category) 
+    protected boolean getLayout(final ProfileLS   loader,
+                                final UserProfile profile,
+                                final PortalUser  info,
+                                final String      category,
+                                final String      layoutKey) 
     throws Exception {
         final Map key = this.buildKey(category, 
                                       ProfileLS.PROFILETYPE_LAYOUT,  
                                       info, 
-                                      true);
+                                      true,
+                                      layoutKey);
         final Map parameters = new HashMap();
         parameters.put(ProfileLS.PARAMETER_PROFILETYPE, 
                        ProfileLS.PROFILETYPE_LAYOUT);        
@@ -552,7 +567,7 @@
                        profile.getCopletInstanceDatas());
         try {
             Layout l = (Layout)loader.loadProfile(key, parameters);
-            this.prepareObject(l, service);
+            this.prepareObject(l);
             profile.setRootLayout(l);
 
             return true;
@@ -564,10 +579,11 @@
         }
     }
 
-    protected Map buildKey(String        category,
-                           String        profileType,
-                           UserInfo      info,
-                           boolean       load) {
+    protected Map buildKey(String   category,
+                           String   profileType,
+                           PortalUser info,
+                           boolean  load,
+                           String   layoutKey) {
         final StringBuffer config = new StringBuffer(profileType);
         config.append('-');
         config.append(category);
@@ -577,13 +593,13 @@
         } else {
             config.append("save");            
         }
-        final String uri = (String)info.getConfigurations().get(config.toString());
+        final String uri = (String)this.provider.getConfiguration(this.portalService.getPortalName()).get(config.toString());
 
         final Map key = new LinkedMap();
         key.put("baseuri", uri);
         key.put("separator", "?");
-        key.put("portal", info.getPortalName());
-        key.put("layout", info.getLayoutKey());
+        key.put("portal", this.portalService.getPortalName());
+        key.put("layout", layoutKey);
         key.put("type", category);
         if ( "group".equals(category) ) {
             key.put("group", info.getGroup());
@@ -591,53 +607,32 @@
         if ( "user".equals(category) ) {
             key.put("user", info.getUserName());
         }
-        
+
         return key;
     }
-    
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.cocoon.portal.profile.ProfileManager#storeProfile(org.apache.cocoon.portal.layout.Layout, java.lang.String)
      */
     public void storeProfile(Layout rootLayout, String layoutKey) {
-        PortalService service = null;
-
-        try {
-            UserProfile oldProfile = this.getUserProfile(null);
-            service = (PortalService) this.manager.lookup(PortalService.ROLE);
-            if ( null == layoutKey ) {
-                layoutKey = service.getDefaultLayoutKey();
-            }
-            // FIXME for now we just copy the root profile, except the root layout
-            UserProfile newProfile = new UserProfile();
-            newProfile.setCopletBaseDatas(oldProfile.getCopletBaseDatas());
-            newProfile.setCopletDatas(oldProfile.getCopletDatas());
-            newProfile.setCopletInstanceDatas(oldProfile.getCopletInstanceDatas());
-            newProfile.setRootLayout(rootLayout);
-            
-            this.storeUserProfile(layoutKey, service, newProfile);
-        } catch (Exception ce) {
-            throw new CascadingRuntimeException("Exception during loading of profile.", ce);
-        } finally {
-            this.manager.release(service);
-        }
+        UserProfile oldProfile = this.getUserProfile(null);
+        if ( null == layoutKey ) {
+            layoutKey = this.portalService.getDefaultLayoutKey();
+        }
+        // FIXME for now we just copy the root profile, except the root layout
+        UserProfile newProfile = new UserProfile();
+        newProfile.setCopletBaseDatas(oldProfile.getCopletBaseDatas());
+        newProfile.setCopletDatas(oldProfile.getCopletDatas());
+        newProfile.setCopletInstanceDatas(oldProfile.getCopletInstanceDatas());
+        newProfile.setRootLayout(rootLayout);
+        
+        this.storeUserProfile(layoutKey, newProfile);
     }
-    
-    
-    /* (non-Javadoc)
+
+    /**
      * @see org.apache.cocoon.portal.profile.ProfileManager#getUser()
      */
     public PortalUser getUser() {
-        PortalService service = null;
-        try {
-            service = (PortalService) this.manager.lookup(PortalService.ROLE);
-            final String layoutKey = service.getDefaultLayoutKey();
-            final UserInfo info = this.provider.getUserInfo(service.getPortalName(), layoutKey);
-            return info;
-        } catch (Exception ce) {
-            throw new CascadingRuntimeException("Exception during getUser().", ce);
-        } finally {
-            this.manager.release(service);
-        }            
+        return this.provider.getPortalUser(this.portalService.getPortalName());
     }
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfoProvider.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfoProvider.java?rev=293160&r1=293159&r2=293160&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfoProvider.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfoProvider.java Sun Oct  2 13:21:13 2005
@@ -1,12 +1,12 @@
 /*
- * Copyright 1999-2004 The Apache Software Foundation.
- * 
+ * Copyright 1999-2005 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.
@@ -19,9 +19,12 @@
  * Get the 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@apache.org">Carsten Ziegeler</a>
  * @version CVS $Id: MapProfileLS.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ * @deprecated This interface is not supported anymore.
+ *             Use {@link org.apache.cocoon.portal.profile.PortalUserInfoProvider} instead.
  */
 public interface UserInfoProvider {
     

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/scratchpad/Profile.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/scratchpad/Profile.java?rev=293160&r1=293159&r2=293160&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/scratchpad/Profile.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/scratchpad/Profile.java Sun Oct  2 13:21:13 2005
@@ -40,8 +40,6 @@
     Iterator getCopletInstanceDataObjects();
     Iterator getLayoutObjects();
 
-    Object searchObject(String uniqueIdentifer);
-
     Layout searchLayout(String layoutId);
     
     CopletBaseData searchCopletBaseData(String copletBaseDataId);

Modified: cocoon/trunk/lib/jars.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/lib/jars.xml?rev=293160&r1=293159&r2=293160&view=diff
==============================================================================
--- cocoon/trunk/lib/jars.xml (original)
+++ cocoon/trunk/lib/jars.xml Sun Oct  2 13:21:13 2005
@@ -1084,7 +1084,7 @@
       with special support for the portal.
     </description>
     <used-by>Portal</used-by>
-    <lib>optional/cowarp-0.4.jar</lib>
+    <lib>optional/cowarp-0.5-dev-20051002.jar</lib>
     <homepage>http://osoco.sourceforge.net/cowarp/</homepage>
   </file>
 

Added: cocoon/trunk/lib/optional/cowarp-0.5-dev-20051002.jar
URL: http://svn.apache.org/viewcvs/cocoon/trunk/lib/optional/cowarp-0.5-dev-20051002.jar?rev=293160&view=auto
==============================================================================
Binary file - no diff available.

Propchange: cocoon/trunk/lib/optional/cowarp-0.5-dev-20051002.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message