cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r349271 - in /cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal: event/layout/ layout/renderer/aspect/impl/ pluto/om/
Date Sun, 27 Nov 2005 18:16:28 GMT
Author: cziegeler
Date: Sun Nov 27 10:15:43 2005
New Revision: 349271

URL: http://svn.apache.org/viewcvs?rev=349271&view=rev
Log:
Minor bug fixes and improvements. Make remove event convertable

Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/layout/LayoutRemoveEvent.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/RemovableAspect.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/layout/LayoutRemoveEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/layout/LayoutRemoveEvent.java?rev=349271&r1=349270&r2=349271&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/layout/LayoutRemoveEvent.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/layout/LayoutRemoveEvent.java
Sun Nov 27 10:15:43 2005
@@ -15,21 +15,56 @@
  */
 package org.apache.cocoon.portal.event.layout;
 
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.coplet.CopletInstanceDataFeatures;
+import org.apache.cocoon.portal.event.ConvertableEvent;
 import org.apache.cocoon.portal.event.LayoutEvent;
 import org.apache.cocoon.portal.event.impl.AbstractActionEvent;
+import org.apache.cocoon.portal.layout.Layout;
+import org.apache.cocoon.portal.layout.impl.CopletLayout;
 
 /**
+ * This event can be used to remove a layout object from the profile.
  *
  * @version $Id$
  */
 public class LayoutRemoveEvent
     extends AbstractActionEvent
