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 2006/02/12 14:09:55 UTC

svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/

Author: cziegeler
Date: Sun Feb 12 05:09:54 2006
New Revision: 377171

URL: http://svn.apache.org/viewcvs?rev=377171&view=rev
Log:
Add profile manager aspects

Added:
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java   (with props)
Modified:
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManagerAspectContext.java
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/DefaultProfileManagerAspectContext.java
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileManagerAspectChain.java
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java

Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java?rev=377171&r1=377170&r2=377171&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java Sun Feb 12 05:09:54 2006
@@ -108,6 +108,8 @@
             this.prepareObject(rootLayout);
             profile.setRootLayout(rootLayout);
 
+            this.processProfile(profile);
+
             this.storeUserProfile(layoutKey, profile);
             return profile;
         }

Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManagerAspectContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManagerAspectContext.java?rev=377171&r1=377170&r2=377171&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManagerAspectContext.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManagerAspectContext.java Sun Feb 12 05:09:54 2006
@@ -18,7 +18,6 @@
 import java.util.Map;
 
 import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.portal.PortalService;
 
 /**
@@ -32,8 +31,7 @@
     /**
      * Invoke next aspect .
      */
-    void invokeNext()
-    throws ProcessingException;
+    void invokeNext();
 
     /** 
      * Get the {@link Parameters} of the aspect.

Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java?rev=377171&r1=377170&r2=377171&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java Sun Feb 12 05:09:54 2006
@@ -41,6 +41,7 @@
 import org.apache.cocoon.portal.profile.PortalUser;
 import org.apache.cocoon.portal.profile.ProfileManager;
 import org.apache.cocoon.portal.profile.ProfileManagerAspect;
+import org.apache.cocoon.portal.profile.ProfileManagerAspectContext;
 import org.apache.cocoon.portal.scratchpad.Profile;
 
 /**
@@ -219,5 +220,16 @@
             }
         }
         return layout;
+    }
+
+    /**
+     * Process a freshly loaded profile.
+     */
+    protected void processProfile(Profile profile) {
+        // FIXME we should add the calls to prepareObject here as well
+        if ( this.chain.hasAspects() ) {
+            ProfileManagerAspectContext aspectContext = new DefaultProfileManagerAspectContext(this.chain, this.portalService, this.portalService.getObjectModel(), profile);
+            aspectContext.invokeNext();
+        }
     }
 }

Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/DefaultProfileManagerAspectContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/DefaultProfileManagerAspectContext.java?rev=377171&r1=377170&r2=377171&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/DefaultProfileManagerAspectContext.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/DefaultProfileManagerAspectContext.java Sun Feb 12 05:09:54 2006
@@ -19,7 +19,6 @@
 import java.util.Map;
 
 import org.apache.avalon.framework.parameters.Parameters;
-import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.profile.ProfileManagerAspect;
 import org.apache.cocoon.portal.profile.ProfileManagerAspectContext;
@@ -54,8 +53,7 @@
 	/**
 	 * @see org.apache.cocoon.portal.profile.ProfileManagerAspectContext#invokeNext()
 	 */
