cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r468519 - in /cocoon/trunk/blocks/cocoon-portal: cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/aspect/impl/ cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/impl/ cocoon-portal-impl/src/main/java/o...
Date Fri, 27 Oct 2006 20:14:31 GMT
Author: cziegeler
Date: Fri Oct 27 13:14:30 2006
New Revision: 468519

URL: http://svn.apache.org/viewvc?view=rev&rev=468519
Log:
Continue profile handling cleanup

Modified:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/aspect/impl/AbstractContentEventAspect.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/aspect/impl/LinkEventAspect.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/impl/DefaultLinkRenderer.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LinkLayout.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/aspect/impl/AbstractContentEventAspect.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/aspect/impl/AbstractContentEventAspect.java?view=diff&rev=468519&r1=468518&r2=468519
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/aspect/impl/AbstractContentEventAspect.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/aspect/impl/AbstractContentEventAspect.java
Fri Oct 27 13:14:30 2006
@@ -24,6 +24,7 @@
 import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.portal.LayoutException;
 import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.event.Event;
 import org.apache.cocoon.portal.event.EventManager;
@@ -60,7 +61,8 @@
      * @param layout  The corresponding layout
      * @param values  The values contained in the request
      */
-    protected abstract void publish(PortalService service, Layout layout, String[] values);
+    protected abstract void publish(PortalService service, Layout layout, String[] values)
+    throws LayoutException;
 
     /**
      * Publish the event.
@@ -69,9 +71,13 @@
      * @param values The values contained in the request
      */
     protected void publish( PortalService service, String[] values) {
-        Layout layout = service.getProfileManager().getLayout(values[0] );
+        final Layout layout = service.getProfileManager().getLayout(values[0] );
         if ( layout != null ) {
-            this.publish( service, layout, values);
+            try {
+                this.publish( service, layout, values);
+            } catch (Exception e) {
+                this.getLogger().warn("Unable to publish event. Ignoring exception.", e);
+            }
         }
     }
 

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/aspect/impl/LinkEventAspect.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/aspect/impl/LinkEventAspect.java?view=diff&rev=468519&r1=468518&r2=468519
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/aspect/impl/LinkEventAspect.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/aspect/impl/LinkEventAspect.java
Fri Oct 27 13:14:30 2006
@@ -16,6 +16,7 @@
  */
 package org.apache.cocoon.portal.event.aspect.impl;
 
+import org.apache.cocoon.portal.LayoutException;
 import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.event.Event;
 import org.apache.cocoon.portal.event.layout.LayoutInstanceChangeAttributeEvent;
