jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Haderka <jan.hade...@magnolia.info>
Subject Re: Import of whole workspace
Date Fri, 04 Apr 2008 09:50:06 GMT
I had the same problem when trying to use the backup tool to restore
versions. What have been done there is unprotecting the node before
restoring into it:

NodeDefinitionImpl def = (NodeDefinitionImpl) parent.getDefinition();
NodeDefImpl nd = (NodeDefImpl) def.unwrap();
nd.setProtected(false);

Also, restoring versions every node in the hierarchy seems to be
protected after restoring it so I had to do this in SessionImporter
(just extend the default one and override createNode() method like 

protected NodeImpl createNode(NodeImpl parent, QName nodeName,
            QName nodeTypeName, QName[] mixinNames, NodeId id)
            throws RepositoryException {
        unprotect(parent);
	node = super.createNode(...)
	protect(parent);
	return node;
}

HTH,
Jan


On Fri, 2008-04-04 at 02:37 -0700, Roman Puchkovskiy wrote:
> Hi.
> 
> I'm trying to do the following: export whole workspace, then import it to
> another repository to blank workspace.
> Exporting using
> 
> session.exportSystemView("/", out, false, false);
> 
> Importing using
> 
> workspace.importXML("/", in,
> ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
> 
> In both cases I login to repository using SimpleCredentials with non-empty
> username/password, so it seems my code is allowed to read/write everything.
> And I get following:
> 
> 
> Caused by: javax.jcr.nodetype.ConstraintViolationException:
> /jcr:root/jcr:system/jcr:nodeTypes: cannot add a child to a protected node
> 	at
> org.apache.jackrabbit.core.NodeImpl.internalAddChildNode(NodeImpl.java:779)
> 	at org.apache.jackrabbit.core.NodeImpl.addNode(NodeImpl.java:1546)
> 	at
> org.apache.jackrabbit.core.xml.SessionImporter.createNode(SessionImporter.java:93)
> 	at
> org.apache.jackrabbit.core.xml.SessionImporter.startNode(SessionImporter.java:215)
> 	at
> org.apache.jackrabbit.core.xml.SysViewImportHandler.processNode(SysViewImportHandler.java:86)
> 	at
> org.apache.jackrabbit.core.xml.SysViewImportHandler.startElement(SysViewImportHandler.java:127)
> 	at
> org.apache.jackrabbit.core.xml.ImportHandler.startElement(ImportHandler.java:192)
> 	at
> org.apache.jackrabbit.commons.DefaultContentHandler.startElement(DefaultContentHandler.java:214)
> 	at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
> 	at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
> Source)
> 	at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
> 	at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> 	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> 	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> 	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> 	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> 	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
> 	at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
> 	at
> org.apache.jackrabbit.commons.DefaultContentHandler.parse(DefaultContentHandler.java:82)
> 	at
> org.apache.jackrabbit.commons.AbstractSession.importXML(AbstractSession.java:125)
> 
> Could someone help? Am I wrong trying to import at root? Or it's possible
> but I missed something?


Mime
View raw message