Re: Using the output of a pipeline to call another pipeline?

2005-10-07 Thread Antonio Gallardo

Derek Hohls wrote:


Yes... but I am saying that the block itself does not
contain enough to really get going with real-world
situations.  The only code examples I could find for
Groovy were in the Wiki, and they dealt with SQL and
forms - not with how to go about creating an action.
 


This are not action-script samples in javascript?:

http://svn.apache.org/viewcvs.cgi/cocoon/blocks/bsf/trunk/samples/script-action/

You should search a little longer for the gold! ;-)

Best Regards,

Antonio Gallardo.

 


[EMAIL PROTECTED] 2005/10/02 05:02:13 AM 
   


Derek Hohls wrote:

 


(Just on the side here - sorry to disrupt the thread - I would
echo the support for more detailed info - tutorial + sets of 
examples would be *really* good - for creating Actions using
Javascript - this would open up an area of Cocoon for us 
non-Java gurus - Thanks...) 



   

To use action and/or generators writen in javascript, groovy, jpython et 
al, see the bsf block.


Best Regards,

Antonio Gallardo.


-
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 





 




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using the output of a pipeline to call another pipeline?

2005-10-06 Thread Derek Hohls
Yes... but I am saying that the block itself does not
contain enough to really get going with real-world
situations.  The only code examples I could find for
Groovy were in the Wiki, and they dealt with SQL and
forms - not with how to go about creating an action.

 [EMAIL PROTECTED] 2005/10/02 05:02:13 AM 
Derek Hohls wrote:

(Just on the side here - sorry to disrupt the thread - I would
echo the support for more detailed info - tutorial + sets of 
examples would be *really* good - for creating Actions using
Javascript - this would open up an area of Cocoon for us 
non-Java gurus - Thanks...) 
 

To use action and/or generators writen in javascript, groovy, jpython et 
al, see the bsf block.

Best Regards,

Antonio Gallardo.


-
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 




-- 
This message is subject to the CSIR's copyright, terms and conditions and
e-mail legal notice. Views expressed herein do not necessarily represent the
views of the CSIR.
 
CSIR E-mail Legal Notice
http://mail.csir.co.za/CSIR_eMail_Legal_Notice.html 
 
CSIR Copyright, Terms and Conditions
http://mail.csir.co.za/CSIR_Copyright.html 
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR
Legal Notice send a blank message with REQUEST LEGAL in the subject line to
[EMAIL PROTECTED]


This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their 
support.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using the output of a pipeline to call another pipeline?

2005-10-01 Thread Antonio Gallardo

Derek Hohls wrote:


(Just on the side here - sorry to disrupt the thread - I would
echo the support for more detailed info - tutorial + sets of 
examples would be *really* good - for creating Actions using
Javascript  - this would open up an area of Cocoon for us 
non-Java gurus - Thanks...) 
 

To use action and/or generators writen in javascript, groovy, jpython et 
al, see the bsf block.


Best Regards,

Antonio Gallardo.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using the output of a pipeline to call another pipeline?

2005-10-01 Thread Antonio Gallardo

Derek Hohls wrote:


(Just on the side here - sorry to disrupt the thread - I would
echo the support for more detailed info - tutorial + sets of 
examples would be *really* good - for creating Actions using
Javascript  - this would open up an area of Cocoon for us 
non-Java gurus - Thanks...) 

 


[EMAIL PROTECTED] 2005/09/30 09:09:10 AM 
   


Thank's for the replies,
Both using an action, and using a flowscript seem promising, but also
problematic.

For the flowscript solution to work, I need to read the xQuery result
from a cocoon pipeline. Unfortunately, cocoon.processPipelineTo() does
not work as in this example:
readImage() {
// get request uri in here somehow
var realfile =
cocoon.processPipelineTo(flow/locateimage+cocoon.getRequestUri());

//parse response
var realFilename = getFilenameFromResponse(realfile);

Cocoon.sendPage(flow/readimage/+realFileName);
}
processPipelineTo wants an outputstream to send the response to,
rather than storing it in a variable, as I need to do. Is there a way
around this?
 

You can also use a more specific methods instead of processPipelineTo(). 
See:

http://cocoon.apache.org/2.1/apidocs/org/apache/cocoon/components/flow/util/PipelineUtil.html

Best Regards,

Antonio Gallardo.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using the output of a pipeline to call another pipeline?

