cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r348921 - in /cocoon/blocks: portal-sample/trunk/samples/profiles/copletdata/ portal-sample/trunk/samples/profiles/copletinstancedata/ portal/trunk/java/org/apache/cocoon/portal/coplet/ portal/trunk/java/org/apache/cocoon/portal/event/cople...
Date Fri, 25 Nov 2005 10:00:44 GMT
Author: cziegeler
Date: Fri Nov 25 02:00:31 2005
New Revision: 348921

URL: http://svn.apache.org/viewcvs?rev=348921&view=rev
Log:
Several bug fixes and improved error handling

Modified:
    cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml
    cocoon/blocks/portal-sample/trunk/samples/profiles/copletinstancedata/portal-user-cocoon.xml
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletData.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/coplet/CopletDataAddedEvent.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/om/PortletDefinitionRegistryImpl.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java

Modified: cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml?rev=348921&r1=348920&r2=348921&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml (original)
+++ cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml Fri Nov 25 02:00:31
2005
@@ -441,33 +441,12 @@
    </coplet-data>
 
 
-   <!--
-     +  JSR-168 portlets from the Pluto testsuite
+   <!--+
+       | JSR-168 portlets provided by Cocoon. If Cocoon is running in a different
+       | web application context, you have to change the configuration below
+       | from "webapp.TestPortlet1" to "<CONTEXT_NAME>.TestPortlet1". The same
+       | change has to be applied to the CocoonPortlet.
      -->
-   <coplet-data id="Portlet1">
-      <title>Portlet-Test 1</title>
-      <coplet-base-data>Portlet</coplet-base-data>
-      <attribute>
-         <name>portlet</name>
-         <value xsi:type="java:java.lang.String">testsuite.TestPortlet1</value>
-      </attribute>
-      <attribute>
-         <name>buffer</name>
-         <value xsi:type="java:java.lang.Boolean">true</value>
-      </attribute>
-   </coplet-data>
-   <coplet-data id="Portlet2">
-      <title>Portlet-Test 2</title>
-      <coplet-base-data>Portlet</coplet-base-data>
-      <attribute>
-         <name>portlet</name>
-         <value xsi:type="java:java.lang.String">testsuite.TestPortlet2</value>
-      </attribute>
-      <attribute>
-         <name>buffer</name>
-         <value xsi:type="java:java.lang.Boolean">true</value>
-      </attribute>
-   </coplet-data>
    <coplet-data id="TestPortlet1">
       <title>Portlet-Test</title>
       <coplet-base-data>Portlet</coplet-base-data>

Modified: cocoon/blocks/portal-sample/trunk/samples/profiles/copletinstancedata/portal-user-cocoon.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/profiles/copletinstancedata/portal-user-cocoon.xml?rev=348921&r1=348920&r2=348921&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/profiles/copletinstancedata/portal-user-cocoon.xml
(original)
+++ cocoon/blocks/portal-sample/trunk/samples/profiles/copletinstancedata/portal-user-cocoon.xml
Fri Nov 25 02:00:31 2005
@@ -40,11 +40,11 @@
    </coplet-instance-data>
 
    <coplet-instance-data id="Portlet-1">
-      <coplet-data>Portlet1</coplet-data>
+      <coplet-data>testsuite.TestPortlet1</coplet-data>
    </coplet-instance-data>
 
    <coplet-instance-data id="Portlet-2">
