use of org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException in project jackrabbit by apache.
the class TestAll method testWrite.
/**
* Test for writing a node type definition file. Writing is tested
* by writing and re-reading the test node types using an internal
* byte array. The resulting node type map is then compared to the
* original test node types.
*
* @throws IOException on IO errors
* @throws RepositoryException on repository errors
*/
public void testWrite() throws IOException, RepositoryException {
try {
ByteArrayOutputStream xml = new ByteArrayOutputStream();
NodeTypeWriter.write(xml, types, registry);
byte[] bytes = xml.toByteArray();
QNodeTypeDefinition[] output = NodeTypeReader.read(new ByteArrayInputStream(bytes));
assertTrue("write output", Arrays.equals(types, output));
} catch (InvalidNodeTypeDefException e) {
fail(e.getMessage());
}
}
use of org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException in project jackrabbit by apache.
the class RepositoryCopier method copyNodeTypes.
private void copyNodeTypes() throws RepositoryException {
NodeTypeRegistry sourceRegistry = source.getNodeTypeRegistry();
NodeTypeRegistry targetRegistry = target.getNodeTypeRegistry();
logger.info("Copying registered node types");
Collection<Name> existing = Arrays.asList(targetRegistry.getRegisteredNodeTypes());
Collection<QNodeTypeDefinition> register = new ArrayList<QNodeTypeDefinition>();
for (Name name : sourceRegistry.getRegisteredNodeTypes()) {
// TODO: what about modified node types?
if (!existing.contains(name)) {
register.add(sourceRegistry.getNodeTypeDef(name));
}
}
try {
targetRegistry.registerNodeTypes(register);
} catch (InvalidNodeTypeDefException e) {
throw new RepositoryException("Unable to copy node types", e);
}
}
Aggregations