-	public void invokeNext() 
-    throws ProcessingException {
+	public void invokeNext() {
         if (this.iterator.hasNext()) {
             this.config = (Parameters)this.configIterator.next();
             final ProfileManagerAspect aspect = (ProfileManagerAspect) iterator.next();

Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java?rev=377171&r1=377170&r2=377171&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java Sun Feb 12 05:09:54 2006
@@ -358,6 +358,7 @@
         }
 
         this.storeUserProfile(layoutKey, profile);
+        this.processProfile(profile);
         return profile;
     }
 

Added: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java?rev=377171&view=auto
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java (added)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java Sun Feb 12 05:09:54 2006
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.profile.impl;
+
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.portal.layout.CompositeLayout;
+import org.apache.cocoon.portal.layout.Item;
+import org.apache.cocoon.portal.layout.Layout;
+import org.apache.cocoon.portal.layout.NamedItem;
+import org.apache.cocoon.portal.profile.ProfileManagerAspect;
+import org.apache.cocoon.portal.profile.ProfileManagerAspectContext;
+import org.apache.cocoon.portal.scratchpad.Profile;
+
+/**
+ * $Id$
+ */
+public class PageLabelProfileManagerAspect
+    implements ProfileManagerAspect, ThreadSafe {
+
+    /**
+     * @see org.apache.cocoon.portal.profile.ProfileManagerAspect#prepare(org.apache.cocoon.portal.profile.ProfileManagerAspectContext, org.apache.cocoon.portal.scratchpad.Profile)
+     */
+    public void prepare(ProfileManagerAspectContext context, Profile profile) {
+        final Layout rootLayout = profile.getRootLayout();
+        if ( rootLayout instanceof CompositeLayout ) {
+            this.populate((CompositeLayout)rootLayout, "");
+        }
+        context.invokeNext();
+    }
+
+    private void populate(CompositeLayout layout, String name) {
+        for (int j = 0; j < layout.getSize(); j++) {
+            final Item tab = layout.getItem(j);
+            final StringBuffer label = new StringBuffer(name);
+            if (label.length() > 0) {
+                label.append(".");
+            }
+            label.append((tab instanceof NamedItem) ? ((NamedItem) tab).getName()
+                                                    : Integer.toString(j));
+            final Layout child = tab.getLayout();
+            if (child != null && child instanceof CompositeLayout) {
+                this.populate((CompositeLayout) child, label.toString());
+            }
+        }
+    }
+}

Propchange: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileManagerAspectChain.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileManagerAspectChain.java?rev=377171&r1=377170&r2=377171&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileManagerAspectChain.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileManagerAspectChain.java Sun Feb 12 05:09:54 2006
@@ -37,12 +37,15 @@
 
     protected List configs = new ArrayList(3);
 
+    protected boolean process = false;
+
     public void configure(ServiceSelector selector,
                           Configuration   conf)
     throws ConfigurationException {
         if ( conf != null ) {
             Configuration[] aspects = conf.getChildren("aspect");
             for(int i=0; i < aspects.length; i++) {
+                this.process = true;
                 final Configuration current = aspects[i];
                 final String role = current.getAttribute("type");
                 try {
@@ -55,9 +58,11 @@
                     throw new ConfigurationException("Unable to lookup profile manager aspect: " + role, se);
                 }
             }
-        } else {
-            throw new ConfigurationException("No aspects configured.");
         }
+    }
+
+    public boolean hasAspects() {
+        return this.process;
     }
 
     public Iterator getIterator() {

Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java?rev=377171&r1=377170&r2=377171&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java Sun Feb 12 05:09:54 2006
@@ -37,7 +37,8 @@
 import org.apache.excalibur.source.SourceValidity;
 
 /**
- *
+ * FIXME - This profile manager implementation does not use all of the new features of 2.2 yet,
+ *         like profile manager aspects etc.
  * @version $Id$
  */
 public class StaticProfileManager 



Re: svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/

Posted by Ralph Goers <Ra...@dslextreme.com>.

Carsten Ziegeler wrote:
> Ralph Goers wrote:
>   
>>>> Item item = getParent().getParent();
>>>> if (item == null || !(item instanceof NamedItem)) {
>>>>     this.label = this.name;
>>>> } else {
>>>>     this.label = item.getLabel() + "." + this.name;
>>>> }
>>>>
>>>>     
>>>>         
>>>   
>>>       
>> I would create a setLabel method to NamedItem (probably protected or 
>> even private) and then have setName() call it.
>>     
> Ok, sounds good to me - I'll change that today. Don't we need a loop in
> the code you provided above? For example if there sub tabs are not
> directly nested inside the main tab?
>   
I don't believe a loop is required. Castor is creating each of the 
NamedItems and so it provides the "looping".

Ralph

Re: svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/

Posted by Carsten Ziegeler <cz...@apache.org>.
Ralph Goers wrote:
> 
>>>
>>> Item item = getParent().getParent();
>>> if (item == null || !(item instanceof NamedItem)) {
>>>     this.label = this.name;
>>> } else {
>>>     this.label = item.getLabel() + "." + this.name;
>>> }
>>>
>>>     
>>   
> I would create a setLabel method to NamedItem (probably protected or 
> even private) and then have setName() call it.
Ok, sounds good to me - I'll change that today. Don't we need a loop in
the code you provided above? For example if there sub tabs are not
directly nested inside the main tab?

Carsten

-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

Re: svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/

Posted by Ralph Goers <Ra...@dslextreme.com>.

Carsten Ziegeler wrote:
> Ralph Goers schrieb:
>   
>> I'm having a hard time understanding this.  populate seems to go through 
>> and figure out what all the page labels should be, but it doesn't do 
>> anything with them.  I assume this is part of the discussion we've been 
>> having? As I said there I'm not even sure this is necessary. When Castor 
>> builds the layout each named item should be able to create its page 
>> label by doing:
>>
>> Item item = getParent().getParent();
>> if (item == null || !(item instanceof NamedItem)) {
>>     this.label = this.name;
>> } else {
>>     this.label = item.getLabel() + "." + this.name;
>> }
>>
>>     
> Yes, that's true. Now the question is: Where to put this code? We could
> add this to the item.
> My idea was to provide extensions to the profile manager which are able
> to post process the profile, like adding the page labels.
> This label will then picked up by the tab renderer - and this part is
> currently missing. Hmm, perhaps you're right and we can add this code
> directly to an item or named item. Have to think about it.
>   
I would create a setLabel method to NamedItem (probably protected or 
even private) and then have setName() call it.
>
>
> Carsten
>   

Re: svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/

Posted by Carsten Ziegeler <cz...@apache.org>.
Ralph Goers schrieb:
> I'm having a hard time understanding this.  populate seems to go through 
> and figure out what all the page labels should be, but it doesn't do 
> anything with them.  I assume this is part of the discussion we've been 
> having? As I said there I'm not even sure this is necessary. When Castor 
> builds the layout each named item should be able to create its page 
> label by doing:
> 
> Item item = getParent().getParent();
> if (item == null || !(item instanceof NamedItem)) {
>     this.label = this.name;
> } else {
>     this.label = item.getLabel() + "." + this.name;
> }
> 
Yes, that's true. Now the question is: Where to put this code? We could
add this to the item.
My idea was to provide extensions to the profile manager which are able
to post process the profile, like adding the page labels.
This label will then picked up by the tab renderer - and this part is
currently missing. Hmm, perhaps you're right and we can add this code
directly to an item or named item. Have to think about it.



Carsten
-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

Re: svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/

Posted by Ralph Goers <Ra...@dslextreme.com>.
I'm having a hard time understanding this.  populate seems to go through 
and figure out what all the page labels should be, but it doesn't do 
anything with them.  I assume this is part of the discussion we've been 
having? As I said there I'm not even sure this is necessary. When Castor 
builds the layout each named item should be able to create its page 
label by doing:

Item item = getParent().getParent();
if (item == null || !(item instanceof NamedItem)) {
    this.label = this.name;
} else {
    this.label = item.getLabel() + "." + this.name;
}

cziegeler@apache.org wrote:
>
> Added: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java
> URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java?rev=377171&view=auto
> ==============================================================================
> --- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java (added)
> +++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java Sun Feb 12 05:09:54 2006
> @@ -0,0 +1,59 @@
> +/*
> + * Copyright 2006 The Apache Software Foundation.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +package org.apache.cocoon.portal.profile.impl;
> +
> +import org.apache.avalon.framework.thread.ThreadSafe;
> +import org.apache.cocoon.portal.layout.CompositeLayout;
> +import org.apache.cocoon.portal.layout.Item;
> +import org.apache.cocoon.portal.layout.Layout;
> +import org.apache.cocoon.portal.layout.NamedItem;
> +import org.apache.cocoon.portal.profile.ProfileManagerAspect;
> +import org.apache.cocoon.portal.profile.ProfileManagerAspectContext;
> +import org.apache.cocoon.portal.scratchpad.Profile;
> +
> +/**
> + * $Id$
> + */
> +public class PageLabelProfileManagerAspect
> +    implements ProfileManagerAspect, ThreadSafe {
> +
> +    /**
> +     * @see org.apache.cocoon.portal.profile.ProfileManagerAspect#prepare(org.apache.cocoon.portal.profile.ProfileManagerAspectContext, org.apache.cocoon.portal.scratchpad.Profile)
> +     */
> +    public void prepare(ProfileManagerAspectContext context, Profile profile) {
> +        final Layout rootLayout = profile.getRootLayout();
> +        if ( rootLayout instanceof CompositeLayout ) {
> +            this.populate((CompositeLayout)rootLayout, "");
> +        }
> +        context.invokeNext();
> +    }
> +
> +    private void populate(CompositeLayout layout, String name) {
> +        for (int j = 0; j < layout.getSize(); j++) {
> +            final Item tab = layout.getItem(j);
> +            final StringBuffer label = new StringBuffer(name);
> +            if (label.length() > 0) {
> +                label.append(".");
> +            }
> +            label.append((tab instanceof NamedItem) ? ((NamedItem) tab).getName()
> +                                                    : Integer.toString(j));
> +            final Layout child = tab.getLayout();
> +            if (child != null && child instanceof CompositeLayout) {
> +                this.populate((CompositeLayout) child, label.toString());
> +            }
> +        }
> +    }
> +}
>
>
>