Return-Path: Delivered-To: apmail-jackrabbit-users-archive@minotaur.apache.org Received: (qmail 90629 invoked from network); 3 Sep 2009 18:20:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 3 Sep 2009 18:20:32 -0000 Received: (qmail 1332 invoked by uid 500); 3 Sep 2009 18:20:31 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 1296 invoked by uid 500); 3 Sep 2009 18:20:31 -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 1285 invoked by uid 99); 3 Sep 2009 18:20:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Sep 2009 18:20:31 +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 (nike.apache.org: domain of mitziuro@gmail.com designates 209.85.218.206 as permitted sender) Received: from [209.85.218.206] (HELO mail-bw0-f206.google.com) (209.85.218.206) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Sep 2009 18:20:22 +0000 Received: by bwz2 with SMTP id 2so139509bwz.43 for ; Thu, 03 Sep 2009 11:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=Yu1E+2zS1l3fcXgQBt/nPI4UtroOT/7Y02T9S00J9+E=; b=lGR54xJhZzMXITAjTtqqN7oG19juFgEBfCiniqvMXPrgpvmYc2lNmOZnyWnWAXv8aZ lzVB5frQgmPuUbuygmh2IymsIfdgynDq6g/6qr3zBeOu6YGbP6kfgclY9NoipI7kxWPH KaCRq/koAv6fJyBZCX3Aa66fpKYmPb9bu4txs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=JHz5Idtg8601oZa2z8W/eVi5spurxeTFVWIHGHAegVblObvTTRaKjj2ZjIomIgHtTe nMOE2QUqgSYosLCUuX2nA1bkG2SdW7G/lNWbxNg7/HoQ0f8wfyHWVleqXZSNbZBEyiGK unrGrJeCFq23no0Mq55BxhC1sBp4J2KvE6Ai8= MIME-Version: 1.0 Received: by 10.204.20.138 with SMTP id f10mr764443bkb.212.1252002001485; Thu, 03 Sep 2009 11:20:01 -0700 (PDT) In-Reply-To: <2bc800bc0909031115l48743b8fn51a2165610fa7ddc@mail.gmail.com> References: <2bc800bc0909030140x400084f2w3c937c677533a343@mail.gmail.com> <2bc800bc0909031115l48743b8fn51a2165610fa7ddc@mail.gmail.com> Date: Thu, 3 Sep 2009 21:20:01 +0300 Message-ID: <2bc800bc0909031120k35038bd5gc59de33b9a8064a9@mail.gmail.com> Subject: Re: Delete problem From: mitziuro To: users@jackrabbit.apache.org Content-Type: multipart/alternative; boundary=000325558ee68e81950472b06e72 X-Virus-Checked: Checked by ClamAV on apache.org --000325558ee68e81950472b06e72 Content-Type: text/plain; charset=ISO-8859-1 So, I have the following code for deleting a node: VersionHistory vh = null; boolean versionable = false; String uuid = node.getUUID(); try { // check if node is versionable if (((NodeImpl) node).isNodeType(NameConstants.MIX_VERSIONABLE)) { node.checkout(); logger.debug("node is versionable...get version history"); vh = node.getVersionHistory(); versionable = true; } } catch (Exception e) { // just log the exception...don't throw it logger.debug("Error at getting the version history for node: " .concat(uuid), e); } Node child = null; // before removing the node, first remove all its children and their versions NodeIterator nit = node.getNodes(); while(nit.hasNext()){ child = nit.nextNode(); // check if the child is rep:policy if (child.getPrimaryNodeType().isNodeType(NODE_TYPE_ACL)) { //no op. rep:policy children are deleted automatically } else{ // delete the child and its subtree and their versions delete(session, child); } } node.remove(); session.save(); try { // check if node is versionable if (versionable) { logger.debug("node is versionable...delete all versions"); // delete version history VersionIterator vit = vh.getAllVersions(); // skip the root version(it cannot be deleted) vit.skip(1); Version v = null; while (vit.hasNext()) { v = vit.nextVersion(); vh.removeVersion(v.getName()); } } } catch (Exception e) { // just log the exception...don't throw it logger.error("Error at deleting versions for node: ".concat(uuid), e); and after that i'm commiting the transaction started before: DMETransaction.getInstance().commit((Session) args[0]) with the code public void commit(Session s) { logger.debug("-----< comit transaction >-------"); Xid xid = null; try { XASession session = (XASession) s; // get XAResource XAResource xares = session.getXAResource(); xid = xids.get(s.toString()); //commit transaction xares.end(xid, XAResource.TMSUCCESS); xares.prepare(xid); xares.commit(xid, false); //remove xid that unique identifies this transaction xids.remove(s.toString()); } catch(Exception e) { logger.error("", e); } } and i've got this: javax.jcr.ReferentialIntegrityException: feea1825-175a-4579-a894-efb217b1a779: the node cannot be removed because it is still being referenced. Is there a way to include the version delete process in the same transaction with the node ? --000325558ee68e81950472b06e72--