You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2005/09/28 21:44:53 UTC
svn commit: r292281 - in /cocoon: blocks/portal-sample/trunk/
blocks/portal-sample/trunk/samples/
blocks/portal-sample/trunk/samples/conf/ blocks/portal/trunk/
blocks/portal/trunk/java/org/apache/cocoon/portal/
blocks/portal/trunk/java/org/apache/cocoo...
Author: cziegeler
Date: Wed Sep 28 12:44:06 2005
New Revision: 292281
URL: http://svn.apache.org/viewcvs?rev=292281&view=rev
Log:
Update to CoWarp 0.4
Make use of per sitemap components and simplify component handling
Added:
cocoon/trunk/legal/cowarp-0.4.jar.license.txt
- copied unchanged from r292229, cocoon/trunk/legal/cowarp-0.3.jar.license.txt
cocoon/trunk/lib/optional/cowarp-0.4.jar (with props)
Removed:
cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/acting/PreparePortalAction.java
cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalServiceInfo.java
cocoon/trunk/legal/cowarp-0.3.jar.license.txt
cocoon/trunk/lib/optional/cowarp-0.3.jar
Modified:
cocoon/blocks/portal-sample/trunk/pom.xml
cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf
cocoon/blocks/portal-sample/trunk/samples/sitemap.xmap
cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/Constants.java
cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/PortalService.java
cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
cocoon/blocks/portal/trunk/pom.xml
cocoon/trunk/lib/jars.xml
Modified: cocoon/blocks/portal-sample/trunk/pom.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/pom.xml?rev=292281&r1=292280&r2=292281&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/pom.xml (original)
+++ cocoon/blocks/portal-sample/trunk/pom.xml Wed Sep 28 12:44:06 2005
@@ -68,7 +68,7 @@
<dependency>
<groupId>cowarp</groupId>
<artifactId>cowarp</artifactId>
- <version>0.3</version>
+ <version>0.4</version>
</dependency>
</dependencies>
</project>
Modified: cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf?rev=292281&r1=292280&r2=292281&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf (original)
+++ cocoon/blocks/portal-sample/trunk/samples/conf/cocoon-portal-sample.xconf Wed Sep 28 12:44:06 2005
@@ -37,6 +37,9 @@
<!-- If you don't need WSRP support, you can remove the following include: -->
<include src="resource://org/apache/cocoon/portal/wsrp/portal.roles"/>
+ <!-- Include CoWarp components. If you don't use CoWarp you this statement. -->
+ <include src="resource://org/osoco/cowarp/roles.xconf"/>
+
<input-modules>
<component-instance name="portalpath"
class="org.apache.cocoon.components.modules.input.ProjectPathModule">
@@ -44,8 +47,6 @@
</component-instance>
</input-modules>
- <component role="org.osoco.cowarp.ApplicationManager"
- class="org.osoco.cowarp.impl.StandardApplicationManager"/>
<!-- This security handler uses OJB and the hsqldb for the authentication: -->
<component role="org.osoco.cowarp.SecurityHandler/portal"
class="org.apache.cocoon.portal.security.DBSecurityHandler"/>
@@ -79,27 +80,25 @@
</component>
<portal-service>
- <portals>
- <portal name="portal">
- <!-- This is the sample portal:
- - we use the cowarp profile manager
- -->
- <profile-manager>org.apache.cocoon.portal.profile.ProfileManager/Cowarp</profile-manager>
- <!-- If you want to use the authentication framework, comment out the above line
- and uncomment the following line:
- <profile-manager>org.apache.cocoon.portal.profile.ProfileManager/Auth</profile-manager>
- -->
- <!-- These are the skins the user can choose from: -->
- <skins>
- <skin name="basic" base-path="context://samples/blocks/portal-sample/skins/basic">
- <thumbnail-path>images/thumb.jpg</thumbnail-path>
- </skin>
- <skin name="common" base-path="context://samples/blocks/portal-sample/skins/common">
- <thumbnail-path>images/thumb.jpg</thumbnail-path>
- </skin>
- </skins>
- </portal>
- </portals>
+ <portal name="portal">
+ <!-- This is the sample portal:
+ - we use the cowarp profile manager
+ -->
+ <profile-manager>org.apache.cocoon.portal.profile.ProfileManager/Cowarp</profile-manager>
+ <!-- If you want to use the authentication framework, comment out the above line
+ and uncomment the following line:
+ <profile-manager>org.apache.cocoon.portal.profile.ProfileManager/Auth</profile-manager>
+ -->
+ <!-- These are the skins the user can choose from: -->
+ <skins>
+ <skin name="basic" base-path="context://samples/blocks/portal-sample/skins/basic">
+ <thumbnail-path>images/thumb.jpg</thumbnail-path>
+ </skin>
+ <skin name="common" base-path="context://samples/blocks/portal-sample/skins/common">
+ <thumbnail-path>images/thumb.jpg</thumbnail-path>
+ </skin>
+ </skins>
+ </portal>
</portal-service>
<!-- This is the portal manager.
Modified: cocoon/blocks/portal-sample/trunk/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/sitemap.xmap?rev=292281&r1=292280&r2=292281&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/sitemap.xmap (original)
+++ cocoon/blocks/portal-sample/trunk/samples/sitemap.xmap Wed Sep 28 12:44:06 2005
@@ -23,6 +23,9 @@
<map:include src="conf/cocoon-portal-sample.xconf"/>
<map:include src="conf/cocoon-portal-tools.xconf"/>
+ <!-- Load Sitemap components provided by CoWarp. -->
+ <map:include src="resource://org/osoco/cowarp/sitemap-addons.xconf"/>
+
<map:generators default="file">
<map:generator name="portal" src="org.apache.cocoon.portal.generation.PortalGenerator"/>
</map:generators>
@@ -60,17 +63,8 @@
<map:action src="org.apache.cocoon.portal.acting.BookmarkAction" name="portal-bookmark">
<parameter name="src" value="resources/bookmarks.xml"/>
</map:action>
- <map:action name="portal-prepare"
- src="org.apache.cocoon.portal.acting.PreparePortalAction"/>
<map:action name="portal-urlhelper"
src="org.apache.cocoon.portal.acting.URLAction"/>
-
- <map:action name="cowarp-is-logged-in"
- src="org.osoco.cowarp.acting.LoggedInAction"/>
- <map:action name="cowarp-login"
- src="org.osoco.cowarp.acting.LoginAction"/>
- <map:action name="cowarp-logout"
- src="org.osoco.cowarp.acting.LogoutAction"/>
</map:actions>
</map:components>
@@ -96,16 +90,6 @@
</map:component-configurations>
- <map:pipeline>
- <!-- This action sets the portal name for the current request and
- initializes the portal service. So this should be the first
- task for every request!
- -->
- <map:act type="portal-prepare">
- <map:parameter name="portal-name" value="portal"/>
- </map:act>
- </map:pipeline>
-
<!-- The internal pipelines for loading and saving -->
<map:pipeline internal-only="true">
<map:match pattern="sunrise-authuser">
Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/Constants.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/Constants.java?rev=292281&r1=292280&r2=292281&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/Constants.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/Constants.java Wed Sep 28 12:44:06 2005
@@ -20,7 +20,7 @@
*
* @author <a href="mailto:bluetkemeier@s-und-n.de">Björn Lütkemeier</a>
*
- * @version CVS $Id: Constants.java,v 1.3 2004/03/05 13:02:08 bdelacretaz Exp $
+ * @version CVS $Id$
*/
public class Constants {
Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/PortalService.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/PortalService.java?rev=292281&r1=292280&r2=292281&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/PortalService.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/PortalService.java Wed Sep 28 12:44:06 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * Copyright 1999-2002,2004-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,55 +43,53 @@
*/
String getPortalName();
- void setPortalName(String value);
-
/**
- * Return the value of an attribute
+ * Return the value of an attribute.
* @param key The key of the attribute
* @return The value of the attribute or null.
*/
Object getAttribute(String key);
/**
- * Set an attribute
+ * Set an attribute.
* @param key The key of the attribute
* @param value The new value
*/
void setAttribute(String key, Object value);
/**
- * Remove an attribute
+ * Remove an attribute.
* @param key The key of the attribute
*/
- void removeAttribute(String key);
+ Object removeAttribute(String key);
/**
- * Return the names of all attributes
+ * Return the names of all attributes.
*/
Iterator getAttributeNames();
/**
- * Return the value of a temporary attribute
+ * Return the value of a temporary attribute.
* @param key The key of the attribute
* @return The value of the attribute or null.
*/
Object getTemporaryAttribute(String key);
/**
- * Set a temporary attribute
+ * Set a temporary attribute.
* @param key The key of the attribute
* @param value The new value
*/
void setTemporaryAttribute(String key, Object value);
/**
- * Remove a temporary attribute
+ * Remove a temporary attribute.
* @param key The key of the attribute
*/
- void removeTemporaryAttribute(String key);
+ Object removeTemporaryAttribute(String key);
/**
- * Return the names of all temporary attributes
+ * Return the names of all temporary attributes.
*/
Iterator getTemporaryAttributeNames();
Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java?rev=292281&r1=292280&r2=292281&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java Wed Sep 28 12:44:06 2005
@@ -16,6 +16,8 @@
package org.apache.cocoon.portal.impl;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -37,7 +39,7 @@
import org.apache.avalon.framework.service.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.ContextHelper;
-import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Session;
import org.apache.cocoon.portal.PortalComponentManager;
import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.layout.Layout;
@@ -66,12 +68,18 @@
protected ServiceManager manager;
- protected Map portalComponentManagers = new HashMap();
+ protected PortalComponentManager portalComponentManager;
- protected Map portalConfigurations = new HashMap();
-
- protected Map skins = new HashMap();
+ protected List skinList = new ArrayList();
+
+ protected String portalName;
+
+ protected String defaultLayoutKey;
+
+ protected final Map temporaryAttributes = new HashMap();
+ protected String attributePrefix;
+
final protected static String KEY = PortalServiceImpl.class.getName();
/**
@@ -81,92 +89,102 @@
this.manager = serviceManager;
}
- protected PortalServiceInfo getInfo() {
- final Request request = ContextHelper.getRequest( this.context );
- PortalServiceInfo info = (PortalServiceInfo) request.getAttribute(KEY, Request.GLOBAL_SCOPE);
- if ( info == null ) {
- info = new PortalServiceInfo();
- info.setup(ContextHelper.getObjectModel(this.context), this.portalComponentManagers);
- request.setAttribute(KEY, info, Request.GLOBAL_SCOPE);
- }
- return info;
- }
-
/**
* @see org.apache.cocoon.portal.PortalService#getPortalName()
*/
public String getPortalName() {
- return this.getInfo().getPortalName();
- }
-
- /**
- * @see org.apache.cocoon.portal.PortalService#setPortalName(java.lang.String)
- */
- public void setPortalName(String value) {
- this.getInfo().setPortalName(value);
+ return this.portalName;
}
/**
* @see org.apache.cocoon.portal.PortalService#getAttribute(java.lang.String)
*/
public Object getAttribute(String key) {
- return this.getInfo().getAttribute(key);
+ final Session session = ContextHelper.getRequest(this.context).getSession(false);
+ if (session == null) {
+ return null;
+ }
+ return session.getAttribute( this.attributePrefix + key);
}
/**
* @see org.apache.cocoon.portal.PortalService#setAttribute(java.lang.String, java.lang.Object)
*/
public void setAttribute(String key, Object value) {
- this.getInfo().setAttribute(key, value);
+ final Session session = ContextHelper.getRequest(this.context).getSession();
+ session.setAttribute( this.attributePrefix + key, value);
}
/**
* @see org.apache.cocoon.portal.PortalService#removeAttribute(java.lang.String)
*/
- public void removeAttribute(String key) {
- this.getInfo().removeAttribute(key);
+ public Object removeAttribute(String key) {
+ final Session session = ContextHelper.getRequest(this.context).getSession(false);
+ if ( session != null ) {
+ Object value = session.getAttribute(this.attributePrefix + key);
+ if ( value != null ) {
+ session.removeAttribute( this.attributePrefix + key );
+ }
+ return value;
+ }
+ return null;
}
/**
* @see org.apache.cocoon.portal.PortalService#getAttributeNames()
*/
public Iterator getAttributeNames() {
- return this.getInfo().getAttributeNames();
+ final Session session = ContextHelper.getRequest(this.context).getSession(false);
+ if ( session != null ) {
+ List names = new ArrayList();
+ Enumeration e = session.getAttributeNames();
+ final int pos = this.attributePrefix.length() + 1;
+ if ( e != null ) {
+ while ( e.hasMoreElements() ) {
+ final String name = (String)e.nextElement();
+ if ( name.startsWith( this.attributePrefix )) {
+ names.add( name.substring( pos ) );
+ }
+ }
+ }
+ return names.iterator();
+ }
+ return Collections.EMPTY_MAP.keySet().iterator();
}
/**
* @see org.apache.cocoon.portal.PortalService#getTemporaryAttribute(java.lang.String)
*/
public Object getTemporaryAttribute(String key) {
- return this.getInfo().getTemporaryAttribute(key);
+ return this.temporaryAttributes.get( key );
}
/**
* @see org.apache.cocoon.portal.PortalService#setTemporaryAttribute(java.lang.String, java.lang.Object)
*/
public void setTemporaryAttribute(String key, Object value) {
- this.getInfo().setTemporaryAttribute(key, value);
+ this.temporaryAttributes.put( key, value );
}
/**
* @see org.apache.cocoon.portal.PortalService#removeTemporaryAttribute(java.lang.String)
*/
- public void removeTemporaryAttribute(String key) {
- this.getInfo().removeTemporaryAttribute(key);
+ public Object removeTemporaryAttribute(String key) {
+ return this.temporaryAttributes.remove( key );
}
/**
* @see org.apache.cocoon.portal.PortalService#getTemporaryAttributeNames()
*/
public Iterator getTemporaryAttributeNames() {
- return this.getInfo().getTemporaryAttributeNames();
+ return this.temporaryAttributes.keySet().iterator();
}
/**
* @see org.apache.cocoon.portal.PortalService#getComponentManager()
*/
public PortalComponentManager getComponentManager() {
- return this.getInfo().getComponentManager();
+ return this.portalComponentManager;
}
/**
@@ -190,13 +208,8 @@
* @see org.apache.avalon.framework.activity.Disposable#dispose()
*/
public void dispose() {
- final Iterator i = this.portalComponentManagers.values().iterator();
- while ( i.hasNext() ) {
- ContainerUtil.dispose( i.next() );
- }
- this.portalComponentManagers.clear();
- this.portalConfigurations.clear();
- // remove the portal service to the servlet context - if available
+ ContainerUtil.dispose( this.portalComponentManager );
+ // remove the portal service from the servlet context - if available
try {
final ServletConfig servletConfig = (ServletConfig) context.get(CocoonServlet.CONTEXT_SERVLET_CONFIG);
servletConfig.getServletContext().removeAttribute(PortalService.ROLE);
@@ -209,40 +222,39 @@
* @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
public void configure(Configuration config) throws ConfigurationException {
- final Configuration[] portals = config.getChild("portals").getChildren("portal");
- for(int i=0; i < portals.length; i++ ) {
- final Configuration current = portals[i];
- final String name = current.getAttribute("name");
- try {
- PortalComponentManager c = new DefaultPortalComponentManager(this, this.context);
- this.portalComponentManagers.put( name, c );
- ContainerUtil.enableLogging( c, this.getLogger() );
- ContainerUtil.contextualize( c, this.context );
- ContainerUtil.service( c, this.manager );
- ContainerUtil.configure( c, current );
- ContainerUtil.initialize( c );
-
- this.portalConfigurations.put( name, current );
-
- // scan for skins
- final List skinList = new ArrayList();
- this.skins.put(name, skinList);
- final Configuration[] skinConfs = current.getChild("skins").getChildren("skin");
- if ( skinConfs != null ) {
- for(int s=0;s<skinConfs.length;s++) {
- final Configuration currentSkin = skinConfs[s];
- final String skinName = currentSkin.getAttribute("name");
- final SkinDescription desc = new SkinDescription();
- desc.setName(skinName);
- desc.setBasePath(currentSkin.getAttribute("base-path"));
- desc.setThumbnailPath(currentSkin.getChild("thumbnail-path").getValue(null));
- skinList.add(desc);
- }
+ final Configuration portal = config.getChild("portal", false);
+ if ( portal == null ) {
+ throw new ConfigurationException("No portal configured.", config);
+ }
+ this.portalName = portal.getAttribute("name");
+ this.defaultLayoutKey = portal.getAttribute("default-layout-key", "portal");
+ this.attributePrefix = this.getClass().getName() + '/' + this.portalName + '/';
+ try {
+ PortalComponentManager c = new DefaultPortalComponentManager(this, this.context);
+ this.portalComponentManager = c;
+ ContainerUtil.enableLogging( c, this.getLogger() );
+ ContainerUtil.contextualize( c, this.context );
+ ContainerUtil.service( c, this.manager );
+ ContainerUtil.configure( c, portal );
+ ContainerUtil.initialize( c );
+
+ // scan for skins
+ final Configuration[] skinConfs = portal.getChild("skins").getChildren("skin");
+ if ( skinConfs != null ) {
+ for(int s=0;s<skinConfs.length;s++) {
+ final Configuration currentSkin = skinConfs[s];
+ final String skinName = currentSkin.getAttribute("name");
+ final SkinDescription desc = new SkinDescription();
+ desc.setName(skinName);
+ desc.setBasePath(currentSkin.getAttribute("base-path"));
+ desc.setThumbnailPath(currentSkin.getChild("thumbnail-path").getValue(null));
+ this.skinList.add(desc);
}
- } catch (Exception e) {
- throw new ConfigurationException("Unable to setup new portal component manager for portal " + name, e);
}
-
+ } catch (ConfigurationException ce) {
+ throw ce;
+ } catch (Exception e) {
+ throw new ConfigurationException("Unable to setup new portal component manager for portal " + this.portalName, e);
}
}
@@ -287,11 +299,8 @@
public String getDefaultLayoutKey() {
String key = (String)this.getAttribute("default-layout-key");
if ( key == null ) {
- Configuration config = (Configuration)this.portalConfigurations.get(this.getPortalName());
- key = config.getAttribute("default-layout-key", "portal");
- if ( key != null ) {
- this.setDefaultLayoutKey(key);
- }
+ key = this.defaultLayoutKey;
+ this.setDefaultLayoutKey(key);
}
return key;
}
@@ -300,7 +309,7 @@
* @see org.apache.cocoon.portal.PortalService#getSkinDescriptions()
*/
public List getSkinDescriptions() {
- return (List)this.skins.get(this.getPortalName());
+ return this.skinList;
}
/**
Modified: cocoon/blocks/portal/trunk/pom.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/pom.xml?rev=292281&r1=292280&r2=292281&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/pom.xml (original)
+++ cocoon/blocks/portal/trunk/pom.xml Wed Sep 28 12:44:06 2005
@@ -146,7 +146,7 @@
<dependency>
<groupId>cowarp</groupId>
<artifactId>cowarp</artifactId>
- <version>0.3</version>
+ <version>0.4</version>
</dependency>
</dependencies>
</project>
Modified: cocoon/trunk/lib/jars.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/lib/jars.xml?rev=292281&r1=292280&r2=292281&view=diff
==============================================================================
--- cocoon/trunk/lib/jars.xml (original)
+++ cocoon/trunk/lib/jars.xml Wed Sep 28 12:44:06 2005
@@ -1086,7 +1086,7 @@
with special support for the portal.
</description>
<used-by>Portal</used-by>
- <lib>optional/cowarp-0.3.jar</lib>
+ <lib>optional/cowarp-0.4.jar</lib>
<homepage>http://osoco.sourceforge.net/cowarp/</homepage>
</file>
Added: cocoon/trunk/lib/optional/cowarp-0.4.jar
URL: http://svn.apache.org/viewcvs/cocoon/trunk/lib/optional/cowarp-0.4.jar?rev=292281&view=auto
==============================================================================
Binary file - no diff available.
Propchange: cocoon/trunk/lib/optional/cowarp-0.4.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream