cziegeler 2003/12/08 07:56:26
Modified: src/blocks/portal/conf portal.samplesxconf portal.xconf
src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl
RequestAspectDataStore.java
src/blocks/portal/java/org/apache/cocoon/portal/event
EventConverter.java
src/blocks/portal/java/org/apache/cocoon/portal/event/aspect/impl
FullScreenCopletEventAspect.java
src/blocks/portal/java/org/apache/cocoon/portal/impl
DefaultLinkService.java
Added: src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl
TemporaryAspectDataStore.java
Log:
Adding temporary aspect data store
A coplet can now test, if it is display in fullScreen mode
Revision Changes Path
1.7 +5 -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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- portal.samplesxconf 2 Sep 2003 09:53:00 -0000 1.6
+++ portal.samplesxconf 8 Dec 2003 15:56:25 -0000 1.7
@@ -189,6 +189,11 @@
store="session"
auto-create="true"
value="1"/>
+ <aspect name="fullScreen"
+ class="java.lang.Boolean"
+ store="temporary"
+ auto-create="true"
+ value="false"/>
</coplet-instance-data-aspects>
</coplet>
</coplets>
1.26 +1 -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.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- portal.xconf 1 Sep 2003 14:45:07 -0000 1.25
+++ portal.xconf 8 Dec 2003 15:56:26 -0000 1.26
@@ -68,6 +68,7 @@
<!-- Aspect Storage configuration -->
<component class="org.apache.cocoon.components.ExtendedComponentSelector"
role="org.apache.cocoon.portal.aspect.AspectDataStoreSelector">
+ <store name="temporary"
class="org.apache.cocoon.portal.aspect.impl.TemporaryAspectDataStore"/>
<store name="request"
class="org.apache.cocoon.portal.aspect.impl.RequestAspectDataStore"/>
<store name="session"
class="org.apache.cocoon.portal.aspect.impl.SessionAspectDataStore"/>
<store name="persistent"
class="org.apache.cocoon.portal.aspect.impl.PersistentAspectDataStore"/>
1.6 +5 -60
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/RequestAspectDataStore.java
Index: RequestAspectDataStore.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/RequestAspectDataStore.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RequestAspectDataStore.java 20 Oct 2003 13:36:41 -0000 1.5
+++ RequestAspectDataStore.java 8 Dec 2003 15:56:26 -0000 1.6
@@ -50,26 +50,12 @@
*/
package org.apache.cocoon.portal.aspect.impl;
-import java.util.HashMap;
-import java.util.Map;
-
import org.apache.avalon.framework.CascadingRuntimeException;
-import org.apache.avalon.framework.component.Component;
-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.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.service.ServiceManager;
-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.portal.LinkService;
-import org.apache.cocoon.portal.aspect.AspectDataStore;
import org.apache.cocoon.portal.aspect.Aspectalizable;
import org.apache.cocoon.portal.coplet.CopletInstanceData;
import org.apache.cocoon.portal.event.impl.ChangeAspectDataEvent;
@@ -83,43 +69,14 @@
* @version CVS $Id$
*/
public class RequestAspectDataStore
- extends AbstractLogEnabled
- implements Component, Serviceable, ThreadSafe, AspectDataStore,
Contextualizable, Parameterizable {
-
- protected Context context;
+ extends TemporaryAspectDataStore
+ implements Parameterizable {
protected String requestParameterName;
- protected ServiceManager manager;
-
- /* (non-Javadoc)
- * @see
org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
- */
- public void service(ServiceManager manager) throws ServiceException {
- this.manager = manager;
- }
-
- protected Map getMap(Aspectalizable owner) {
- final Request request = ContextHelper.getRequest(this.context);
- Map componentMap =
(Map)request.getAttribute(this.getClass().getName());
- if ( componentMap == null) {
- componentMap = new HashMap(3);
- request.setAttribute(this.getClass().getName(), componentMap);
- }
- Map ownerMap = (Map)componentMap.get( owner );
- if ( ownerMap == null ) {
- ownerMap = new HashMap(3);
- componentMap.put( owner, ownerMap );
- }
- return ownerMap;
- }
-
- public Object getAspectData(Aspectalizable owner, String aspectName) {
- return this.getMap(owner).get( aspectName );
- }
-
public void setAspectData(Aspectalizable owner, String aspectName,
Object data) {
- this.getMap(owner).put(aspectName, data);
+ super.setAspectData(owner, aspectName, data);
+
// create persistence
ChangeAspectDataEvent e;
if ( owner instanceof CopletInstanceData) {
@@ -140,18 +97,6 @@
this.manager.release( service );
}
- }
-
- public boolean isPersistent() {
- return false;
- }
-
- /* (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;
-
}
/* (non-Javadoc)
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/TemporaryAspectDataStore.java
Index: TemporaryAspectDataStore.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
[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.aspect.impl;
import java.util.HashMap;
import java.util.Map;
import org.apache.avalon.framework.component.Component;
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.Serviceable;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.ContextHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.portal.aspect.AspectDataStore;
import org.apache.cocoon.portal.aspect.Aspectalizable;
/**
* An aspect data store is a component that manages aspect data objects.
* This store holds the data for the current request.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: TemporaryAspectDataStore.java,v 1.1 2003/12/08 15:56:26
cziegeler Exp $
*/
public class TemporaryAspectDataStore
extends AbstractLogEnabled
implements Component, Serviceable, ThreadSafe, AspectDataStore,
Contextualizable {
protected Context context;
protected ServiceManager manager;
/* (non-Javadoc)
* @see
org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
public void service(ServiceManager manager) throws ServiceException {
this.manager = manager;
}
protected Map getMap(Aspectalizable owner) {
final Request request = ContextHelper.getRequest(this.context);
Map componentMap =
(Map)request.getAttribute(this.getClass().getName());
if ( componentMap == null) {
componentMap = new HashMap(3);
request.setAttribute(this.getClass().getName(), componentMap);
}
Map ownerMap = (Map)componentMap.get( owner );
if ( ownerMap == null ) {
ownerMap = new HashMap(3);
componentMap.put( owner, ownerMap );
}
return ownerMap;
}
public Object getAspectData(Aspectalizable owner, String aspectName) {
return this.getMap(owner).get( aspectName );
}
public void setAspectData(Aspectalizable owner, String aspectName, Object
data) {
this.getMap(owner).put(aspectName, data);
}
public boolean isPersistent() {
return false;
}
/* (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 +19 -2
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/EventConverter.java
Index: EventConverter.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/EventConverter.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EventConverter.java 7 May 2003 06:22:26 -0000 1.1
+++ EventConverter.java 8 Dec 2003 15:56:26 -0000 1.2
@@ -64,12 +64,29 @@
String ROLE = EventConverter.class.getName();
-
+ /**
+ * Encode an event.
+ * This is used to "activate" events using a link
+ * @param event The event to encode
+ * @return A unique string representation for this event
+ */
String encode(Event event);
+ /**
+ * Decode an event
+ * This is used to "activate" events using a link
+ * @param value The string representation created using [EMAIL
PROTECTED] #encode(Event)}
+ * @return The event or null
+ */
Event decode(String value);
+ /**
+ * This notifies the converter that a new event processing phase starts
+ */
void start();
+ /**
+ * This notifies the converter that an event processing phase ends
+ */
void finish();
}
1.5 +19 -11
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/aspect/impl/FullScreenCopletEventAspect.java
Index: FullScreenCopletEventAspect.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/aspect/impl/FullScreenCopletEventAspect.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FullScreenCopletEventAspect.java 20 Oct 2003 13:36:42 -0000 1.4
+++ FullScreenCopletEventAspect.java 8 Dec 2003 15:56:26 -0000 1.5
@@ -69,6 +69,8 @@
import org.apache.cocoon.portal.event.aspect.EventAspectContext;
import org.apache.cocoon.portal.event.impl.FullScreenCopletEvent;
import org.apache.cocoon.portal.layout.Layout;
+import org.apache.cocoon.portal.layout.impl.CopletLayout;
+import org.apache.cocoon.portal.profile.ProfileManager;
/**
*
@@ -139,17 +141,23 @@
*/
public void inform(Event event) {
FullScreenCopletEvent e = (FullScreenCopletEvent) event;
- final Layout startingLayout = e.getLayout();
- if ( null != startingLayout ) {
- PortalService portalService = null;
- try {
- portalService = (PortalService)
this.manager.lookup(PortalService.ROLE);
-
portalService.getComponentManager().getProfileManager().setEntryLayout(
startingLayout );
- } catch (ServiceException ce) {
- // ignore
- } finally {
- this.manager.release(portalService);
+ final Layout startingLayout = (CopletLayout)e.getLayout();
+ PortalService portalService = null;
+ try {
+ portalService = (PortalService)
this.manager.lookup(PortalService.ROLE);
+ ProfileManager pm =
portalService.getComponentManager().getProfileManager();
+ final Layout old = pm.getEntryLayout();
+ if ( old != null && old instanceof CopletLayout) {
+
((CopletLayout)old).getCopletInstanceData().setAspectData("fullScreen",
Boolean.FALSE);
}
+ pm.setEntryLayout( startingLayout );
+ if ( startingLayout != null && startingLayout instanceof
CopletLayout) {
+
((CopletLayout)startingLayout).getCopletInstanceData().setAspectData("fullScreen",
Boolean.TRUE);
+ }
+ } catch (ServiceException ce) {
+ // ignore
+ } finally {
+ this.manager.release(portalService);
}
}
1.9 +12 -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.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- DefaultLinkService.java 8 Dec 2003 13:47:51 -0000 1.8
+++ DefaultLinkService.java 8 Dec 2003 15:56:26 -0000 1.9
@@ -88,7 +88,7 @@
*/
class Info {
StringBuffer linkBase = new StringBuffer();
- boolean hasParameters = false;
+ boolean hasParameters = false;
ArrayList comparableEvents = new ArrayList(5);
}
@@ -243,6 +243,16 @@
final Info info = this.getInfo();
if ( event instanceof ComparableEvent) {
+ // search if we already have an event for this!
+ final Iterator iter = info.comparableEvents.iterator();
+ boolean found = false;
+ while ( !found && iter.hasNext() ) {
+ Object[] objects = (Object[])iter.next();
+ if (
((ComparableEvent)objects[0]).equalsEvent((ComparableEvent)event) ) {
+ found = true;
+ info.comparableEvents.remove(objects[0]);
+ }
+ }
info.comparableEvents.add( new Object[] {event, parameterName,
value} );
} else {
this.addParameterToLink(parameterName, value);