cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r306534 - in /cocoon: blocks/portal-sample/trunk/samples/ blocks/portal-sample/trunk/samples/conf/ blocks/portal/trunk/java/org/apache/cocoon/portal/ blocks/portal/trunk/java/org/apache/cocoon/portal/acting/ blocks/portal/trunk/java/org/apa...
Date Thu, 06 Oct 2005 05:58:16 GMT
Author: cziegeler
Date: Wed Oct  5 22:57:28 2005
New Revision: 306534

URL: http://svn.apache.org/viewcvs?rev=306534&view=rev
Log:
Further cleanup of profile handling, improve user related event handling and adding profile
saving to group based profile manager.

Added:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/LoginAction.java
      - copied, changed from r294901, cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/acting/LoginAction.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/LogoutAction.java
      - copied, changed from r294901, cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/acting/LogoutAction.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/User.java  
(with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserEventUtil.java
  (with props)
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserIsAccessingEvent.java
  (with props)
Removed:
    cocoon/blocks/portal-sample/trunk/samples/conf/auth-fw.xconf
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/acting/LoginAction.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/acting/LogoutAction.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/PortalUserInfoProvider.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/UserInfoProvider.java
Modified:
    cocoon/blocks/portal-sample/trunk/samples/conf/auth-cowarp.xconf
    cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf
    cocoon/blocks/portal-sample/trunk/samples/sitemap-auth.xmap
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/portal.roles
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/ProfileManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.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/MapProfileLS.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfo.java
    cocoon/trunk/lib/optional/cowarp-0.5-dev-20051002.jar

Modified: cocoon/blocks/portal-sample/trunk/samples/conf/auth-cowarp.xconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/conf/auth-cowarp.xconf?rev=306534&r1=306533&r2=306534&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/conf/auth-cowarp.xconf (original)
+++ cocoon/blocks/portal-sample/trunk/samples/conf/auth-cowarp.xconf Wed Oct  5 22:57:28 2005
@@ -34,25 +34,6 @@
   -->
   <component role="org.osoco.cowarp.Application/portal" 
              class="org.osoco.cowarp.portal.StandardPortalApplication" 
-             security-handler="portal">
-    <profiles>
-      <copletbasedata-global-load uri="cocoon:raw:/load-global-profile?profile=copletbasedata"/>
-      <copletdata-global-load uri="cocoon:raw:/load-global-profile?profile=copletdata"/>
-      <copletdata-role-load uri="cocoon:raw:/load-role-profile?profile=copletdata"/>
-      <copletdata-user-load uri="cocoon:raw:/load-user-profile?profile=copletdata"/>
-      <copletinstancedata-global-load uri="cocoon:raw:/load-global-profile?profile=copletinstancedata"/>
-      <copletinstancedata-role-load uri="cocoon:raw:/load-role-profile?profile=copletinstancedata"/>
-      <copletinstancedata-user-load uri="cocoon:raw:/load-user-profile?profile=copletinstancedata"/>
-      <copletinstancedata-user-save uri="cocoon:raw:/save-user-profile?profile=copletinstancedata"/>
-      <layout-global-load uri="cocoon:raw:/load-global-profile?profile=layout"/>
-      <layout-role-load uri="cocoon:raw:/load-role-profile?profile=layout"/>
-      <layout-user-load uri="cocoon:raw:/load-user-profile?profile=layout"/>
-      <layout-user-save uri="cocoon:raw:/save-user-profile?profile=layout"/>
-    </profiles>
-  </component>
-  <component class="org.apache.cocoon.portal.profile.impl.GroupBasedProfileManager"
-             role="org.apache.cocoon.portal.profile.ProfileManager">
-    <parameter name="userinfo-provider" value="org.osoco.cowarp.portal.UserInfoProviderImpl"/>
-  </component>
+             security-handler="portal"/>
 
 </components>

Modified: cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf?rev=306534&r1=306533&r2=306534&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf (original)
+++ cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf Wed Oct  5 22:57:28
2005
@@ -40,10 +40,6 @@
   <!-- We use CoWarp for authentication. If you don't use CoWarp remove this line: -->
   <include src="auth-cowarp.xconf"/>
   
-  <!-- If you want to use the authentication-fw use the following include:
-    <include src="auth-fw.xconf"/>
-  -->
-
   <input-modules>
     <component-instance name="portalpath"
                         class="org.apache.cocoon.components.modules.input.ProjectPathModule">
@@ -64,6 +60,22 @@
       </skins>
     </portal>
   </portal-service>
+
+  <!--  This is the profile manager using pipelines to load the various parts. -->
+  <portal-profile-manager class="org.apache.cocoon.portal.profile.impl.GroupBasedProfileManager">
+    <parameter name="copletbasedata-global-load" value="cocoon:raw:/load-global-profile?profile=copletbasedata"/>
+    <parameter name="copletdata-global-load" value="cocoon:raw:/load-global-profile?profile=copletdata"/>
+    <parameter name="copletdata-role-load" value="cocoon:raw:/load-role-profile?profile=copletdata"/>
+    <parameter name="copletdata-user-load" value="cocoon:raw:/load-user-profile?profile=copletdata"/>
+    <parameter name="copletinstancedata-global-load" value="cocoon:raw:/load-global-profile?profile=copletinstancedata"/>
+    <parameter name="copletinstancedata-role-load" value="cocoon:raw:/load-role-profile?profile=copletinstancedata"/>
+    <parameter name="copletinstancedata-user-load" value="cocoon:raw:/load-user-profile?profile=copletinstancedata"/>
+    <parameter name="copletinstancedata-user-save" value="cocoon:raw:/save-user-profile?profile=copletinstancedata"/>
+    <parameter name="layout-global-load" value="cocoon:raw:/load-global-profile?profile=layout"/>
+    <parameter name="layout-role-load" value="cocoon:raw:/load-role-profile?profile=layout"/>
+    <parameter name="layout-user-load" value="cocoon:raw:/load-user-profile?profile=layout"/>
+    <parameter name="layout-user-save" value="cocoon:raw:/save-user-profile?profile=layout"/>
+  </portal-profile-manager>
 
   <!-- This is the portal manager.
        The portal manager can be extended with different aspects.

Modified: cocoon/blocks/portal-sample/trunk/samples/sitemap-auth.xmap
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/sitemap-auth.xmap?rev=306534&r1=306533&r2=306534&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/sitemap-auth.xmap (original)
+++ cocoon/blocks/portal-sample/trunk/samples/sitemap-auth.xmap Wed Oct  5 22:57:28 2005
@@ -49,9 +49,9 @@
     <map:selectors default="browser"/>
     <map:actions>
       <map:action name="portal-login"
-                  src="org.apache.cocoon.portal.acting.LoginAction"/>
+                  src="org.apache.cocoon.portal.authenticationfw.LoginAction"/>
       <map:action name="portal-logout"
-                  src="org.apache.cocoon.portal.acting.LogoutAction"/>
+                  src="org.apache.cocoon.portal.authenticationfw.LogoutAction"/>
       <map:action name="portal-set-object-model"
                   src="org.apache.cocoon.acting.SetterAction"/>
       <map:action name="portal-set-data"
@@ -87,26 +87,6 @@
           <handler name="portal-handler">
             <redirect-to uri="cocoon:/login"/>
             <authentication uri="cocoon:raw:/sunrise-authuser"/>
-            <applications>
-              <application loadondemand="true" name="portal">
-                <configuration name="portal">
-                  <profiles>
-                    <copletbasedata-load uri="cocoon:raw:/load-global-profile?profile=copletbasedata"/>
-                    <copletdata-global-load uri="cocoon:raw:/load-global-profile?profile=copletdata"/>
-                    <copletdata-role-load uri="cocoon:raw:/load-role-profile?profile=copletdata"/>
-                    <copletdata-user-load uri="cocoon:raw:/load-user-profile?profile=copletdata"/>
-                    <copletinstancedata-global-load uri="cocoon:raw:/load-global-profile?profile=copletinstancedata"/>
-                    <copletinstancedata-role-load uri="cocoon:raw:/load-role-profile?profile=copletinstancedata"/>
-                    <copletinstancedata-user-load uri="cocoon:raw:/load-user-profile?profile=copletinstancedata"/>
-                    <copletinstancedata-user-save uri="cocoon:raw:/save-user-profile?profile=copletinstancedata"/>
-                    <layout-global-load uri="cocoon:raw:/load-global-profile?profile=layout"/>
-                    <layout-role-load uri="cocoon:raw:/load-role-profile?profile=layout"/>
-                    <layout-user-load uri="cocoon:raw:/load-user-profile?profile=layout"/>
-                    <layout-user-save uri="cocoon:raw:/save-user-profile?profile=layout"/>
-                  </profiles>
-                </configuration>
-              </application>
-            </applications>
           </handler>
         </handlers>
       </authentication-manager>

Copied: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/LoginAction.java
(from r294901, cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/acting/LoginAction.java)
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/LoginAction.java?p2=cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/LoginAction.java&p1=cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/acting/LoginAction.java&r1=294901&r2=306534&rev=306534&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/acting/LoginAction.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/LoginAction.java
Wed Oct  5 22:57:28 2005
@@ -13,15 +13,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.cocoon.portal.acting;
+package org.apache.cocoon.portal.authenticationfw;
 
 import java.util.Map;
 
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.environment.Redirector;
 import org.apache.cocoon.environment.SourceResolver;
-import org.apache.cocoon.portal.event.Event;
-import org.apache.cocoon.portal.event.user.UserDidLoginEvent;
+import org.apache.cocoon.portal.acting.AbstractPortalAction;
+import org.apache.cocoon.portal.event.user.UserEventUtil;
 import org.apache.cocoon.portal.profile.PortalUser;
 
 /**
@@ -46,9 +46,8 @@
             this.getLogger().debug("Portal login action called.");
         }
 
-        PortalUser user = this.portalService.getComponentManager().getProfileManager().getUser();
-        Event event = new UserDidLoginEvent(user);
-        this.portalService.getComponentManager().getEventManager().send(event);
+        PortalUser user = User.getPortalUser(this.manager, this.portalService.getPortalName());
+        UserEventUtil.sendUserDidLoginEvent(this.portalService, user);
 
         return EMPTY_MAP;
     }

Copied: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/LogoutAction.java
(from r294901, cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/acting/LogoutAction.java)
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/LogoutAction.java?p2=cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/LogoutAction.java&p1=cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/acting/LogoutAction.java&r1=294901&r2=306534&rev=306534&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/acting/LogoutAction.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/LogoutAction.java
Wed Oct  5 22:57:28 2005
@@ -13,15 +13,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.cocoon.portal.acting;
+package org.apache.cocoon.portal.authenticationfw;
 
 import java.util.Map;
 
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.environment.Redirector;
 import org.apache.cocoon.environment.SourceResolver;
-import org.apache.cocoon.portal.event.Event;
-import org.apache.cocoon.portal.event.user.UserWillLogoutEvent;
+import org.apache.cocoon.portal.acting.AbstractPortalAction;
+import org.apache.cocoon.portal.event.user.UserEventUtil;
 import org.apache.cocoon.portal.profile.PortalUser;
 
 /**
@@ -47,8 +47,7 @@
         }
 
         PortalUser user = this.portalService.getComponentManager().getProfileManager().getUser();
-        Event event = new UserWillLogoutEvent(user);
-        this.portalService.getComponentManager().getEventManager().send(event);
+        UserEventUtil.sendUserWillLogoutEvent(this.portalService, user);
 
         return EMPTY_MAP;
     }

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/User.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/User.java?rev=306534&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/User.java (added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/authenticationfw/User.java Wed
Oct  5 22:57:28 2005
@@ -0,0 +1,75 @@
+/*
+ * 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.authenticationfw;
+
+import org.apache.avalon.framework.CascadingRuntimeException;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.portal.profile.PortalUser;
+import org.apache.cocoon.portal.profile.impl.UserInfo;
+import org.apache.cocoon.webapps.authentication.AuthenticationManager;
+import org.apache.cocoon.webapps.authentication.user.RequestState;
+import org.apache.cocoon.webapps.authentication.user.UserHandler;
+
+/**
+ * The User object used by the authentication-fw implementation.
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version $Id$
+ */
+public class User extends UserInfo { 
+
+    protected final UserHandler handler;
+
+    /**
+     * @param handler
+     */
+    public User(UserHandler handler) {
+        this.handler = handler;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.profile.PortalUser#isUserInRole(java.lang.String)
+     */
+    public boolean isUserInRole(String role) {
+        return this.handler.isUserInRole(role);
+    }
+
+    public static PortalUser getPortalUser(ServiceManager manager, String portalName) {
+        AuthenticationManager authManager = null;
+        try {
+            authManager = (AuthenticationManager)manager.lookup(AuthenticationManager.ROLE);
+            final RequestState state = authManager.getState();
+            final UserHandler handler = state.getHandler();
+
+            final UserInfo info = new User(handler);
+
+            info.setUserName(handler.getUserId());
+            try {
+                info.setGroup((String)handler.getContext().getContextInfo().get("group"));
+            } catch (ProcessingException pe) {
+                // ignore this
+            }
+
+            return info;
+        } catch (ServiceException se) {
+            throw new CascadingRuntimeException("Unable to lookup authentication manager.",
se);
+        } finally {
+            manager.release( authManager );
+        }
+    }
+}

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

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

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java?rev=306534&r1=306533&r2=306534&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
Wed Oct  5 22:57:28 2005
@@ -1,12 +1,12 @@
 /*
  * 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.
@@ -86,6 +86,12 @@
     /** Introspected receiver classes */
     protected Map receiverClasses = new HashMap();
 
+    /** Are we currently processing events? */
+    protected int isSendingEvents = 0;
+
+    /** Additional receivers if we are currenlty sending events. */
+    protected List additionalReceiverClasses = new ArrayList();
+
     /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
@@ -101,7 +107,7 @@
         return ContextHelper.getObjectModel( this.context );
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
      */
     public void configure(Configuration conf) 
@@ -109,7 +115,7 @@
         this.configuration = conf;
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.framework.activity.Disposable#dispose()
      */
     public void dispose() {
@@ -125,7 +131,7 @@
         }
     }
 
-    /* (non-Javadoc)
+    /**
      * @see org.apache.avalon.framework.activity.Initializable#initialize()
      */
     public void initialize()
@@ -171,13 +177,6 @@
 
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.portal.event.Publisher#publish(org.apache.cocoon.portal.event.Event)
-     */
-    public void publish( final Event event ) {
-        this.send(event);        
-    }
-    
     /**
      * @see org.apache.cocoon.portal.event.EventManager#processEvents()
      */
@@ -234,26 +233,42 @@
     public void send(Event event) {
         if ( getLogger().isDebugEnabled() ) {
             getLogger().debug("Publishing event " + event.getClass());
-        } 
-        for (Iterator re = receivers.entrySet().iterator(); re.hasNext(); ) {
-            final Map.Entry current = (Map.Entry)re.next();
-            final Receiver receiver = (Receiver)current.getKey();
-            final List methodInfos = (List)current.getValue();
-            boolean found = false;
-            final Iterator ci = methodInfos.iterator();
-            while ( !found && ci.hasNext() ) {
-                final MethodInfo info = (MethodInfo)ci.next();
-                if ( info.eventClass.isAssignableFrom(event.getClass()) ) {
-                    if ( getLogger().isDebugEnabled() ) {
-                        getLogger().info("Informing receiver "+receiver+" of event "+event.getClass());
-                    }
-                    try {
-                        info.method.invoke(receiver, new Object[] {event, this.service});
-                    } catch (Exception ignore) {
-                        this.getLogger().warn("Exception during event dispatching on receiver
" + receiver
-                                             +" and event " + event, ignore);
+        }
+        this.isSendingEvents++;
+        try {
+            for (Iterator re = receivers.entrySet().iterator(); re.hasNext(); ) {
+                final Map.Entry current = (Map.Entry)re.next();
+                final Receiver receiver = (Receiver)current.getKey();
+                final List methodInfos = (List)current.getValue();
+                boolean found = false;
+                final Iterator ci = methodInfos.iterator();
+                while ( !found && ci.hasNext() ) {
+                    final MethodInfo info = (MethodInfo)ci.next();
+                    if ( info.eventClass.isAssignableFrom(event.getClass()) ) {
+                        if ( getLogger().isDebugEnabled() ) {
+                            getLogger().info("Informing receiver "+receiver+" of event "+event.getClass());
+                        }
+                        try {
+                            info.method.invoke(receiver, new Object[] {event, this.service});
+                        } catch (Exception ignore) {
+                            this.getLogger().warn("Exception during event dispatching on
receiver " + receiver
+                                                 +" and event " + event, ignore);
+                        }
+                        found = true;
                     }
-                    found = true;
+                }
+            }
+        } finally {
+            this.isSendingEvents--;
+            if ( this.isSendingEvents == 0 && this.additionalReceiverClasses.size()
> 0) {
+                List copy = null;
+                synchronized ( this.additionalReceiverClasses ) {
+                    copy = new ArrayList(this.additionalReceiverClasses);
+                    this.additionalReceiverClasses.clear();
+                }
+                final Iterator i = copy.iterator();
+                while (i.hasNext() ) {
+                    this.subscribe((Receiver)i.next());
                 }
             }
         }
@@ -296,6 +311,15 @@
      * @see org.apache.cocoon.portal.event.EventManager#subscribe(org.apache.cocoon.portal.event.Receiver)
      */
     public void subscribe(Receiver receiver) {
+        // if we are currently sending events, we just store the receiver
+        // and add it later on
+        if ( this.isSendingEvents > 0 ) {
+            synchronized ( this.additionalReceiverClasses ) {
+                this.additionalReceiverClasses.add(receiver);
+                return;
+            }
+        }
+
         List infos = this.introspect(receiver.getClass());
         if ( infos == null ) {
             throw new RuntimeException("Invalid event receiver type: " + receiver);

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserEventUtil.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserEventUtil.java?rev=306534&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserEventUtil.java
(added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserEventUtil.java
Wed Oct  5 22:57:28 2005
@@ -0,0 +1,51 @@
+/*
+ * 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.event.user;
+
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.event.Event;
+import org.apache.cocoon.portal.profile.PortalUser;
+
+/**
+ * Utility class for user events.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public class UserEventUtil {
+
+    private UserEventUtil() {
+        // avoid instantiation
+    }
+
+    public static void sendUserDidLoginEvent(PortalService service,
+                                             PortalUser    user) {
+        final Event event = new UserDidLoginEvent(user);
+        service.getComponentManager().getEventManager().send(event);
+    }
+
+    public static void sendUserWillLogoutEvent(PortalService service,
+                                               PortalUser    user) {
+        final Event event = new UserWillLogoutEvent(user);
+        service.getComponentManager().getEventManager().send(event);
+    }
+
+    public static void sendUserIsAccessingEvent(PortalService service,
+                                                PortalUser    user) {
+        final Event event = new UserIsAccessingEvent(user);
+        service.getComponentManager().getEventManager().send(event);
+    }
+}

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserEventUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserEventUtil.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserIsAccessingEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserIsAccessingEvent.java?rev=306534&view=auto
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserIsAccessingEvent.java
(added)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserIsAccessingEvent.java
Wed Oct  5 22:57:28 2005
@@ -0,0 +1,36 @@
+/*
+ * 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.event.user;
+
+import org.apache.cocoon.portal.profile.PortalUser;
+
+/**
+ * This event is send when a user is accessing(using) the portal.
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public class UserIsAccessingEvent implements UserEvent {
+
+    protected final PortalUser portalUser;
+
+    public UserIsAccessingEvent(PortalUser pu) {
+        this.portalUser = pu;
+    }
+    public PortalUser getPortalUser() {
+        return portalUser;
+    }
+}

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserIsAccessingEvent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/user/UserIsAccessingEvent.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/portal.roles
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/portal.roles?rev=306534&r1=306533&r2=306534&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/portal.roles (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/portal.roles Wed Oct  5 22:57:28
2005
@@ -291,4 +291,12 @@
     <role name="org.apache.cocoon.portal.coplet.CopletFactory"
           default-class="org.apache.cocoon.portal.coplet.impl.DefaultCopletFactory"
           shorthand="portal-coplet-factory"/>
+
+  <!--+
+      | Profile Manager.
+      |
+      +-->
+    <role name="org.apache.cocoon.portal.profile.ProfileManager"
+          shorthand="portal-profile-manager"/>
+
 </role-list>

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/ProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/ProfileManager.java?rev=306534&r1=306533&r2=306534&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/ProfileManager.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/ProfileManager.java Wed
Oct  5 22:57:28 2005
@@ -111,7 +111,4 @@
      * Get current user information
      */
     PortalUser getUser();
-
-    void login();
-    void logout();
 }

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=306534&r1=306533&r2=306534&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
Wed Oct  5 22:57:28 2005
@@ -43,6 +43,9 @@
     extends AbstractLogEnabled 
     implements Serviceable, Disposable, ProfileManager, ThreadSafe, Receiver, Initializable
{
 
+    /** Attribute to store the current user. */
+    public static final String USER_ATTRIBUTE = AbstractProfileManager.class.getName() +
"/User";
+
     /** The service manager of the portal application. */
     protected ServiceManager manager;
 
@@ -83,6 +86,7 @@
      * @see Receiver
      */
     public void inform(UserEvent event, PortalService service) {
+        this.portalService.setTemporaryAttribute(USER_ATTRIBUTE, event.getPortalUser());
         if ( event instanceof UserDidLoginEvent ) {
             this.login(event.getPortalUser());
         } else if ( event instanceof UserWillLogoutEvent ) {
@@ -152,19 +156,5 @@
      */
     protected void logout(PortalUser user) {
         // overwrite in subclass
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.profile.ProfileManager#login()
-     */
-    public void login() {
-        throw new RuntimeException("Don't use the login method anymore.");
-    }
-
-    /**
-     * @see org.apache.cocoon.portal.profile.ProfileManager#logout()
-     */
-    public void logout() {
-        throw new RuntimeException("Don't use the logout method anymore.");
     }
 }

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=306534&r1=306533&r2=306534&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
Wed Oct  5 22:57:28 2005
@@ -25,8 +25,6 @@
 
 import org.apache.avalon.framework.CascadingRuntimeException;
 import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.context.Context;
 import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.context.Contextualizable;
@@ -42,9 +40,7 @@
 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;
 import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.excalibur.source.SourceNotFoundException;
@@ -73,7 +69,7 @@
  */
 public class GroupBasedProfileManager 
     extends AbstractProfileManager
-    implements Parameterizable, Contextualizable, Initializable, Disposable { 
+    implements Parameterizable, Contextualizable, Disposable { 
 
     public static final String CATEGORY_GLOBAL = "global";
     public static final String CATEGORY_GROUP  = "group";
@@ -92,18 +88,15 @@
     final protected ProfileInfo copletBaseDatas = new ProfileInfo();
     final protected ProfileInfo copletDatas = new ProfileInfo();
 
-    /** The userinfo provider - the connection to the authentication mechanism */
-    protected PortalUserInfoProvider provider;
-
-    /** The class name of the userinfo provider */
-    protected String portalUserInfoProviderClassName;
-
     /** The component context */
     protected Context context;
 
     /** Check for changes? */
     protected boolean checkForChanges = true;
 
+    /** The parameters for the profile configuration. */
+    protected Parameters parameters;
+
     /**
      * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
      */
@@ -115,28 +108,8 @@
      * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
      */
     public void parameterize(Parameters params) throws ParameterException {
-        this.portalUserInfoProviderClassName = params.getParameter("userinfo-provider");
         this.checkForChanges = params.getParameterAsBoolean("check-for-changes", this.checkForChanges);
-    }
-
-    /**
-     * @see org.apache.avalon.framework.activity.Initializable#initialize()
-     */
-    public void initialize() throws Exception {
-        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);
-    }
-
-    /**
-     * @see org.apache.avalon.framework.activity.Disposable#dispose()
-     */
-    public void dispose() {
-        ContainerUtil.dispose(this.provider);
-        this.provider = null;
-        super.dispose();
+        this.parameters = params;
     }
 
     protected UserProfile getUserProfile(String layoutKey) {
@@ -377,7 +350,7 @@
      */
     protected UserProfile loadProfile(final String layoutKey) 
     throws Exception {
-        final PortalUser info = this.provider.getPortalUser(this.portalService.getPortalName());
+        final PortalUser info = (PortalUser)this.portalService.getTemporaryAttribute(USER_ATTRIBUTE);
         ProfileLS loader = null;
         try {
             loader = (ProfileLS)this.manager.lookup( ProfileLS.ROLE );
@@ -524,7 +497,7 @@
                                              final String      category,
                                              final String      layoutKey) 
     throws Exception {
-        Map key = this.buildKey(category, 
+        Map key = this.buildKey(category,
                                 ProfileLS.PROFILETYPE_COPLETINSTANCEDATA, 
                                 info, 
                                 true,
@@ -583,7 +556,8 @@
                            String   profileType,
                            PortalUser info,
                            boolean  load,
-                           String   layoutKey) {
+                           String   layoutKey)
+    throws ParameterException {
         final StringBuffer config = new StringBuffer(profileType);
         config.append('-');
         config.append(category);
@@ -593,7 +567,7 @@
         } else {
             config.append("save");            
         }
-        final String uri = (String)this.provider.getConfiguration(this.portalService.getPortalName()).get(config.toString());
+        final String uri = this.parameters.getParameter(config.toString());
 
         final Map key = new LinkedMap();
         key.put("baseuri", uri);
@@ -615,6 +589,68 @@
      * @see org.apache.cocoon.portal.profile.ProfileManager#getUser()
      */
     public PortalUser getUser() {
-        return this.provider.getPortalUser(this.portalService.getPortalName());
+        return (PortalUser)this.portalService.getTemporaryAttribute(USER_ATTRIBUTE);
     }
+
+    /**
+     * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserCopletInstanceDatas(java.lang.String)
+     */
+    public void saveUserCopletInstanceDatas(String layoutKey) {
+        ProfileLS adapter = null;
+        try {
+            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
+            if (layoutKey == null) {
+                layoutKey = this.portalService.getDefaultLayoutKey();
+            }
+            final UserProfile profile = this.getUserProfile(layoutKey);
+
+            final Map parameters = new HashMap();
+            parameters.put(ProfileLS.PARAMETER_PROFILETYPE, 
+                           ProfileLS.PROFILETYPE_COPLETINSTANCEDATA);        
+
+            final Map key = this.buildKey(CATEGORY_USER,
+                                          ProfileLS.PROFILETYPE_COPLETINSTANCEDATA, 
+                                          this.getUser(), 
+                                          false,
+                                          layoutKey);
+            adapter.saveProfile(key, parameters, profile.getCopletInstanceDatas());
+        } catch (Exception e) {
+            // TODO
+            throw new CascadingRuntimeException("Exception during save profile", e);
+        } finally {
+            this.manager.release(adapter);
+        }
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.profile.ProfileManager#saveUserLayout(java.lang.String)
+     */
+    public void saveUserLayout(String layoutKey) {
+        ProfileLS adapter = null;
+        try {
+            adapter = (ProfileLS) this.manager.lookup(ProfileLS.ROLE);
+            if (layoutKey == null) {
+                layoutKey = this.portalService.getDefaultLayoutKey();
+            }
+            final UserProfile profile = this.getUserProfile(layoutKey);
+
+            final Map parameters = new HashMap();
+            parameters.put(ProfileLS.PARAMETER_PROFILETYPE, 
+                           ProfileLS.PROFILETYPE_LAYOUT);        
+
+            final Map key = this.buildKey(CATEGORY_USER,
+                                          ProfileLS.PROFILETYPE_LAYOUT, 
+                                          this.getUser(), 
+                                          false,
+                                          layoutKey);
+            adapter.saveProfile(key, parameters, profile.getRootLayout());
+        } catch (Exception e) {
+            // TODO
+            throw new CascadingRuntimeException("Exception during save profile", e);
+        } finally {
+            this.manager.release(adapter);
+        }
+    }
+
+
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java?rev=306534&r1=306533&r2=306534&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/MapProfileLS.java
Wed Oct  5 22:57:28 2005
@@ -123,7 +123,7 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.profile.ProfileLS#loadProfile(java.lang.Object)
+     * @see org.apache.cocoon.portal.profile.ProfileLS#loadProfile(java.lang.Object, java.util.Map)
      */
     public Object loadProfile(Object key, Map parameters) 
     throws Exception {
@@ -149,7 +149,7 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.profile.ProfileLS#saveProfile(java.lang.Object, java.lang.Object)
+     * @see org.apache.cocoon.portal.profile.ProfileLS#saveProfile(java.lang.Object, java.util.Map,
java.lang.Object)
      */
     public void saveProfile(Object key, Map parameters, Object profile) throws Exception
{
         final Map keyMap = (Map) key;
@@ -214,7 +214,7 @@
     }
 
     /**
-     * @see org.apache.cocoon.portal.profile.ProfileLS#getValidity(java.lang.Object)
+     * @see org.apache.cocoon.portal.profile.ProfileLS#getValidity(java.lang.Object, java.util.Map)
      */
     public SourceValidity getValidity(Object key, Map parameters) {
 		SourceResolver resolver = null;

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfo.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfo.java?rev=306534&r1=306533&r2=306534&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfo.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/UserInfo.java Wed
Oct  5 22:57:28 2005
@@ -16,7 +16,6 @@
 package org.apache.cocoon.portal.profile.impl;
 
 import java.io.Serializable;
-import java.util.Map;
 
 import org.apache.cocoon.portal.profile.PortalUser;
 
@@ -34,15 +33,8 @@
 
     protected String group;
 
-    protected String portalName;
-
-    protected String layoutKey;
-
-    protected Map    configurations;
-
-    public UserInfo(String portalName, String layoutKey) {
-        this.portalName = portalName;
-        this.layoutKey = layoutKey;
+    public UserInfo() {
+        // nothing to do
     }
 
     /**
@@ -71,33 +63,5 @@
      */
     public void setUserName(String userName) {
         this.userName = userName;
-    }
-
-    /**
-     * @return Returns the configurations.
-     */
-    public Map getConfigurations() {
-        return configurations;
-    }
-
-    /**
-     * @param configurations The configurations to set.
-     */
-    public void setConfigurations(Map configurations) {
-        this.configurations = configurations;
-    }
-
-    /**
-     * @return Returns the layoutKey.
-     */
-    public String getLayoutKey() {
-        return layoutKey;
-    }
-
-    /**
-     * @return Returns the portalName.
-     */
-    public String getPortalName() {
-        return portalName;
     }
 }

Modified: 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=306534&r1=306533&r2=306534&view=diff
==============================================================================
Binary files - no diff available.



Mime
View raw message