Return-Path: Delivered-To: apmail-jackrabbit-users-archive@minotaur.apache.org Received: (qmail 99254 invoked from network); 17 Sep 2009 05:38:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 17 Sep 2009 05:38:17 -0000 Received: (qmail 19868 invoked by uid 500); 17 Sep 2009 05:38:17 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 19803 invoked by uid 500); 17 Sep 2009 05:38:17 -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 19790 invoked by uid 99); 17 Sep 2009 05:38:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 17 Sep 2009 05:38:16 +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; Thu, 17 Sep 2009 05:38:05 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Mo9ge-00075e-Bj for users@jackrabbit.apache.org; Wed, 16 Sep 2009 22:37:44 -0700 Message-ID: <25485428.post@talk.nabble.com> Date: Wed, 16 Sep 2009 22:37:44 -0700 (PDT) From: freak182 To: users@jackrabbit.apache.org Subject: Re: UUID In-Reply-To: <90a8d1c00909160454i49ae64bcm71af097d84541914@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: eman.nollase@gmail.com References: <9616867.post@talk.nabble.com> <9618986.post@talk.nabble.com> <25467222.post@talk.nabble.com> <90a8d1c00909160219xd6b0b9bha5c875d079979321@mail.gmail.com> <25469884.post@talk.nabble.com> <90a8d1c00909160454i49ae64bcm71af097d84541914@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Hello, Sorry, is hould do this instead to get uuid: Node file =3D folder.addNode(name, "nt:file"); file.addMixin(JcrConstants.MIX_REFERENCEABLE); not the other way around. thanks a lot. cheers. Stefan Guggisberg wrote: >=20 > On Wed, Sep 16, 2009 at 12:39 PM, freak182 wrote= : >> >> Hello, >> >> it does not fail on the assert becuase i set this before saving: >> fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE); >> and i wonder why now it is not working? still when i access this: >> nodeToRemove.getUUID(); throws an exception. >=20 > can you provide a simple test case? > please also provide detailed information about your environment. >=20 > cheers > stefan >=20 >=20 >> >> cheers. >> >> >> Stefan Guggisberg wrote: >>> >>> On Wed, Sep 16, 2009 at 9:19 AM, freak182 >>> wrote: >>>> >>>> Hello, >>>> >>>> I have problem retreiving the uuid? >>>> here is the scenario: >>>> >>>> when i save the file, here is the code: >>>> >>>> ................................. >>>> >>>> Node file =3D folder.addNode(name, "nt:file"); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Node fileContent =3D file.add= Node("jcr:content", >>>> "nt:resource"); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fileContent.addMixin(JcrConst= ants.MIX_REFERENCEABLE); >>>> >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0session.save(); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0uuid =3D fileContent.getUUID(= ); >>>> >>>> ..this save fine and some metadata save in DB also including the uuid. >>>> >>>> Now i want to delete the file: >>>> >>>> Node nodeToRemove =3D session.getRootNode().getNode(path.substring(1))= ; >>>> =C2=A0String uuid =3D nodeToRemove.getUUID(); ---> error here >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0if (nodeToRemove !=3D null) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0{ >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0nodeToRemove.remove(); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0session.save(); >>>> >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0// >>>> jcrFileStorageDao.delete(jcrFileStorageDao.loadByUUID(uuid)); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0} >>>> >>>> javax.jcr.UnsupportedRepositoryOperationException >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> org.apache.jackrabbit.core.NodeImpl.getUUID(NodeImpl.java:3040) >>> >>> nodeToRemove is probably not mix:referenceable. you can test this by >>> adding >>> >>> assert(node.isNodeType(JcrConstants.MIX_REFERENCEABLE)); >>> >>> cheers >>> stefan >>> >>>> >>>> how can i resolve this? >>>> >>>> thanks a lot. >>>> cheers. >>>> >>>> >>>> Christoph Kiehl-3 wrote: >>>>> >>>>> Michal Hybler wrote: >>>>> >>>>>> I have this method >>>>>> >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0ws =3D session.getWorkspace(); >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0manager =3D ws.getQueryManager(); >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0query =3D manager.createQuery("select * from >>>>>> nt:unstructured where >>>>>> jcr:uuid >>>>>> =3D '"+id+"'",Query.SQL); >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0QueryResult result =3D query.execute(); >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0NodeIterator it =3D result.getNodes(); >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0return it.nextNode(); >>>>>> with Id which I remembered when I insert file into jackrabbit. >>>>>> >>>>>> after that I run this code >>>>>> >>>>>> HashMap properties =3D new HashMap(); >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0try { >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0PropertyIterator iter =3D node.getProperties(); >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0while(iter.hasNext()){ >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Property prop =3D iter.nextProperty()= ; >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!prop.getDefinition().isMultiple(= )) >>>>>> { >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0propertie= s.put(prop.getName(), >>>>>> prop.getValue().getString()); >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>>>>> >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0} >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0if (getResNode(node) !=3D null) { >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Node resNode =3D getResNode(node); >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0iter =3D resNode.getProperties(); >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0while(iter.hasNext()){ >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Property = prop =3D >>>>>> iter.nextProperty(); >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if >>>>>> (!prop.getDefinition().isMultiple()) { >>>>>> >>>>>> =C2=A0properties.put(prop.getName(), prop.getValue().getString()); >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>>>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0} >>>>> >>>>> 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 perform= s >>>>> 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. >>>> >>>> >>> >>> >> >> -- >> View this message in context: >> http://www.nabble.com/UUID-tp9616867p25469884.html >> Sent from the Jackrabbit - Users mailing list archive at Nabble.com. >> >> >=20 >=20 --=20 View this message in context: http://www.nabble.com/UUID-tp9616867p25485428= .html Sent from the Jackrabbit - Users mailing list archive at Nabble.com.