cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r377171 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: pluto/ profile/ profile/impl/
Date Sun, 12 Feb 2006 13:09:55 GMT
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 



Mime
View raw message