use of org.apache.jackrabbit.core.nodetype.NodeTypeRegistry in project jackrabbit by apache.
the class LostFromCacheIssueTest method setUp.
public void setUp() throws Exception {
super.setUp();
Workspace workspace = superuser.getWorkspace();
NamespaceRegistry namespaceRegistry = workspace.getNamespaceRegistry();
NodeTypeManager ntmgr = workspace.getNodeTypeManager();
NodeTypeRegistry nodetypeRegistry = ((NodeTypeManagerImpl) ntmgr).getNodeTypeRegistry();
try {
namespaceRegistry.registerNamespace(NAMESPACE_PREFIX, NAMESPACE_URI);
} catch (NamespaceException ignore) {
//already exists
}
QNodeTypeDefinition nodeTypeDefinition = new QNodeTypeDefinitionImpl(((SessionImpl) superuser).getQName(NODETYPE_1), Name.EMPTY_ARRAY, Name.EMPTY_ARRAY, true, false, true, false, null, QPropertyDefinition.EMPTY_ARRAY, QNodeDefinition.EMPTY_ARRAY);
try {
nodetypeRegistry.registerNodeType(nodeTypeDefinition);
} catch (InvalidNodeTypeDefException ignore) {
//already exists
}
nodeTypeDefinition = new QNodeTypeDefinitionImpl(((SessionImpl) superuser).getQName(NODETYPE_2), Name.EMPTY_ARRAY, Name.EMPTY_ARRAY, true, false, true, false, null, QPropertyDefinition.EMPTY_ARRAY, QNodeDefinition.EMPTY_ARRAY);
try {
nodetypeRegistry.registerNodeType(nodeTypeDefinition);
} catch (InvalidNodeTypeDefException ignore) {
//already exists
}
getOrCreate(superuser.getRootNode(), TESTNODE_PATH);
superuser.save();
}
use of org.apache.jackrabbit.core.nodetype.NodeTypeRegistry 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);
}
}
use of org.apache.jackrabbit.core.nodetype.NodeTypeRegistry in project jackrabbit-oak by apache.
the class RepositoryUpgrade method copyNodeTypes.
private void copyNodeTypes(NodeTypeManager ntMgr, ValueFactory valueFactory) throws RepositoryException {
NodeTypeRegistry sourceRegistry = source.getNodeTypeRegistry();
List<NodeTypeTemplate> templates = Lists.newArrayList();
for (Name name : sourceRegistry.getRegisteredNodeTypes()) {
String oakName = getOakName(name);
// skip built-in nodetypes (OAK-1235)
if (!ntMgr.hasNodeType(oakName)) {
QNodeTypeDefinition def = sourceRegistry.getNodeTypeDef(name);
templates.add(createNodeTypeTemplate(valueFactory, ntMgr, oakName, def));
}
}
ntMgr.registerNodeTypes(templates.toArray(new NodeTypeTemplate[templates.size()]), true);
}
Aggregations