Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 5619 invoked by uid 500); 18 May 2003 22:11:45 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 5604 invoked from network); 18 May 2003 22:11:44 -0000 Received: from smtp5.wanadoo.fr (HELO mwinf0403.wanadoo.fr) (193.252.22.27) by daedalus.apache.org with SMTP; 18 May 2003 22:11:44 -0000 Received: from anyware-tech.com (unknown [81.50.74.36]) by mwinf0403.wanadoo.fr (SMTP Server) with ESMTP id AF6DB500028A for ; Mon, 19 May 2003 00:11:50 +0200 (CEST) Message-ID: <3EC80527.20201@anyware-tech.com> Date: Mon, 19 May 2003 00:11:51 +0200 From: Sylvain Wallez Organization: Anyware Technologies User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2) Gecko/20021126 X-Accept-Language: fr, en, en-us MIME-Version: 1.0 To: cocoon-dev@xml.apache.org Subject: Re: source resolving help References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Geoff Howard wrote: >Source resolving in cocoon is pretty opaque to me - complicated >by the fact that the API docs aren't included at excalibur's site. >I've tried tracking this down through the source, but I'm never >confident that I've found the current best practice and not a >deprecated area. If there's a great example of how to do this, >or message from the archives feel free to point me there instead >but I haven't found anything clear for a source meant to be a >_destination_ as outlined below. > >Here's my situation: in a sitemap component (a file upload handler >which will move a PartOnDisk, or write out the stream of a >FileInMemory), I want to: >1) resolve a directory path relative to the current sitemap, >2) create a file in that directory, >3) write to the file one time, and close/release it as necessary. > >so, I could do (?) >FileSource fs = (FileSource)resolver.resolveURI("directory/filename.ext"); > Yes. >Then I guess I could do >orignalFile.renameTo(fs.getSystemId()) or > originalFile.renameTo(fs.getFile) would be better. >fs.getOutputStream() ?? > This what you'd like to do if you want to _copy_ the file, or fill the target file with some data that doesn't come from another file. >- Have I understood all this correctly? > Nearly ;-) >- What are the hidden gotchas? > You may look at ModifiableSource and SourceUtil.copy/move that give some higher abstraction. >- Do I need file:/directory/filename.ext ?? > For the source or the destination ? >- Can I use relative or absolute paths? (eg ../../directory or /var ) with this scheme? > The SourceResolver considers relative paths as starting from the current sitemap's directory. And you should be able to use ../.. if needed. Hope this helps, Sylvain -- Sylvain Wallez Anyware Technologies http://www.apache.org/~sylvain http://www.anyware-tech.com { XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }