cziegeler 2003/12/11 05:31:55
Modified: src/blocks/portal/java/org/apache/cocoon/portal/transformation
CopletTransformer.java
src/blocks/portal/samples/resources login.xml
src/blocks/portal/samples/skins/basic/styles login-html.xsl
src/blocks/portal/samples sitemap.xmap
src/blocks/portal/samples/skins/common/styles login-html.xsl
src/blocks/portal/java/org/apache/cocoon/portal/impl
DefaultLinkService.java
src/blocks/portal/conf actions.xmap
Added: src/blocks/portal/java/org/apache/cocoon/portal/acting
BookmarkAction.java
Log:
Add new bookmark action for bookmarking the portal
Fix bug in uri generation for events
Correct the authentication redirekt
Revision Changes Path
1.9 +3 -1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
Index: CopletTransformer.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- CopletTransformer.java 11 Dec 2003 09:44:14 -0000 1.8
+++ CopletTransformer.java 11 Dec 2003 13:31:55 -0000 1.9
@@ -83,6 +83,8 @@
* Please see also the documentation of superclass AbstractCopletTransformer
for how
* the coplet instance data are acquired.
*
+ * FIXME - Don't create <a> elements for links!
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Björn Lütkemeier</a>
* @version CVS $Id$
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/acting/BookmarkAction.java
Index: BookmarkAction.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
[EMAIL PROTECTED]
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 <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.acting;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.SAXConfigurationHandler;
import org.apache.avalon.framework.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameterizable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.acting.ServiceableAction;
import org.apache.cocoon.components.source.SourceUtil;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.Request;
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.excalibur.source.Source;
import org.xml.sax.SAXException;
/**
* This action helps you in creating bookmarks
*
* The definition file is:
* <events>
* <event type="jxpath" id="ID">
* <targetid>tagetId</targetid>
* <targettype>layout|coplet</targettype>
* <path/>
* </event>
* </events>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @version CVS $Id: BookmarkAction.java,v 1.1 2003/12/11 13:31:55 cziegeler
Exp $
*/
public class BookmarkAction
extends ServiceableAction
implements ThreadSafe, Parameterizable {
protected Map eventMap = new HashMap();
/* (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;
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 {
throw new ParameterException("Unknown target type " +
targetType);
}
} catch (ConfigurationException ce) {
throw new ParameterException("Configuration exception"
,ce);
}
}
}
}
public Map act(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String source,
Parameters par)
throws Exception {
if (this.getLogger().isDebugEnabled() ) {
this.getLogger().debug("BEGIN act resolver="+resolver+
", objectModel="+objectModel+
", source="+source+
", par="+par);
}
Map result;
PortalService service = null;
try {
service = (PortalService)this.manager.lookup(PortalService.ROLE);
service.setPortalName(par.getParameter("portal-name"));
PortalManager portalManager = null;
try {
portalManager = (PortalManager)
this.manager.lookup(PortalManager.ROLE);
portalManager.process();
} finally {
this.manager.release(portalManager);
}
Request request = ObjectModelHelper.getRequest(objectModel);
Enumeration enum = request.getParameterNames();
List events = new ArrayList();
while (enum.hasMoreElements()) {
String name = (String)enum.nextElement();
String value = request.getParameter(name);
Mapping m = (Mapping) this.eventMap.get(name);
if ( m != null ) {
events.add(m.getEvent(service, value));
}
}
String uri =
service.getComponentManager().getLinkService().getLinkURI(events);
result = new HashMap();
result.put("uri", uri.substring(uri.indexOf('?')+1));
} catch (ParameterException pe) {
throw new ProcessingException("Parameter portal-name is
required.");
} catch (ServiceException ce) {
throw new ProcessingException("Unable to lookup portal service.",
ce);
} finally {
this.manager.release(service);
}
if (this.getLogger().isDebugEnabled() ) {
this.getLogger().debug("END act map={}");
}
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.2 +2 -2 cocoon-2.1/src/blocks/portal/samples/resources/login.xml
Index: login.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/resources/login.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- login.xml 19 May 2003 09:14:09 -0000 1.1
+++ login.xml 11 Dec 2003 13:31:55 -0000 1.2
@@ -7,7 +7,7 @@
<content>
<form>
- <url>auth?resource=portal</url>
+ <url>auth</url>
<field name="name" type="text" length="24" description="User"/>
<field name="password" type="password" length="10"
description="Password"/>
</form>
1.2 +11 -2
cocoon-2.1/src/blocks/portal/samples/skins/basic/styles/login-html.xsl
Index: login-html.xsl
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/samples/skins/basic/styles/login-html.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- login-html.xsl 25 Jun 2003 08:23:16 -0000 1.1
+++ login-html.xsl 11 Dec 2003 13:31:55 -0000 1.2
@@ -8,6 +8,8 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:param name="resource"/>
+
<xsl:template match="content">
<table bgColor="#ffffff" border="0" cellPadding="0" cellSpacing="0"
width="100%"><tbody>
<tr>
@@ -43,7 +45,14 @@
<xsl:template match="form">
<form method="post" target="_top">
- <xsl:attribute name="action"><xsl:value-of
select="normalize-space(url)"/></xsl:attribute>
+ <xsl:choose>
+ <xsl:when test="$resource=''">
+ <xsl:attribute name="action"><xsl:value-of
select="normalize-space(url)"/>?resource=portal</xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="action"><xsl:value-of
select="normalize-space(url)"/>?resource=<xsl:value-of
select="$resource"/></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
<table>
<xsl:apply-templates select="field"/><br/>
</table>
1.14 +3 -1 cocoon-2.1/src/blocks/portal/samples/sitemap.xmap
Index: sitemap.xmap
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/samples/sitemap.xmap,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- sitemap.xmap 20 Aug 2003 12:05:35 -0000 1.13
+++ sitemap.xmap 11 Dec 2003 13:31:55 -0000 1.14
@@ -135,7 +135,9 @@
<map:redirect-to uri="portal"/>
</map:act>
<map:generate src="resources/login.xml"/>
- <map:transform src="{global:skin}styles/login-html.xsl"/>
+ <map:transform src="{global:skin}styles/login-html.xsl">
+ <map:parameter name="resource" value="{request-param:resource}"/>
+ </map:transform>
<map:transform src="{global:skin}styles/portal-page.xsl"/>
<map:transform type="encodeURL"/>
<map:serialize/>
1.3 +11 -2
cocoon-2.1/src/blocks/portal/samples/skins/common/styles/login-html.xsl
Index: login-html.xsl
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/samples/skins/common/styles/login-html.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- login-html.xsl 27 May 2003 11:10:20 -0000 1.2
+++ login-html.xsl 11 Dec 2003 13:31:55 -0000 1.3
@@ -8,6 +8,8 @@
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:param name="resource"/>
+
<xsl:template match="content">
<table bgColor="#ffffff" border="0" cellPadding="0" cellSpacing="0"
width="100%"><tbody>
<tr>
@@ -43,7 +45,14 @@
<xsl:template match="form">
<form method="post" target="_top">
- <xsl:attribute name="action"><xsl:value-of
select="normalize-space(url)"/></xsl:attribute>
+ <xsl:choose>
+ <xsl:when test="$resource=''">
+ <xsl:attribute name="action"><xsl:value-of
select="normalize-space(url)"/>?resource=portal</xsl:attribute>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:attribute name="action"><xsl:value-of
select="normalize-space(url)"/>?resource=<xsl:value-of
select="$resource"/></xsl:attribute>
+ </xsl:otherwise>
+ </xsl:choose>
<table>
<xsl:apply-templates select="field"/><br/>
</table>
1.10 +2 -2
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultLinkService.java
Index: DefaultLinkService.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultLinkService.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- DefaultLinkService.java 8 Dec 2003 15:56:26 -0000 1.9
+++ DefaultLinkService.java 11 Dec 2003 13:31:55 -0000 1.10
@@ -191,7 +191,7 @@
public String getLinkURI(List events) {
final Info info = this.getInfo();
boolean hasParams = info.hasParameters;
- final StringBuffer buffer = new StringBuffer(info.toString());
+ final StringBuffer buffer = new
StringBuffer(info.linkBase.toString());
// add comparable events
Iterator iter = info.comparableEvents.iterator();
1.5 +2 -0 cocoon-2.1/src/blocks/portal/conf/actions.xmap
Index: actions.xmap
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/actions.xmap,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- actions.xmap 10 Dec 2003 15:31:41 -0000 1.4
+++ actions.xmap 11 Dec 2003 13:31:55 -0000 1.5
@@ -13,4 +13,6 @@
src="org.apache.cocoon.portal.acting.CopletSetDataAction"/>
<map:action name="portal-save-profile"
src="org.apache.cocoon.portal.acting.SaveAction"/>
+ <map:action name="portal-bookmark"
+ src="org.apache.cocoon.portal.acting.BookmarkAction"/>
</xmap>