@@ -36,7 +37,7 @@
     }
 
     protected int getRequiredValueCount() {
-        return 3;
+        return 2;
     }
 
     /**
@@ -44,21 +45,13 @@
      */
     protected void publish(PortalService service,
                            Layout layout,
-                           String[] values) {
-        if (layout instanceof LinkLayout) {
-            LayoutInstance instance;
-            instance = LayoutFeatures.getLayoutInstance(service, layout, false);
-            if ( instance == null ) {
-                Event e = new LayoutInstanceChangeAttributeEvent(instance, "link-layout-key",
values[2], true);
-                service.getEventManager().send(e);                    
-                e = new LayoutInstanceChangeAttributeEvent(instance, "llink-layout-id", values[3],
true);
-                service.getEventManager().send(e);                    
-            }
-        } else {
-            this.getLogger().warn(
-                "the configured layout: "
-                    + layout.getType()
-                    + " is not a LinkLayout.");
+                           String[] values)
+    throws LayoutException {
+        LayoutFeatures.checkLayoutClass(layout, LinkLayout.class, true);
+        final LayoutInstance instance = LayoutFeatures.getLayoutInstance(service, layout,
false);
+        if ( instance == null ) {
+            final Event e = new LayoutInstanceChangeAttributeEvent(instance, LinkLayout.ATTRIBUTE_LAYOUT_ID,
values[2], true);
+            service.getEventManager().send(e);                    
         }
     }
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/impl/DefaultLinkRenderer.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/impl/DefaultLinkRenderer.java?view=diff&rev=468519&r1=468518&r2=468519
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/impl/DefaultLinkRenderer.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/impl/DefaultLinkRenderer.java
Fri Oct 27 13:14:30 2006
@@ -48,7 +48,7 @@
         String layoutId = null;
         final LayoutInstance instance = LayoutFeatures.getLayoutInstance(service, layout,
false);
         if ( instance != null ) {
-            layoutId = (String)instance.getTemporaryAttribute("link-layout-id");        
       
+            layoutId = (String)instance.getTemporaryAttribute(LinkLayout.ATTRIBUTE_LAYOUT_ID);
               
         }
         if ( layoutId == null){
             // get default values

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LinkLayout.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LinkLayout.java?view=diff&rev=468519&r1=468518&r2=468519
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LinkLayout.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LinkLayout.java
Fri Oct 27 13:14:30 2006
@@ -20,13 +20,16 @@
 
 /**
  * A link layout references another layout to be used instead. The reference
- * can be changed using events.
+ * can be changed at runtime using {@link LayoutInstance}.
  *
  * @version $Id$
  */
 public class LinkLayout extends Layout {
 
-    protected String linkedLayoutKey;
+    /** This is the name of the temporary attribute in the layout instance holding the current
layout id. */
+    public static final String ATTRIBUTE_LAYOUT_ID = "link-layout-id";
+
+    protected String linkedProfileName;
     protected String linkedLayoutId;
 
     /**
@@ -34,26 +37,18 @@
      * Never create a layout object directly. Use the
      * {@link LayoutFactory} instead.
      * @param id The unique identifier of the layout object or null.
-     * @param name The name of the layout.
+     * @param name The name of the profile.
      */
     public LinkLayout(String id, String name) {
         super(id, name);
     }
 
-    public void setLayoutId(String layoutId) {
-        this.linkedLayoutId = layoutId;
-    }
-
     public String getLayoutId() {
         return this.linkedLayoutId;
     }
 
-    public String getLayoutKey() {
-        return linkedLayoutKey;
-    }
-
-    public void setLayoutKey(String key) {
-        linkedLayoutKey = key;
+    public String getProfileName() {
+        return linkedProfileName;
     }
 
     /**
@@ -63,7 +58,7 @@
         LinkLayout clone = (LinkLayout)super.clone();
 
         clone.linkedLayoutId = this.linkedLayoutId;
-        clone.linkedLayoutKey = this.linkedLayoutKey;
+        clone.linkedProfileName = this.linkedProfileName;
 
         return clone;
     }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java?view=diff&rev=468519&r1=468518&r2=468519
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
Fri Oct 27 13:14:30 2006
@@ -314,42 +314,61 @@
      */
     protected Profile loadProfile() 
     throws ProfileException {
-        final String layoutKey = this.portalService.getUserService().getDefaultProfileName();
+        final String defaultProfileName = this.portalService.getUserService().getDefaultProfileName();
         final PortalUser user = this.portalService.getUserService().getUser();
         ProfileImpl profile = new ProfileImpl();
 
         try {
             // first "load" the global data
-            profile.setCopletTypes( this.getGlobalCopletTypes(layoutKey) );
-            profile.setCopletDefinitions( this.getGlobalDatas(user, profile, layoutKey) );
+            profile.setCopletTypes( this.getGlobalCopletTypes() );
+            // FIXME - We should be able to merge definitions from various locations
+            //         This could also be handled by aspects?
+            profile.setCopletDefinitions( this.getGlobalCopletDefinitions(user, profile)
);
     
             // now load the user/group specific data
-            if ( !this.getCopletInstanceDatas(profile, user, CATEGORY_USER, layoutKey) )
{
-                if ( user.getGroups().size() == 0 || !this.getCopletInstanceDatas(profile,
user, CATEGORY_GROUP, layoutKey)) {
-                    if ( !this.getCopletInstanceDatas(profile, user, CATEGORY_GLOBAL, layoutKey)
) {
+            this.loadProfile(profile, user, defaultProfileName);
+            // FIXME - Traverse the layout tree for link layouts
+        } catch (ProfileException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new ProfileException("Unable to load profile '" + defaultProfileName +
"' for user " + user + ".", e);
+        }
+        final Profile processedProfile = this.processProfile(profile);
+        this.storeUserProfile(processedProfile);
+        return processedProfile;
+    }
+
+    protected void loadProfile(ProfileImpl profile, PortalUser user, String profileName)
+    throws ProfileException {
+        try {
+            if ( !this.getCopletInstanceDatas(profile, user, CATEGORY_USER, profileName)
) {
+                if ( user.getGroups().size() == 0 || !this.getCopletInstanceDatas(profile,
user, CATEGORY_GROUP, profileName)) {
+                    if ( !this.getCopletInstanceDatas(profile, user, CATEGORY_GLOBAL, profileName)
) {
                         throw new ProcessingException("No profile for copletinstancedatas
found.");
                     }
                 }
             }
-
-            if ( !this.getLayout(profile, user, CATEGORY_USER, layoutKey) ) {
-                if ( user.getGroups().size() == 0 || !this.getLayout(profile, user, CATEGORY_GROUP,
layoutKey)) {
-                    if ( !this.getLayout(profile, user, CATEGORY_GLOBAL, layoutKey) ) {
+    
+            if ( !this.getLayout(profile, user, CATEGORY_USER, profileName) ) {
+                if ( user.getGroups().size() == 0 || !this.getLayout(profile, user, CATEGORY_GROUP,
profileName)) {
+                    if ( !this.getLayout(profile, user, CATEGORY_GLOBAL, profileName) ) {
                         throw new ProcessingException("No profile for layout found.");
                     }
                 }
-            }
+            }        
         } catch (ProfileException e) {
             throw e;
         } catch (Exception e) {
-            throw new ProfileException("Unable to load profile '" + layoutKey + "' for user
" + user + ".", e);
+            throw new ProfileException("Unable to load profile '" + profileName + "' for
user " + user + ".", e);
         }
-        final Profile processedProfile = this.processProfile(profile);
-        this.storeUserProfile(processedProfile);
-        return processedProfile;
     }
 
-    protected Map getGlobalCopletTypes(final String profileName)
+    /**
+     * Return the current set of global coplet types.
+     * @return
+     * @throws Exception
+     */
+    protected Map getGlobalCopletTypes()
     throws Exception {
         // if we already have loaded the profile and don't check
         // for changes, just return the profile
@@ -357,11 +376,12 @@
             return this.copletTypes.objects;
         }
 
+        // build key for loading the profile
         final Map key = this.buildKey(CATEGORY_GLOBAL,
                 ProfileLS.PROFILETYPE_COPLETTYPE,
                 null,
                 true,
-                profileName);
+                null);
 
         SourceValidity newValidity = null;
         // if we have a profile, check for reloading
@@ -392,6 +412,7 @@
                 newValidity = loader.getValidity(key, ProfileLS.PROFILETYPE_COPLETTYPE);
             }
             this.copletTypes.validity = newValidity;
+            // now invalidate coplet definitions
             this.copletDefinitions.objects = null;
             this.copletDefinitions.validity = null;
             this.prepareObject(null, this.copletTypes.objects);
@@ -399,9 +420,8 @@
         }
     }
 
-    protected Map getGlobalDatas(final PortalUser  info,
-                                 final ProfileImpl profile,
-                                 final String      layoutKey)
+    protected Map getGlobalCopletDefinitions(final PortalUser  info,
+                                             final ProfileImpl profile)
     throws Exception {
         // if we already have loaded the profile and don't check
         // for changes, just return the profile
@@ -413,7 +433,7 @@
                 ProfileLS.PROFILETYPE_COPLETDEFINITION,
                 info,
                 true,
-                layoutKey);
+                null);
         SourceValidity newValidity = null;
         // if we have a profile, check for reloading
         if ( this.copletDefinitions.validity != null ) {
@@ -608,9 +628,11 @@
         if ( this.copletTypes.objects == null ) {
             try {
                 // first "load" the global data
-                this.getGlobalCopletTypes(this.portalService.getUserService().getDefaultProfileName());
+                this.getGlobalCopletTypes();
+            } catch (ProfileException e) {
+                throw e;
             } catch (Exception e) {
-                throw new ProfileException("Unable to load global base datas.", e);
+                throw new ProfileException("Unable to load global coplet types.", e);
             }            
         }
         return this.copletTypes.objects.values();

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java?view=diff&rev=468519&r1=468518&r2=468519
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
Fri Oct 27 13:14:30 2006
@@ -59,9 +59,8 @@
 
     protected Profile loadProfile() 
     throws ProfileException {
-        final PortalUser info = this.portalService.getUserService().getUser();
-        final String layoutKey = this.portalService.getUserService().getDefaultProfileName();
-        if ( info.getUserName().equals("test") ) {
+        final PortalUser user = this.portalService.getUserService().getUser();
+        if ( user.getUserName().equals("test") ) {
             try {
                 // if the request parameter 'portletName' is available we only
                 // display the portlets specified with the parameter. Otherwise
@@ -76,9 +75,9 @@
                 }
                 final ProfileImpl profile = new ProfileImpl();
     
-                // first "load" the global data
-                profile.setCopletTypes( this.getGlobalCopletTypes( layoutKey) );
-                profile.setCopletDefinitions( this.getGlobalDatas( info, profile, layoutKey)
);
+                // first "load" the global coplet types
+                profile.setCopletTypes( this.getGlobalCopletTypes() );
+                profile.setCopletDefinitions( this.getGlobalCopletDefinitions( user, profile
) );
     
                 // create root layout
                 CompositeLayout rootLayout = new CompositeLayout("root", "row");
@@ -105,7 +104,6 @@
                 }
                 profile.setCopletInstances(instances);
                 this.prepareObject(profile, instances);
-    
                 this.prepareObject(profile, rootLayout);
                 profile.setRootLayout(rootLayout);
     
@@ -115,7 +113,7 @@
             } catch (ProfileException e) {
                 throw e;
             } catch (Exception e) {
-                throw new ProfileException("Unable to load profile for '" + layoutKey + "'.",
e);
+                throw new ProfileException("Unable to load profile '" + this.portalService.getUserService().getDefaultProfileName()
+ "' for user" + user + ".", e);
             }
         }
         return super.loadProfile();



Mime
View raw message