cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r429125 - in /cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: layout/ profile/impl/ source/
Date Sun, 06 Aug 2006 11:43:40 GMT
Author: cziegeler
Date: Sun Aug  6 04:43:39 2006
New Revision: 429125

URL: http://svn.apache.org/viewvc?rev=429125&view=rev
Log:
Code cleanup

Modified:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/AbstractParameters.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/Layout.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/LayoutFeatures.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/source/CopletSource.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSourceFactory.java

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/AbstractParameters.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/AbstractParameters.java?rev=429125&r1=429124&r2=429125&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/AbstractParameters.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/AbstractParameters.java
Sun Aug  6 04:43:39 2006
@@ -27,7 +27,7 @@
 public abstract class AbstractParameters 
     implements Cloneable, Serializable {
 
-    protected Map parameters = new LinkedMap();
+    protected final Map parameters = new LinkedMap();
 
     public final Map getParameters() {
         return parameters;
@@ -64,9 +64,9 @@
      * @see java.lang.Object#clone()
      */
     protected Object clone() throws CloneNotSupportedException {
-        AbstractParameters clone = (AbstractParameters)super.clone();
+        final AbstractParameters clone = (AbstractParameters)super.clone();
 
-        clone.parameters = new LinkedMap(this.parameters);
+        clone.parameters.putAll(this.parameters);
 
         return clone;
     }

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/Layout.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/Layout.java?rev=429125&r1=429124&r2=429125&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/Layout.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/Layout.java
Sun Aug  6 04:43:39 2006
@@ -205,7 +205,7 @@
             final Layout clone = (Layout)c.newInstance(new Object[] {this.id, this.type});

 
             // clone fields from AbstractParameters
-            clone.parameters = new LinkedMap(this.parameters);
+            clone.parameters.putAll(this.parameters);
             
             // we don't clone the parent; we just set it to null
             clone.parent = null;

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/LayoutFeatures.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/LayoutFeatures.java?rev=429125&r1=429124&r2=429125&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/LayoutFeatures.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/LayoutFeatures.java
Sun Aug  6 04:43:39 2006
@@ -103,13 +103,33 @@
     }
 
     /**
-     * Traverse the whole layout tree.
+     * Traverse the whole layout tree including links.
+     * @param service The portal service.
      * @param rootLayout The root layout to start the traversal.
      * @param traverser The traverser which gets notified
      * @return If the traverser stops the traversing process, the layout will be returned.
      *         Otherwise null wil be returned.
      */
-    public static Layout traverseLayout(PortalService service, Layout rootLayout, LayoutTraverser
traverser) {
+    public static Layout traverseLayout(PortalService   service,
+                                        Layout          rootLayout,
+                                        LayoutTraverser traverser) {
+        return traverseLayout(service, rootLayout, traverser, true);
+    }
+    
+    /**
+     * Traverse the whole layout tree. Depending on the parameters, link layouts are
+     * either followed or not.
+     * @param service The portal service.
+     * @param rootLayout The root layout to start the traversal.
+     * @param traverser The traverser which gets notified
+     * @param followLinks Should LinkLayouts be followed or not.
+     * @return If the traverser stops the traversing process, the layout will be returned.
+     *         Otherwise null wil be returned.
+     */
+    public static Layout traverseLayout(PortalService   service,
+                                        Layout          rootLayout,
+                                        LayoutTraverser traverser,
+                                        boolean         followLinks) {
         if ( rootLayout != null ) {
             if ( !traverser.processLayout(rootLayout) ) {
                 return rootLayout;
@@ -125,7 +145,7 @@
                         }
                     }
                 }
-            } else if ( rootLayout instanceof LinkLayout ) {
+            } else if ( rootLayout instanceof LinkLayout && followLinks) {
                 final LinkLayout linkLayout = (LinkLayout)rootLayout;
                 return traverseLayout(service, service.getProfileManager().getPortalLayout(linkLayout.getLayoutKey(),
linkLayout.getLayoutId()), traverser);
             }

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=429125&r1=429124&r2=429125&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
Sun Aug  6 04:43:39 2006
@@ -126,8 +126,8 @@
     /**
      * @see org.apache.cocoon.portal.impl.AbstractComponent#service(org.apache.avalon.framework.service.ServiceManager)
      */
-    public void service(ServiceManager manager) throws ServiceException {
-        super.service(manager);
+    public void service(ServiceManager serviceManager) throws ServiceException {
+        super.service(serviceManager);
         this.loader = (ProfileLS)this.manager.lookup(ProfileLS.ROLE);
     }
 

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSource.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSource.java?rev=429125&r1=429124&r2=429125&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSource.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSource.java
Sun Aug  6 04:43:39 2006
@@ -20,15 +20,11 @@
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceSelector;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.cocoon.CascadingIOException;
-import org.apache.cocoon.components.ContextHelper;
+import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.coplet.CopletInstance;
 import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
 import org.apache.cocoon.serialization.Serializer;
@@ -45,12 +41,10 @@
  * @version $Id$
  */
 public class CopletSource 
-    implements Source, XMLizable, Serviceable, Contextualizable {
+    implements Source, XMLizable, Serviceable {
 
     protected ServiceManager manager;
 
-    protected Context context;
-
     protected String uri;
     protected String copletControllerName;
     protected CopletInstance copletInstanceData;
@@ -58,6 +52,9 @@
     /** The used protocol */
     protected String scheme;
 
+    /** The portal service. */
+    protected final PortalService portalService;
+
     /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
@@ -65,15 +62,11 @@
         this.manager = aManager;
     }
 
-    /**
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
-     */
-    public void contextualize(Context context) throws ContextException {
-        this.context = context;
-    }
-
-    public CopletSource(String location, String protocol,
-                         CopletInstance coplet) {
+    public CopletSource(String         location,
+                        String         protocol,
+                        CopletInstance coplet,
+                        PortalService  service) {
+        this.portalService = service;
         this.uri = location;
         this.scheme = (protocol == null ? "coplet" : protocol);
         this.copletInstanceData = coplet;
@@ -84,29 +77,19 @@
 	 * @see org.apache.excalibur.source.Source#getInputStream()
 	 */
 	public InputStream getInputStream() throws IOException, SourceNotFoundException {
+        Serializer serializer = null;
         try {
-            ServiceManager sitemapManager = (ServiceManager) this.context.get(ContextHelper.CONTEXT_SITEMAP_SERVICE_MANAGER);
-            ServiceSelector serializerSelector = null;
-            Serializer serializer = null;
-            try {
-                serializerSelector = (ServiceSelector) sitemapManager.lookup(Serializer.ROLE+"Selector");
-                serializer = (Serializer) serializerSelector.select("xml");
-                ByteArrayOutputStream os = new ByteArrayOutputStream();
-                serializer.setOutputStream(os);
-                this.toSAX(serializer);
-                return new ByteArrayInputStream(os.toByteArray());
-            } catch (SAXException se) {
-                throw new CascadingIOException("Unable to stream content.", se);
-            } catch (ServiceException ce) {
-                throw new CascadingIOException("Unable to get components for serializing.",
ce);
-            } finally {
-                if ( serializer != null ) {
-                    serializerSelector.release(serializer);
-                }
-                sitemapManager.release(serializerSelector);
-            }
-        } catch (ContextException ce) {
-            throw new CascadingIOException("Unable to get service manager.", ce);
+            serializer = (Serializer) this.manager.lookup(Serializer.ROLE + "/xml");
+            ByteArrayOutputStream os = new ByteArrayOutputStream();
+            serializer.setOutputStream(os);
+            this.toSAX(serializer);
+            return new ByteArrayInputStream(os.toByteArray());
+        } catch (SAXException se) {
+            throw new CascadingIOException("Unable to stream content.", se);
+        } catch (ServiceException ce) {
+            throw new CascadingIOException("Unable to get components for serializing.", ce);
+        } finally {
+            this.manager.release(serializer);
         }
 	}
 
@@ -157,22 +140,9 @@
 	 */
 	public void toSAX(ContentHandler handler) 
     throws SAXException {
-        ServiceSelector copletAdapterSelector = null;
-        CopletAdapter copletAdapter = null;
-        try {
-            copletAdapterSelector = (ServiceSelector)this.manager.lookup(CopletAdapter.ROLE+"Selector");
-            copletAdapter = (CopletAdapter)copletAdapterSelector.select(this.copletControllerName);
-            
-            copletAdapter.toSAX(this.copletInstanceData, handler);
-        } catch (ServiceException ce) {
-            throw new SAXException("Unable to lookup coplet adaptor or adaptor selector.",
ce);
-        } finally {
-            if ( null != copletAdapter ) {
-                 copletAdapterSelector.release( copletAdapter );
-            }
-            this.manager.release(copletAdapterSelector);
-        }
-            
+        final CopletAdapter copletAdapter = this.portalService.getCopletAdapter(this.copletControllerName);
+
+        copletAdapter.toSAX(this.copletInstanceData, handler);
 	}
 
     /**

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSourceFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSourceFactory.java?rev=429125&r1=429124&r2=429125&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSourceFactory.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSourceFactory.java
Sun Aug  6 04:43:39 2006
@@ -19,7 +19,6 @@
 import java.net.MalformedURLException;
 import java.util.Map;
 
-import org.apache.avalon.framework.context.ContextException;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.cocoon.portal.coplet.CopletInstance;
 import org.apache.cocoon.portal.impl.AbstractComponent;
@@ -57,13 +56,12 @@
                 throw new IOException("Unable to get coplet for " + location);
             }
             CopletSource copletSource =
-                new CopletSource(uri, protocol,
-                                 coplet);
-            copletSource.contextualize(this.context);
+                new CopletSource(uri,
+                                 protocol,
+                                 coplet,
+                                 this.portalService);
             copletSource.service(this.manager);
             return copletSource;
-        } catch (ContextException ce) {
-            throw new SourceException("Unable to setup coplet source.", ce);
         } catch (ServiceException ce) {
             throw new SourceException("Unable to setup coplet source.", ce);
         }



Mime
View raw message