Return-Path: Delivered-To: apmail-jackrabbit-users-archive@minotaur.apache.org Received: (qmail 33364 invoked from network); 16 Sep 2009 07:20:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Sep 2009 07:20:25 -0000 Received: (qmail 78044 invoked by uid 500); 16 Sep 2009 07:20:25 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 78019 invoked by uid 500); 16 Sep 2009 07:20:25 -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 78008 invoked by uid 99); 16 Sep 2009 07:20:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Sep 2009 07:20:25 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Sep 2009 07:20:14 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Mnonx-0005Q3-E1 for users@jackrabbit.apache.org; Wed, 16 Sep 2009 00:19:53 -0700 Message-ID: <25467222.post@talk.nabble.com> Date: Wed, 16 Sep 2009 00:19:53 -0700 (PDT) From: freak182 To: users@jackrabbit.apache.org Subject: Re: UUID In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: eman.nollase@gmail.com References: <9616867.post@talk.nabble.com> <9618986.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org Hello, I have problem retreiving the uuid? here is the scenario: when i save the file, here is the code: ................................. Node file = folder.addNode(name, "nt:file"); Node fileContent = file.addNode("jcr:content", "nt:resource"); fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE); session.save(); uuid = fileContent.getUUID(); ..this save fine and some metadata save in DB also including the uuid. Now i want to delete the file: Node nodeToRemove = session.getRootNode().getNode(path.substring(1)); String uuid = nodeToRemove.getUUID(); ---> error here if (nodeToRemove != null) { nodeToRemove.remove(); session.save(); // jcrFileStorageDao.delete(jcrFileStorageDao.loadByUUID(uuid)); } javax.jcr.UnsupportedRepositoryOperationException at org.apache.jackrabbit.core.NodeImpl.getUUID(NodeImpl.java:3040) how can i resolve this? thanks a lot. cheers. Christoph Kiehl-3 wrote: > > Michal Hybler wrote: > >> I have this method >> >> ws = session.getWorkspace(); >> manager = ws.getQueryManager(); >> query = manager.createQuery("select * from nt:unstructured where >> jcr:uuid >> = '"+id+"'",Query.SQL); >> QueryResult result = query.execute(); >> NodeIterator it = result.getNodes(); >> return it.nextNode(); >> with Id which I remembered when I insert file into jackrabbit. >> >> after that I run this code >> >> HashMap properties = new HashMap(); >> try { >> PropertyIterator iter = node.getProperties(); >> while(iter.hasNext()){ >> Property prop = iter.nextProperty(); >> if (!prop.getDefinition().isMultiple()) { >> properties.put(prop.getName(), prop.getValue().getString()); >> } >> >> } >> if (getResNode(node) != null) { >> Node resNode = getResNode(node); >> iter = resNode.getProperties(); >> while(iter.hasNext()){ >> Property prop = iter.nextProperty(); >> if (!prop.getDefinition().isMultiple()) { >> properties.put(prop.getName(), prop.getValue().getString()); >> } >> } >> } > > I don't know what getResNode(node) does, but I suppose it loads some other > node > which is different to the one retrieved by the query. If you remove this > if-block the uuids should be equal as far as I can see. > And as Brian already wrote: you should be better off using > session.getNodeByUUID() instead of using a query. This method performs > much > faster than a query. > > Cheers, > Christoph > > > -- View this message in context: http://www.nabble.com/UUID-tp9616867p25467222.html Sent from the Jackrabbit - Users mailing list archive at Nabble.com.