cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Ratcliffe" <a...@prema.co.nz>
Subject RE: Source Resolving Problem
Date Sun, 27 Feb 2005 21:48:59 GMT
Hi Claus

Here's an example of what you would like to do in flowscript:

/**
 * Returns a file representation of the resource identified by the
<code>uri</code>
 * parameter, or <code>null</code> if <code>uri</code> can not be
resolved
to a
 * file resource.
 *
 * @param uri the <code>uri</code> of the resource to be returned as a file
 */
function resolveToFile(uri)
{
    var resolver = null;
    var filesource = null;
    try {
       resolver =
cocoon.getComponent(Packages.org.apache.cocoon.environment.SourceResolver.RO
LE);
       filesource = resolver.resolveURI(uri);
       var file = new java.io.File(new java.net.URI(filesource.getURI()));
       return file;
    } finally {
       if(filesource != null) resolver.release(filesource);
       cocoon.releaseComponent(resolver);
    }
}

HTH
Adam
  -----Original Message-----
  From: Claus Straube [mailto:claus.straube@xdoo.de]
  Sent: Sunday, 27 February 2005 11:05 p.m.
  To: users@cocoon.apache.org
  Subject: Source Resolving Problem


  Hello,



  I try to get a file that I’ve uploaded before (I’ve copied the stream, so
it’s definitely in my upload folder). How can I reach the source now via a
java class? I wanted to get the correct path with that code:



       public String resolvePath(String path) {



          try {

              Source src = this.resolver.resolveURI(path);

              path = SourceUtil.getPath(src.getURI());

          } catch (Exception ex) {



              System.out.println(ex);

          }



          return path;

      }



  but it doesn’t work. What I would expect is, that this method will return
a path relative to my sitemap if I would give something like “context://” to
it. But it’ll return the same string, that I gave to it.



  Are there API Docs for the package “org.apache.excalibur.source”? I can’t
find anything… Is there a description how to resolve sources on the net? I
found the one in the dev guide, but that is not enough for me to understand.



  Best regards - Claus

  __________________________________________



  Claus Straube

  Francéstrasse 31

  80997 München

  +49 (089) 14 16 682



Mime
View raw message