cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r599623 - in /cocoon/trunk/blocks/cocoon-portal: cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/ cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/persistence/castor/ cocoon-portal-impl/src/main/java/org/apache/cocoon/...
Date Thu, 29 Nov 2007 23:21:20 GMT
Author: cziegeler
Date: Thu Nov 29 15:21:15 2007
New Revision: 599623

URL: http://svn.apache.org/viewvc?rev=599623&view=rev
Log:
Create new element to simplify layout type definition in spring bean definitions; adjust castor
mapping and remove old layout factory.

Added:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/LayoutTypeDefinitionParser.java
  (with props)
Removed:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLayoutFactory.java
Modified:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CompositeLayout.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CopletLayout.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/FrameLayout.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/Layout.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.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/persistence/castor/ReferenceFieldHandler.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileLS.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-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileHolder.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LayoutFactory.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/NewDefaultLayoutFactory.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/PortalNamespaceHandler.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/persistence/castor/layout.xml
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/spring/schema/cocoon-portal-1.0.xsd
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/layout-types.xml

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CompositeLayout.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CompositeLayout.java?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CompositeLayout.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CompositeLayout.java
Thu Nov 29 15:21:15 2007
@@ -36,10 +36,9 @@
      * Never create a layout object directly. Use the
      * {@link org.apache.cocoon.portal.services.LayoutFactory} instead.
      * @param id The unique identifier of the layout object or null.
-     * @param type The layout type.
      */
