camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Trying to use splitter to process list of URIs
Date Wed, 05 Sep 2012 06:20:00 GMT
Hi

It seems like you want to call a dynamic endpoint to grab the zip
file. And for that see this FAQ
http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html


On Tue, Sep 4, 2012 at 9:29 PM, clarkcb <clarkcb@gmail.com> wrote:
> Hello,
>
> I'm trying to create a route that reads an HTML directory index page,
> process it to get the list of zip files that are listed in the index, and
> split the list to grab each zip file separately. It's what to do after split
> that has me stumped. Here's what I have so far (it's Scala but using the
> Java RouteBuilder syntax):
>
>
> import org.apache.camel.builder.{RouteBuilder => JRouteBuilder}
> . . .
> class HtmlToZipFileListProcessor(url: String) extends Processor {
>   val FileLineRegex = """<li><a\shref=&quot;(.+?\.zip)&quot;>.+?\.zip
> </li>""".r
>
>   def fileNamesFromLines(lines: List[String]): List[String] = {
>     lines match {
>       case head :: tail =>
>         head match {
>           case FileLineRegex(filename) =>
>             (url + "/" + filename) :: fileNamesFromLines(tail)
>           case _ => fileNamesFromLines(tail)
>         }
>         case Nil => List[String]()
>     }
>   }
>
>   def process(exchange: Exchange): Unit = {
>     val lines =
> exchange.getIn.getBody(classOf[String]).split("""\n+""").toList
>     val filenames = fileNamesFromLines(lines)
>     exchange.getIn.setBody(filenames.mkString(",")) // set body.in to
> comma,separated list of URIs
>   }
> }
>
> class HttpZipCopyBuilder(timerString:String, indexUrl:String,
> targetDir:String) extends JRouteBuilder {
>   @Override
>   def configure() {
>     from(timerString).
>       to(indexUrl).
>       process(new HtmlToZipFileListProcessor(indexUrl)).
>       split(body().tokenize(",")).
>         to(body(classOf[String])). // trying to use the body as the URI
>         to("file://" + targetDir) // copy the file to targetDir
>   }
> }
>
> The thing that I can't figure out is how to get the step after split to
> treat the body as a URI.
>
> Thanks in advance for any guidance.
>
> Cary
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Trying-to-use-splitter-to-process-list-of-URIs-tp5718622.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Mime
View raw message