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 2006/02/12 15:29:17 UTC
svn commit: r377181 - in
/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal:
layout/renderer/aspect/impl/ pluto/ profile/ profile/impl/
Author: cziegeler
Date: Sun Feb 12 06:29:16 2006
New Revision: 377181
URL: http://svn.apache.org/viewcvs?rev=377181&view=rev
Log:
Clean up and add support for using the named item name as event data
Modified:
cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java
cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManagerAspectContext.java
cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/DefaultProfileManagerAspectContext.java
cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java
Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java?rev=377181&r1=377180&r2=377181&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java Sun Feb 12 06:29:16 2006
@@ -107,6 +107,8 @@
public class TabContentAspect
extends CompositeContentAspect {
+ public static final String TAB_TEMPORARY_ATTRIBUTE_NAME = "tab";
+
/**
* @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)
*/
@@ -119,7 +121,7 @@
// check for maximized information
final RenderInfo maximizedInfo = LayoutFeatures.getRenderInfo(layout);
- TabPreparedConfiguration config = (TabPreparedConfiguration)context.getAspectConfiguration();
+ final TabPreparedConfiguration config = (TabPreparedConfiguration)context.getAspectConfiguration();
if ( config.rootTag ) {
XMLUtils.startElement(handler, config.tagName);
@@ -129,26 +131,43 @@
CompositeLayout tabLayout = (CompositeLayout) layout;
// selected tab
- String data = (String)layout.getTemporaryAttribute("tab");
- int selected = 0;
- if ( data != null ) {
- selected = Integer.valueOf(data).intValue();
+ String selectedTabName = (String)layout.getTemporaryAttribute(TAB_TEMPORARY_ATTRIBUTE_NAME);
+ int selectedTabIndex = 0;
+ if ( selectedTabName != null && !config.useNames) {
+ selectedTabIndex = Integer.valueOf(selectedTabName).intValue();
}
// loop over all tabs
for (int j = 0; j < tabLayout.getSize(); j++) {
- Item tab = tabLayout.getItem(j);
- LayoutChangeParameterEvent event = null;
+ final Item tab = tabLayout.getItem(j);
// open named-item tag
attributes.clear();
if ( tab instanceof NamedItem ) {
attributes.addCDATAAttribute("name", ((NamedItem)tab).getName());
}
- if (j == selected) {
+ boolean selected = false;
+ if ( config.useNames ) {
+ if ( selectedTabName == null ) {
+ selected = (j == 0);
+ } else {
+ if ( tab instanceof NamedItem ) {
+ selected = selectedTabName.equalsIgnoreCase(((NamedItem)tab).getName());
+ }
+ }
+ } else {
+ selected = (j == selectedTabIndex);
+ }
+ if ( selected ) {
attributes.addCDATAAttribute("selected", "true");
}
- event = new LayoutChangeParameterEvent(tabLayout, "tab", String.valueOf(j), true);
+ final String eventData;
+ if ( config.useNames ) {
+ eventData = ((NamedItem)tab).getName();
+ } else {
+ eventData = String.valueOf(j);
+ }
+ final LayoutChangeParameterEvent event = new LayoutChangeParameterEvent(tabLayout, TAB_TEMPORARY_ATTRIBUTE_NAME, eventData, true);
attributes.addCDATAAttribute("parameter", service.getLinkService().getLinkURI(event));
// add parameters
@@ -159,7 +178,7 @@
}
XMLUtils.startElement(handler, "named-item", attributes);
- if (j == selected) {
+ if (selected) {
if ( maximizedInfo != null && maximizedInfo.item.equals(tab) ) {
this.processLayout(maximizedInfo.layout, service, handler);
} else {
@@ -168,12 +187,12 @@
if (config.includeSelected) {
List events = new ArrayList();
events.add(event);
- this.processNav(context, tab.getLayout(), service, handler, events);
+ this.processNavigation(tab.getLayout(), service, handler, events, config);
}
} else if (config.showAllNav) {
List events = new ArrayList();
events.add(event);
- this.processNav(context, tab.getLayout(), service, handler, events);
+ this.processNavigation(tab.getLayout(), service, handler, events, config);
}
// close named-item tag
@@ -196,11 +215,11 @@
* @param handler
* @throws SAXException
*/
- private void processNav(RendererAspectContext context,
- Layout layout,
- PortalService service,
- ContentHandler handler,
- List parentEvents)
+ private void processNavigation(Layout layout,
+ PortalService service,
+ ContentHandler handler,
+ List parentEvents,
+ TabPreparedConfiguration config)
throws SAXException {
if (layout instanceof CompositeLayout) {
CompositeLayout tabLayout = (CompositeLayout)layout;
@@ -208,8 +227,6 @@
if (tabLayout.getSize() == 0) {
return;
}
- TabPreparedConfiguration config =
- (TabPreparedConfiguration) context.getAspectConfiguration();
AttributesImpl attributes = new AttributesImpl();
boolean subNav = false;
@@ -224,10 +241,18 @@
XMLUtils.startElement(handler, config.childTagName);
subNav = true;
}
- attributes.addCDATAAttribute("name",
- String.valueOf(((NamedItem) tab).getName()));
- LayoutChangeParameterEvent event = new LayoutChangeParameterEvent(tabLayout,
- "tab", String.valueOf(j), true);
+ attributes.addCDATAAttribute("name", ((NamedItem) tab).getName());
+ final String eventData;
+ if ( config.useNames ) {
+ eventData = ((NamedItem) tab).getName();
+ } else {
+ eventData = String.valueOf(j);
+ }
+ final LayoutChangeParameterEvent event =
+ new LayoutChangeParameterEvent(tabLayout,
+ TAB_TEMPORARY_ATTRIBUTE_NAME,
+ eventData,
+ true);
List events = new ArrayList(parentEvents);
events.add(event);
@@ -244,7 +269,7 @@
XMLUtils.startElement(handler, "named-item", attributes);
- this.processNav(context, tab.getLayout(), service, handler, events);
+ this.processNavigation(tab.getLayout(), service, handler, events, config);
// close named-item tag
XMLUtils.endElement(handler, "named-item");
@@ -261,12 +286,14 @@
public boolean showAllNav = false;
public boolean includeSelected = false;
public String childTagName;
+ public boolean useNames = false;
public void takeValues(TabPreparedConfiguration from) {
super.takeValues(from);
this.showAllNav = from.showAllNav;
this.includeSelected = from.includeSelected;
this.childTagName = from.childTagName;
+ this.useNames = from.useNames;
}
}
@@ -284,6 +311,7 @@
pc.showAllNav = configuration.getParameterAsBoolean("show-all-nav", false);
}
pc.includeSelected = configuration.getParameterAsBoolean("include-selected", false);
+ pc.useNames = configuration.getParameterAsBoolean("use-names", false);
return pc;
}
}
Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java?rev=377181&r1=377180&r2=377181&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java Sun Feb 12 06:29:16 2006
@@ -108,10 +108,11 @@
this.prepareObject(rootLayout);
profile.setRootLayout(rootLayout);
- this.processProfile(profile);
+ final Profile processedProfile = this.processProfile(profile);
+ this.storeUserProfile(layoutKey, processedProfile);
- this.storeUserProfile(layoutKey, profile);
- return profile;
+ this.storeUserProfile(layoutKey, processedProfile);
+ return processedProfile;
}
return super.loadProfile(layoutKey);
}
Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManagerAspectContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManagerAspectContext.java?rev=377181&r1=377180&r2=377181&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManagerAspectContext.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileManagerAspectContext.java Sun Feb 12 06:29:16 2006
@@ -15,10 +15,9 @@
*/
package org.apache.cocoon.portal.profile;
-import java.util.Map;
-
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.scratchpad.Profile;
/**
* The context for a {@link ProfileManagerAspect}
@@ -31,17 +30,12 @@
/**
* Invoke next aspect .
*/
- void invokeNext();
+ void invokeNext(Profile profile);
/**
* Get the {@link Parameters} of the aspect.
*/
Parameters getAspectParameters();
-
- /**
- * Get the object model.
- */
- Map getObjectModel();
/**
* Get the portal service.
Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java?rev=377181&r1=377180&r2=377181&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java Sun Feb 12 06:29:16 2006
@@ -41,7 +41,6 @@
import org.apache.cocoon.portal.profile.PortalUser;
import org.apache.cocoon.portal.profile.ProfileManager;
import org.apache.cocoon.portal.profile.ProfileManagerAspect;
-import org.apache.cocoon.portal.profile.ProfileManagerAspectContext;
import org.apache.cocoon.portal.scratchpad.Profile;
/**
@@ -225,11 +224,13 @@
/**
* Process a freshly loaded profile.
*/
- protected void processProfile(Profile profile) {
+ protected Profile processProfile(Profile profile) {
// FIXME we should add the calls to prepareObject here as well
if ( this.chain.hasAspects() ) {
- ProfileManagerAspectContext aspectContext = new DefaultProfileManagerAspectContext(this.chain, this.portalService, this.portalService.getObjectModel(), profile);
- aspectContext.invokeNext();
+ DefaultProfileManagerAspectContext aspectContext = new DefaultProfileManagerAspectContext(this.chain, this.portalService);
+ aspectContext.invokeNext(profile);
+ profile = aspectContext.getProfile();
}
+ return profile;
}
}
Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/DefaultProfileManagerAspectContext.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/DefaultProfileManagerAspectContext.java?rev=377181&r1=377180&r2=377181&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/DefaultProfileManagerAspectContext.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/DefaultProfileManagerAspectContext.java Sun Feb 12 06:29:16 2006
@@ -16,7 +16,6 @@
package org.apache.cocoon.portal.profile.impl;
import java.util.Iterator;
-import java.util.Map;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.portal.PortalService;
@@ -33,27 +32,23 @@
implements ProfileManagerAspectContext {
private final PortalService service;
- private final Map objectModel;
private final Iterator iterator;
private final Iterator configIterator;
private Parameters config;
- private final Profile profile;
+ private Profile profile;
public DefaultProfileManagerAspectContext(ProfileManagerAspectChain chain,
- PortalService service,
- Map objectModel,
- Profile profile) {
+ PortalService service) {
this.service = service;
- this.objectModel = objectModel;
this.iterator = chain.getIterator();
this.configIterator = chain.getConfigIterator();
- this.profile = profile;
}
/**
- * @see org.apache.cocoon.portal.profile.ProfileManagerAspectContext#invokeNext()
+ * @see org.apache.cocoon.portal.profile.ProfileManagerAspectContext#invokeNext(org.apache.cocoon.portal.scratchpad.Profile)
*/
- public void invokeNext() {
+ public void invokeNext(Profile profile) {
+ this.profile = profile;
if (this.iterator.hasNext()) {
this.config = (Parameters)this.configIterator.next();
final ProfileManagerAspect aspect = (ProfileManagerAspect) iterator.next();
@@ -69,16 +64,13 @@
}
/**
- * @see org.apache.cocoon.portal.profile.ProfileManagerAspectContext#getObjectModel()
- */
- public Map getObjectModel() {
- return this.objectModel;
- }
-
- /**
* @see org.apache.cocoon.portal.profile.ProfileManagerAspectContext#getPortalService()
*/
public PortalService getPortalService() {
return this.service;
+ }
+
+ public Profile getProfile() {
+ return this.profile;
}
}
Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java?rev=377181&r1=377180&r2=377181&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java Sun Feb 12 06:29:16 2006
@@ -23,12 +23,8 @@
import java.util.List;
import java.util.Map;
-import org.apache.avalon.framework.activity.Disposable;
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.parameters.ParameterException;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceException;
@@ -74,8 +70,7 @@
* @version $Id: AbstractUserProfileManager.java 37123 2004-08-27 12:11:53Z cziegeler $
*/
public class GroupBasedProfileManager
- extends AbstractProfileManager
- implements Contextualizable, Disposable {
+ extends AbstractProfileManager {
public static final String CATEGORY_GLOBAL = "global";
public static final String CATEGORY_GROUP = "group";
@@ -97,9 +92,6 @@
/** All deployed coplet datas. */
final protected Map deployedCopletDatas = new HashMap();
- /** The component context. */
- protected Context context;
-
/** Check for changes? */
protected boolean checkForChanges = true;
@@ -110,13 +102,6 @@
protected ProfileLS loader;
/**
- * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
- */
- public void contextualize(Context context) throws ContextException {
- this.context = context;
- }
-
- /**
* @see org.apache.cocoon.portal.profile.impl.AbstractProfileManager#configure(org.apache.avalon.framework.configuration.Configuration)
*/
public void configure(Configuration config) throws ConfigurationException {
@@ -334,7 +319,7 @@
protected Profile loadProfile(final String layoutKey)
throws Exception {
final PortalUser info = (PortalUser)this.portalService.getTemporaryAttribute(USER_ATTRIBUTE);
- final ProfileImpl profile = new ProfileImpl(layoutKey);
+ ProfileImpl profile = new ProfileImpl(layoutKey);
// first "load" the global data
profile.setCopletBaseDatas( this.getGlobalBaseDatas(layoutKey) );
@@ -357,9 +342,9 @@
}
}
- this.storeUserProfile(layoutKey, profile);
- this.processProfile(profile);
- return profile;
+ final Profile processedProfile = this.processProfile(profile);
+ this.storeUserProfile(layoutKey, processedProfile);
+ return processedProfile;
}
protected Map getGlobalBaseDatas(final String layoutKey)
Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java?rev=377181&r1=377180&r2=377181&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java (original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/PageLabelProfileManagerAspect.java Sun Feb 12 06:29:16 2006
@@ -38,7 +38,7 @@
if ( rootLayout instanceof CompositeLayout ) {
this.populate((CompositeLayout)rootLayout, "");
}
- context.invokeNext();
+ context.invokeNext(profile);
}
private void populate(CompositeLayout layout, String name) {