-    public CompositeLayout(String id, LayoutType type) {
-        super(id, type);
+    public CompositeLayout(String id) {
+        super(id);
     }
 
     /**

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CopletLayout.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CopletLayout.java?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CopletLayout.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CopletLayout.java
Thu Nov 29 15:21:15 2007
@@ -31,10 +31,9 @@
      * Never create a layout object directly. Use the
      * {@link org.apache.cocoon.portal.services.LayoutFactory} instead.
      * @param id The unique identifier of the layout object or null.
-     * @param type The layout type.
      */
-    public CopletLayout(String id, LayoutType type) {
-        super(id, type);
+    public CopletLayout(String id) {
+        super(id);
     }
 
     public void setCopletInstanceId(String cid) {

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/FrameLayout.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/FrameLayout.java?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/FrameLayout.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/FrameLayout.java
Thu Nov 29 15:21:15 2007
@@ -35,10 +35,9 @@
      * Never create a layout object directly. Use the
      * {@link org.apache.cocoon.portal.services.LayoutFactory} instead.
      * @param id The unique identifier of the layout object or null.
-     * @param type The layout type.
      */
-    public FrameLayout(String id, LayoutType type) {
-        super(id, type);
+    public FrameLayout(String id) {
+        super(id);
     }
 
     /**

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/Layout.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/Layout.java?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/Layout.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/Layout.java
Thu Nov 29 15:21:15 2007
@@ -55,7 +55,7 @@
     protected boolean isStatic;
 
     /** The corresponding layout type. */
-    protected final LayoutType layoutType;
+    protected LayoutType layoutType;
 
     /** The optional renderer to render this layout. If this layout should use
      * a different renderer than the default renderer, this property will point
@@ -68,10 +68,9 @@
      * Never create a layout object directly. Use the
      * {@link LayoutFactory} instead.
      * @param id The unique identifier of the layout object or null.
-     * @param type The type of the layout.
      * @see PortalUtils#testId(String)
      */
-    public Layout(String id, LayoutType type) {
+    public Layout(String id) {
         // check id, null for id is allowed!
         if ( id != null ) {
             final String idErrorMsg = PortalUtils.testId(id);
@@ -80,7 +79,6 @@
             }
         }
         this.id = id;
-        this.layoutType = type;
     }
 
     /**
@@ -189,8 +187,19 @@
         }
     }
 
+    /**
+     * The type of the layout object.
+     * @return A layout type.
+     */
     public LayoutType getLayoutType() {
         return this.layoutType;
+    }
+
+    /**
+     * Set the type of the layout object.
+     */
+    public void setLayoutType(final LayoutType t) {
+        this.layoutType = t;
     }
 
     /**

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/LayoutType.java
Thu Nov 29 15:21:15 2007
@@ -49,6 +49,13 @@
     /** TODO */
     protected boolean defaultIsStatic = false;
 
+    /** The unique id of this layout type. */
+    protected final String id;
+
+    public LayoutType(String typeId) {
+        this.id = typeId;
+    }
+
     public Renderer getDefaultRenderer() {
         return (Renderer) renderers.get(0);
     }
@@ -116,5 +123,13 @@
 
     public void setDefaultIsStatic(boolean value) {
         this.defaultIsStatic = value;
+    }
+
+    /**
+     * Return the unique id of this layout type.
+     * @return A non-null identifier.
+     */
+    public String getId() {
+        return this.id;
     }
 }

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?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- 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
Thu Nov 29 15:21:15 2007
@@ -35,10 +35,9 @@
      * Never create a layout object directly. Use the
      * {@link org.apache.cocoon.portal.services.LayoutFactory} instead.
      * @param id The unique identifier of the layout object or null.
-     * @param type The layout type.
      */
-    public LinkLayout(String id, LayoutType type) {
-        super(id, type);
+    public LinkLayout(String id) {
+        super(id);
     }
 
     public String getLayoutId() {

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/persistence/castor/ReferenceFieldHandler.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/persistence/castor/ReferenceFieldHandler.java?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/persistence/castor/ReferenceFieldHandler.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/persistence/castor/ReferenceFieldHandler.java
Thu Nov 29 15:21:15 2007
@@ -21,6 +21,8 @@
 import org.apache.cocoon.portal.om.CopletDefinition;
 import org.apache.cocoon.portal.om.CopletInstance;
 import org.apache.cocoon.portal.om.CopletType;
+import org.apache.cocoon.portal.om.Layout;
+import org.apache.cocoon.portal.om.LayoutType;
 import org.exolab.castor.mapping.AbstractFieldHandler;
 
 /**
@@ -40,6 +42,9 @@
         if ( object instanceof CopletInstance ) {
             return ((CopletInstance)object).getCopletDefinition().getId();
         }
+        if ( object instanceof Layout ) {
+            return ((Layout)object).getLayoutType().getId();
+        }
         return null;
     }
 
@@ -67,6 +72,9 @@
         if ( object instanceof CopletInstance ) {
             ((CopletInstance)object).setCopletDefinition(null);
         }
+        if ( object instanceof Layout ) {
+            ((Layout)object).setLayoutType(null);
+        }
     }
 
     /**
@@ -80,6 +88,9 @@
         }
         if ( object instanceof CopletInstance ) {
             ((CopletInstance)object).setCopletDefinition((CopletDefinition)reference);
+        }
+        if ( object instanceof Layout ) {
+            ((Layout)object).setLayoutType((LayoutType)reference);
         }
     }
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileLS.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileLS.java?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileLS.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileLS.java
Thu Nov 29 15:21:15 2007
@@ -22,6 +22,17 @@
 
 /**
  * This component is used for loading/saving of a profile.
+ *
+ * The load/save method is able to load/save the various parts of the profile.
+ * The correct profile type is specified by a constant. For resolving
+ * references during loading an object map is passsed to the loadProfile method.
+ * This object map varies depending on the profile type:
+ * PROFILETYPE_LAYOUT: A map with layout types.
+ * PROFILETYPE_LAYOUTINSTANCE: -
+ * PROFILETYPE_COPLETTYPE: -
+ * PROFILETYPE_COPLETDEFINITION: A map with coplet types.
+ * PROFILETYPE_COPLETINSTANCE: A map with coplet definitions
+ *
  * @version $Id$
  */
 public interface ProfileLS {
@@ -40,10 +51,10 @@
      * @param key The key to identifier the profile. This key contains information
      *            like user etc.
      * @param profileType The type of the profile (instances, types, layouts etc. )
-     * @param objectMap Map with object which might be references by the profile.
+     * @param objectMap Map with objects which might be references by the profile.
      */
     Object loadProfile(Object key, String profileType, Map objectMap)
-    throws Exception;  
+    throws Exception;
 
     /**
      * Save a profile.
@@ -52,7 +63,7 @@
      * @param profileType The type of the profile (instances, types, layouts etc. )
      * @param profile The profile itself.
      */
-    void saveProfile(Object key, String profileType, Object profile) throws Exception;  
+    void saveProfile(Object key, String profileType, Object profile) throws Exception;
 
     /**
      * Get the validity of a profile.

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?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- 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
Thu Nov 29 15:21:15 2007
@@ -58,17 +58,17 @@
  * each user has belong to exactly one group.
  * In the case that the user does not belong to a group, a global
  * profile is loaded.
- * 
+ *
  * This profile manager does not check for changes of the profile,
  * which means for example once a global profile is loaded, it is
  * used until Cocoon is restarted. (This will be changed later on)
- * 
+ *
  * THIS IS A WORK IN PROGRESS - IT'S NOT FINISHED YET
- * 
+ *
  * @version $Id$
  */
-public class GroupBasedProfileManager 
-    extends AbstractProfileManager { 
+public class GroupBasedProfileManager
+    extends AbstractProfileManager {
 
     public static final String CATEGORY_GLOBAL = "global";
     public static final String CATEGORY_GROUP  = "group";
@@ -282,11 +282,12 @@
      * This loads the profile for the current user. First the default profile is read. This
might
      * contain links to other profiles which are then loaded recursively.
      */
-    protected ProfileHolder loadProfile() 
+    protected ProfileHolder loadProfile()
     throws ProfileException {
         final String defaultProfileName = this.portalService.getUserService().getDefaultProfileName();
         final PortalUser user = this.portalService.getUserService().getUser();
         ProfileHolder profile = new ProfileHolder();
+        profile.setLayoutTypes(this.portalService.getLayoutFactory().getLayoutTypes());
 
         try {
             // first "load" the global data
@@ -294,7 +295,7 @@
             // 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
             this.loadProfile(profile, user, defaultProfileName);
             // FIXME - Traverse the layout tree for link layouts
@@ -317,14 +318,14 @@
                     }
                 }
             }
-    
+
             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) {
@@ -493,7 +494,7 @@
                                       true,
                                       layoutKey);
         try {
-            Layout l = (Layout)loader.loadProfile(key, ProfileLS.PROFILETYPE_LAYOUT, profile.getCopletInstancesMap());
+            Layout l = (Layout)loader.loadProfile(key, ProfileLS.PROFILETYPE_LAYOUT, profile.getLayoutTypesMap());
             l = this.processLayout(profile, l);
             profile.setRootLayout(l);
 
@@ -522,7 +523,7 @@
         if ( load ) {
             config.append("load");
         } else {
-            config.append("save");            
+            config.append("save");
         }
         final String uri = this.configuration.getProperty(config.toString());
         if ( uri == null ) {
@@ -572,7 +573,7 @@
         try {
             final ProfileHolder profile = this.getUserProfile();
             final Map key = this.buildKey(CATEGORY_USER,
-                                          ProfileLS.PROFILETYPE_LAYOUTINSTANCE, 
+                                          ProfileLS.PROFILETYPE_LAYOUTINSTANCE,
                                           this.portalService.getUserService().getUser(),
                                           false,
                                           null);
@@ -605,7 +606,7 @@
                 throw e;
             } catch (Exception e) {
                 throw new ProfileException("Unable to load global coplet types.", e);
-            }            
+            }
         }
         return this.copletTypes.objects.values();
     }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileHolder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileHolder.java?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileHolder.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileHolder.java
Thu Nov 29 15:21:15 2007
@@ -30,6 +30,7 @@
 import org.apache.cocoon.portal.om.Item;
 import org.apache.cocoon.portal.om.Layout;
 import org.apache.cocoon.portal.om.LayoutInstance;
+import org.apache.cocoon.portal.om.LayoutType;
 
 /**
  * This class is an utility class holding all profile information of the
@@ -61,6 +62,9 @@
     /** The root element of the layout. */
     protected Layout rootLayout;
 
+    /** A map of all layout types. */
+    protected Map layoutTypes;
+
     /**
      * Set the root layout for this profile.
      */
@@ -234,7 +238,7 @@
                     this.traverseLayouts( current.getLayout() );
                 }
             }
-        }        
+        }
     }
 
     /**
@@ -311,5 +315,19 @@
 
     public Map getCopletTypesMap() {
         return this.copletTypes;
+    }
+
+    public Map getLayoutTypesMap() {
+        return this.layoutTypes;
+    }
+
+    public void setLayoutTypes(final Collection c) {
+        final Map types = new HashMap();
+        final Iterator i = c.iterator();
+        while ( i.hasNext() ) {
+            final LayoutType layoutType = (LayoutType)i.next();
+            types.put(layoutType.getId(), layoutType);
+        }
+        this.layoutTypes = types;
     }
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
Thu Nov 29 15:21:15 2007
@@ -23,6 +23,7 @@
 import java.util.List;
 import java.util.Map;
 
+import org.apache.cocoon.portal.PortalRuntimeException;
 import org.apache.cocoon.portal.om.CompositeLayout;
 import org.apache.cocoon.portal.om.CopletDefinition;
 import org.apache.cocoon.portal.om.CopletInstance;
@@ -30,9 +31,8 @@
 import org.apache.cocoon.portal.om.Item;
 import org.apache.cocoon.portal.om.Layout;
 import org.apache.cocoon.portal.om.LayoutInstance;
-import org.apache.cocoon.portal.profile.ProfileLS;
 import org.apache.cocoon.portal.profile.ProfileException;
-import org.apache.cocoon.portal.PortalRuntimeException;
+import org.apache.cocoon.portal.profile.ProfileLS;
 import org.apache.commons.collections.map.LinkedMap;
 import org.apache.commons.collections.map.StaticBucketMap;
 import org.apache.excalibur.source.SourceValidity;
@@ -43,8 +43,8 @@
  * FIXME - Events for adding/removing coplet instances/layouts not implemented yet
  * @version $Id$
  */
