jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Fry <Peter....@aquilaheywood.co.uk>
Subject remove invalid child node entries script
Date Fri, 27 Jul 2012 12:55:44 GMT
Hi,

I am using Apache Jackrabbit 2.4.1 (via Apache Chemistry JCR Bridge).

There are currently a number of corruptions in the repository:

i.e.

2012-07-27 13:44:00,122 ERROR NodeState 'e06ec16d-4b1e-48f7-87a8-689ef747ce72' references
inexistent child '{}documents.xml' with id 'ec7c210c-ad26-4337-a616-0d4cecfedeb2' [org.apache.jackrabbit.core.persistence.bundle.ConsistencyCheckerImpl]
(http--0.0.0.0-16891-2)

I am trying to figure out how I can translate this groovy script (also attached to the end
of this mail):

http://wiki.magnolia-cms.com/display/WIKI/JCR+Troubles+FAQs

Apache Jackrabbit is currently deployed as a resource adapter archive (RAR file)  in JBoss
As 7.1. It is accessed within Apache Chemistry via the JCR 2 API with the session being obtained
thus:

Context ctx = new InitialContext();
Repository repository = (Repository) ctx.lookup("java:/jca/DocumentStore") ;
Session ses = repository.login(new SimpleCredentials("someone", "secret".toCharArray()), "REPO");

It is from this point on that I am unclear, can I obtain a node, cast it to NodeImpl and then
get its NodeState? The script below then suggest that I need the persistence manager but will
that be available accessing a session looked up via JNDI? If so how do I get it?

Thanks,

Peter.

import info.magnolia.context.*;
import info.magnolia.*;
import java.util.*;
import info.magnolia.tools.*;
import org.apache.jackrabbit.core.state.*;

// define the repository:
reponame = "data";
hm = MgnlContext.getSystemContext().getHierarchyManager(reponame);

// configure the root node either by uuid or by path:
//node = hm.getContentByUUID("root_node_uuid");
node = hm.getContent("/path/to/root/node");

jcrNode = node.getJCRNode();
// The PersistenceManagerUtil class is part of the MagnoliaTools. Maybe someone can extend
the script so that we don't need the class?
pm = PersistenceManagerUtil.getPM(jcrNode);
checkNode(jcrNode,"");

def checkNode(jcrNode, prefix) {
  println(prefix + jcrNode.getName());
  state = pm.load(jcrNode.getNodeId());
  cl = new ChangeLog();
  childNodeEntries = state.getChildNodeEntries();
  for (childNodeEntry in childNodeEntries) {
    childnode = ContentUtil.getContentByUUID(reponame, childNodeEntry.getId().toString());
    if (childnode == null) {
      println("Subnode missing: " +childNodeEntry.getId().toString());
      // uncomment these lines if you want the corrupt child node entries to be deleted
/*      state.removeChildNodeEntry(childNodeEntry.getId());
      state.setStatus(ItemState.STATUS_STALE_MODIFIED);
      cl.modified(state);
      pm.store(cl);*/
    } else {
      // to visualize the hierarchy:
      checkNode(childnode.getJCRNode(),prefix+"....");
    }
  }
}

aquilaheywood - European Pensions Technology Provider of the Year 2012

This email and any files transmitted with it are confidential and intended solely for the
use of the individual or entity to which they are addressed. If you have received this communication
in error, please inform the sender by email immediately then delete the original e-mail and
any attachments from your system.

Aquila Group Holdings Limited. Registered in England No. 3613039.
Registered Office: Aquila House 35 London Road Redhill Surrey RH1 1NJ
Please think about your environment before printing
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message