eXo Platform 3.0

- Prev
- Next

## Chapter 11. Namespace altering

eXo JCR implementation since 1.11 version have support of altering namespaces.

## Adding new namespace

    ExtendedNamespaceRegistry namespaceRegistry = (ExtendedNamespaceRegistry) workspace.getNamespaceRegistry();
    namespaceRegistry.registerNamespace("newMapping", "http://dumb.uri/jcr");

## Changing existing namespace

    ExtendedNamespaceRegistry namespaceRegistry = (ExtendedNamespaceRegistry) workspace.getNamespaceRegistry();
    namespaceRegistry.registerNamespace("newMapping", "http://dumb.uri/jcr");
    namespaceRegistry.registerNamespace("newMapping2", "http://dumb.uri/jcr");
    try {
        assertNull(namespaceRegistry.getURI("newMapping"));
        fail("exception should have been thrown");
    } catch (NamespaceException e) {
    }
    assertNotNull(namespaceRegistry.getURI("newMapping2"));
    assertEquals("http://dumb.uri/jcr", namespaceRegistry.getURI("newMapping2"));

## Removing existing namespace

    ExtendedNamespaceRegistry namespaceRegistry = (ExtendedNamespaceRegistry) workspace.getNamespaceRegistry();
    namespaceRegistry.registerNamespace("newMapping", "http://dumb.uri/jcr");
    namespaceRegistry.unregisterNamespace("newMapping");

- Prev
- Up
- Home
- Next