-public class StaticProfileManager 
-    extends AbstractProfileManager { 
+public class StaticProfileManager
+    extends AbstractProfileManager {
 
     protected String profilesPath = "cocoon:/profiles";
 
@@ -84,15 +84,6 @@
                     return layout;
             }
 
-            // put instances into map
-            Collection c = this.loadCopletInstances();
-            final Map objectMap = new HashMap();
-            final Iterator i = c.iterator();
-            while ( i.hasNext() ) {
-                CopletInstance current = (CopletInstance)i.next();
-                objectMap.put(current.getId(), current);
-            }
-
             // load layout
             final Map map = new LinkedMap();
             map.put("base", this.profilesPath);
@@ -108,7 +99,7 @@
             }
 
             // get Layout specified in the map
-            Layout layout = (Layout) this.loader.loadProfile(map, ProfileLS.PROFILETYPE_LAYOUT,
objectMap);
+            Layout layout = (Layout) this.loader.loadProfile(map, ProfileLS.PROFILETYPE_LAYOUT,
null);
             layout = this.processLayout(null, layout);
 
             final Map layouts = new HashMap();
@@ -150,7 +141,7 @@
         }
     }
 
-    private Map getCopletDefinitionManager() 
+    private Map getCopletDefinitionManager()
     throws Exception {
         final String portalName = this.portalService.getPortalName();
         // ensure that profile is loaded
@@ -158,7 +149,7 @@
         return (Map)this.copletDefinitions.get(portalName);
     }
 
