You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2004/09/02 13:36:10 UTC

svn commit: rev 37370 - in cocoon/branches/BRANCH_2_1_X: . src/blocks/portal/java/org/apache/cocoon/portal/layout/impl src/blocks/portal/java/org/apache/cocoon/portal/profile/impl

Author: cziegeler
Date: Thu Sep  2 04:36:09 2004
New Revision: 37370

Modified:
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/CopletLayout.java
   cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
   cocoon/branches/BRANCH_2_1_X/status.xml
Log:
First buggy version of group based profile manager

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/CopletLayout.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/CopletLayout.java	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/CopletLayout.java	Thu Sep  2 04:36:09 2004
@@ -15,8 +15,6 @@
  */
 package org.apache.cocoon.portal.layout.impl;
 
-import java.util.Map;
-
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.layout.AbstractLayout;
 import org.apache.cocoon.portal.layout.Layout;
@@ -48,7 +46,7 @@
     protected Object clone() throws CloneNotSupportedException {
         CopletLayout clone = (CopletLayout)super.clone();
         
-        this.copletInstanceData = null;
+        clone.copletInstanceData = null;
         
         return clone;
     }
@@ -56,16 +54,13 @@
     /* (non-Javadoc)
      * @see org.apache.cocoon.portal.layout.Layout#copy()
      */
-    public Layout copy(Map copletInstanceDatas) {
+    public Layout copy() {
         CopletLayout clone = (CopletLayout)super.copy();
-        if (copletInstanceDatas == null) {
-            clone.copletInstanceData = this.copletInstanceData;
-        } else {
-            if ( this.copletInstanceData != null ) {
-                clone.copletInstanceData = this.copletInstanceData.copy();
-            }
-            
+
+        if ( this.copletInstanceData != null ) {
+            clone.copletInstanceData = this.copletInstanceData.copy();
         }
+            
         return clone;
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java	(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java	Thu Sep  2 04:36:09 2004
@@ -109,6 +109,13 @@
         }
     }
 
+    protected void storeUserProfile(String layoutKey, PortalService service, UserProfile profile) {
+        if ( layoutKey == null ) {
+            layoutKey = this.getDefaultLayoutKey();
+        }
+        service.setAttribute(KEY_PREFIX + layoutKey, profile);
+    }
+    
     /**
      * Prepares the object by using the specified factory.
      */
@@ -121,6 +128,8 @@
             if (object instanceof Layout) {
                 service.getComponentManager().getLayoutFactory().prepareLayout((Layout)object);
             } else if (object instanceof Collection) {
+                ServiceSelector adapterSelector = null;
+                try {
                 final CopletFactory copletFactory = service.getComponentManager().getCopletFactory();
                 final Iterator iterator = ((Collection)object).iterator();
                 while (iterator.hasNext()) {
@@ -128,8 +137,26 @@
                     if ( o instanceof CopletData ) {
                         copletFactory.prepare((CopletData)o);
                     } else if ( o instanceof CopletInstanceData) {
-                        copletFactory.prepare((CopletInstanceData)o);
+                            if ( adapterSelector == null ) {
+                                adapterSelector = (ServiceSelector)this.manager.lookup(CopletAdapter.ROLE+"Selector");                            
+                            }
+                            CopletInstanceData cid = (CopletInstanceData)o;
+                            copletFactory.prepare(cid);
+                            // now invoke login on each instance
+                            CopletAdapter adapter = null;
+                            try {
+                                adapter = (CopletAdapter) adapterSelector.select(cid.getCopletData().getCopletBaseData().getCopletAdapterName());
+                                adapter.login( cid );
+                            } finally {
+                                adapterSelector.release( adapter );
+                            }
+                        }
                     }
+                } catch (ServiceException se) {
+                    // this should never happen
+                    throw new ProcessingException("Unable to get component.", se);
+                } finally {
+                    this.manager.release(adapterSelector);
                 }
             }
         }
@@ -369,6 +396,7 @@
         try {
             loader = (ProfileLS)this.manager.lookup( ProfileLS.ROLE );
         final UserProfile profile = new UserProfile();
+            this.storeUserProfile(layoutKey, service, profile);
         
             // first "load" the global data
             profile.setCopletBaseDatas( this.getGlobalBaseDatas(loader, info, service) );
@@ -376,7 +404,7 @@
             
             // now load the user/group specific data
             if ( !this.getCopletInstanceDatas(loader, profile, info, service, CATEGORY_USER) ) {
-                if ( !this.getCopletInstanceDatas(loader, profile, info, service, CATEGORY_GROUP)) {
+                if ( info.getGroup() == null || !this.getCopletInstanceDatas(loader, profile, info, service, CATEGORY_GROUP)) {
                     if ( !this.getCopletInstanceDatas(loader, profile, info, service, CATEGORY_GLOBAL) ) {
                         throw new ProcessingException("No profile for copletinstancedatas found.");
                     }
@@ -384,7 +412,7 @@
             }
 
             if ( !this.getLayout(loader, profile, info, service, CATEGORY_USER) ) {
-                if ( !this.getLayout(loader, profile, info, service, CATEGORY_GROUP)) {
+                if ( info.getGroup() == null || !this.getLayout(loader, profile, info, service, CATEGORY_GROUP)) {
                     if ( !this.getLayout(loader, profile, info, service, CATEGORY_GLOBAL) ) {
                         throw new ProcessingException("No profile for layout found.");
                     }

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml	(original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml	Thu Sep  2 04:36:09 2004
@@ -204,6 +204,9 @@
 
   <changes>
  <release version="@version@" date="@date@">
+   <action dev="CZ" type="add">
+     Portal block: New Group Based Profile Manager.
+   </action>
    <action dev="VG" type="update">
      Cron block: Add support for persistent job stores, type "tx" and "cmt".
    </action>