jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benjamin Brown <benjamin.br...@thisisnumero.com>
Subject RE: ImportXML and checked-in nodes
Date Thu, 01 Jul 2010 13:11:55 GMT
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:benjamin.brown@thisisnumero.com] 
Sent: 25 June 2010 14:47
To: users@jackrabbit.apache.org
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 spam@epagency.net
______________________________________________________________________

Mime
View raw message