Return-Path: Delivered-To: apmail-jackrabbit-users-archive@minotaur.apache.org Received: (qmail 35755 invoked from network); 12 May 2009 21:04:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 12 May 2009 21:04:24 -0000 Received: (qmail 29350 invoked by uid 500); 12 May 2009 21:04:23 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 29287 invoked by uid 500); 12 May 2009 21:04:23 -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 29276 invoked by uid 99); 12 May 2009 21:04:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 May 2009 21:04:23 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [82.199.75.25] (HELO ex-nl-e1.vanenburg.com) (82.199.75.25) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 May 2009 21:04:15 +0000 Received: from EX-NL-U1.vanenburg.com (10.1.36.17) by ex-nl-e1.vanenburg.com (192.168.23.15) with Microsoft SMTP Server (TLS) id 8.1.340.0; Tue, 12 May 2009 23:04:07 +0200 Received: from EX-NL-U1.vanenburg.com ([10.1.36.17]) by EX-NL-U1.vanenburg.com ([10.1.36.17]) with mapi; Tue, 12 May 2009 23:03:52 +0200 From: Stefan Droog To: "users@jackrabbit.apache.org" Date: Tue, 12 May 2009 23:03:52 +0200 Subject: Storing and retrieving PDF file Thread-Topic: Storing and retrieving PDF file Thread-Index: AQHJ00UnBd7J8V47bU2qb5XBr2EXTA== Message-ID: Accept-Language: nl-NL, en-US Content-Language: nl-NL X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: nl-NL, en-US Content-Type: multipart/alternative; boundary="_000_C55F36AD3838F44AA99978C58E96677E6CC2C35EEXNLU1vanenburg_" MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org --_000_C55F36AD3838F44AA99978C58E96677E6CC2C35EEXNLU1vanenburg_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I have some doubts about retrieving a pdf file from Jackrabbit. Currently I stored a PDF file in Jackrabbit like this: File newFile =3D new File("d:\\BIRTRefCard.pdf"); Repository repository =3D null; Session session =3D null; try { repository =3D new TransientRepository(); //jackrabbit's default JAAS LoginModule (SimpleLoginModule) is just a dummy //implementation which only distinguishes between anonymous/non-anonymous //login's. any non-anonymous login has full read/write permissions. session =3D repository.login(new SimpleCredentials("johndoe","password".toC= harArray())); Node root =3D session.getRootNode(); Node fileNode =3D root.addNode(newFile.getName(), "nt:file"); //create the mandatory child node - jcr:content Node resNode =3D fileNode.addNode("jcr:content", "nt:resource"); InputStream in =3D new FileInputStream(newFile); resNode.setProperty("jcr:mimeType", "application/pdf"); resNode.setProperty("jcr:data", in); Calendar lastModified =3D Calendar.getInstance(); lastModified.setTimeInMillis(newFile.lastModified()); resNode.setProperty("jcr:lastModified", lastModified); session.save(); } catch (LoginException e) { e.printStackTrace(); } catch (RepositoryException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { session.logout(); } But how can I get the pdf file back from the system? I tried something like the code below but I am not sure if it is the correc= t way. I want to stream this pdf to the client Node root =3D session.getRootNode(); Node content =3D root.getNode("BIRTRefCard.pdf/jcr:content"); final InputStream in =3D content.getProperty("jcr:data").getStream(); final String mime =3D content.getProperty("jcr:mimeType").getString(); ..... Pls help. Thanks in advance ________________________________ The information contained in this communication is confidential, intended s= olely for the use of the individual or entity to whom it is addressed and m= ay be legally privileged and protected by professional secrecy. Access to t= his message by anyone else is unauthorized. If you are not the intended rec= ipient, any disclosure, copying, or distribution of the message, or any act= ion or omission taken by you in reliance on it is prohibited and may be unl= awful. Please immediately contact the sender if you have received this mess= age in error. This email does not constitute any commitment from Cordys Hol= ding BV or any of its subsidiaries except when expressly agreed in a writte= n agreement between the intended recipient and Cordys Holding BV or its sub= sidiaries. Cordys is neither liable for the proper and complete transmissio= n of the information contained in this communication nor for any delay in i= ts receipt. Cordys does not guarantee that the integrity of this communicat= ion has been maintained nor that the communication is free of viruses, inte= rceptions or interference. If you are not the intended recipient of this co= mmunication please return the communication to the sender and delete and de= stroy all copies. --_000_C55F36AD3838F44AA99978C58E96677E6CC2C35EEXNLU1vanenburg_--