Examples of NamespaceRegistry


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 javax.jcr.NamespaceRegistry

     */
    public void registerNamespace(SessionInfo sessionInfo,
                                  String prefix,
                                  String uri) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
        Session session = getSessionInfoImpl(sessionInfo).getSession();
        NamespaceRegistry nsReg = session.getWorkspace().getNamespaceRegistry();
        nsReg.registerNamespace(prefix, uri);
    }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

     * {@inheritDoc}
     */
    public void unregisterNamespace(SessionInfo sessionInfo, String uri)
            throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
        Session session = getSessionInfoImpl(sessionInfo).getSession();
        NamespaceRegistry nsReg = session.getWorkspace().getNamespaceRegistry();
        nsReg.unregisterNamespace(nsReg.getPrefix(uri));
    }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

        if (getResourceResolverType() == ResourceResolverType.JCR_MOCK) {
            try {
                // dummy namespace registrations to make sure sling JCR resolver
                // does not get mixed up with the prefixes
                NamespaceRegistry namespaceRegistry = resolver.adaptTo(Session.class).getWorkspace()
                        .getNamespaceRegistry();
                namespaceRegistry.registerNamespace("sling", "http://mock/sling");
                namespaceRegistry.registerNamespace("app", "http://mock/app");
                namespaceRegistry.registerNamespace("dam", "http://mock/dam");
            } catch (RepositoryException ex) {
                throw new RuntimeException("Unable to register namespaces.", ex);
            }
        }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

        assertEquals(ImmutableSet.of("jcr", "dummy"), ImmutableSet.copyOf(this.session.getNamespacePrefixes()));
        assertEquals("http://mydummy", this.session.getNamespaceURI("dummy"));
        assertEquals("dummy", this.session.getNamespacePrefix("http://mydummy"));

        // test via namespace registry
        NamespaceRegistry namespaceRegistry = this.session.getWorkspace().getNamespaceRegistry();

        assertEquals(ImmutableSet.of("jcr", "dummy"), ImmutableSet.copyOf(namespaceRegistry.getPrefixes()));
        assertEquals(ImmutableSet.of("http://www.jcp.org/jcr/1.0", "http://mydummy"),
                ImmutableSet.copyOf(namespaceRegistry.getURIs()));
        assertEquals("http://mydummy", namespaceRegistry.getURI("dummy"));
        assertEquals("dummy", namespaceRegistry.getPrefix("http://mydummy"));

        // remove dummy namespace
        namespaceRegistry.unregisterNamespace("dummy");

        assertEquals(ImmutableSet.of("jcr"), ImmutableSet.copyOf(this.session.getNamespacePrefixes()));
        assertEquals("http://www.jcp.org/jcr/1.0", this.session.getNamespaceURI("jcr"));
        assertEquals("jcr", this.session.getNamespacePrefix("http://www.jcp.org/jcr/1.0"));
    }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

    private static void initializeJcrMock(ResourceResolverFactory factory) throws RepositoryException, LoginException {
        // register default namespaces
        ResourceResolver resolver = factory.getResourceResolver(null);
        Session session = resolver.adaptTo(Session.class);
        NamespaceRegistry namespaceRegistry = session.getWorkspace().getNamespaceRegistry();
        namespaceRegistry.registerNamespace("sling", "http://sling.apache.org/jcr/sling/1.0");
    }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

        if (getResourceResolverType() == ResourceResolverType.JCR_MOCK) {
            try {
                // dummy namespace registrations to make sure sling JCR resolver
                // does not get mixed up with the prefixes
                NamespaceRegistry namespaceRegistry = resolver.adaptTo(Session.class).getWorkspace()
                        .getNamespaceRegistry();
                namespaceRegistry.registerNamespace("sling", "http://mock/sling");
                namespaceRegistry.registerNamespace("app", "http://mock/app");
                namespaceRegistry.registerNamespace("dam", "http://mock/dam");
            } catch (RepositoryException ex) {
                throw new RuntimeException("Unable to register namespaces.", ex);
            }
        }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

            this.mapEntries = new MapEntries(resFac, repository);
            PrivateAccessor.setField(resFac, "mapEntries", mapEntries);

            try {
                NamespaceRegistry nsr = session.getWorkspace().getNamespaceRegistry();
                nsr.registerNamespace(SlingConstants.NAMESPACE_PREFIX, JcrResourceConstants.SLING_NAMESPACE_URI);
            } catch (Exception e) {
                // don't care for now
            }

            PrivateAccessor.setField(resFac, "useMultiWorkspaces", true);
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

        // create the session
        getSession();

        try {
            NamespaceRegistry nsr = session.getWorkspace().getNamespaceRegistry();
            nsr.registerNamespace(SlingConstants.NAMESPACE_PREFIX,
                JcrResourceConstants.SLING_NAMESPACE_URI);
        } catch (Exception e) {
            // don't care for now
        }
View Full Code Here

Examples of javax.jcr.NamespaceRegistry

            mapEntries = new MapEntries(resFac, mock(BundleContext.class), mock(EventAdmin.class));
            PrivateAccessor.setField(resFac, "mapEntries", mapEntries);

            try {
                NamespaceRegistry nsr = session.getWorkspace().getNamespaceRegistry();
                nsr.registerNamespace(SlingConstants.NAMESPACE_PREFIX, JcrResourceConstants.SLING_NAMESPACE_URI);
            } catch (Exception e) {
                // don't care for now
            }

            Map<String, Object> authInfo = Collections.<String, Object> singletonMap(
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.