-    private Collection loadCopletInstances() 
+    private Collection loadCopletInstances()
     throws Exception {
         String portalName = this.portalService.getPortalName();
         Collection instances = (Collection) this.copletInstances.get(portalName);

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LayoutFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LayoutFactory.java?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LayoutFactory.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LayoutFactory.java
Thu Nov 29 15:21:15 2007
@@ -22,6 +22,7 @@
 import org.apache.cocoon.portal.om.Layout;
 import org.apache.cocoon.portal.om.LayoutException;
 import org.apache.cocoon.portal.om.LayoutInstance;
+import org.apache.cocoon.portal.om.LayoutType;
 
 /**
  * This factory is for creating and managing layout objects.
@@ -32,7 +33,7 @@
 
     /**
      * Return all available types.
-     * TODO - Do we need this?
+     * @return A non-null collection of {@link LayoutType}s.
      */
     Collection getLayoutTypes();
 

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/NewDefaultLayoutFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/NewDefaultLayoutFactory.java?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/NewDefaultLayoutFactory.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/NewDefaultLayoutFactory.java
Thu Nov 29 15:21:15 2007
@@ -149,7 +149,7 @@
      * @see org.apache.cocoon.portal.services.LayoutFactory#getLayoutTypes()
      */
     public Collection getLayoutTypes() {
-        return this.layoutTypes.keySet();
+        return this.layoutTypes.values();
     }
 
     /**

Added: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/LayoutTypeDefinitionParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/LayoutTypeDefinitionParser.java?rev=599623&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/LayoutTypeDefinitionParser.java
(added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/LayoutTypeDefinitionParser.java
Thu Nov 29 15:21:15 2007
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.spring;
+
+import org.apache.cocoon.portal.layout.renderer.Renderer;
+import org.apache.cocoon.portal.om.LayoutType;
+import org.apache.cocoon.spring.configurator.impl.AbstractElementParser;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.ManagedList;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+*
+* @version $Id$
+*/
+public class LayoutTypeDefinitionParser extends AbstractElementParser {
+
+    /**
+     * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element,
org.springframework.beans.factory.xml.ParserContext)
+     */
+    public BeanDefinition parse(Element element, ParserContext parserContext) {
+        // create a new bean definition for the layout type
+        RootBeanDefinition beanDef = this.createBeanDefinition(LayoutType.class, null, false);
+        final String layoutTypeId = element.getAttribute("id");
+        beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, layoutTypeId);
+
+        beanDef.getPropertyValues().addPropertyValue("className", element.getAttribute("layoutClass"));
+        if ( this.getAttributeValue(element, "createLayoutId", null) != null ) {
+            beanDef.getPropertyValues().addPropertyValue("createId", this.getAttributeValue(element,
"createLayoutId", "false"));
+        }
+        beanDef.getPropertyValues().addPropertyValue("itemClassName", element.getAttribute("itemClass"));
+        if ( this.getAttributeValue(element, "defaultIsStatic", null) != null ) {
+            beanDef.getPropertyValues().addPropertyValue("defaultIStatic", this.getAttributeValue(element,
"defaultIStatic", "false"));
+        }
+
+        final ManagedList rendererBeans = new ManagedList();
+        rendererBeans.setSource(parserContext.getReaderContext().extractSource(element));
+
+        final Element[] rendererElements = this.getChildElements(element, "renderer");
+        for(int i=0; i<rendererElements.length; i++) {
+            final String ref = this.getAttributeValue(rendererElements[i], "ref", null);
+            final String type= this.getAttributeValue(rendererElements[i], "type", null);
+            if ( ref == null && type == null ) {
+                throw new BeanDefinitionStoreException("Element 'renderer' must have either
a 'ref' or a 'type' attribute.");
+            }
+            if ( ref != null && type != null ) {
+                throw new BeanDefinitionStoreException("Element 'renderer' must have either
a 'ref' or a 'type' attribute, but not both.");
+            }
+            final String beanName = (ref != null ? ref : Renderer.class.getName() + '.' +
type);
+            rendererBeans.add(new RuntimeBeanReference(beanName));
+        }
+        beanDef.getPropertyValues().addPropertyValue("renderers", rendererBeans);
+
+        this.register(beanDef, LayoutType.class.getName() + "." + layoutTypeId, parserContext.getRegistry());
+        return null;
+    }
+
+}

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/LayoutTypeDefinitionParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/LayoutTypeDefinitionParser.java
------------------------------------------------------------------------------
    svn:keywords = author date id revision url

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/PortalNamespaceHandler.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/PortalNamespaceHandler.java?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/PortalNamespaceHandler.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/PortalNamespaceHandler.java
Thu Nov 29 15:21:15 2007
@@ -37,5 +37,6 @@
         this.registerBeanDefinitionParser("request-processor-aspects", new AspectsBeanDefinitionParser(RequestProcessorAspect.class.getName()));
         this.registerBeanDefinitionParser("response-processor-aspects", new AspectsBeanDefinitionParser(ResponseProcessorAspect.class.getName()));
         this.registerBeanDefinitionParser("profile-manager-aspects", new AspectsBeanDefinitionParser(ProfileManagerAspect.class.getName()));
+        this.registerBeanDefinitionParser("layout-type", new LayoutTypeDefinitionParser());
     }
 }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/persistence/castor/layout.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/persistence/castor/layout.xml?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/persistence/castor/layout.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/persistence/castor/layout.xml
