cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r365597 - in /cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal: pluto/TestProfileManager.java profile/impl/TestProfileManager.java
Date Tue, 03 Jan 2006 10:19:01 GMT
Author: cziegeler
Date: Tue Jan  3 02:18:56 2006
New Revision: 365597

URL: http://svn.apache.org/viewcvs?rev=365597&view=rev
Log:
Move test profile manager and add support for TCK

Added:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
      - copied, changed from r365556, cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/TestProfileManager.java
Removed:
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/TestProfileManager.java

Copied: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
(from r365556, cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/TestProfileManager.java)
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/TestProfileManager.java?p2=cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/TestProfileManager.java&p1=cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/TestProfileManager.java&r1=365556&r2=365597&rev=365597&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/profile/impl/TestProfileManager.java
(original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
Tue Jan  3 02:18:56 2006
@@ -13,12 +13,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.cocoon.portal.profile.impl;
+package org.apache.cocoon.portal.pluto;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.cocoon.environment.ObjectModelHelper;
+import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.portal.coplet.CopletData;
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.layout.CompositeLayout;
@@ -26,13 +28,25 @@
 import org.apache.cocoon.portal.layout.impl.CompositeLayoutImpl;
 import org.apache.cocoon.portal.layout.impl.CopletLayout;
 import org.apache.cocoon.portal.profile.PortalUser;
+import org.apache.cocoon.portal.profile.impl.GroupBasedProfileManager;
 import org.apache.cocoon.portal.scratchpad.Profile;
 import org.apache.cocoon.portal.scratchpad.ProfileImpl;
+import org.apache.commons.lang.StringUtils;
 
 /**
  * This is an extension of the {@link GroupBasedProfileManager} to test
- * all deployed (JSR 168) coplets. It provides a generated profile for
+ * all deployed JSR 168 portlets. It provides a generated profile for
  * the user with the id "test".
+ * This manager can be used to test own portlets or in combination with the
+ * TCK to test the compatibility of Cocoon's JSR 168 implementation.
+ *
+ * This implementation has some limitations. It expects some default configuration
+ * in order to run properly:
+ * a) the user must have the id "test".
+ * b) a composite layout named "row" must exist.
+ * c) the coplet adapter for portlets must be named "portlet".
+ * d) The layout for coplets must be named "coplet".
+ * e) The renderer for portlets must be named "portlet-window".
  *
  * @version $Id$
  */
@@ -42,6 +56,17 @@
     throws Exception {
         final PortalUser info = (PortalUser)this.portalService.getTemporaryAttribute(USER_ATTRIBUTE);
         if ( info.getUserName().equals("test") ) {
+            // if the request parameter 'portletName' is available we only
+            // display the portlets specified with the parameter. Otherwise
+            // we show all portlets
+            final List portletNames = new ArrayList();
+            final Request r = ObjectModelHelper.getRequest(this.portalService.getObjectModel());
+            final String[] values = r.getParameterValues("portletName");
+            if ( values != null && values.length > 0 ) {
+                for(int i=0; i<values.length; i++) {
+                    portletNames.add(StringUtils.replaceChars(values[i], '/', '.'));
+                }
+            }
             final ProfileImpl profile = new ProfileImpl(layoutKey);
 
             // first "load" the global data
@@ -56,15 +81,20 @@
             final Iterator i = this.deployedCopletDatas.values().iterator();
             while ( i.hasNext() ) {
                 final CopletData cd = (CopletData)i.next();
-                final CopletInstanceData cid = new CopletInstanceData(cd.getId() + "-1");
-                cid.setCopletData(cd);
-                instances.add(cid);
-                final CopletLayout copletLayout = new CopletLayout(null, "coplet");
-                copletLayout.setCopletInstanceData(cid);
-                copletLayout.setLayoutRendererName("portlet-window");
-                final Item item = new Item();
-                item.setLayout(copletLayout);
-                rootLayout.addItem(item);
+                // check for portlets
+                if ( "portlet".equals(cd.getCopletBaseData().getCopletAdapterName()) ) {
+                    if ( portletNames.size() == 0 || portletNames.contains(cd.getId())) {
+                        final CopletInstanceData cid = new CopletInstanceData(cd.getId()
+ "-1");
+                        cid.setCopletData(cd);
+                        instances.add(cid);
+                        final CopletLayout copletLayout = new CopletLayout(null, "coplet");
+                        copletLayout.setCopletInstanceData(cid);
+                        copletLayout.setLayoutRendererName("portlet-window");
+                        final Item item = new Item();
+                        item.setLayout(copletLayout);
+                        rootLayout.addItem(item);
+                    }
+                }
             }
             profile.setCopletInstanceDatas(instances);
             this.prepareObject(instances);



Mime
View raw message