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 2003/12/12 11:13:34 UTC
cvs commit: cocoon-2.1/src/blocks/portal/samples/resources bookmarks.xml
cziegeler 2003/12/12 02:13:34
Modified: src/blocks/portal/conf portal.samplesxconf portal.xconf
src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/impl
AspectRenderer.java
src/blocks/portal/java/org/apache/cocoon/portal/acting
BookmarkAction.java
src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect
RendererAspectContext.java
src/blocks/portal/samples/news/content/xdocs
portal-intro.xml
src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl
DefaultRendererContext.java AbstractAspect.java
src/blocks/portal/samples/resources bookmarks.xml
Added: src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers
CopletEventDescription.java Mapping.java
CopletMapping.java LayoutEventDescription.java
LayoutMapping.java
src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl
HistoryAspect.java
Log:
Add the feature to create a browsable history
Add some warnings about the portal demo
Revision Changes Path
1.9 +10 -0 cocoon-2.1/src/blocks/portal/conf/portal.samplesxconf
Index: portal.samplesxconf
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/portal.samplesxconf,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- portal.samplesxconf 9 Dec 2003 10:21:56 -0000 1.8
+++ portal.samplesxconf 12 Dec 2003 10:13:34 -0000 1.9
@@ -2,6 +2,12 @@
<samplesxconf xpath="/cocoon" unless="component[@role='org.apache.cocoon.portal.profile.ProfileManager/Auth']">
+ <!-- THIS IS A SAMPLE PORTAL
+ It demonstrates several features of the portal engine,
+ so it's not optimized for production. Make sure that
+ if you use the portal for your own projects that you
+ remove all unused stuff from the configuration!
+ -->
<component class="org.apache.cocoon.portal.profile.impl.AuthenticationProfileManager" logger="portal" role="org.apache.cocoon.portal.profile.ProfileManager/Auth">
</component>
@@ -41,6 +47,7 @@
<aspect type="parameter">
<parameter name="tag-name" value="tab-layout"/>
</aspect>
+ <aspect type="history"/>
<aspect type="tab-content">
<parameter name="root-tag" value="false"/>
<parameter name="store" value="session"/>
@@ -55,6 +62,7 @@
<aspect type="parameter">
<parameter name="tag-name" value="linktab-layout"/>
</aspect>
+ <aspect type="history"/>
<aspect type="tab-content">
<parameter name="root-tag" value="false"/>
<parameter name="store" value="session"/>
@@ -75,6 +83,7 @@
<aspect type="coplet-removing"/>
<aspect type="coplet-full-screen"/>
<aspect type="coplet-sizing"/>
+ <aspect type="history"/>
<aspect type="coplet-cinclude"/>
</aspects>
</renderer>
@@ -87,6 +96,7 @@
</renderer>
<renderer name="nowindow" class="org.apache.cocoon.portal.layout.renderer.impl.AspectRenderer" logger="portal" >
<aspects>
+ <aspect type="history"/>
<aspect type="coplet"/>
</aspects>
</renderer>
1.29 +5 -0 cocoon-2.1/src/blocks/portal/conf/portal.xconf
Index: portal.xconf
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/portal.xconf,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- portal.xconf 11 Dec 2003 09:30:17 -0000 1.28
+++ portal.xconf 12 Dec 2003 10:13:34 -0000 1.29
@@ -67,6 +67,11 @@
use the coplet aspect below to directly stream the content -->
<aspect name="coplet-cinclude" class="org.apache.cocoon.portal.layout.renderer.aspect.impl.CIncludeCopletAspect"/>
+ <!-- This aspect creates a history of all layout aspect datas,
+ coplet aspect datas and coplet attributes. It can be used by
+ the bookmark action to browse the history -->
+ <aspect name="history" class="org.apache.cocoon.portal.layout.renderer.aspect.impl.HistoryAspect"/>
+
<!-- This aspect can be used to render the content of the coplet -->
<aspect name="coplet" class="org.apache.cocoon.portal.layout.renderer.aspect.impl.DefaultCopletAspect"/>
<aspect name="frame" class="org.apache.cocoon.portal.layout.renderer.aspect.impl.FrameAspect"/>
1.4 +18 -5 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/impl/AspectRenderer.java
Index: AspectRenderer.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/impl/AspectRenderer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AspectRenderer.java 20 Oct 2003 13:37:10 -0000 1.3
+++ AspectRenderer.java 12 Dec 2003 10:13:34 -0000 1.4
@@ -56,17 +56,20 @@
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
+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.logger.AbstractLogEnabled;
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.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.components.ContextHelper;
import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.layout.Layout;
import org.apache.cocoon.portal.layout.renderer.Renderer;
import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect;
-import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
import org.apache.cocoon.portal.layout.renderer.aspect.impl.DefaultRendererContext;
import org.apache.cocoon.portal.layout.renderer.aspect.impl.RendererAspectChain;
import org.xml.sax.ContentHandler;
@@ -81,7 +84,7 @@
*/
public class AspectRenderer
extends AbstractLogEnabled
- implements Renderer, Serviceable, Configurable, Disposable, ThreadSafe {
+ implements Renderer, Serviceable, Configurable, Disposable, ThreadSafe, Contextualizable {
protected ServiceManager manager;
@@ -89,6 +92,8 @@
protected ServiceSelector aspectSelector;
+ protected Context context;
+
/* (non-Javadoc)
* @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
@@ -101,8 +106,9 @@
* Stream out raw layout
*/
public void toSAX(Layout layout, PortalService service, ContentHandler handler) throws SAXException {
- RendererAspectContext context = new DefaultRendererContext(this.chain);
- context.invokeNext(layout, service, handler);
+ DefaultRendererContext renderContext = new DefaultRendererContext(this.chain);
+ renderContext.setObjectModel(ContextHelper.getObjectModel(this.context));
+ renderContext.invokeNext(layout, service, handler);
}
/* (non-Javadoc)
@@ -132,6 +138,13 @@
*/
public Iterator getAspectDescriptions() {
return this.chain.getAspectDescriptionIterator();
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
+ */
+ public void contextualize(Context context) throws ContextException {
+ this.context = context;
}
}
1.2 +89 -91 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/BookmarkAction.java
Index: BookmarkAction.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/BookmarkAction.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BookmarkAction.java 11 Dec 2003 13:31:55 -0000 1.1
+++ BookmarkAction.java 12 Dec 2003 10:13:34 -0000 1.2
@@ -54,6 +54,7 @@
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -71,14 +72,13 @@
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Session;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.portal.PortalManager;
import org.apache.cocoon.portal.PortalService;
-import org.apache.cocoon.portal.coplet.CopletInstanceData;
-import org.apache.cocoon.portal.event.Event;
-import org.apache.cocoon.portal.event.impl.CopletJXPathEvent;
-import org.apache.cocoon.portal.event.impl.JXPathEvent;
-import org.apache.cocoon.portal.layout.Layout;
+import org.apache.cocoon.portal.acting.helpers.CopletMapping;
+import org.apache.cocoon.portal.acting.helpers.LayoutMapping;
+import org.apache.cocoon.portal.acting.helpers.Mapping;
import org.apache.excalibur.source.Source;
import org.xml.sax.SAXException;
@@ -86,6 +86,7 @@
* This action helps you in creating bookmarks
*
* The definition file is:
+ * <bookmarks>
* <events>
* <event type="jxpath" id="ID">
* <targetid>tagetId</targetid>
@@ -93,6 +94,7 @@
* <path/>
* </event>
* </events>
+ * </bookmarks>
*
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
* @version CVS $Id$
@@ -103,70 +105,73 @@
protected Map eventMap = new HashMap();
+ protected String historyParameterName;
+
/* (non-Javadoc)
* @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
*/
public void parameterize(Parameters parameters) throws ParameterException {
- final String configurationFile = parameters.getParameter("src", null);
- if ( configurationFile == null ) return;
+ this.historyParameterName = parameters.getParameter("history-parameter-name", "history");
+ final String configurationFile = parameters.getParameter("src", null);
+ if ( configurationFile == null ) return;
- Configuration config;
- org.apache.excalibur.source.SourceResolver resolver = null;
- try {
- resolver = (org.apache.excalibur.source.SourceResolver) this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);
- Source source = null;
- try {
- source = resolver.resolveURI(configurationFile);
- SAXConfigurationHandler handler = new SAXConfigurationHandler();
- SourceUtil.toSAX(source, handler);
- config = handler.getConfiguration();
- } catch (ProcessingException se) {
- throw new ParameterException("Unable to read configuration from " + configurationFile, se);
- } catch (SAXException se) {
- throw new ParameterException("Unable to read configuration from " + configurationFile, se);
- } catch (IOException ioe) {
- throw new ParameterException("Unable to read configuration from " + configurationFile, ioe);
- } finally {
- resolver.release(source);
- }
- } catch (ServiceException se) {
- throw new ParameterException("Unable to lookup source resolver.", se);
- } finally {
- this.manager.release(resolver);
- }
- Configuration[] events = config.getChildren("event");
- if ( events != null ) {
- for(int i=0; i<events.length;i++) {
- try {
- final String type = events[i].getAttribute("type");
- final String id = events[i].getAttribute("id");
- if ( !"jxpath".equals(type) ) {
- throw new ParameterException("Unknown event type for event " + id + ": " + type);
- }
- if ( this.eventMap.containsKey(id)) {
- throw new ParameterException("The id for the event " + id + " is not unique.");
- }
- final String targetType = events[i].getChild("targettype").getValue();
- final String targetId = events[i].getChild("targetid").getValue();
- final String path = events[i].getChild("path").getValue();
- if ( "layout".equals(targetType) ) {
- LayoutMapping mapping = new LayoutMapping();
- mapping.layoutId = targetId;
- mapping.path = path;
- this.eventMap.put(id, mapping);
- } else if ( "coplet".equals(targetType) ) {
- CopletMapping mapping = new CopletMapping();
- mapping.copletId = targetId;
- mapping.path = path;
- this.eventMap.put(id, mapping);
- } else {
+ Configuration config;
+ org.apache.excalibur.source.SourceResolver resolver = null;
+ try {
+ resolver = (org.apache.excalibur.source.SourceResolver) this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);
+ Source source = null;
+ try {
+ source = resolver.resolveURI(configurationFile);
+ SAXConfigurationHandler handler = new SAXConfigurationHandler();
+ SourceUtil.toSAX(source, handler);
+ config = handler.getConfiguration();
+ } catch (ProcessingException se) {
+ throw new ParameterException("Unable to read configuration from " + configurationFile, se);
+ } catch (SAXException se) {
+ throw new ParameterException("Unable to read configuration from " + configurationFile, se);
+ } catch (IOException ioe) {
+ throw new ParameterException("Unable to read configuration from " + configurationFile, ioe);
+ } finally {
+ resolver.release(source);
+ }
+ } catch (ServiceException se) {
+ throw new ParameterException("Unable to lookup source resolver.", se);
+ } finally {
+ this.manager.release(resolver);
+ }
+ Configuration[] events = config.getChild("bookmarks").getChildren("event");
+ if ( events != null ) {
+ for(int i=0; i<events.length;i++) {
+ try {
+ final String type = events[i].getAttribute("type");
+ final String id = events[i].getAttribute("id");
+ if ( !"jxpath".equals(type) ) {
+ throw new ParameterException("Unknown event type for event " + id + ": " + type);
+ }
+ if ( this.eventMap.containsKey(id)) {
+ throw new ParameterException("The id for the event " + id + " is not unique.");
+ }
+ final String targetType = events[i].getChild("targettype").getValue();
+ final String targetId = events[i].getChild("targetid").getValue();
+ final String path = events[i].getChild("path").getValue();
+ if ( "layout".equals(targetType) ) {
+ LayoutMapping mapping = new LayoutMapping();
+ mapping.layoutId = targetId;
+ mapping.path = path;
+ this.eventMap.put(id, mapping);
+ } else if ( "coplet".equals(targetType) ) {
+ CopletMapping mapping = new CopletMapping();
+ mapping.copletId = targetId;
+ mapping.path = path;
+ this.eventMap.put(id, mapping);
+ } else {
throw new ParameterException("Unknown target type " + targetType);
- }
- } catch (ConfigurationException ce) {
- throw new ParameterException("Configuration exception" ,ce);
- }
- }
- }
+ }
+ } catch (ConfigurationException ce) {
+ throw new ParameterException("Configuration exception" ,ce);
+ }
+ }
+ }
}
public Map act(Redirector redirector,
@@ -196,9 +201,27 @@
this.manager.release(portalManager);
}
- Request request = ObjectModelHelper.getRequest(objectModel);
+ final Request request = ObjectModelHelper.getRequest(objectModel);
+ final Session session = request.getSession(false);
+ final List events = new ArrayList();
+
+ // is the history invoked?
+ final String historyValue = request.getParameter(this.historyParameterName);
+ if ( historyValue != null && session != null) {
+ // get the history
+ final List history = (List)session.getAttribute("portal-history");
+ if ( history != null ) {
+ final List state = (List)history.get(Integer.parseInt(historyValue));
+ if ( state != null ) {
+ final Iterator iter = state.iterator();
+ while ( iter.hasNext() ) {
+ Mapping m = (Mapping)iter.next();
+ events.add(m.getEvent(service, null));
+ }
+ }
+ }
+ }
Enumeration enum = request.getParameterNames();
- List events = new ArrayList();
while (enum.hasMoreElements()) {
String name = (String)enum.nextElement();
String value = request.getParameter(name);
@@ -227,29 +250,4 @@
return result;
}
- static abstract class Mapping {
- public abstract Event getEvent(PortalService service, Object data);
- }
- static class CopletMapping extends Mapping {
- public String copletId;
- public String path;
-
- public Event getEvent(PortalService service, Object data) {
- CopletInstanceData cid = service.getComponentManager().getProfileManager().getCopletInstanceData(this.copletId);
- Event e = new CopletJXPathEvent(cid, this.path, data);
- return e;
- }
-
- }
-
- static class LayoutMapping extends Mapping {
- public String layoutId;
- public String path;
-
- public Event getEvent(PortalService service, Object data) {
- Layout layout = service.getComponentManager().getProfileManager().getPortalLayout(null, this.layoutId);
- Event e = new JXPathEvent(layout, this.path, data);
- return e;
- }
-}
}
1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/CopletEventDescription.java
Index: CopletEventDescription.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.acting.helpers;
import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.event.Event;
/**
* Helper class for an coplet event
*
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
* @version CVS $Id: CopletEventDescription.java,v 1.1 2003/12/12 10:13:34 cziegeler Exp $
*/
public class CopletEventDescription extends CopletMapping {
public Object data;
public Event getEvent(PortalService service, Object data) {
return super.getEvent(service, (data == null ? this.data : data));
}
}
1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/Mapping.java
Index: Mapping.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.acting.helpers;
import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.event.Event;
/**
* Helper class for an event
*
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
* @version CVS $Id: Mapping.java,v 1.1 2003/12/12 10:13:34 cziegeler Exp $
*/
public abstract class Mapping {
public abstract Event getEvent(PortalService service, Object data);
}
1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/CopletMapping.java
Index: CopletMapping.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.acting.helpers;
import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.coplet.CopletInstanceData;
import org.apache.cocoon.portal.event.Event;
import org.apache.cocoon.portal.event.impl.CopletJXPathEvent;
/**
* Helper class for an coplet event
*
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
* @version CVS $Id: CopletMapping.java,v 1.1 2003/12/12 10:13:34 cziegeler Exp $
*/
public class CopletMapping extends Mapping {
public String copletId;
public String path;
public Event getEvent(PortalService service, Object data) {
CopletInstanceData cid = service.getComponentManager().getProfileManager().getCopletInstanceData(this.copletId);
Event e = new CopletJXPathEvent(cid, this.path, data);
return e;
}
}
1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/LayoutEventDescription.java
Index: LayoutEventDescription.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.acting.helpers;
import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.event.Event;
/**
* Helper class for a layout event
*
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
* @version CVS $Id: LayoutEventDescription.java,v 1.1 2003/12/12 10:13:34 cziegeler Exp $
*/
public class LayoutEventDescription extends LayoutMapping {
public Object data;
public Event getEvent(PortalService service, Object data) {
return super.getEvent(service, (data == null ? this.data : data));
}
}
1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/LayoutMapping.java
Index: LayoutMapping.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.acting.helpers;
import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.event.Event;
import org.apache.cocoon.portal.event.impl.JXPathEvent;
import org.apache.cocoon.portal.layout.Layout;
/**
* Helper class for a layout event
*
* @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
* @version CVS $Id: LayoutMapping.java,v 1.1 2003/12/12 10:13:34 cziegeler Exp $
*/
public class LayoutMapping extends Mapping {
public String layoutId;
public String path;
public Event getEvent(PortalService service, Object data) {
Layout layout = service.getComponentManager().getProfileManager().getPortalLayout(null, this.layoutId);
Event e = new JXPathEvent(layout, this.path, data);
return e;
}
}
1.4 +8 -1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/RendererAspectContext.java
Index: RendererAspectContext.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/RendererAspectContext.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RendererAspectContext.java 15 Jun 2003 16:56:09 -0000 1.3
+++ RendererAspectContext.java 12 Dec 2003 10:13:34 -0000 1.4
@@ -50,6 +50,8 @@
*/
package org.apache.cocoon.portal.layout.renderer.aspect;
+import java.util.Map;
+
import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.layout.Layout;
import org.xml.sax.ContentHandler;
@@ -92,4 +94,9 @@
* Remove an attribute
*/
void removeAttribute(String key);
+
+ /**
+ * Get the object model
+ */
+ Map getObjectModel();
}
1.4 +6 -0 cocoon-2.1/src/blocks/portal/samples/news/content/xdocs/portal-intro.xml
Index: portal-intro.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/news/content/xdocs/portal-intro.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- portal-intro.xml 11 Dec 2003 16:05:01 -0000 1.3
+++ portal-intro.xml 12 Dec 2003 10:13:34 -0000 1.4
@@ -17,6 +17,12 @@
<li>The TabDemo2 shows the same content as TabDemo2 but with just a different stylesheet for the tab.</li>
<li>The Coplets tab show some more coplets. You need to also have the petstore example installed!</li>
</ul>
+ <note>THIS IS A SAMPLE PORTAL. It demonstrates several features of
+ the portal engine, so it's not optimized for production. Make sure
+ that if you use the portal for your own projects that you
+ remove all unused stuff from the configuration! Every configured
+ feature might have an impact on the performance.
+ </note>
<p>For more information <fork href="http://cocoon.apache.org">visit the Cocoon Homepage</fork>.</p>
</s1>
1.4 +17 -1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/DefaultRendererContext.java
Index: DefaultRendererContext.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/DefaultRendererContext.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultRendererContext.java 24 Sep 2003 21:22:33 -0000 1.3
+++ DefaultRendererContext.java 12 Dec 2003 10:13:34 -0000 1.4
@@ -74,6 +74,7 @@
private Iterator configIterator;
private Object config;
private Map attributes;
+ private Map objectModel;
public DefaultRendererContext(RendererAspectChain chain) {
this.iterator = chain.getIterator();
@@ -131,6 +132,21 @@
if ( this.attributes != null && key != null) {
this.attributes.remove( key );
}
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext#getObjectModel()
+ */
+ public Map getObjectModel() {
+ return this.objectModel;
+ }
+
+ /**
+ * Set the object model
+ * @param map The object model
+ */
+ public void setObjectModel(Map map) {
+ this.objectModel = map;
}
}
1.6 +1 -3 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractAspect.java
Index: AbstractAspect.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractAspect.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractAspect.java 20 Oct 2003 13:37:10 -0000 1.5
+++ AbstractAspect.java 12 Dec 2003 10:13:34 -0000 1.6
@@ -95,8 +95,6 @@
PortalService service,
ContentHandler handler)
throws SAXException {
- // TODO Auto-generated method stub
-
}
/**
1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/HistoryAspect.java
Index: HistoryAspect.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
apache@apache.org.
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <st...@apache.org>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.layout.renderer.aspect.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Session;
import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.acting.helpers.LayoutEventDescription;
import org.apache.cocoon.portal.coplet.CopletInstanceData;
import org.apache.cocoon.portal.layout.Layout;
import org.apache.cocoon.portal.layout.impl.CopletLayout;
import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
/**
* Save the current state of the layout into the session
*
* @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
*
* @version CVS $Id: HistoryAspect.java,v 1.1 2003/12/12 10:13:34 cziegeler Exp $
*/
public class HistoryAspect
extends AbstractAspect {
/**
* Add the values to the state
* @param id
* @param state
* @param values
*/
protected void addValues(String id, List state, Map values, String prefix) {
final Iterator iter = values.entrySet().iterator();
while ( iter.hasNext() ) {
final Map.Entry entry = (Map.Entry)iter.next();
final String path = prefix + entry.getKey();
LayoutEventDescription led = new LayoutEventDescription();
led.path = path;
led.layoutId = id;
led.data = entry.getValue();
state.add(led);
}
}
/* (non-Javadoc)
* @see org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect#toSAX(org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext, org.apache.cocoon.portal.layout.Layout, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler)
*/
public void toSAX(RendererAspectContext context,
Layout layout,
PortalService service,
ContentHandler handler)
throws SAXException {
if ( layout.getId() != null ) {
final Request request = ObjectModelHelper.getRequest(context.getObjectModel());
final Session session = request.getSession(false);
if ( session != null ) {
List history = (List)session.getAttribute("portal-history");
if ( history == null ) {
history = new ArrayList();
}
List state = (List)request.getAttribute("portal-history");
if ( state == null ) {
state = new ArrayList();
request.setAttribute("portal-history", state);
history.add(state);
}
this.addValues(layout.getId(), state, layout.getAspectDatas(), "aspectDatas/");
// are we a coplet layout
if ( layout instanceof CopletLayout ) {
CopletInstanceData cid = ((CopletLayout)layout).getCopletInstanceData();
this.addValues(cid.getId(), state, cid.getAspectDatas(), "aspectDatas/");
this.addValues(cid.getId(), state, cid.getAttributes(), "attributes/");
}
session.setAttribute("portal-history", history);
}
}
context.invokeNext(layout, service, handler);
}
}
1.2 +2 -0 cocoon-2.1/src/blocks/portal/samples/resources/bookmarks.xml
Index: bookmarks.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/resources/bookmarks.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- bookmarks.xml 11 Dec 2003 14:41:32 -0000 1.1
+++ bookmarks.xml 12 Dec 2003 10:13:34 -0000 1.2
@@ -1,3 +1,4 @@
+<bookmarks>
<events>
<event type="jxpath" id="showtab">
<targettype>layout</targettype>
@@ -5,3 +6,4 @@
<path>aspectDatas/tab</path>
</event>
</events>
+</bookmarks>