Return-Path: Delivered-To: apmail-jackrabbit-users-archive@locus.apache.org Received: (qmail 88906 invoked from network); 11 Dec 2007 14:44:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Dec 2007 14:44:56 -0000 Received: (qmail 81101 invoked by uid 500); 11 Dec 2007 14:44:44 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 81086 invoked by uid 500); 11 Dec 2007 14:44:44 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 81077 invoked by uid 99); 11 Dec 2007 14:44:44 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 06:44:44 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of fmandelbaum@gmail.com designates 64.233.184.235 as permitted sender) Received: from [64.233.184.235] (HELO wr-out-0506.google.com) (64.233.184.235) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Dec 2007 14:44:21 +0000 Received: by wr-out-0506.google.com with SMTP id c37so6397462wra for ; Tue, 11 Dec 2007 06:44:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; bh=usLVST859nmdO4BmVQQfiv15DS57aBq5sO2WIZDuEoo=; b=W4kB6wbVL+ajJahfBVQQiE/jcWzn2sbPS3dLqM/8C7MXSwYhMYIPVSrsfsWmfVxfwB+EEqfwSTh/6DHWU7Jrymg2syXZed+4thT2Ex0pm30hatrNlZT++AcvlNTVkgg4sozJDLQhfjVHds6M91K5zIuneU85w07XQHA6TRycfOw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=Sq6clh5DDIvbWGvBm2382/Hci//WwW0DaI8vvU5TQSxFbslzftTjRzPUwlesisjuiTqOUaGjSiKt+6DwmMS8JPVNku2eozSU286hpS8KZD+D3DjPzjHxrCovds3h7SL4PcIWC+0QSCKIiQjn/8FYzBm8IIcp5ioTmpBAU4VtmpM= Received: by 10.70.42.6 with SMTP id p6mr9840794wxp.1197384260262; Tue, 11 Dec 2007 06:44:20 -0800 (PST) Received: from ?192.168.1.10? ( [190.16.113.254]) by mx.google.com with ESMTPS id i39sm17156888wxd.2007.12.11.06.44.15 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 11 Dec 2007 06:44:17 -0800 (PST) Message-ID: <475EA239.2050504@gmail.com> Date: Tue, 11 Dec 2007 11:44:09 -0300 From: =?UTF-8?B?RmFiacOhbiBNYW5kZWxiYXVt?= User-Agent: Thunderbird 2.0.0.6 (X11/20071022) MIME-Version: 1.0 To: users@jackrabbit.apache.org Subject: Re: How do i get a stored file back from the repository? References: In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org File f = new File("file_retrieved_from_the_repo.txt"); Node contentNode = instance.session.getRootNode().getNode("/hello/world/test/jcr:content"); InputStream contentStream = contentNode.getProperty("jcr:data").getStream(); IOUtils.copy(contentStream, FileUtils.openOutputStream(f)); Please note the following: * This example was written QUICKLY, so it may have errors, double check everything, notably the XPATH for the getNode(). * The example uses IOUtils and FileUtils from Apache's Common IO lib (http://commons.apache.org/io/), you can copy the stream as you wish. Good luck! Christian Cronen escribió: > hey there, > i have saved a simple file called example.txt in my repository with the > following code lines. > root = instance.session.getRootNode(); > Node hello = root.addNode("hello"); > Node world = hello.addNode("world"); > world.setProperty("message", "Hello, > world!"); > Node test = world.addNode("test", > "nt:file"); > Node res = test.addNode("jcr:content", > "nt:resource"); > > File testfile = new > File("D:/example.txt"); > > world.setProperty("filename", > testfile.getName() ); > world.setProperty("size", > testfile.length() ); > FileInputStream in = new > FileInputStream(testfile); > res.setProperty("jcr:encoding", ""); > res.setProperty("jcr:mimeType", > "text/plain"); > res.setProperty("jcr:data", in ); > > Calendar lastModified = > Calendar.getInstance(); > lastModified.setTimeInMillis( > testfile.lastModified() ); > > res.setProperty("jcr:lastModified", > lastModified); > > instance.session.save(); > But now i could not get the file back from the repository. So my question > is what i have to do to get it back. > > Kind regards > Christian > > > Christian Cronen > Diplom-Student > > maxence solutions gmbh > phone > fax > cell > internet > skype > +49-(0)-2133-2599-0 > +49-(0)-2133-2599-29 > +49-(0)-160-90532507 > christian.cronen@maxence.de > christian.cronen > > > > Am Weissen Stein 1 > Stuerzelbergcenter > D - 41541 Dormagen > Sitz der Gesellschaft: Dormagen > Handelsregister: HRB 12561, Neuss > Geschäftsführer: Dipl.-Math. Ralf Granderath > www.maxence.de > > >