-      <coplet-data>Portlet2</coplet-data>
+      <coplet-data>testsuite.TestPortlet2</coplet-data>
    </coplet-instance-data>
 
    <coplet-instance-data id="TestPortlet-1">

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletData.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletData.java?rev=348921&r1=348920&r2=348921&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletData.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletData.java Fri Nov
25 02:00:31 2005
@@ -206,6 +206,6 @@
      */
     public String toString() {
         return "CopletData (" + this.hashCode() +
-               "), id=" + this.getId() + ", coplet-base-data=" + this.getCopletBaseData().getId();
+               "), id=" + this.getId() + ", coplet-base-data=" + (this.getCopletBaseData()
== null ? "null" : this.getCopletBaseData().getId());
     }
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java?rev=348921&r1=348920&r2=348921&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/coplet/CopletInstanceData.java
Fri Nov 25 02:00:31 2005
@@ -218,6 +218,6 @@
      */
     public String toString() {
         return "CopletInstanceData (" + this.hashCode() +
-               "), id=" + this.getId() + ", coplet-data=" + this.getCopletData().getId();
+               "), id=" + this.getId() + ", coplet-data=" + (this.getCopletData() == null
? "null" : this.getCopletData().getId());
     }
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/coplet/CopletDataAddedEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/coplet/CopletDataAddedEvent.java?rev=348921&r1=348920&r2=348921&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/coplet/CopletDataAddedEvent.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/coplet/CopletDataAddedEvent.java
Fri Nov 25 02:00:31 2005
@@ -16,7 +16,6 @@
 package org.apache.cocoon.portal.event.coplet;
 
 import org.apache.cocoon.portal.coplet.CopletData;
-import org.apache.cocoon.portal.event.CopletDataEvent;
 import org.apache.cocoon.portal.event.impl.AbstractActionEvent;
 
 /**
@@ -25,8 +24,7 @@
  * @version $Id$
  */
 public class CopletDataAddedEvent
