Return-Path: Delivered-To: apmail-jackrabbit-users-archive@locus.apache.org Received: (qmail 82534 invoked from network); 23 Jul 2008 14:23:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Jul 2008 14:23:08 -0000 Received: (qmail 53808 invoked by uid 500); 23 Jul 2008 14:23:07 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 53787 invoked by uid 500); 23 Jul 2008 14:23:07 -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 53776 invoked by uid 99); 23 Jul 2008 14:23:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jul 2008 07:23:06 -0700 X-ASF-Spam-Status: No, hits=3.2 required=10.0 tests=HTML_MESSAGE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.198.236] (HELO rv-out-0506.google.com) (209.85.198.236) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Jul 2008 14:22:12 +0000 Received: by rv-out-0506.google.com with SMTP id k40so2261368rvb.31 for ; Wed, 23 Jul 2008 07:22:36 -0700 (PDT) Received: by 10.141.88.3 with SMTP id q3mr98944rvl.94.1216822956819; Wed, 23 Jul 2008 07:22:36 -0700 (PDT) Received: by 10.141.122.15 with HTTP; Wed, 23 Jul 2008 07:22:36 -0700 (PDT) Message-ID: <272c2bf60807230722i2243524g143804696c59f613@mail.gmail.com> Date: Wed, 23 Jul 2008 10:22:36 -0400 From: "Nick Stuart" To: users@jackrabbit.apache.org Subject: Re: saving files In-Reply-To: <82670ba40807230716m43b7925wb9d72862d78d18c0@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_40047_29902525.1216822956804" References: <82670ba40807221022w7d56f206h2d5ca6e18385b645@mail.gmail.com> <488624DA.9000804@gmx.de> <82670ba40807221205t1d59daf5see3fde2703f8a617@mail.gmail.com> <82670ba40807230716m43b7925wb9d72862d78d18c0@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_40047_29902525.1216822956804 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline All you can really do is retrieve the InputStream for said file. Which should be enough, and the nodes hold the rest of the info if you need it obviously (file name, type, etc). Something like: Node resNode = fileNode.getNode("jcr:content"); resNode.getProperty("jcr:data").getStream(); Where fileNode is the jcr:file node type. You wont be able to actually get a File object becuase thats part of JCR, that it extracts that stuff away from you, and you just deal with the contents and info. -Nick On Wed, Jul 23, 2008 at 10:16 AM, Michael Harris wrote: > ladies and gentlemen > > its still not obvious to me how to retrieve the saved file. Can someone > please illuminate the situation? > > thanx in advance. > > On Tue, Jul 22, 2008 at 3:05 PM, Michael Harris < > michael.e.harris@gmail.com> > wrote: > > > comments inline below. Thank you for the response. > > > > On Tue, Jul 22, 2008 at 2:20 PM, Julian Reschke > > wrote: > > > >> Michael Harris wrote: > >> > >>> hey all, > >>> > >>> more newb questions here. > >>> Want to save a file in the repository. found this on the wiki > >>> > >>> Node folderNode = session.getRootNode(); > >>> Node fileNode = folderNode.addNode(file.getName(), "nt:file"); > >>> > >>> // create the mandatory child node - jcr:content > >>> Node resNode = fileNode.addNode("jcr:content", "nt:resource"); > >>> resNode.setProperty("jcr:mimeType", ""); > >>> resNode.setProperty("jcr:encoding", ""); > >>> > >> > ... > >> > >> That is very bad advice. If you don't know mimeType or encoding, do not > >> set it. > > > > > >> Where did you find that? > >> > > > > I got the code from the wiki. It had the mimetype and the encoding type. > > I modified the code and just put empty strings in for now. > > > > > > > >> > >> resNode.setProperty("jcr:data", new FileInputStream(file)); > >>> Calendar lastModified = Calendar.getInstance(); > >>> lastModified.setTimeInMillis(file.lastModified()); > >>> resNode.setProperty("jcr:lastModified", lastModified); > >>> > >>> Is the file itself being put in the repository (jcr.data) or just the > >>> content? > >>> > >> > >> The contents. > >> > >> Do I even need the resNode? Can I just save the file into the > fileNode? > >>> > >> > >> Not unless you use a different node type. > >> > > > > So does it mean anything to say "Can I save the file itself?" > > > > > > so the above code I put into a DAO method saveFile(File, Session). In > the > > test for that method, i have > > > > Node root = session.getRootNode(); > > // testFile is the file in the Dao > > Node fileNode = root.getNode(testFile.getName()); > > Node fileDetails = fileNode.getNode("jcr:content"); > > > > Property fileProp = fileDetails.getProperty("jcr:data"); > > > > I am trying to get at the file contents, which is just a string "some > > content". > > > > on the property retrieved I dont see the file content (Im in eclipse's > > debugger). How do I retrieve the file. What would a > > loadFile(Session, filename) method look like? > > > > > > > > > > > > > >> Finally, we are going to need to lock the file (which is why we are > using > >>> jcr). Is it possible to attach info (like who owns the lock) to the > >>> locked > >>> file? > >>> > >> > >> To some extent, that's part of the JCR locking model (it remembers who > >> owns the lock, and exposes the information both in the API and on > properties > >> defined in mix:lockable). > >> > >> Thanx. This community has been quite helpful. > >>> > >> > >> BR, Julian > >> > > > > > > > > -- > > --------------------- > > Michael Harris > > > > > > -- > --------------------- > Michael Harris > ------=_Part_40047_29902525.1216822956804--