Thu Nov 29 15:21:15 2007
@@ -39,6 +39,12 @@
     <field name="static" type="java.lang.Boolean" set-method="setIsStatic" get-method="isStatic">
       <bind-xml name="static" node="attribute"/>
     </field>
+
+    <field name="layoutType"
+           type="java.lang.String"
+           handler="org.apache.cocoon.portal.persistence.castor.ReferenceFieldHandler">
+      <bind-xml name="type" node="attribute"/>
+    </field>
   </class>
 
   <class name="org.apache.cocoon.portal.om.LinkLayout"
@@ -50,10 +56,6 @@
       <bind-xml name="id" node="attribute" />
     </field>
 
-    <field name="type" type="java.lang.String" set-method="%2" get-method="getType">
-      <bind-xml name="type" node="attribute"/>
-    </field>
-
     <field name="profileName" type="java.lang.String">
       <bind-xml name="profile-name" node="attribute"/>
     </field>
@@ -71,10 +73,6 @@
       <bind-xml name="id" node="attribute" />
     </field>
 
-    <field name="type" type="java.lang.String" set-method="%2" get-method="getType">
-      <bind-xml name="type" node="attribute"/>
-    </field>
-
     <field name="items" type="org.apache.cocoon.portal.om.Item"
            collection="collection" set-method="addItem" get-method="getItems">
       <bind-xml matches="named-item item"/>
