stephan 2002/08/19 10:32:15 Modified: src/scratchpad/src/org/apache/cocoon/generation SourceDescriptionGenerator.java src/scratchpad/webapp/samples/slide sitemap.xmap Log: Make the information, which the description includes optional to increase the speed for some operations. Revision Changes Path 1.11 +37 -29 xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java Index: SourceDescriptionGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/src/org/apache/cocoon/generation/SourceDescriptionGenerator.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- SourceDescriptionGenerator.java 19 Aug 2002 08:06:23 -0000 1.10 +++ SourceDescriptionGenerator.java 19 Aug 2002 17:32:15 -0000 1.11 @@ -53,12 +53,8 @@ import org.apache.avalon.excalibur.pool.Recyclable; -import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.ComponentException; -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.parameters.Parameters; import org.apache.cocoon.ProcessingException; @@ -105,7 +101,7 @@ * @version CVS $Id$ */ public class SourceDescriptionGenerator extends ComposerGenerator - implements CacheableProcessingComponent, Configurable{ + implements CacheableProcessingComponent{ /** Namespace of the source description. */ private static final String SOURCE_NS = "http://xml.apache.org/cocoon/source/2.0"; @@ -146,22 +142,31 @@ private static final String EXPIRATION_ATTR_NAME = "expiration"; private static final String EXCLUSIVE_ATTR_NAME = "exclusive"; + /** Include properties into the description */ + private boolean properties = true; + + /** Include permissions into the description */ + private boolean permissions = true; + + /** Include locks into the description */ + private boolean locks = true; + + /** How deep the generator traverse the source */ + private int deep = 1; + /** - * Pass the Configuration to the Configurable class. This method must - * always be called after the constructor and before any other method. - * - * @param conf the class configurations. - * - * @throws ConfigurationException Thrown when a Configurable component - * cannot be configured properly, or if - * a value cannot be retrieved properly. + * Set the <code>SourceResolver</code>, objectModel <code>Map</code>, + * the source and sitemap <code>Parameters</code> used to process the request. */ - public void configure(Configuration conf) throws ConfigurationException { - } - public void setup(SourceResolver resolver, Map objectModel, String location, Parameters parameters) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, location, parameters); + + this.properties = parameters.getParameterAsBoolean("properties", true); + this.permissions = parameters.getParameterAsBoolean("permissions", true); + this.locks = parameters.getParameterAsBoolean("locks", true); + + this.deep = parameters.getParameterAsInteger("deep", 1); } /** @@ -174,7 +179,7 @@ StringBuffer key = new StringBuffer(); key.append("SDG("); Stack sources = new Stack(); - collectSources(sources, this.source, 1); + collectSources(sources, this.source, this.deep); Source source; while (!sources.empty()) { source = (Source)sources.pop(); @@ -196,7 +201,7 @@ public SourceValidity generateValidity() { AggregatedValidity validity = new AggregatedValidity(); Stack sources = new Stack(); - collectSources(sources, this.source, 1); + collectSources(sources, this.source, this.deep); Source source; while (!sources.empty()) { source = (Source)sources.pop(); @@ -243,7 +248,7 @@ this.contentHandler.startDocument(); this.contentHandler.startPrefixMapping(SOURCE_PREFIX,SOURCE_NS); - pushSourceDescription(this.source, 1); + pushSourceDescription(this.source, this.deep); this.contentHandler.endPrefixMapping(SOURCE_PREFIX); this.contentHandler.endDocument(); @@ -325,20 +330,23 @@ this.contentHandler.startElement(SOURCE_NS, SOURCE_NODE_NAME, SOURCE_PREFIX+":"+SOURCE_NODE_NAME, attributes); - if (source instanceof InspectableSource) + if ((source instanceof InspectableSource) && this.properties) pushLiveSourceProperties((InspectableSource)source); - pushComputedSourceProperties(source); + if (this.properties) + pushComputedSourceProperties(source); - try { - if (source instanceof RestrictableSource) - pushSourcePermissions((RestrictableSource)source); - } catch (SourceException se) { - if (getLogger().isDebugEnabled()) - getLogger().debug("Could not retrieve source permissions", se); + if (this.permissions) { + try { + if (source instanceof RestrictableSource) + pushSourcePermissions((RestrictableSource)source); + } catch (SourceException se) { + if (getLogger().isDebugEnabled()) + getLogger().debug("Could not retrieve source permissions", se); + } } - if (source instanceof LockableSource) + if ((source instanceof LockableSource) && this.locks) pushSourceLocks((LockableSource)source); if ((isCollection) && (deep>0)) { 1.14 +6 -2 xml-cocoon2/src/scratchpad/webapp/samples/slide/sitemap.xmap Index: sitemap.xmap =================================================================== RCS file: /home/cvs/xml-cocoon2/src/scratchpad/webapp/samples/slide/sitemap.xmap,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- sitemap.xmap 19 Aug 2002 14:04:27 -0000 1.13 +++ sitemap.xmap 19 Aug 2002 17:32:15 -0000 1.14 @@ -164,10 +164,14 @@ <!-- ============= Source description ============= --> <map:match pattern="description/**"> - <map:generate type="sourcedescription" src="slide://{1}?cocoon-source-principal=root"> + <map:generate type="sourcedescription" src="slide://{1}?cocoon-source-principal={../ID}"> <map:parameter name="repository" value="slide"/> <map:parameter name="namespace" value="myrepository"/> - <map:parameter name="principal" value="{../ID}"/> +<!-- <map:parameter name="principal" value="{../ID}"/>--> + <map:parameter name="properties" value="true"/> + <map:parameter name="permissions" value="true"/> + <map:parameter name="locks" value="true"/> + <map:parameter name="depth" value="1"/> </map:generate> <map:serialize type="xml"/>
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]