sylvain 2003/01/09 09:45:01 Modified: . Tag: cocoon_2_0_3_branch changes.xml src/java/org/apache/cocoon/components/source Tag: cocoon_2_0_3_branch FileSource.java src/java/org/apache/cocoon/components/treeprocessor/sitemap Tag: cocoon_2_0_3_branch ReadNode.java ReadNodeBuilder.java SerializeNode.java SerializeNodeBuilder.java src/java/org/apache/cocoon/components/treeprocessor/variables Tag: cocoon_2_0_3_branch PreparedVariableResolver.java VariableResolver.java Log: Added sitemap variable expansion to "mime-type" in <map:read> and <map:serialize> Revision Changes Path No revision No revision 1.138.2.83 +5 -1 xml-cocoon2/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/changes.xml,v retrieving revision 1.138.2.82 retrieving revision 1.138.2.83 diff -u -r1.138.2.82 -r1.138.2.83 --- changes.xml 6 Jan 2003 15:24:11 -0000 1.138.2.82 +++ changes.xml 9 Jan 2003 17:45:00 -0000 1.138.2.83 @@ -41,6 +41,10 @@ <release version="@version@" date="@date@"> <action dev="SW" type="update"> + The "mime-type" attribute on <map:read> and <map:serialize> is now + expanded if it contains sitemap variables. + </action> + <action dev="SW" type="update"> ZipArchiveSerializer now accepts inline content for entries of the zip archive and not only source URLs. </action> No revision No revision 1.2.2.3 +6 -1 xml-cocoon2/src/java/org/apache/cocoon/components/source/FileSource.java Index: FileSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/FileSource.java,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -u -r1.2.2.2 -r1.2.2.3 --- FileSource.java 21 Sep 2002 02:23:52 -0000 1.2.2.2 +++ FileSource.java 9 Jan 2003 17:45:01 -0000 1.2.2.3 @@ -220,6 +220,11 @@ throw new IllegalArgumentException("The stream is not associated to this source"); } + /** Get the underlying <code>File</code> object */ + public File getFile() { + return this.file; + } + /** * A file outputStream that will rename the temp file to the destination file upon close() * and discard the temp file upon cancel(). No revision No revision 1.1.2.2 +7 -5 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNode.java Index: ReadNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNode.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- ReadNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 +++ ReadNode.java 9 Jan 2003 17:45:01 -0000 1.1.2.2 @@ -73,7 +73,7 @@ private VariableResolver source; - private String mimeType; + private VariableResolver mimeType; private int statusCode; @@ -86,7 +86,7 @@ * @param mimeType the mime-type, or <code>null</code> not specified. * @param statusCode the HTTP response status code, or <code>-1</code> if not specified. */ - public ReadNode(String name, VariableResolver source, String mimeType, int statusCode) { + public ReadNode(String name, VariableResolver source, VariableResolver mimeType, int statusCode) { this.readerName = name; this.source = source; this.mimeType = mimeType; @@ -104,7 +104,9 @@ StreamPipeline pipeline = context.getStreamPipeline(); - if (this.mimeType == null) { + String actualMimeType = this.mimeType.resolve(context, objectModel); + + if (actualMimeType == null || actualMimeType.length() == 0) { // No mime-type set on node pipeline.setReader( this.readerName, @@ -118,7 +120,7 @@ this.readerName, source.resolve(context, objectModel), VariableResolver.buildParameters(this.parameters, context, objectModel), - this.mimeType + actualMimeType ); } 1.1.2.2 +2 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNodeBuilder.java Index: ReadNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNodeBuilder.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- ReadNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 +++ ReadNodeBuilder.java 9 Jan 2003 17:45:01 -0000 1.1.2.2 @@ -76,7 +76,7 @@ ReadNode node = new ReadNode( type, VariableResolverFactory.getResolver(config.getAttribute("src", null), this.manager), - config.getAttribute("mime-type", null), + VariableResolverFactory.getResolver(config.getAttribute("mime-type", null), this.manager), config.getAttributeAsInteger("status-code", -1) ); 1.1.2.3 +6 -7 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java Index: SerializeNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- SerializeNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.2 +++ SerializeNode.java 9 Jan 2003 17:45:01 -0000 1.1.2.3 @@ -74,7 +74,7 @@ private String serializerName; - private String mimeType; + private VariableResolver mimeType; private int statusCode; @@ -86,7 +86,7 @@ * @param mimeType the mime-type, or <code>null</code> not specified. * @param statusCode the HTTP response status code, or <code>-1</code> if not specified. */ - public SerializeNode(String name, String mimeType, int statusCode) throws PatternException { + public SerializeNode(String name, VariableResolver mimeType, int statusCode) throws PatternException { this.serializerName = name; this.mimeType = mimeType; this.statusCode = statusCode; @@ -123,10 +123,9 @@ StreamPipeline pipeline = context.getStreamPipeline(); - List mapStack = context.getMapStack(); - Map objectModel = env.getObjectModel(); + String actualType = this.mimeType.resolve(context, env.getObjectModel()); - if (this.mimeType == null) { + if (actualType == null || actualType.length() == 0) { // No mime-type set on node pipeline.setSerializer( this.serializerName, @@ -140,7 +139,7 @@ this.serializerName, null, Parameters.EMPTY_PARAMETERS, // No parameters on serializers - this.mimeType + actualType ); } 1.1.2.2 +3 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNodeBuilder.java Index: SerializeNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNodeBuilder.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- SerializeNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 +++ SerializeNodeBuilder.java 9 Jan 2003 17:45:01 -0000 1.1.2.2 @@ -59,6 +59,7 @@ import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder; import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; import java.util.*; @@ -88,7 +89,7 @@ this.node = new SerializeNode( type, - config.getAttribute("mime-type", null), + VariableResolverFactory.getResolver(config.getAttribute("mime-type", null), this.manager), config.getAttributeAsInteger("status-code", -1) ); return this.treeBuilder.setupNode(node, config); No revision No revision 1.6.2.2 +15 -7 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolver.java Index: PreparedVariableResolver.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolver.java,v retrieving revision 1.6.2.1 retrieving revision 1.6.2.2 diff -u -r1.6.2.1 -r1.6.2.2 --- PreparedVariableResolver.java 25 Nov 2002 21:52:01 -0000 1.6.2.1 +++ PreparedVariableResolver.java 9 Jan 2003 17:45:01 -0000 1.6.2.2 @@ -80,11 +80,12 @@ final private List items = new ArrayList(); // Special constants used for levels + // ROOT and ANCHOR are placed first as they need a context to be resolved (see resolve()) static final int ROOT = 0; - static final int LITERAL = -1; - static final int THREADSAFE_MODULE = -2; - static final int STATEFUL_MODULE = -3; - static final int ANCHOR = -4; + static final int ANCHOR = -1; + static final int LITERAL = -2; + static final int THREADSAFE_MODULE = -3; + static final int STATEFUL_MODULE = -4; private static final Integer ROOT_OBJ = new Integer(ROOT); private static final Integer LITERAL_OBJ = new Integer(LITERAL); @@ -223,14 +224,21 @@ } public final String resolve(InvokeContext context, Map objectModel) throws PatternException { - List mapStack = context.getMapStack(); + List mapStack = null; // = context.getMapStack(); + int stackSize = 0; StringBuffer result = new StringBuffer(); - int stackSize = mapStack.size(); - for (int i = 0; i < this.items.size(); i++) { int type = ((Integer)this.items.get(i)).intValue(); + + if (type >= ANCHOR && mapStack == null) { + if (context == null) { + throw new PatternException("Need an invoke context to resolve " + this); + } + mapStack = context.getMapStack(); + stackSize = mapStack.size(); + } if (type > 0) { // relative sitemap variable 1.3.2.2 +8 -1 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/VariableResolver.java Index: VariableResolver.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/VariableResolver.java,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -u -r1.3.2.1 -r1.3.2.2 --- VariableResolver.java 25 Nov 2002 21:52:01 -0000 1.3.2.1 +++ VariableResolver.java 9 Jan 2003 17:45:01 -0000 1.3.2.2 @@ -104,6 +104,13 @@ } /** + * Resolve all {...} patterns using the values given in the object model. + */ + public String resolve(Map objectModel) throws PatternException { + return resolve(null, objectModel); + } + + /** * Resolve all {...} patterns using the values given in the list of maps and the object model. */ public abstract String resolve(InvokeContext context, Map objectModel) throws PatternException;
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]