-    extends AbstractActionEvent
-    implements CopletDataEvent {
+    extends AbstractActionEvent {
 
     public CopletDataAddedEvent(CopletData target) {
         super(target);

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=348921&r1=348920&r2=348921&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
Fri Nov 25 02:00:31 2005
@@ -47,7 +47,6 @@
 import org.apache.cocoon.portal.deployment.DeploymentException;
 import org.apache.cocoon.portal.deployment.DeploymentStatus;
 import org.apache.cocoon.portal.event.Receiver;
-import org.apache.cocoon.portal.event.coplet.CopletDataAddedEvent;
 import org.apache.cocoon.portal.impl.AbstractComponent;
 import org.apache.cocoon.portal.pluto.deployment.Deployer;
 import org.apache.cocoon.portal.pluto.deployment.WebApplicationRewriter;
@@ -113,6 +112,12 @@
     /** Should we scan the webapps directory on startup? */
     protected boolean scanOnStartup = true;
 
+    /** Create coplets. */
+    protected boolean createCoplets = true;
+
+    /** The name of the coplet base data for portlets. */
+    protected String copletBaseDataName = "Portlet";
+
     /** The threadpool name to be used for daemon thread. */
     protected String threadPoolName = "daemon";
 
@@ -144,6 +149,8 @@
         this.stripLoggers = params.getParameterAsBoolean("strip-loggers", this.stripLoggers);
         this.scanOnStartup = params.getParameterAsBoolean("scan-on-startup", this.scanOnStartup);
         this.threadPoolName = params.getParameter("thread-pool-name", this.threadPoolName);
+        this.createCoplets = params.getParameterAsBoolean("create-coplets", this.createCoplets);
+        this.copletBaseDataName = params.getParameter("coplet-base-data", this.copletBaseDataName);
     }
 
     /**
@@ -468,7 +475,6 @@
 
         // fill portletsKeyObjectId and
         // register new coplet data for each portlet
-        // FIXME - we have to make this configurable (adapter name, enable)
         final PortalComponentManager pcm = this.portalService.getComponentManager();
         final Iterator portlets = portletApp.getPortletDefinitionList().iterator();
         while (portlets.hasNext()) {
@@ -485,8 +491,14 @@
             if ( this.getLogger().isInfoEnabled() ) {
                 this.getLogger().info("Adding portlet '" + portlet.getId() + "'.");
             }
-            final CopletBaseData cbd = pcm.getProfileManager().getCopletBaseData("Portlet");
-            final CopletData cd = pcm.getCopletFactory().newInstance(cbd, portlet.getId().toString());
+            if ( this.createCoplets ) {
+                final CopletBaseData cbd = pcm.getProfileManager().getCopletBaseData(this.copletBaseDataName);
+                final CopletData cd = pcm.getCopletFactory().newInstance(cbd, portlet.getId().toString());
+                cd.setAttribute("portlet", portlet.getId().toString());
+                if ( this.getLogger().isInfoEnabled() ) {
+                    this.getLogger().info("Created coplet data: " + cd.getId());
+                }
+            }
         }
     }
 

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java?rev=348921&r1=348920&r2=348921&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
Fri Nov 25 02:00:31 2005
@@ -27,8 +27,11 @@
 import org.apache.cocoon.portal.event.user.UserEvent;
 import org.apache.cocoon.portal.event.user.UserWillLogoutEvent;
 import org.apache.cocoon.portal.impl.AbstractComponent;
+import org.apache.cocoon.portal.layout.CompositeLayout;
+import org.apache.cocoon.portal.layout.Item;
 import org.apache.cocoon.portal.layout.Layout;
 import org.apache.cocoon.portal.layout.LayoutException;
+import org.apache.cocoon.portal.layout.impl.CopletLayout;
 import org.apache.cocoon.portal.profile.PortalUser;
 import org.apache.cocoon.portal.profile.ProfileManager;
 import org.apache.cocoon.portal.scratchpad.Profile;
@@ -125,20 +128,49 @@
                 object = ((Map)object).values();
             }
             if (object instanceof Layout) {
-                this.portalService.getComponentManager().getLayoutFactory().prepareLayout((Layout)object);
+                object = this.checkAvailability((Layout)object);
+                if ( object != null ) {
+                    this.portalService.getComponentManager().getLayoutFactory().prepareLayout((Layout)object);
+                }
             } else if (object instanceof Collection) {
                 final Iterator iterator = ((Collection)object).iterator();
                 while (iterator.hasNext()) {
                     final Object o = iterator.next();
                     if ( o instanceof CopletInstanceData) {
                         CopletInstanceData cid = (CopletInstanceData)o;
-                        // now invoke login on each instance
-                        CopletAdapter adapter;
-                        adapter = (CopletAdapter)this.portalService.getComponentManager().getCopletAdapter(cid.getCopletData().getCopletBaseData().getCopletAdapterName());
-                        adapter.login( cid );
+                        // check if the coplet data is set; if not the instance
+                        // will be removed later on
+                        if ( cid.getCopletData() != null ) {
+                            // now invoke login on each instance
+                            CopletAdapter adapter;
+                            adapter = (CopletAdapter)this.portalService.getComponentManager().getCopletAdapter(cid.getCopletData().getCopletBaseData().getCopletAdapterName());
+                            adapter.login( cid );
+                        }
                     }
                 }
             }
         }
+    }
+
+    protected Layout checkAvailability(Layout layout) {
+        // is the coplet instance available?
+        if ( layout instanceof CopletLayout ) {
+            final CopletLayout cl = (CopletLayout)layout;
+            if ( cl.getCopletInstanceData() == null || cl.getCopletInstanceData().getCopletData()
== null ) {
+                return null;
+            }
+        } else if ( layout instanceof CompositeLayout ) {
+            final CompositeLayout cl = (CompositeLayout)layout;
+            final Iterator i = cl.getItems().iterator();
+            while ( i.hasNext() ) {
+                Layout current = ((Item)i.next()).getLayout();
+                if ( this.checkAvailability(current) == null ) {
+                    // coplet or instance is not available: remove layout
+                    // FIXME: We could display a dummy coplet instead?
+                    i.remove();
+                }
+            }
+        }
+        return layout;
     }
 }

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java?rev=348921&r1=348920&r2=348921&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
Fri Nov 25 02:00:31 2005
@@ -240,7 +240,10 @@
      * @see Receiver
      */
     public void inform(CopletDataAddedEvent event, PortalService service) {
-        this.deployedCopletDatas.put(((CopletData)event.getTarget()), event.getTarget());
+        this.deployedCopletDatas.put(((CopletData)event.getTarget()).getId(), event.getTarget());
+        if ( this.copletDatas.objects != null ) {
+            this.copletDatas.objects.put(((CopletData)event.getTarget()).getId(), event.getTarget());
+        }
     }
 
     /**



Mime
View raw message