cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r328461 - in /cocoon/blocks/portal/trunk: ./ java/org/apache/cocoon/portal/coplet/adapter/impl/ java/org/apache/cocoon/portal/event/aspect/impl/ java/org/apache/cocoon/portal/event/impl/ java/org/apache/cocoon/portal/event/layout/ java/org/...
Date Tue, 25 Oct 2005 19:44:31 GMT
Author: cziegeler
Date: Tue Oct 25 12:44:00 2005
New Revision: 328461

URL: http://svn.apache.org/viewcvs?rev=328461&view=rev
Log:
Add temporary parameters to Layout objects

Modified:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/aspect/impl/FrameEventAspect.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/aspect/impl/LinkEventAspect.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/InternalEventReceiver.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/layout/LayoutChangeParameterEvent.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/AbstractLayout.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/Layout.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/FrameAspect.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/HistoryAspect.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/impl/DefaultLinkRenderer.java
    cocoon/blocks/portal/trunk/status.xml

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/adapter/impl/ApplicationCopletAdapter.java
Tue Oct 25 12:44:00 2005
@@ -182,7 +182,7 @@
      * @return String the name of the new item
      */
     private String getNewInstanceTabName(CompositeLayout layout) {
-        Integer data = Integer.valueOf(layout.getParameter("tab"));
+        Integer data = Integer.valueOf(layout.getTemporaryParameter("tab"));
         Item selectedItem = (NamedItem) layout.getItem(data.intValue());
 
         if (selectedItem instanceof NamedItem) {

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/aspect/impl/FrameEventAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/aspect/impl/FrameEventAspect.java?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/aspect/impl/FrameEventAspect.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/aspect/impl/FrameEventAspect.java
Tue Oct 25 12:44:00 2005
@@ -43,7 +43,7 @@
                            Layout layout,
                            String[] values) {
         if (layout instanceof FrameLayout) {
-            final Event e = new LayoutChangeParameterEvent(layout, "frame", values[2]);
+            final Event e = new LayoutChangeParameterEvent(layout, "frame", values[2], true);
             publisher.send(e);
         } else {
             this.getLogger().warn(

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/aspect/impl/LinkEventAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/aspect/impl/LinkEventAspect.java?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/aspect/impl/LinkEventAspect.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/aspect/impl/LinkEventAspect.java
Tue Oct 25 12:44:00 2005
@@ -46,11 +46,11 @@
             LinkLayout linkLayout = (LinkLayout) layout;
             Event e = new LayoutChangeParameterEvent(linkLayout,
                                                 "link-layout-key",
-                                                values[2]);
+                                                values[2], true);
             publisher.send(e);
             e = new LayoutChangeParameterEvent(linkLayout,
                                           "link-layout-id",
-                                          values[3]);
+                                          values[3], true);
             publisher.send(e);
         } else {
             this.getLogger().warn(

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/InternalEventReceiver.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/InternalEventReceiver.java?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/InternalEventReceiver.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/InternalEventReceiver.java
Tue Oct 25 12:44:00 2005
@@ -111,6 +111,10 @@
      */
     public void inform(LayoutChangeParameterEvent e, PortalService service) {
         final Layout l = (Layout)e.getTarget();
-        l.setParameter(e.getParameterName(), e.getValue());
+        if ( e.isTemporary() ) {
+            l.setTemporaryParameter(e.getParameterName(), e.getValue());
+        } else {
+            l.setParameter(e.getParameterName(), e.getValue());
+        }
     }
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/layout/LayoutChangeParameterEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/layout/LayoutChangeParameterEvent.java?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/layout/LayoutChangeParameterEvent.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/layout/LayoutChangeParameterEvent.java
Tue Oct 25 12:44:00 2005
@@ -33,6 +33,7 @@
 
     protected String parameterName;
     protected String value;
+    protected boolean temporary;
 
     public LayoutChangeParameterEvent(PortalService service, String eventData) {
         super(null);
@@ -44,8 +45,12 @@
         if ( pos2 == -1 ) {
             throw new IllegalArgumentException("Corrupt event data: " + eventData);
         }
+        if ( eventData.charAt(pos+1) != 'T' && eventData.charAt(pos+1) != 'P') {
+            throw new IllegalArgumentException("Corrupt event data: " + eventData);     
      
+        }
         final String layoutId = eventData.substring(0, pos);
-        this.parameterName = eventData.substring(pos+1, pos2);
+        this.temporary = (eventData.charAt(pos+1) == 'T');
+        this.parameterName = eventData.substring(pos+2, pos2);
         this.value= eventData.substring(pos2+1);
         this.target = service.getComponentManager().getProfileManager().getPortalLayout(null,
layoutId);
     }
@@ -53,10 +58,20 @@
     /**
      * @param target
      */
-    public LayoutChangeParameterEvent(Layout target, String parameterName, String value)
{
+    public LayoutChangeParameterEvent(Layout target,
+                                      String parameterName,
+                                      String value) {
+        this(target, parameterName, value, false);
+    }
+
+    public LayoutChangeParameterEvent(Layout target,
+                                      String parameterName,
+                                      String value,
+                                      boolean temporary) {
         super(target);
         this.parameterName = parameterName;
         this.value = value;
+        this.temporary = temporary;
     }
 
     public String getParameterName() {
@@ -67,13 +82,19 @@
         return this.value;
     }
 
+    public boolean isTemporary() {
+        return this.temporary;
+    }
+
     /**
      * @see org.apache.cocoon.portal.event.ComparableEvent#equalsEvent(org.apache.cocoon.portal.event.ComparableEvent)
      */
     public boolean equalsEvent(ComparableEvent event) {
         if ( event instanceof LayoutChangeParameterEvent ) {
-            return ObjectUtils.equals(this.getTarget(), ((LayoutChangeParameterEvent)event).getTarget())
-                   && ObjectUtils.equals(this.getParameterName(), ((LayoutChangeParameterEvent)event).getParameterName());
+            LayoutChangeParameterEvent e = (LayoutChangeParameterEvent)event;
+            return this.temporary == e.temporary
+                   && ObjectUtils.equals(this.getTarget(), e.getTarget())
+                   && ObjectUtils.equals(this.getParameterName(), e.getParameterName());
         }
         return false;
     }
@@ -86,7 +107,7 @@
         if ( l.getId() == null ) {
             return null;
         }
-        return l.getId() + ':' + this.parameterName + ':' + this.value;
+        return l.getId() + ':' + (this.temporary ? 'T' : 'P') + this.parameterName + ':'
+ this.value;
     }
 
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelManager.java?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelManager.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PageLabelManager.java Tue
Oct 25 12:44:00 2005
@@ -252,7 +252,7 @@
         for (int j = 0; j < layout.getSize(); j++) {
             Item tab = layout.getItem(j);
             LayoutChangeParameterEvent event =
-                new LayoutChangeParameterEvent(layout, this.aspectName, String.valueOf(j));
+                new LayoutChangeParameterEvent(layout, this.aspectName, String.valueOf(j),
true);
             StringBuffer label = new StringBuffer(name);
             if (label.length() > 0) {
                 label.append(".");

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/AbstractLayout.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/AbstractLayout.java?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/AbstractLayout.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/AbstractLayout.java Tue
Oct 25 12:44:00 2005
@@ -15,6 +15,8 @@
  */
 package org.apache.cocoon.portal.layout;
 
+import java.util.Map;
+
 import org.apache.commons.collections.map.LinkedMap;
 
 /**
@@ -34,8 +36,12 @@
 
     protected String id;
 
+    /** TODO we should remove the description from here. */
     transient protected LayoutDescription description;
 
+    /** The temporary parameters. */
+    protected Map temporaryParameters = new LinkedMap();
+
     /**
      * @return The configured name
      */
@@ -108,6 +114,27 @@
      */
     public String getLayoutRendererName() {
         return this.rendererName;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.layout.Layout#getTemporaryParameter(java.lang.String)
+     */
+    public String getTemporaryParameter(String key) {
+        return (String)this.temporaryParameters.get(key);
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.layout.Layout#getTemporaryParameters()
+     */
+    public Map getTemporaryParameters() {
+        return this.temporaryParameters;
+    }
+
+    /**
+     * @see org.apache.cocoon.portal.layout.Layout#setTemporaryParameter(java.lang.String,
java.lang.String)
+     */
+    public void setTemporaryParameter(String key, String value) {
+        this.temporaryParameters.put(key, value);
     }
 
     /**

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/Layout.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/Layout.java?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/Layout.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/Layout.java Tue Oct 25
12:44:00 2005
@@ -19,8 +19,11 @@
 
 /**
  * 
- * Parameters:
- * A parameter is a key-value pair consisting of strings for both key and value.
+ * Parameters and temporary parameters:
+ * A parameter is a key-value pair consisting of strings for
+ * both key and value. While the parameters are persisted,
+ * the temporary parameters have only the life-time of a
+ * session.
  *
  * @version $Id$
  */
@@ -68,6 +71,27 @@
      * @param value The value.
      */
     void setParameter(String key, String value);
+
+    /**
+     * Get the temporary parameters map.
+     * This method never returns null.
+     * @return A map with key value pairs.
+     */
+    Map getTemporaryParameters();
+
+    /**
+     * Return the temporary parameter value for the given key.
+     * @param key The name of the parameter.
+     * @return The value of the parameter or null.
+     */
+    String getTemporaryParameter(String key);
+
+    /**
+     * Set the temporary parameter to a value.
+     * @param key The name of the parameter.
+     * @param value The value.
+     */
+    void setTemporaryParameter(String key, String value);
 
     /**
      * Get the name of the {@link org.apache.cocoon.portal.layout.renderer.Renderer} to draw
this layout.

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/FrameAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/FrameAspect.java?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/FrameAspect.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/FrameAspect.java
Tue Oct 25 12:44:00 2005
@@ -58,7 +58,7 @@
             throw new SAXException("Wrong layout type, FrameLayout expected: " + layout.getClass().getName());
         }
 
-        String source = layout.getParameter(config.aspectName);
+        String source = layout.getTemporaryParameter(config.aspectName);
         if (source == null) {
             source = ((FrameLayout) layout).getSource();
         }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/HistoryAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/HistoryAspect.java?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/HistoryAspect.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/HistoryAspect.java
Tue Oct 25 12:44:00 2005
@@ -107,6 +107,7 @@
                 }
 
                 this.addValues(layout.getId(), state, layout.getParameters(), "parameters/",
false);
+                this.addValues(layout.getId(), state, layout.getTemporaryParameters(), "temporaryParameters/",
false);
 
                 // are we a coplet layout
                 if ( layout instanceof CopletLayout ) {

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java
Tue Oct 25 12:44:00 2005
@@ -126,7 +126,7 @@
             CompositeLayout tabLayout = (CompositeLayout) layout;
 
             // selected tab
-            String data = layout.getParameter(config.aspectName);
+            String data = layout.getTemporaryParameter(config.aspectName);
             int selected = 0;
             if ( data != null ) {
                 selected = Integer.valueOf(data).intValue();
@@ -145,7 +145,7 @@
                 if (j == selected) {
                     attributes.addCDATAAttribute("selected", "true");
                 }
-                event = new LayoutChangeParameterEvent(tabLayout, config.aspectName, String.valueOf(j));
+                event = new LayoutChangeParameterEvent(tabLayout, config.aspectName, String.valueOf(j),
true);
                 attributes.addCDATAAttribute("parameter", service.getComponentManager().getLinkService().getLinkURI(event));

 
                 // add parameters
@@ -240,7 +240,7 @@
                     attributes.addCDATAAttribute("name",
                         String.valueOf(((NamedItem) tab).getName()));
                     LayoutChangeParameterEvent event = new LayoutChangeParameterEvent(tabLayout,
-                        config.aspectName, String.valueOf(j));
+                        config.aspectName, String.valueOf(j), true);
                     List events = new ArrayList(parentEvents);
                     events.add(event);
 

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/impl/DefaultLinkRenderer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/impl/DefaultLinkRenderer.java?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/impl/DefaultLinkRenderer.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/layout/renderer/impl/DefaultLinkRenderer.java
Tue Oct 25 12:44:00 2005
@@ -36,8 +36,8 @@
     public void process(Layout layout, PortalService service, ContentHandler handler)
     throws SAXException {
         if (layout instanceof LinkLayout) {
-            String layoutKey = layout.getParameter("link-layout-key");
-			String layoutId = layout.getParameter("link-layout-id");
+            String layoutKey = layout.getTemporaryParameter("link-layout-key");
+			String layoutId = layout.getTemporaryParameter("link-layout-id");
             if ( layoutKey == null && layoutId == null){
 				// get default values
 				layoutKey = ((LinkLayout)layout).getLayoutKey();

Modified: cocoon/blocks/portal/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/status.xml?rev=328461&r1=328460&r2=328461&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/status.xml (original)
+++ cocoon/blocks/portal/trunk/status.xml Tue Oct 25 12:44:00 2005
@@ -65,6 +65,9 @@
  <!-- The following list contains the changes since the latest 2.1.x version. -->
  <changes>
   <release version="@version@" date="@date@">
+    <action dev="CZ" type="add">
+      Add temporary attributes to Layout objects.
+    </action>
     <action dev="CZ" type="update">
       Move Castor support into own package and support roles files for Castor. This makes
       including/excluding the Castor support easier.



Mime
View raw message