javax.jcr.NamespaceRegistry Java Examples

The following examples show how to use javax.jcr.NamespaceRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QNameComparatorTest.java    From jackrabbit-filevault with Apache License 2.0 6 votes vote down vote up
@Test
public void testCompare() {
    List<QName> names = new LinkedList<>();
    QName name1 = new QName("localonly");
    names.add(name1);
    QName name2 = new QName(XMLConstants.XML_NS_URI, "xhtml", XMLConstants.XML_NS_PREFIX);
    names.add(name2);
    QName name3 = new QName(NamespaceRegistry.NAMESPACE_JCR, "UpperCase", NamespaceRegistry.PREFIX_JCR);
    names.add(name3);
    QName name4 = new QName(NamespaceRegistry.NAMESPACE_JCR, "primaryType", NamespaceRegistry.PREFIX_JCR);
    names.add(name4);
    QName name5 = new QName(NamespaceRegistry.NAMESPACE_JCR, "PrimaryType", NamespaceRegistry.PREFIX_JCR);
    names.add(name5);
    Collections.sort(names, new QNameComparator());
    
    Assert.assertThat(names, Matchers.contains(name2, name5, name4, name3, name1));
}
 
Example #2
Source File: JcrSessionFactory.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Removes the namespaces.
 */
protected void unregisterNamespaces() throws Exception {

	if (namespaces == null || namespaces.isEmpty() || keepNewNamespaces)
		return;

	LOG.debug("unregistering custom namespaces " + namespaces);

	NamespaceRegistry registry = getSession().getWorkspace()
			.getNamespaceRegistry();

	for (Object key : namespaces.keySet()) {
		String prefix = (String) key;
		registry.unregisterNamespace(prefix);
	}

	if (forceNamespacesRegistration) {

		LOG.debug("reverting back overwritten namespaces "
				+ overwrittenNamespaces);
		if (overwrittenNamespaces != null)
			for (Map.Entry<String, String> entry : overwrittenNamespaces
					.entrySet()) {
				Map.Entry<String, String> namespace = entry;
				registry.registerNamespace(namespace.getKey(),
						namespace.getValue());
			}
	}
}
 
Example #3
Source File: NamespaceRegistryWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
public NamespaceRegistryWrapper(NamespaceRegistry jcr) {
    this.jcr = jcr;
}
 
Example #4
Source File: WorkspaceWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
    return new NamespaceRegistryWrapper(delegate.getNamespaceRegistry());
}
 
Example #5
Source File: WorkspaceImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
    return null;
}
 
Example #6
Source File: StorageUpdate0.java    From nextreports-server with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
private void createNodeTypes() throws RepositoryException {
   	Session session = SessionFactoryUtils.getSession(getTemplate().getSessionFactory(), false);
   	Workspace workspace = session.getWorkspace();
   	
   	LOG.info("Registering namespace 'next' -> http://nextreports.ro/jcr/2.0");
       NamespaceRegistry namespaceRegistry = workspace.getNamespaceRegistry();
       namespaceRegistry.registerNamespace("next", "http://nextreports.ro/jcr/2.0");

   	/*
       // check if the node type is registered already
	if (nodeTypeManager.hasNodeType(NEXT_REPORT_MIXIN)) {
		return;
	}
	*/

   	LOG.info("Creating node type mixin '" + StorageConstants.NEXT_REPORT_MIXIN + "'");
   	NodeTypeManagerImpl nodeTypeManager = (NodeTypeManagerImpl) workspace.getNodeTypeManager();
   	NodeTypeTemplate nodeTypeTemplate = nodeTypeManager.createNodeTypeTemplate();
   	nodeTypeTemplate.setName(StorageConstants.NEXT_REPORT_MIXIN);
   	nodeTypeTemplate.setMixin(true);
   	nodeTypeTemplate.setOrderableChildNodes(false);
   	nodeTypeTemplate.setPrimaryItemName("nt:unstructured");
   	nodeTypeTemplate.setDeclaredSuperTypeNames(new String[] { "mix:referenceable", "mix:versionable" });

   	/*
   	PropertyDefinitionTemplate propertyDefinitionTemplate = nodeTypeManager.createPropertyDefinitionTemplate();
   	propertyDefinitionTemplate.setName("*");
   	propertyDefinitionTemplate.setRequiredType(PropertyType.UNDEFINED);
   	propertyDefinitionTemplate.setAutoCreated(false);
   	propertyDefinitionTemplate.setMandatory(false);
   	propertyDefinitionTemplate.setOnParentVersion(OnParentVersionAction.COPY);
   	propertyDefinitionTemplate.setProtected(false);
   	propertyDefinitionTemplate.setMultiple(false);

   	nodeTypeTemplate.getPropertyDefinitionTemplates().add(propertyDefinitionTemplate);
   	*/

   	NodeDefinitionTemplate nodeDefinitionTemplate = nodeTypeManager.createNodeDefinitionTemplate();
   	nodeDefinitionTemplate.setName("runHistory");
   	nodeDefinitionTemplate.setDefaultPrimaryTypeName("nt:unstructured");
   	nodeDefinitionTemplate.setRequiredPrimaryTypeNames(new String[] { "nt:unstructured" });
   	nodeDefinitionTemplate.setAutoCreated(true);
   	nodeDefinitionTemplate.setMandatory(false);
   	nodeDefinitionTemplate.setOnParentVersion(OnParentVersionAction.IGNORE);
   	nodeDefinitionTemplate.setProtected(false);
   	nodeDefinitionTemplate.setSameNameSiblings(false);

   	nodeTypeTemplate.getNodeDefinitionTemplates().add(nodeDefinitionTemplate);

   	LOG.info("Registering node type mixin '" + StorageConstants.NEXT_REPORT_MIXIN + "'");
   	nodeTypeManager.registerNodeType(nodeTypeTemplate, true);

   	getTemplate().save();
}