Examples of NamespaceRegistry


Examples of javax.jcr.NamespaceRegistry

    //--------------------------------------------------------------------------
    protected void initProperties() {
        super.initProperties();
        try {
            // init workspace specific properties
            NamespaceRegistry nsReg = getRepositorySession().getWorkspace().getNamespaceRegistry();
            DavProperty namespacesProp = new NamespacesProperty(nsReg);
            properties.add(namespacesProp);
        } catch (RepositoryException e) {
            log.error("Failed to access NamespaceRegistry: " + e.getMessage());
        }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

        assertThat(workspace.getName(), is(workspaceName));
    }

    @Test
    public void shouldProvideNamespaceRegistry() throws Exception {
        NamespaceRegistry registry = workspace.getNamespaceRegistry();
        assertThat(registry, is(notNullValue()));
        assertThat(registry.getURI(JcrLexicon.Namespace.PREFIX), is(JcrLexicon.Namespace.URI));
    }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

    }

    @Test
    public void testMappings() throws Exception {
        final ContentSession session = createContentSession();
        NamespaceRegistry r = new ReadWriteNamespaceRegistry() {
            @Override
            protected Tree getReadTree() {
                return session.getLatestRoot().getTree("/");
            }
            @Override
            protected Root getWriteRoot() {
                return session.getLatestRoot();
            }
        };

        assertEquals("", r.getURI(""));
        assertEquals("http://www.jcp.org/jcr/1.0", r.getURI("jcr"));
        assertEquals("http://www.jcp.org/jcr/nt/1.0", r.getURI("nt"));
        assertEquals("http://www.jcp.org/jcr/mix/1.0", r.getURI("mix"));
        assertEquals("http://www.w3.org/XML/1998/namespace", r.getURI("xml"));

        assertEquals("", r.getPrefix(""));
        assertEquals("jcr", r.getPrefix("http://www.jcp.org/jcr/1.0"));
        assertEquals("nt", r.getPrefix("http://www.jcp.org/jcr/nt/1.0"));
        assertEquals("mix", r.getPrefix("http://www.jcp.org/jcr/mix/1.0"));
        assertEquals("xml", r.getPrefix("http://www.w3.org/XML/1998/namespace"));

        r.registerNamespace("p", "n");
        assertEquals(r.getURI("p"), "n");
        assertEquals(r.getPrefix("n"), "p");

        r.registerNamespace("p2", "n2");
        assertEquals(r.getURI("p2"), "n2");
        assertEquals(r.getPrefix("n2"), "p2");

    }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

        assertFalse(ntMgr.hasNodeType("foo"));
    }

    @Test
    public void testNamespaceRegistry() throws RepositoryException {
        NamespaceRegistry nsReg =
                getAdminSession().getWorkspace().getNamespaceRegistry();
        assertFalse(asList(nsReg.getPrefixes()).contains("foo"));
        assertFalse(asList(nsReg.getURIs()).contains("file:///foo"));

        nsReg.registerNamespace("foo", "file:///foo");
        assertTrue(asList(nsReg.getPrefixes()).contains("foo"));
        assertTrue(asList(nsReg.getURIs()).contains("file:///foo"));

        nsReg.unregisterNamespace("foo");
        assertFalse(asList(nsReg.getPrefixes()).contains("foo"));
        assertFalse(asList(nsReg.getURIs()).contains("file:///foo"));
    }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

        assertFalse(asList(nsReg.getURIs()).contains("file:///foo"));
    }

    @Test
    public void sessionRemappedNamespace() throws RepositoryException {
        NamespaceRegistry nsReg =
                getAdminSession().getWorkspace().getNamespaceRegistry();
        nsReg.registerNamespace("foo", "file:///foo");

        getAdminSession().getRootNode().addNode("foo:test");
        getAdminSession().save();

        Session s = createAdminSession();
        s.setNamespacePrefix("bar", "file:///foo");
        assertTrue(s.getRootNode().hasNode("bar:test"));
        Node n = s.getRootNode().getNode("bar:test");
        assertEquals("bar:test", n.getName());
        s.logout();

        getAdminSession().getRootNode().getNode("foo:test").remove();
        getAdminSession().save();
        nsReg.unregisterNamespace("foo");
    }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

        nsReg.unregisterNamespace("foo");
    }

    @Test
    public void registryRemappedNamespace() throws RepositoryException {
        NamespaceRegistry nsReg =
                getAdminSession().getWorkspace().getNamespaceRegistry();
        nsReg.registerNamespace("foo", "file:///foo");

        getAdminSession().getRootNode().addNode("foo:test");
        getAdminSession().save();

        try {
            nsReg.registerNamespace("bar", "file:///foo");
            fail("Remapping namespace through NamespaceRegistry must not be allowed");
        } catch (NamespaceException e) {
            // expected
        } finally {
            getAdminSession().getRootNode().getNode("foo:test").remove();
            getAdminSession().save();

            nsReg.unregisterNamespace("foo");
        }
    }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

        mixLockable = superuser.getNamespacePrefix(NS_MIX_URI) + ":lockable";
        ntQuery = superuser.getNamespacePrefix(NS_NT_URI) + ":query";

        // setup custom namespaces
        if (isSupported(Repository.LEVEL_2_SUPPORTED)) {
            NamespaceRegistry nsReg = superuser.getWorkspace().getNamespaceRegistry();
            String namespaces = getProperty(RepositoryStub.PROP_NAMESPACES);
            if (namespaces != null) {
                String[] prefixes = namespaces.split(" ");
                for (int i = 0; i < prefixes.length; i++) {
                    String uri = getProperty(RepositoryStub.PROP_NAMESPACES + "." + prefixes[i]);
                    if (uri != null) {
                        try {
                            nsReg.getPrefix(uri);
                        } catch (NamespaceException e) {
                            // not yet registered
                            nsReg.registerNamespace(prefixes[i], uri);
                        }
                    }
                }
            }
        }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

     * {@inheritDoc}
     */
    public Map<String, String> getRegisteredNamespaces(SessionInfo sessionInfo)
            throws RepositoryException {
        SessionInfoImpl sInfo = getSessionInfoImpl(sessionInfo);
        NamespaceRegistry nsReg = sInfo.getSession().getWorkspace().getNamespaceRegistry();
        Map<String, String> namespaces = new HashMap<String, String>();
        for (String prefix : nsReg.getPrefixes()) {
            namespaces.put(prefix, nsReg.getURI(prefix));
        }
        return namespaces;
    }
View Full Code Here

Examples of org.andromda.core.namespace.NamespaceRegistry

                {
                    final Namespaces namespacesConfiguration = Namespaces.instance();
                    for (final Iterator iterator = namespacesConfiguration.getNamespaceRegistries().iterator();
                        iterator.hasNext();)
                    {
                        final NamespaceRegistry namespaceRegistry = (NamespaceRegistry)iterator.next();
                        final String namespaceRegistryName = namespaceRegistry.getName();
                        if (!modelNamespaces.contains(namespaceRegistryName))
                        {
                            this.registerMetafacadeClasses(
                                metafacadeClasses,
                                namespacesConfiguration,
View Full Code Here

Examples of org.andromda.core.namespace.NamespaceRegistry

     * @param namespaceName the name of the namespace.
     * @return the list of properties contained in the namespace.
     */
    public PropertyDefinition[] getPropertyDefinitions(final String namespaceName)
    {
        final NamespaceRegistry registry = this.getRegistry(namespaceName);
        return registry == null ? new PropertyDefinition[0] : registry.getPropertyDefinitions();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.