In response to my own post and in case anyone else notices the (seeming) lack
of feature for importing versioned nodes the following methods should handle
the problem (where the path argument is the parent path of the root node being
imported). There may still be other issues with it such as references which
I've not dealt with.
private void checkOutNodesPreImport(Session session, String path)
throws PathNotFoundException, RepositoryException {
Node n = (Node)session.getItem(path);
if (!n.isCheckedOut()) {
n.checkout();
}
NodeIterator iter = n.getNodes();
if (iter != null && iter.hasNext()) {
Node subNode = iter.nextNode();
checkOutNodesPreImport(session, subNode.getPath());
}
}
private void checkInNodesPostImport(Session session, String path)
throws PathNotFoundException, RepositoryException {
Node n = (Node)session.getItem(path);
if (n.isModified()) {
n.save();
}
if (n.isCheckedOut()) {
n.checkin();
}
NodeIterator iter = n.getNodes();
if (iter != null && iter.hasNext()) {
Node subNode = iter.nextNode();
checkInNodesPostImport(session, subNode.getPath());
}
}
All the best,
Benjamin
-----Original Message-----
From: Benjamin Brown [mailto:[email protected]]
Sent: 25 June 2010 14:47
To: [email protected]
Subject: ImportXML and checked-in nodes
Hi,
I'm trying to get importXML working for a system view export and it fails with
exceptions (message wording changes depending on whether workspace/session)
that the node I am trying to add to is checked in (I am using
IMPORT_UUID_COLLISION_REPLACE_EXISTING) . Now I know that in order to add nodes
I need to ensure they are checked out however I expected the importXML method
to do this automagically for me. If I need to do this manually before import
does anyone have some example recursive code that will avoid the system nodes
and/or just alter the paths in an import?
Many thanks,
Benjamin
______________________________________________________________________
This email has been scanned for viruses by www.epagency.net
If you consider this email spam, please forward it to [email protected]
______________________________________________________________________