@@ -91,10 +89,6 @@
       <bind-xml name="id" node="attribute" />
     </field>
 
-    <field name="type" type="java.lang.String" set-method="%2" get-method="getType">
-      <bind-xml name="type" node="attribute"/>
-    </field>
-
     <field name="copletInstanceId"
            type="java.lang.String">
       <bind-xml name="coplet-instance"/>
@@ -108,10 +102,6 @@
 
     <field name="id" type="java.lang.String" set-method="%1" get-method="getId">
       <bind-xml name="id" node="attribute" />
-    </field>
-
-    <field name="type" type="java.lang.String" set-method="%2" get-method="getType">
-      <bind-xml name="type" node="attribute"/>
     </field>
 
     <field name="source" type="java.lang.String"/>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/spring/schema/cocoon-portal-1.0.xsd
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/spring/schema/cocoon-portal-1.0.xsd?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/spring/schema/cocoon-portal-1.0.xsd
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/spring/schema/cocoon-portal-1.0.xsd
Thu Nov 29 15:21:15 2007
@@ -77,4 +77,22 @@
       <xsd:attribute name="value" type="xsd:string" use="required"/>
     </xsd:complexType>
   </xsd:element>
+  
+  <xsd:element name="layout-type">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element name="renderer" minOccurs="1" maxOccurs="unbounded">
+          <xsd:complexType>
+            <xsd:attribute name="ref" type="xsd:string" use="optional"/>
+            <xsd:attribute name="type" type="xsd:string" use="optional"/>
+          </xsd:complexType>
+        </xsd:element>
+      </xsd:sequence>
+      <xsd:attribute name="id" type="xsd:ID" use="required"/>
+      <xsd:attribute name="layoutClass" type="xsd:string" use="required"/>
+      <xsd:attribute name="createLayoutId" type="xsd:boolean" use="optional"/>
+      <xsd:attribute name="itemClass" type="xsd:string" use="optional"/>
+      <xsd:attribute name="defaultIsStatic" type="xsd:boolean" use="optional"/>
+    </xsd:complexType>
+  </xsd:element>
 </xsd:schema>

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?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- 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
Thu Nov 29 15:21:15 2007
@@ -74,6 +74,9 @@
                 }
                 final ProfileHolder profile = new ProfileHolder();
 
