Search in sources :

Example 6 with NamespaceResolver

use of org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver in project jackrabbit by apache.

the class ReadTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    rs = helper.getRepositoryService();
    si = helper.getAdminSessionInfo();
    NamespaceResolver nsResolver = new AbstractNamespaceResolver() {

        public String getURI(String prefix) {
            return ("jcr".equals(prefix)) ? "http://www.jcp.org/jcr/1.0" : prefix;
        }

        public String getPrefix(String uri) {
            return ("http://www.jcp.org/jcr/1.0".equals(uri)) ? "jcr" : uri;
        }
    };
    resolver = new DefaultNamePathResolver(nsResolver);
    try {
        rs.getNodeInfo(si, getNodeId(testPath));
    } catch (RepositoryException e) {
        Batch b = rs.createBatch(si, getNodeId("/"));
        b.addNode(getNodeId("/"), resolver.getQName("test"), NameConstants.NT_UNSTRUCTURED, null);
        rs.submit(b);
    }
}
Also used : Batch(org.apache.jackrabbit.spi.Batch) AbstractNamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver) NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) RepositoryException(javax.jcr.RepositoryException) AbstractNamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver)

Example 7 with NamespaceResolver

use of org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver in project jackrabbit by apache.

the class ConnectionTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    rs = helper.getRepositoryService();
    NamespaceResolver nsResolver = new AbstractNamespaceResolver() {

        public String getURI(String prefix) {
            return ("jcr".equals(prefix)) ? "http://www.jcp.org/jcr/1.0" : prefix;
        }

        public String getPrefix(String uri) {
            return ("http://www.jcp.org/jcr/1.0".equals(uri)) ? "jcr" : uri;
        }
    };
    resolver = new DefaultNamePathResolver(nsResolver);
}
Also used : NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) AbstractNamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) AbstractNamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver)

Example 8 with NamespaceResolver

use of org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver in project jackrabbit by apache.

the class CopyTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    rs = helper.getRepositoryService();
    si = helper.getAdminSessionInfo();
    NamespaceResolver nsResolver = new AbstractNamespaceResolver() {

        public String getURI(String prefix) {
            return ("jcr".equals(prefix)) ? "http://www.jcp.org/jcr/1.0" : prefix;
        }

        public String getPrefix(String uri) {
            return ("http://www.jcp.org/jcr/1.0".equals(uri)) ? "jcr" : uri;
        }
    };
    resolver = new DefaultNamePathResolver(nsResolver);
    try {
        rs.getNodeInfo(si, getNodeId(testPath));
    } catch (RepositoryException e) {
        Batch b = rs.createBatch(si, getNodeId("/"));
        b.addNode(getNodeId("/"), resolver.getQName("test"), NameConstants.NT_UNSTRUCTURED, null);
        rs.submit(b);
    }
}
Also used : Batch(org.apache.jackrabbit.spi.Batch) AbstractNamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver) NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) RepositoryException(javax.jcr.RepositoryException) AbstractNamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver)

Example 9 with NamespaceResolver

use of org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver in project jackrabbit by apache.

the class ConsistencyCheckerImplTest method createClusterNode.

private ClusterNode createClusterNode(String id) throws Exception {
    final MemoryJournal journal = new MemoryJournal() {

        protected boolean syncAgainOnNewRecords() {
            return true;
        }
    };
    JournalFactory jf = new JournalFactory() {

        public Journal getJournal(NamespaceResolver resolver) throws RepositoryException {
            return journal;
        }
    };
    ClusterConfig cc = new ClusterConfig(id, SYNC_DELAY, jf);
    SimpleClusterContext context = new SimpleClusterContext(cc);
    journal.setRepositoryHome(context.getRepositoryHome());
    journal.init(id, context.getNamespaceResolver());
    journal.setRecords(records);
    ClusterNode clusterNode = new ClusterNode();
    clusterNode.init(context);
    return clusterNode;
}
Also used : JournalFactory(org.apache.jackrabbit.core.journal.JournalFactory) ClusterNode(org.apache.jackrabbit.core.cluster.ClusterNode) SimpleClusterContext(org.apache.jackrabbit.core.cluster.SimpleClusterContext) NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) MemoryJournal(org.apache.jackrabbit.core.journal.MemoryJournal) ClusterConfig(org.apache.jackrabbit.core.config.ClusterConfig)

Example 10 with NamespaceResolver

use of org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver in project jackrabbit by apache.

the class ClusterRecordTest method createClusterNode.

/**
     * Create a cluster node, with a memory journal referencing a list of records.
     *
     * @param id cluster node id
     * @param records memory journal's list of records
     */
private ClusterNode createClusterNode(String id, ArrayList<MemoryRecord> records) throws Exception {
    final MemoryJournal journal = new MemoryJournal();
    JournalFactory jf = new JournalFactory() {

        public Journal getJournal(NamespaceResolver resolver) throws RepositoryException {
            return journal;
        }
    };
    ClusterConfig cc = new ClusterConfig(id, SYNC_DELAY, jf);
    SimpleClusterContext context = new SimpleClusterContext(cc);
    journal.setRepositoryHome(context.getRepositoryHome());
    journal.init(id, context.getNamespaceResolver());
    if (records != null) {
        journal.setRecords(records);
    }
    ClusterNode clusterNode = new ClusterNode();
    clusterNode.init(context);
    return clusterNode;
}
Also used : JournalFactory(org.apache.jackrabbit.core.journal.JournalFactory) NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) MemoryJournal(org.apache.jackrabbit.core.journal.MemoryJournal) ClusterConfig(org.apache.jackrabbit.core.config.ClusterConfig)

Aggregations

NamespaceResolver (org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver)21 DefaultNamePathResolver (org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)12 RepositoryException (javax.jcr.RepositoryException)10 AbstractNamespaceResolver (org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver)8 ClusterConfig (org.apache.jackrabbit.core.config.ClusterConfig)6 Batch (org.apache.jackrabbit.spi.Batch)6 ClusterNode (org.apache.jackrabbit.core.cluster.ClusterNode)4 SimpleClusterContext (org.apache.jackrabbit.core.cluster.SimpleClusterContext)4 JournalFactory (org.apache.jackrabbit.core.journal.JournalFactory)4 MemoryJournal (org.apache.jackrabbit.core.journal.MemoryJournal)3 QValue (org.apache.jackrabbit.spi.QValue)3 ArrayList (java.util.ArrayList)2 Name (org.apache.jackrabbit.spi.Name)2 NamePathResolver (org.apache.jackrabbit.spi.commons.conversion.NamePathResolver)2 File (java.io.File)1 HashMap (java.util.HashMap)1 NamespaceException (javax.jcr.NamespaceException)1 Value (javax.jcr.Value)1 AssertionFailedError (junit.framework.AssertionFailedError)1 HierarchyManagerImpl (org.apache.jackrabbit.core.HierarchyManagerImpl)1