cziegeler 2003/01/31 04:38:25
Added: src/java/org/apache/cocoon/components/source Tag:
cocoon_2_0_3_branch URLRewriter.java
SourceUtil.java
Log:
Backporting session, authentication and portal framework
Revision Changes Path
No revision
No revision
1.2.2.1 +0 -0
xml-cocoon2/src/java/org/apache/cocoon/components/source/URLRewriter.java
Index: URLRewriter.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/URLRewriter.java,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -u -r1.2 -r1.2.2.1
1.19.2.1 +22 -69
xml-cocoon2/src/java/org/apache/cocoon/components/source/SourceUtil.java
Index: SourceUtil.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/SourceUtil.java,v
retrieving revision 1.19
retrieving revision 1.19.2.1
diff -u -r1.19 -r1.19.2.1
--- SourceUtil.java 31 Jan 2003 09:07:06 -0000 1.19
+++ SourceUtil.java 31 Jan 2003 12:38:24 -0000 1.19.2.1
@@ -51,9 +51,7 @@
package org.apache.cocoon.components.source;
import java.io.IOException;
-import java.io.OutputStream;
import java.util.Iterator;
-import java.util.Map;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
@@ -61,15 +59,16 @@
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.ResourceNotFoundException;
+import org.apache.cocoon.environment.Source;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.environment.WriteableSource;
import org.apache.cocoon.xml.IncludeXMLConsumer;
import org.apache.cocoon.xml.XMLUtils;
import org.apache.cocoon.xml.dom.DOMBuilder;
import org.apache.cocoon.xml.dom.DOMStreamer;
-import org.apache.excalibur.source.Source;
import org.apache.excalibur.source.SourceException;
import org.apache.excalibur.source.SourceNotFoundException;
import org.apache.excalibur.source.SourceParameters;
-import org.apache.excalibur.source.SourceResolver;
import org.apache.excalibur.xmlizer.XMLizer;
import org.apache.regexp.RE;
import org.apache.regexp.RECompiler;
@@ -133,22 +132,16 @@
ContentHandler handler,
ComponentManager manager )
throws SAXException, IOException, ProcessingException {
- if ( source instanceof org.apache.excalibur.xml.sax.XMLizable ) {
- ((org.apache.excalibur.xml.sax.XMLizable)source).toSAX( handler );
- } else if ( source instanceof org.apache.cocoon.xml.XMLizable ) {
+ if ( source instanceof org.apache.cocoon.xml.XMLizable ) {
((org.apache.cocoon.xml.XMLizable)source).toSAX( handler );
} else {
- String mimeType = source.getMimeType();
- if ( null == mimeType) mimeType = mimeTypeHint;
XMLizer xmlizer = null;
try {
xmlizer = (XMLizer) manager.lookup( XMLizer.ROLE);
xmlizer.toSAX( source.getInputStream(),
- mimeType,
- source.getURI(),
+ mimeTypeHint,
+ source.getSystemId(),
handler );
- } catch (SourceException se) {
- throw SourceUtil.handle(se);
} catch (ComponentException ce) {
throw new ProcessingException("Exception during streaming source.",
ce);
} finally {
@@ -214,7 +207,7 @@
if (document==null) {
throw new ProcessingException("Could not build DOM for '"+
- source.getURI()+"'");
+ source.getSystemId()+"'");
}
return document;
@@ -268,14 +261,10 @@
*/
static public InputSource getInputSource(Source source)
throws IOException, ProcessingException {
- try {
- final InputSource newObject = new InputSource(source.getInputStream());
+ final InputSource newObject = new InputSource(source.getInputStream());
- newObject.setSystemId(source.getURI());
- return newObject;
- } catch (SourceException se) {
- throw handle(se);
- }
+ newObject.setSystemId(source.getSystemId());
+ return newObject;
}
/**
@@ -296,7 +285,7 @@
Parameters typeParameters,
SourceParameters resourceParameters,
SourceResolver resolver)
- throws IOException, SAXException, SourceException {
+ throws IOException, SAXException, ProcessingException, SourceException {
// first step: encode parameters which are already appended to the url
int queryPos = uri.indexOf('?');
@@ -360,13 +349,13 @@
uri = buf.toString();
}
}
- Map resolverParameters = new java.util.HashMap();
-
- resolverParameters.put(SourceResolver.METHOD, method);
- resolverParameters.put(SourceResolver.URI_PARAMETERS,
- resourceParameters);
+ Source source = resolver.resolve(uri);
+ if (method.equalsIgnoreCase("POST") == true
+ && source instanceof URLSource) {
+ ((URLSource)source).setPostParameters(resourceParameters);
+ }
- return resolver.resolveURI(uri, null, resolverParameters);
+ return source;
}
/**
@@ -404,46 +393,10 @@
frag.normalize();
- if (ws instanceof WriteableSAXSource) {
- ContentHandler contentHandler = ((WriteableSAXSource)
ws).getContentHandler();
- DOMStreamer streamer = new DOMStreamer(contentHandler);
+ ContentHandler contentHandler = ws.getContentHandler();
+ DOMStreamer streamer = new DOMStreamer(contentHandler);
- streamer.stream(frag);
- } else {
- // Lookup the Serializer
- // FIXME (CZ) : Due to the CM hierarchy we don't get the
- // correct serializer selector...
-// ComponentSelector selector = null;
-// Serializer serializer = null;
-// OutputStream oStream = null;
-// try {
-// selector =
(ComponentSelector)manager.lookup(Serializer.ROLE + "Selector");
-// serializer = (Serializer)selector.select(serializerName);
-// oStream = ws.getOutputStream();
-// serializer.setOutputStream(oStream);
-// DOMStreamer streamer = new DOMStreamer(serializer);
-// streamer.stream(frag);
-// } finally {
-// if (oStream != null) {
-// oStream.flush();
-// try {
-// oStream.close();
-// } finally {
-// if ( selector != null ) {
-// selector.release( serializer );
-// manager.release( selector );
-// }
-// }
-// }
-// }
- final String content = XMLUtils.serializeNode(frag,
-
XMLUtils.defaultSerializeToXMLFormat(false));
- OutputStream oStream = ws.getOutputStream();
-
- oStream.write(content.getBytes());
- oStream.flush();
- oStream.close();
- }
+ streamer.stream(frag);
} else {
// and now serializing...
// Lookup the Serializer
@@ -494,7 +447,7 @@
// } catch (ComponentException ce) {
// throw new ProcessingException("Exception during lookup of
component.", ce);
} finally {
- resolver.release(source);
+ if ( null != source) source.recycle();
}
}
@@ -536,7 +489,7 @@
} catch (SAXException ce) {
throw new ProcessingException(ce);
} finally {
- resolver.release(source);
+ if ( null != source) source.recycle();
}
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]