+                // set global stuff like layout types
+                profile.setLayoutTypes(this.portalService.getLayoutFactory().getLayoutTypes());
+
                 // first "load" the global coplet types
                 profile.setCopletTypes( this.getGlobalCopletTypes() );
                 profile.setCopletDefinitions( this.getGlobalCopletDefinitions( user, profile
) );

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/layout-types.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/layout-types.xml?rev=599623&r1=599622&r2=599623&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/layout-types.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/layout-types.xml
Thu Nov 29 15:21:15 2007
@@ -27,92 +27,43 @@
                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
                            http://cocoon.apache.org/schema/portal http://cocoon.apache.org/schema/portal/cocoon-portal-1.0.xsd">
 
-    <bean name="org.apache.cocoon.portal.om.LayoutType.column"
-          class="org.apache.cocoon.portal.om.LayoutType">
-      <property name="className" value="org.apache.cocoon.portal.om.CompositeLayout"/>
-      <property name="renderers">
-        <list>
-          <ref bean="org.apache.cocoon.portal.layout.renderer.Renderer.column"/>
-        </list>
-      </property>
-    </bean>
-
-    <bean name="org.apache.cocoon.portal.om.LayoutType.row"
-          class="org.apache.cocoon.portal.om.LayoutType">
-      <property name="className" value="org.apache.cocoon.portal.om.CompositeLayout"/>
-      <property name="renderers">
-        <list>
-          <ref bean="org.apache.cocoon.portal.layout.renderer.Renderer.row"/>
-        </list>
-      </property>
-    </bean>
-
-    <bean name="org.apache.cocoon.portal.om.LayoutType.tab"
-          class="org.apache.cocoon.portal.om.LayoutType">
-      <property name="className" value="org.apache.cocoon.portal.om.CompositeLayout"/>
-      <property name="itemClassName" value="org.apache.cocoon.portal.om.NamedItem"/>
-      <property name="defaultIsStatic" value="true"/>
-      <property name="renderers">
-        <list>
-          <ref bean="org.apache.cocoon.portal.layout.renderer.Renderer.tab"/>
-        </list>
-      </property>
-    </bean>
-
-    <bean name="org.apache.cocoon.portal.om.LayoutType.rawtab"
-          class="org.apache.cocoon.portal.om.LayoutType">
-      <property name="className" value="org.apache.cocoon.portal.om.CompositeLayout"/>
-      <property name="itemClassName" value="org.apache.cocoon.portal.om.NamedItem"/>
-      <property name="renderers">
-        <list>
-          <ref bean="org.apache.cocoon.portal.layout.renderer.Renderer.rawtab"/>
-        </list>
-      </property>
-    </bean>
-
-    <bean name="org.apache.cocoon.portal.om.LayoutType.linktab"
-          class="org.apache.cocoon.portal.om.LayoutType">
-      <property name="className" value="org.apache.cocoon.portal.om.CompositeLayout"/>
-      <property name="itemClassName" value="org.apache.cocoon.portal.om.NamedItem"/>
-      <property name="defaultIsStatic" value="true"/>
-      <property name="renderers">
-        <list>
-          <ref bean="org.apache.cocoon.portal.layout.renderer.Renderer.linktab"/>
-        </list>
-      </property>
-    </bean>
-
-    <bean name="org.apache.cocoon.portal.om.LayoutType.frame"
-          class="org.apache.cocoon.portal.om.LayoutType">
-      <property name="className" value="org.apache.cocoon.portal.om.FrameLayout"/>
-      <property name="createId" value="true"/>
-      <property name="renderers">
-        <list>
-          <ref bean="org.apache.cocoon.portal.layout.renderer.Renderer.frame"/>
-        </list>
-      </property>
-    </bean>
-
-    <bean name="org.apache.cocoon.portal.om.LayoutType.coplet"
-          class="org.apache.cocoon.portal.om.LayoutType">
-      <property name="className" value="org.apache.cocoon.portal.om.CopletLayout"/>
-      <property name="renderers">
-        <list>
-          <ref bean="org.apache.cocoon.portal.layout.renderer.Renderer.window"/>
-          <ref bean="org.apache.cocoon.portal.layout.renderer.Renderer.nowindow"/>
-          <ref bean="org.apache.cocoon.portal.layout.renderer.Renderer.borderless-window"/>
-        </list>
-      </property>
-    </bean>
-
-    <bean name="org.apache.cocoon.portal.om.LayoutType.link"
-          class="org.apache.cocoon.portal.om.LayoutType">
-      <property name="className" value="org.apache.cocoon.portal.om.LinkLayout"/>
-      <property name="createId" value="true"/>
-      <property name="renderers">
-        <list>
-          <ref bean="org.apache.cocoon.portal.layout.renderer.Renderer.link"/>
-        </list>
-      </property>
-    </bean>
+    <portal:layout-type id="column" layoutClass="org.apache.cocoon.portal.om.CompositeLayout">
+      <portal:renderer type="column"/>
+    </portal:layout-type>
+
+    <portal:layout-type id="row" layoutClass="org.apache.cocoon.portal.om.CompositeLayout">
+      <portal:renderer type="row"/>
+    </portal:layout-type>
+
+    <portal:layout-type id="tab" layoutClass="org.apache.cocoon.portal.om.CompositeLayout"
+                        itemClassName="org.apache.cocoon.portal.om.NamedItem"
+                        createLayoutId="true" defaultIsStatic="true">
+      <portal:renderer type="tab"/>
+    </portal:layout-type>
+
+    <portal:layout-type id="rawtab" layoutClass="org.apache.cocoon.portal.om.CompositeLayout"
+                        itemClassName="org.apache.cocoon.portal.om.NamedItem"
+                        createLayoutId="true" defaultIsStatic="true">
+      <portal:renderer type="rawtab"/>
+    </portal:layout-type>
+
+    <portal:layout-type id="linktab" layoutClass="org.apache.cocoon.portal.om.CompositeLayout"
+                        itemClassName="org.apache.cocoon.portal.om.NamedItem"
+                        createLayoutId="true" defaultIsStatic="true">
+      <portal:renderer type="linktab"/>
+    </portal:layout-type>
+
+    <portal:layout-type id="frame" layoutClass="org.apache.cocoon.portal.om.FrameLayout"
createLayoutId="true">
+      <portal:renderer type="frame"/>
+    </portal:layout-type>
+
+    <portal:layout-type id="link" layoutClass="org.apache.cocoon.portal.om.LinkLayout"
createLayoutId="true">
+      <portal:renderer type="link"/>
+    </portal:layout-type>
+
+    <portal:layout-type id="coplet" layoutClass="org.apache.cocoon.portal.om.CopletLayout">
+      <portal:renderer type="window"/>
+      <portal:renderer type="nowindow"/>
+      <portal:renderer type="borderless-window"/>
+    </portal:layout-type>
 </beans>



Mime
View raw message