2005-09-30 Thread Jonas Lundberg
Thank's for the replies,
Both using an action, and using a flowscript seem promising, but also
problematic.

For the flowscript solution to work, I need to read the xQuery result
from a cocoon pipeline. Unfortunately, cocoon.processPipelineTo() does
not work as in this example:
readImage() {
   // get request uri in here somehow
   var realfile =
cocoon.processPipelineTo(flow/locateimage+cocoon.getRequestUri());

   //parse response
   var realFilename = getFilenameFromResponse(realfile);

   Cocoon.sendPage(flow/readimage/+realFileName);
}
processPipelineTo wants an outputstream to send the response to,
rather than storing it in a variable, as I need to do. Is there a way
around this?

The Action solution also seems promising, but I do not know how to
create actions, and I cannot find any tutorial about it.
I would need to know:
- how to read from a pipeline inside the action, and store the result
in a variable.
- how to store that resulting variable in a sitemap variable (I have
found tutorials describing that specific part)
- how to compile the action, and where to put it for Cocoon to find it.

I would really appreciate any responses!

Hans



On 9/27/05, Chris Marasti-Georg [EMAIL PROTECTED] wrote:
 I think you have 2 options - a reader, or an action.

 Your action could call the xquery, get the result, and put it in the
 returned map, making it visible to a subsequent read call (my syntax may
 not be perfect, it's been a while since I coded an action):

 map:match pattern=*/*/*.jpg
 map:act type=image-filename-resolver
 map:parameter name=virtual-uri
 value={1}/{2}/{3}.jpg/
 map:read
 src=http://myexistserver/exist/db/jpeg/{filename}/
 /map:act
 /map:match

 Or, implement a special reader that performs both steps... Calling the
 xquery, and then using the result to retrieve the actual image.  I'm not
 sure of the inner workings of readers, with respect to reading from a
 source other than the one that is passed in from the sitemap... My guess
 would be that the action would be a cleaner implementation.

 One other thought I just had, but have no idea how reasonable it would
 be, is to use a flowscript function like

 readImage() {
 // get request uri in here somehow
 var realfile =
 cocoon.processPipelineTo(flow/locateimage+cocoon.getRequestUri());

 //parse response
 var realFilename = getFilenameFromResponse(realfile);

 Cocoon.sendPage(flow/readimage/+realFileName);
 }

 External pipeline
 map:match pattern=**.jpg
 map:call name=readImage()/
 /map:match

 Internal pipeline:
 map:match pattern=flow/locateimage/**
 map:read src=http://myexistserver/exist/db/jpeg/{1}/
 /map:match
 map:match pattern=flow/readimage/**
 map:read src=http://myexistserver/exist/db/jpeg/{1}/
 /map:match

 Just some ideas, and I take no blame if nothing works... I waited to see
 if anyone else would pitch in 2 cents, and they didn't, so you get my
 penny instead ;)
 Good to see another person using eXist...
 Chris Marasti-Georg


  -Original Message-
  From: Jonas Lundberg [mailto:[EMAIL PROTECTED]
  Sent: Tuesday, September 27, 2005 11:54 AM
  To: users@cocoon.apache.org
  Subject: Re: Using the output of a pipeline to call another pipeline?
 
  Thanks for the replies, I'll explain in more detail then.
 
  The images are referenced in an HTML page, which means that
  the browser will request them separately after the page is
  sent. Do you propose that I somehow embed the image data in the page?
 
  All paths in the system are virtual. I use XML files to
  create virtual hierarchies, that gives depth and structure to
  a site. That means that the same contents can be rendered
  using several different site layouts, at the same time.
 
  Therefore, all images are stored in one big collection in the
  eXist database. To avoid that any two images get the same
  file name, each file is renamed when uploaded, and given a
  unique name (a number). The actual name, and the virtual path
  where it is to be shown, is stored in the meta data file.
 
  In the html page generation pipeline, I could put the new
  file name directly in the html page, but that would violate
  the separation between storage and presentation. The author
  of the document should decide what file name to present to
  the user, not the system. A strict separation between storage
  and presentation is a main point with my system.
 
  Also, if I execute an xquery to provide the file name, then I
  can at the same time check whether the metadata file states
  that the file is live or waiting. It should not be
  possible to retreive an image before it is published. And
  when I am doing that, I can also check whether the particular
  user requesting the file should be allowed to see it. If the
  user is not allowed to see the image, or if it is not there,
  I can simply send a different image.
 
  So, when the xquery has

Re: Using the output of a pipeline to call another pipeline?

2005-09-30 Thread Derek Hohls
(Just on the side here - sorry to disrupt the thread - I would
echo the support for more detailed info - tutorial + sets of 
examples would be *really* good - for creating Actions using
Javascript  - this would open up an area of Cocoon for us 
non-Java gurus - Thanks...) 

 [EMAIL PROTECTED] 2005/09/30 09:09:10 AM 
Thank's for the replies,
Both using an action, and using a flowscript seem promising, but also
problematic.

For the flowscript solution to work, I need to read the xQuery result
from a cocoon pipeline. Unfortunately, cocoon.processPipelineTo() does
not work as in this example:
readImage() {
// get request uri in here somehow
var realfile =
cocoon.processPipelineTo(flow/locateimage+cocoon.getRequestUri());

//parse response
var realFilename = getFilenameFromResponse(realfile);

Cocoon.sendPage(flow/readimage/+realFileName);
}
processPipelineTo wants an outputstream to send the response to,
rather than storing it in a variable, as I need to do. Is there a way
around this?

The Action solution also seems promising, but I do not know how to
create actions, and I cannot find any tutorial about it.
I would need to know:
- how to read from a pipeline inside the action, and store the result
in a variable.
- how to store that resulting variable in a sitemap variable (I have
found tutorials describing that specific part)
- how to compile the action, and where to put it for Cocoon to find it.

I would really appreciate any responses!

Hans



On 9/27/05, Chris Marasti-Georg  [EMAIL PROTECTED]  wrote:
 I think you have 2 options - a reader, or an action.

 Your action could call the xquery, get the result, and put it in the
 returned map, making it visible to a subsequent read call (my syntax may
 not be perfect, it's been a while since I coded an action):

 map:match pattern=*/*/*.jpg
 map:act type=image-filename-resolver
 map:parameter name=virtual-uri
 value={1}/{2}/{3}.jpg/
 map:read
 src=http://myexistserver/exist/db/jpeg/{filename}/
 /map:act
 /map:match

 Or, implement a special reader that performs both steps... Calling the
 xquery, and then using the result to retrieve the actual image. I'm not
 sure of the inner workings of readers, with respect to reading from a
 source other than the one that is passed in from the sitemap... My guess
 would be that the action would be a cleaner implementation.

 One other thought I just had, but have no idea how reasonable it would
 be, is to use a flowscript function like

 readImage() {
 // get request uri in here somehow
 var realfile =
 cocoon.processPipelineTo(flow/locateimage+cocoon.getRequestUri());

 //parse response
 var realFilename = getFilenameFromResponse(realfile);

 Cocoon.sendPage(flow/readimage/+realFileName);
 }

 External pipeline
 map:match pattern=**.jpg
 map:call name=readImage()/
 /map:match

 Internal pipeline:
 map:match pattern=flow/locateimage/**
 map:read src=http://myexistserver/exist/db/jpeg/{1}/
 /map:match
 map:match pattern=flow/readimage/**
 map:read src=http://myexistserver/exist/db/jpeg/{1}/
 /map:match

 Just some ideas, and I take no blame if nothing works... I waited to see
 if anyone else would pitch in 2 cents, and they didn't, so you get my
 penny instead ;)
 Good to see another person using eXist...
 Chris Marasti-Georg


  -Original Message-
  From: Jonas Lundberg [mailto:[EMAIL PROTECTED] 
  Sent: Tuesday, September 27, 2005 11:54 AM
  To: users@cocoon.apache.org 
  Subject: Re: Using the output of a pipeline to call another pipeline?
 
  Thanks for the replies, I'll explain in more detail then.
 
  The images are referenced in an HTML page, which means that
  the browser will request them separately after the page is
  sent. Do you propose that I somehow embed the image data in the page?
 
  All paths in the system are virtual. I use XML files to
  create virtual hierarchies, that gives depth and structure to
  a site. That means that the same contents can be rendered
  using several different site layouts, at the same time.
 
  Therefore, all images are stored in one big collection in the
  eXist database. To avoid that any two images get the same
  file name, each file is renamed when uploaded, and given a
  unique name (a number). The actual name, and the virtual path
  where it is to be shown, is stored in the meta data file.
 
  In the html page generation pipeline, I could put the new
  file name directly in the html page, but that would violate
  the separation between storage and presentation. The author
  of the document should decide what file name to present to
  the user, not the system. A strict separation between storage
  and presentation is a main point with my system.
 
  Also, if I execute an xquery to provide the file name, then I
  can at the same time check whether the metadata file states
  that the file is live or waiting. It should not be
  possible to retreive an image before it is published. And
  when I am doing that, I can also check whether the particular
  user requesting

Re: Using the output of a pipeline to call another pipeline?

2005-09-30 Thread Christoph Hermann
Derek Hohls schrieb:

Hello,

 Thank's for the replies,
 Both using an action, and using a flowscript seem promising, but also
 problematic.
 
 For the flowscript solution to work, I need to read the xQuery result
 from a cocoon pipeline. Unfortunately, cocoon.processPipelineTo() does
 not work as in this example:
 readImage() {
 // get request uri in here somehow
 var realfile =
 cocoon.processPipelineTo(flow/locateimage+cocoon.getRequestUri());
 
 //parse response
 var realFilename = getFilenameFromResponse(realfile);
 
 Cocoon.sendPage(flow/readimage/+realFileName);
 }
 processPipelineTo wants an outputstream to send the response to,
 rather than storing it in a variable, as I need to do. Is there a way
 around this?

Just do it like this (if i got you right):

var output = new Packages.java.io.ByteArrayOutputStream();
cocoon.processPipelineTo(flow/locateimage+cocoon.getRequestUri(),null,output);

var realFilename = getFilenameFromResponse(output.toString());
// or whatever you want to do with it

HTH
Christoph

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Using the output of a pipeline to call another pipeline?

2005-09-30 Thread Chris Marasti-Georg
Christoph's solution is probably the easiest one, but here's an example
of a simple action I wrote to simply call a URL and put the response in
the returned map.  Just compile it (need the cocoon jars on the
classpath), jar it up, and stick it in the web-inf/lib folder.  If
anyone notices anything bad, by all means let me know - I have hardly
dipped my toes into programming with cocoon, and this was actually the
first class I created for it.

package com.rjlg.mkb.repo.controller.cocoon;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;

public class RemoteXQLAction extends AbstractAction implements
ThreadSafe, Composable, Disposable
{
long created = System.currentTimeMillis();

public void compose(ComponentManager manager) throws
ComponentException {}

public Map act( Redirector redirector, SourceResolver resolver,
Map objectModel, String source, Parameters param ) throws Exception
{
String remoteURL = param.getParameter(url);
if (remoteURL == null) {
getLogger().error(Missing a url param);
return null;
}

Map map = new HashMap();

try{
URL url = new URL(remoteURL);
HttpURLConnection urlConnection =
(HttpURLConnection)url.openConnection();
urlConnection.setDoInput(true);
urlConnection.setDoOutput(false);
urlConnection.connect();

InputStream is = urlConnection.getInputStream();
ByteArrayOutputStream os = new
ByteArrayOutputStream();
byte[] b = new byte[2048];
int ret = 0;
while ((ret = is.read(b)) != -1) {
os.write(b, 0, ret);
}
String response = os.toString();
is.close();
os.close();
getLogger().debug(got back: +response);
map.put(response, response);

return(map);
} catch (Exception ex){
getLogger().error(Error connecting to/reading
from remote server: +remoteURL);
return null;
}
}

public void dispose() {
}
}

Chris Marasti-Georg
 

 -Original Message-
 From: Jonas Lundberg [mailto:[EMAIL PROTECTED] 
 Sent: Friday, September 30, 2005 3:09 AM
 To: users@cocoon.apache.org
 Subject: Re: Using the output of a pipeline to call another pipeline?
 
 Thank's for the replies,
 Both using an action, and using a flowscript seem promising, 
 but also problematic.
 
 For the flowscript solution to work, I need to read the 
 xQuery result from a cocoon pipeline. Unfortunately, 
 cocoon.processPipelineTo() does not work as in this example:
 readImage() {
// get request uri in here somehow
var realfile =
 cocoon.processPipelineTo(flow/locateimage+cocoon.getRequestUri());
 
//parse response
var realFilename = getFilenameFromResponse(realfile);
 
Cocoon.sendPage(flow/readimage/+realFileName);
 }
 processPipelineTo wants an outputstream to send the response 
 to, rather than storing it in a variable, as I need to do. Is 
 there a way around this?
 
 The Action solution also seems promising, but I do not know 
 how to create actions, and I cannot find any tutorial about it.
 I would need to know:
 - how to read from a pipeline inside the action, and store 
 the result in a variable.
 - how to store that resulting variable in a sitemap variable 
 (I have found tutorials describing that specific part)
 - how to compile the action, and where to put it for Cocoon 
 to find it.
 
 I would really appreciate any responses!
 
 Hans
 
 
 
 On 9/27/05, Chris Marasti-Georg [EMAIL PROTECTED] wrote:
  I think you have 2 options - a reader, or an action.
 
  Your action could call the xquery, get the result, and put 
 it in the 
  returned map, making it visible to a subsequent read call 
 (my syntax 
  may not be perfect, it's been a while since I coded an action):
 
  map:match

Re: Using the output of a pipeline to call another pipeline?

2005-09-30 Thread Jonas Lundberg
Thanks! The flowscript now works perfectly!
(I still have to check the Action.)

The final flowscript code was as follows (Just in case anyone else
wants to read this later...)

function getResource() {
var input = Packages.java.lang.String(cocoon.parameters[input]);

var output = new Packages.java.io.ByteArrayOutputStream();
cocoon.processPipelineTo(flow/locateimage/+input,null,output);
var realFileName = output.toString();

cocoon.sendPage(flow/readimage/+realFileName);
}

In the sitemap, I got:
map:flow language=javascript
map:script src=flowscript/shapeshifter.flow/
/map:flow

This is the first step, that matches my image:
   map:match pattern=images/**.jpg
   map:call function=getResource
   map:parameter name=input value={1}.jpg/
/map:call
   /map:match

This is the second step, that finds the real file name:
 map:match pattern=flow/locateimage/**.jpg
 map:generate src=xq/resource.xq type=xquery
   map:parameter name=input value={1}.jpg/
 /map:generate
 map:serialize type=text/
 /map:match

This is the final step, that reads the image from eXist:
map:match pattern=flow/readimage/**.jpg
 map:read type=image
src=http://guest:[EMAIL PROTECTED]:8080/cocoon/webdav/db/contents/jpeg/{1}.jpg
mime-type=text/jpg /
/map:match

As a test case, I have used an empty xQuery, just returning the parameter:

xquery version 1.0;
declare namespace request=http://exist-db.org/xquery/request;;
declare namespace xmldb=http://exist-db.org/xquery/xmldb;;
declare namespace xi=http://www.w3.org/2001/XInclude;;
data{$input}/data

Hans

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using the output of a pipeline to call another pipeline?

2005-09-27 Thread Upayavira

Jonas Lundberg wrote:

I've got a very basic question that I got stuck with maybe someone
can help me out?

I have a web publishing system that stores all images in eXist, using
a number as the file name, e.g. 44500.jpg

Each image has a metadata file, describing at what URL the image
should be shown (and also some other things, not shown here), e.g.
metadata
liveatwebdesign/cocoon/at/live
filenamebanner.jpg/filename
/metadata

In the html files, the url to the file points at its virutal location,
and virtual name, e.g. webdesign/cocoon/banner.jpg
Thus, I could write a cocoon sitemap matcher like this:

map:match pattern=*/*/*.jpg
  map:generate src=xq/{1}.xq type=xquery
   map:parameter name=file value={1}/{2}/{3}/
  /map:generate
? How to call the second pipeline with the result of the query?
/map:match

The xquery generates the file name to use in the second pipeline, like this
file
44500.jpg
/file

The image is then to be fetched from eXist using this pipeline:
map:match pattern=*.jpg
map:read type=image
  
src=http://guest:[EMAIL PROTECTED]:8080/cocoon/webdav/db/contents/jpeg/{1}.jpg

   mime-type=text/jpg /
/map:match

But how do I call the second pipeline, using the file name created by
the generator in the first pipeline? This is a very basic question,
but I got stuck with it anyway... Any ideas?


Surely all yo do is translate the results of the query into HTML using 
XSLT, you'd have img src=44500.jpg/, which would get your image 
directly out of your db for you.


Or am I missing something?

Regards, Upayavira


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Using the output of a pipeline to call another pipeline?

2005-09-27 Thread Derek Hohls


Its not clear what you mean by the "second pipeline" - do
you mean the **.jpg ? If so, can you not simply call that
from the page where it needs to appear? (And the page
itself is generated using the output from the first pipeline;
cinclude or simply a map:aggregate will feedthe XMLinto your 
page prior to a final transform.)

If you need more help, you may have to lay out your problem
a little more clearly.
 [EMAIL PROTECTED] 2005/09/27 11:40:16 AM I've got a very basic question that I got stuck with maybe someonecan help me out?I have a web publishing system that stores all images in eXist, usinga number as the file name, e.g. 44500.jpgEach image has a metadata file, describing at what URL the imageshould be shown (and also some other things, not shown here), e.g.metadataliveatwebdesign/cocoon/at/livefilenamebanner.jpg/filename/metadataIn the html files, the url to the file points at its virutal location,and virtual name, e.g. webdesign/cocoon/banner.jpgThus, I could write a cocoon sitemap matcher like this:map:match pattern="*/*/*.jpgmap:generate src="" type="xquery"map:parameter name="file" value="{1}/{2}/{3}"//map:generate? How to call the second pipeline with the result of the query?/map:matchThe xquery generates the file name to use in the second pipeline, like thisfile44500.jpg/fileThe image is then to be fetched from eXist using this pipeline:map:match pattern="*.jpg"map:read type="image"src=""mailto:.jpg" ?>.jpg" "mime-type="text/jpg "//map:matchBut how do I call the second pipeline, using the file name created bythe generator in the first pipeline? This is a very basic question,but I got stuck with it anyway... Any ideas?Hans-To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] 
-- 
This message is subject to the CSIR's copyright, terms and conditions and e-mail legal notice. 
Views expressed herein do not necessarily represent the views of the CSIR.
 
CSIR E-mail Legal Notice
 
CSIR Copyright, Terms and Conditions
 
For electronic copies of the CSIR Copyright, Terms and Conditions and the CSIR Legal Notice 
send a blank message with "REQUEST LEGAL" in the subject line to CSIR HelpDesk

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.




Re: Using the output of a pipeline to call another pipeline?

2005-09-27 Thread Jonas Lundberg
Thanks for the replies, I'll explain in more detail then.

The images are referenced in an HTML page, which means that the
browser will request them separately after the page is sent. Do you
propose that I somehow embed the image data in the page?

All paths in the system are virtual. I use XML files to create virtual
hierarchies, that gives depth and structure to a site. That means that
the same contents can be rendered using several different site
layouts, at the same time.

Therefore, all images are stored in one big collection in the eXist
database. To avoid that any two images get the same file name, each
file is renamed when uploaded, and given a unique name (a number). The
actual name, and the virtual path where it is to be shown, is stored
in the meta data file.

In the html page generation pipeline, I could put the new file name
directly in the html page, but that would violate the separation
between storage and presentation. The author of the document should
decide what file name to present to the user, not the system. A strict
separation between storage and presentation is a main point with my
system.

Also, if I execute an xquery to provide the file name, then I can at
the same time check whether the metadata file states that the file is
live or waiting. It should not be possible to retreive an image
before it is published. And when I am doing that, I can also check
whether the particular user requesting the file should be allowed to
see it. If the user is not allowed to see the image, or if it is not
there, I can simply send a different image.

So, when the xquery has created an xml file with the image:
file
44500.jpg
/file
Then I cannot send a HTML file with an img src... because the
browser has requested the actual image file. Also, if I do that, then
I have to check the user premissions, and the live-status of the image
again, when the browser requests the actual image.

If I instead simply cinclude the image then I will get
file
image data
/file
That would be an image embedded in XML, which is not what I want.

So, what I want to do is very basic:

First, I want to generate the internal file name using xQuery, given
the virtual path and the virtual file name. At the same time I check
whether the image is live ,and whether the particular user should be
allowed to view it.
Then, I want to call a different (internal) pipeline using the
resulting file name (embedded in the file/file tag) (for instance
44400.jpg) as the request, and return the result of that pipeline.

Any ideas now of how I can achieve that?

Hans








On 9/27/05, Derek Hohls [EMAIL PROTECTED] wrote:

 Its not clear what you mean by the second pipeline - do
 you mean the **.jpg ?  If so, can you not simply call that
 from the page where it needs to appear?  (And the page
 itself is generated using the output from the first pipeline;
 cinclude or simply a map:aggregate will feed the XML into your
 page prior to a final transform.)

 If you need more help, you may have to lay out your problem
 a little more clearly.

  [EMAIL PROTECTED] 2005/09/27 11:40:16 AM 

 I've got a very basic question that I got stuck with maybe someone
 can help me out?

 I have a web publishing system that stores all images in eXist, using
 a number as the file name, e.g. 44500.jpg

 Each image has a metadata file, describing at what URL the image
 should be shown (and also some other things, not shown here), e.g.
 metadata
 liveatwebdesign/cocoon/at/live
 filenamebanner.jpg/filename
 /metadata

 In the html files, the url to the file points at its virutal location,
 and virtual name, e.g. webdesign/cocoon/banner.jpg
 Thus, I could write a cocoon sitemap matcher like this:

 map:match pattern=*/*/*.jpg
 map:generate src=xq/{1}.xq type=xquery
 map:parameter name=file value={1}/{2}/{3}/
 /map:generate
 ? How to call the second pipeline with the result of the query?
 /map:match

 The xquery generates the file name to use in the second pipeline, like this
 file
 44500.jpg
 /file

 The image is then to be fetched from eXist using this pipeline:
 map:match pattern=*.jpg
 map:read type=image

 src=http://guest:[EMAIL 
 PROTECTED]:8080/cocoon/webdav/db/contents/jpeg/{1}.jpg
 
 mime-type=text/jpg /
 /map:match

 But how do I call the second pipeline, using the file name created by
 the generator in the first pipeline? This is a very basic question,
 but I got stuck with it anyway... Any ideas?

 Hans

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]


 --
 This message is subject to the CSIR's copyright, terms and conditions and
 e-mail legal notice.
 Views expressed herein do not necessarily represent the views of the CSIR.

 CSIR E-mail Legal Notice

 CSIR Copyright, Terms and Conditions

 For electronic copies of the CSIR Copyright, Terms and Conditions and the
 CSIR Legal Notice
 send a blank message with REQUEST LEGAL in the subject 

Re: Using the output of a pipeline to call another pipeline?

2005-09-27 Thread Jason Johnston
 snip /

 So, what I want to do is very basic:

 First, I want to generate the internal file name using xQuery, given
 the virtual path and the virtual file name. At the same time I check
 whether the image is live ,and whether the particular user should be
 allowed to view it.
 Then, I want to call a different (internal) pipeline using the
 resulting file name (embedded in the file/file tag) (for instance
 44400.jpg) as the request, and return the result of that pipeline.

 Any ideas now of how I can achieve that?


So to step back a bit, ignoring the XQuery/eXist details, what you really
are looking for is a way to set the src of a map:read by retrieving it
from an XML file, correct?

In Cocoon's sitemap processing, once the pipeline has been set up it
cannot be altered; in other words the contents of the XML stream cannot
affect the configuration of the pipeline components that are used. 
Therefore the only way you can set the reader src is to do it while the
pipeline is being set up, before the SAX stream starts.  This is done by
matchers, selectors, or actions, with the help of input modules.

So what you probably need is a custom action that examines the meta XML
file, extracts the proper image id from it, and passes that value along to
the reader.  The sitemap for this might look something like this (this is
from memory, so it may be a bit off; you'll want to check the docs.):

map:match pattern=*/*/*.jpg
  map:act type=get-image-id
map:parameter name=xquery value=xq/{1}.xq /
map:parameter name=file value={1}/{2}/{3} /
map:read src=blahblah/{imageId}.jpg ... /
  /map:act
  map:read src=failureimage.jpg /
/map:match

The get-image-id action class would take the parameters and use them to
get the proper image id from the xml file via xquery.  It would then
return that image id in the Map object with a key imageId, so that the
nested map:read has access to it as {imageId}.

If the image id request fails, due to insufficient permissions or other
conditions handled in the action logic, it would return null, which causes
the nested map:read to be ignored and the other map:read would be executed
instead to deliver the failure image to the client.

Another approach might be to use flowscript; the image-id extraction logic
would be coded in the flowscript and it would then sendPage() to an
internal pipeline with that id in its URI.

Does this help at all?
--Jason



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Using the output of a pipeline to call another pipeline?

2005-09-27 Thread Chris Marasti-Georg
I think you have 2 options - a reader, or an action.

Your action could call the xquery, get the result, and put it in the
returned map, making it visible to a subsequent read call (my syntax may
not be perfect, it's been a while since I coded an action):

map:match pattern=*/*/*.jpg
map:act type=image-filename-resolver
map:parameter name=virtual-uri
value={1}/{2}/{3}.jpg/
map:read
src=http://myexistserver/exist/db/jpeg/{filename}/
/map:act
/map:match

Or, implement a special reader that performs both steps... Calling the
xquery, and then using the result to retrieve the actual image.  I'm not
sure of the inner workings of readers, with respect to reading from a
source other than the one that is passed in from the sitemap... My guess
would be that the action would be a cleaner implementation.

One other thought I just had, but have no idea how reasonable it would
be, is to use a flowscript function like

readImage() {
// get request uri in here somehow
var realfile =
cocoon.processPipelineTo(flow/locateimage+cocoon.getRequestUri());

//parse response
var realFilename = getFilenameFromResponse(realfile);

Cocoon.sendPage(flow/readimage/+realFileName);
}

External pipeline
map:match pattern=**.jpg
map:call name=readImage()/
/map:match

Internal pipeline:
map:match pattern=flow/locateimage/**
map:read src=http://myexistserver/exist/db/jpeg/{1}/
/map:match
map:match pattern=flow/readimage/**
map:read src=http://myexistserver/exist/db/jpeg/{1}/
/map:match

Just some ideas, and I take no blame if nothing works... I waited to see
if anyone else would pitch in 2 cents, and they didn't, so you get my
penny instead ;)
Good to see another person using eXist...
Chris Marasti-Georg
 

 -Original Message-
 From: Jonas Lundberg [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, September 27, 2005 11:54 AM
 To: users@cocoon.apache.org
 Subject: Re: Using the output of a pipeline to call another pipeline?
 
 Thanks for the replies, I'll explain in more detail then.
 
 The images are referenced in an HTML page, which means that 
 the browser will request them separately after the page is 
 sent. Do you propose that I somehow embed the image data in the page?
 
 All paths in the system are virtual. I use XML files to 
 create virtual hierarchies, that gives depth and structure to 
 a site. That means that the same contents can be rendered 
 using several different site layouts, at the same time.
 
 Therefore, all images are stored in one big collection in the 
 eXist database. To avoid that any two images get the same 
 file name, each file is renamed when uploaded, and given a 
 unique name (a number). The actual name, and the virtual path 
 where it is to be shown, is stored in the meta data file.
 
 In the html page generation pipeline, I could put the new 
 file name directly in the html page, but that would violate 
 the separation between storage and presentation. The author 
 of the document should decide what file name to present to 
 the user, not the system. A strict separation between storage 
 and presentation is a main point with my system.
 
 Also, if I execute an xquery to provide the file name, then I 
 can at the same time check whether the metadata file states 
 that the file is live or waiting. It should not be 
 possible to retreive an image before it is published. And 
 when I am doing that, I can also check whether the particular 
 user requesting the file should be allowed to see it. If the 
 user is not allowed to see the image, or if it is not there, 
 I can simply send a different image.
 
 So, when the xquery has created an xml file with the image:
 file
 44500.jpg
 /file
 Then I cannot send a HTML file with an img src... because 
 the browser has requested the actual image file. Also, if I 
 do that, then I have to check the user premissions, and the 
 live-status of the image again, when the browser requests the 
 actual image.
 
 If I instead simply cinclude the image then I will get file 
 image data /file That would be an image embedded in XML, 
 which is not what I want.
 
 So, what I want to do is very basic:
 
 First, I want to generate the internal file name using 
 xQuery, given the virtual path and the virtual file name. At 
 the same time I check whether the image is live ,and whether 
 the particular user should be allowed to view it.
 Then, I want to call a different (internal) pipeline using 
 the resulting file name (embedded in the file/file tag) 
 (for instance
 44400.jpg) as the request, and return the result of that pipeline.
 
 Any ideas now of how I can achieve that?
 
 Hans
 
 
 
 
 
 
 
 
 On 9/27/05, Derek Hohls [EMAIL PROTECTED] wrote:
 
  Its not clear what you mean by the second pipeline - do 
 you mean the 
  **.jpg ?  If so, can you not simply call that from the page 
 where it 
  needs to appear?  (And the page itself is generated using 
 the output 
  from