-    implements LayoutEvent {
+    implements LayoutEvent, ConvertableEvent {
 
     /**
+     * Constructor.
      * @param target
      */
-    public LayoutRemoveEvent(Object target) {
+    public LayoutRemoveEvent(Layout target) {
         super(target);
+    }
+
+    public LayoutRemoveEvent(PortalService service, String eventData) {
+        super(null);
+        if ( eventData.charAt(0) == 'L' ) {
+            this.target = service.getComponentManager().getProfileManager().getPortalLayout(null,
eventData.substring(1));
+        } else if ( eventData.charAt(0) == 'C' ) {
+            final Layout rootLayout = service.getComponentManager().getProfileManager().getPortalLayout(null,
null);
+            this.target = CopletInstanceDataFeatures.searchLayout(eventData.substring(1),
rootLayout);            
+        }
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.event.ConvertableEvent#asString()
+     */
+    public String asString() {
+        final Layout l = (Layout)this.getTarget();
+        if ( l.getId() == null ) {
+            // if this is a coplet layout we can use the coplet instance id
+            if ( l instanceof CopletLayout ) {
+                final CopletLayout cl = (CopletLayout)l;
+                if ( cl.getCopletInstanceData() != null ) {
+                    return 'C' + cl.getCopletInstanceData().getId();
+                }
+            }
+            return null;
+        }
+        return 'L' + l.getId();
     }
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/RemovableAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/RemovableAspect.java?rev=349271&r1=349270&r2=349271&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/RemovableAspect.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/RemovableAspect.java
Sun Nov 27 10:15:43 2005
@@ -27,8 +27,9 @@
 import org.xml.sax.SAXException;
 
 /**
- * Add a tag holding a URI used to remove a coplet from a layout to the
- * output stream if the coplet is not set to mandatory.
+ * Add a tag holding a URI used to remove a layout from the profile.
+ * If the layout holds a coplet then the event is only created if
+ * the coplet is not mandatory.
  *
  * <h2>Example XML:</h2>
  * <pre>
@@ -38,7 +39,7 @@
  *
  * <h2>Applicable to:</h2>
  * <ul>
- *  <li>{@link org.apache.cocoon.portal.layout.impl.CopletLayout}</li>
+ *  <li>{@link org.apache.cocoon.portal.layout.Layout}</li>
  * </ul>
  *
  * @version $Id$
@@ -54,12 +55,19 @@
                       PortalService service,
                       ContentHandler handler)
 	throws SAXException {
-        CopletInstanceData cid = ((CopletLayout)layout).getCopletInstanceData();
-
-        boolean mandatory = CopletDataFeatures.isMandatory(cid.getCopletData());
-        if ( !mandatory ) {
+        if ( layout instanceof CopletLayout ) {
+            final CopletInstanceData cid = ((CopletLayout)layout).getCopletInstanceData();
+    
+            boolean mandatory = CopletDataFeatures.isMandatory(cid.getCopletData());
+            if ( !mandatory ) {
+                LayoutRemoveEvent lre = new LayoutRemoveEvent(layout);
+                XMLUtils.createElement(handler, "remove-uri", service.getComponentManager().getLinkService().getLinkURI(lre));
+            }
+        } else {
+            // for any other layout just create the event
             LayoutRemoveEvent lre = new LayoutRemoveEvent(layout);
-            XMLUtils.createElement(handler, "remove-uri", service.getComponentManager().getLinkService().getLinkURI(lre));
+            XMLUtils.createElement(handler, "remove-uri", 
+                                   service.getComponentManager().getLinkService().getLinkURI(lre));
         }
         context.invokeNext(layout, service, handler);
 	}

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java?rev=349271&r1=349270&r2=349271&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java
Sun Nov 27 10:15:43 2005
@@ -29,6 +29,7 @@
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.Configurable;
@@ -89,14 +90,17 @@
 
     protected List variables = new ArrayList();
 
+    /** Additional parameters passed to the stylesheet. */
     protected Parameters parameters;
 
+    /** Source resolver for resolving the stylesheets. */
+    protected SourceResolver resolver;
+
     /**
      * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
      */
     public void configure(Configuration config) throws ConfigurationException {
         Configuration parameterItems = config.getChild("parameters", false);
-
         if (parameterItems != null) {
             this.parameters = Parameters.fromConfiguration(parameterItems);
         }
@@ -114,30 +118,26 @@
 
         XSLTProcessor processor = null;
         Source stylesheet = null;
-        SourceResolver resolver = null;
         try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-            stylesheet = resolver.resolveURI(this.getStylesheetURI(config, layout));
+            stylesheet = this.resolver.resolveURI(this.getStylesheetURI(config, layout));
             processor = (XSLTProcessor) this.manager.lookup(config.xsltRole);
             TransformerHandler transformer = processor.getTransformerHandler(stylesheet);
             // Pass configured parameters to the stylesheet.
-            if (config.parameters.size() > 0) {
-                Map.Entry entry;
+            if (config.parameters.size() > 0) {                
                 Transformer theTransformer = transformer.getTransformer();
                 Iterator iter = config.parameters.entrySet().iterator();
                 while (iter.hasNext()) {
-                    entry = (Map.Entry) iter.next();
+                    Map.Entry entry = (Map.Entry) iter.next();
                     String value = getParameterValue(entry);
                     theTransformer.setParameter((String) entry.getKey(), value);
                 }
             }
 
-            Map parameter = layout.getParameters();
+            final Map parameter = layout.getParameters();
             if (parameter.size() > 0) {
-                Map.Entry entry;
                 Transformer theTransformer = transformer.getTransformer();
                 for (Iterator iter = parameter.entrySet().iterator(); iter.hasNext();) {
-                    entry = (Map.Entry) iter.next();
+                    Map.Entry entry = (Map.Entry) iter.next();
                     theTransformer.setParameter((String)entry.getKey(), entry.getValue());
                 }
             }
@@ -157,10 +157,7 @@
         } catch (ServiceException ce) {
             throw new SAXException("Unable to lookup component.", ce);
         } finally {
-            if (null != resolver) {
-                resolver.release(stylesheet);
-                this.manager.release(resolver);
-            }
+            this.resolver.release(stylesheet);
             this.manager.release(processor);
         }
 	}
@@ -227,6 +224,14 @@
     }
 
     /**
+     * @see org.apache.cocoon.portal.impl.AbstractComponent#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        super.service(manager);
+        this.resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
+    }
+
+    /**
      * @see org.apache.avalon.framework.activity.Disposable#dispose()
      */
     public void dispose() {
@@ -236,6 +241,8 @@
                 ContainerUtil.dispose(vars.next());
             }
             this.variables.clear();
+            this.manager.release(this.resolver);
+            this.resolver = null;
         }
         super.dispose();
     }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java?rev=349271&r1=349270&r2=349271&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java
Sun Nov 27 10:15:43 2005
@@ -495,6 +495,7 @@
                 final CopletBaseData cbd = pcm.getProfileManager().getCopletBaseData(this.copletBaseDataName);
                 final CopletData cd = pcm.getCopletFactory().newInstance(cbd, portlet.getId().toString());
                 cd.setAttribute("portlet", portlet.getId().toString());
+                cd.setAttribute("buffer", Boolean.TRUE);
                 if ( this.getLogger().isInfoEnabled() ) {
                     this.getLogger().info("Created coplet data: " + cd.getId());
                 }



Mime
View raw message