You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sebastian Klamar <se...@tux.wh17.tu-dresden.de> on 2003/11/26 14:04:16 UTC

cocoon:/ does not work with SourceResolver (was: Re: Flow's processePipelineTo inside a Transformer?)

Bruno,

thank you for your reply.

* Bruno Dumon [2003-11-25 19:28 +0100] wrote:
> If you're writing a custom transformer, you can use the SourceResolver
> to resolve a cocoon: URL, which is similar to the processPipelineTo in
> flowscript.

I've tried this.  But for cocoon:/ and cocoon:// prefixed URLs (like
»cocoon://samples/«) I get no response.  The response has always mime
type text/xml and content length -1.  For http:// prefixed URLs (like
»http://localhost:8888/samples/«) resolveURI() works.  So what I'm doing
wrong?


TIA -- Sebastian

<mycodesnippet>

//  String uri = this.fragmentURIPrefix + fragmentID + this.fragmentURISuffix;
    String uri = "cocoon://samples/";
    Source source = null;
    source = this.sourceResolver.resolveURI(uri);
    try {
      source = this.sourceResolver.resolveURI(uri);
    } catch (MalformedURLException e) {
      getLogger().error(e);
    } catch (IOException e) {
      getLogger().error(e);
    }

</mycodesnippet>

-- 
Dinge, die man nicht hören will, wenn man operiert wird:
    »Alle bleiben ruhig stehen.  Ich hab' meine Kontaktlinsen verloren.«
************************************************************************
PGP Key: 0x1E727CE6 / 9085 48BD 8332 4BFC D80C  A6CF D162 20BB 1E72 7CE6

Re: cocoon:/ does not work with SourceResolver (was: Re: Flow's processePipelineTo inside a Transformer?)

Posted by Bruno Dumon <br...@outerthought.org>.
On Wed, 2003-11-26 at 21:32, Sebastian Klamar wrote:
> * Bruno Dumon [2003-11-26 14:29 +0100] wrote:
> > On Wed, 2003-11-26 at 14:04, Sebastian Klamar wrote:
> > > But for cocoon:/ and cocoon:// prefixed URLs (like
> > > »cocoon://samples/«) I get no response.  The response has always
> > > mime type text/xml and content length -1.
> >
> > Can you do source.getInputStream() and read data from the inputstream?
> 
> I can call source.getInputStream().available() that returns the same
> size as source.getContentLength() with http:// URI.  But I can't make
> reading from the InputStream.  I've tried the read() methods from
> InputStream interface
> 
>   byte[] bytes;
>   source.getInputStream().read(bytes);

is this a literal cut and paste from your code? You need to create the
byte array yourself:

byte[] bytes = new byte[10000];

though you should have gotten a NullPointerException in case you didn't
do that. See the javadoc of the InputStream.read  method for more info.

> 
> and
> 
>   source.getInputStream().read(bytes, int, ...getInputStream().length)

this obviously won't work, since getLength() returns -1.

> but both are blocking the whole process and no data gets read.  I've
> also tried to call close() on the InputStream.
> 
> Do you easily see what I'm doing wrong?  If not I can provide more
> information about IOExceptions that were thrown when trying various
> methods tomorrow (no read() but close(), only available() w/ and wo
> close() ...).

If you think you found a bug, best of all would be a full example (full
Java class + pipelines etc. to reproduce the problem) that illustrates
the problem, so that we can reproduce it (submit it to bugzilla in that
case).

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: cocoon:/ does not work with SourceResolver (was: Re: Flow's processePipelineTo inside a Transformer?)

Posted by Sebastian Klamar <se...@tux.wh17.tu-dresden.de>.
* Bruno Dumon [2003-11-26 14:29 +0100] wrote:
> On Wed, 2003-11-26 at 14:04, Sebastian Klamar wrote:
> > But for cocoon:/ and cocoon:// prefixed URLs (like
> > »cocoon://samples/«) I get no response.  The response has always
> > mime type text/xml and content length -1.
>
> Can you do source.getInputStream() and read data from the inputstream?

I can call source.getInputStream().available() that returns the same
size as source.getContentLength() with http:// URI.  But I can't make
reading from the InputStream.  I've tried the read() methods from
InputStream interface

  byte[] bytes;
  source.getInputStream().read(bytes);

and

  source.getInputStream().read(bytes, int, ...getInputStream().length)

but both are blocking the whole process and no data gets read.  I've
also tried to call close() on the InputStream.

Do you easily see what I'm doing wrong?  If not I can provide more
information about IOExceptions that were thrown when trying various
methods tomorrow (no read() but close(), only available() w/ and wo
close() ...).


TIA -- Sebastian

-- 
Dinge, die man nicht hören will, wenn man operiert wird:
                          »Und nun noch ein Bild aus der Richtung; Mann,
                                          das ist wirklich ein Monster.«
************************************************************************
PGP Key: 0x1E727CE6 / 9085 48BD 8332 4BFC D80C  A6CF D162 20BB 1E72 7CE6

Re: cocoon:/ does not work with SourceResolver (was: Re: Flow's processePipelineTo inside a Transformer?)

Posted by Bruno Dumon <br...@outerthought.org>.
On Wed, 2003-11-26 at 14:04, Sebastian Klamar wrote:
> Bruno,
> 
> thank you for your reply.
> 
> * Bruno Dumon [2003-11-25 19:28 +0100] wrote:
> > If you're writing a custom transformer, you can use the SourceResolver
> > to resolve a cocoon: URL, which is similar to the processPipelineTo in
> > flowscript.
> 
> I've tried this.  But for cocoon:/ and cocoon:// prefixed URLs (like
> »cocoon://samples/«) I get no response.  The response has always mime
> type text/xml and content length -1.

Can you do source.getInputStream() and read data from the inputstream?

The content length being -1 is normal behaviour. The javadoc for the
Source interface (part of Avalon Excalibur) states that -1 is returned
when the content length is unknown.

The fact that the mime type is always text/xml might be a bug, don't
know.

-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org