Search in sources :

Example 16 with NamespaceResolver

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

the class PathFactoryTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    factory = PathFactoryImpl.getInstance();
    NamespaceResolver nsresolver = new NamespaceResolver() {

        public String getURI(String prefix) throws NamespaceException {
            throw new UnsupportedOperationException();
        }

        public String getPrefix(String uri) throws NamespaceException {
            if (uri.equals(Name.NS_JCR_URI)) {
                return Name.NS_JCR_PREFIX;
            } else {
                return uri;
            }
        }
    };
    resolver = new DefaultNamePathResolver(nsresolver);
}
Also used : NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)

Example 17 with NamespaceResolver

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

the class DavPropertyTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    repoURI = helper.getProperty(ServiceStubImpl.PROP_REPOSITORY_URI);
    rs = (RepositoryServiceImpl) 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);
        QValueFactory qvf = rs.getQValueFactory();
        b.addProperty(getNodeId("/test"), resolver.getQName("prop"), qvf.create("value", PropertyType.STRING));
        b.addProperty(getNodeId("/test"), resolver.getQName("propMV"), new QValue[] { qvf.create(1), qvf.create(2) });
        rs.submit(b);
    }
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) 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) QValueFactory(org.apache.jackrabbit.spi.QValueFactory)

Example 18 with NamespaceResolver

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

the class CloneTest 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) throws NamespaceException {
            return ("jcr".equals(prefix)) ? "http://www.jcp.org/jcr/1.0" : prefix;
        }

        public String getPrefix(String uri) throws NamespaceException {
            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);
    }
    // todo: retrieve second wsp-name from config
    sInfo = rs.obtain(si, "test");
}
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 19 with NamespaceResolver

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

the class CreateFileTest 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);
    }
    lastModified = rs.getQValueFactory().create(Calendar.getInstance());
    mimeType = rs.getQValueFactory().create("text/plain", PropertyType.STRING);
    enc = rs.getQValueFactory().create("utf-8", PropertyType.STRING);
}
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 20 with NamespaceResolver

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

the class FileJournalTest method testRevisionIsOptional.

/**
     * Create a journal with no revision file name. Verify that the journal
     * is created nonetheless, with a revision file in the repository home.
     *
     * @throws Exception
     * @see <a href="http://issues.apache.org/jira/browse/JCR-904">JCR-904</a>
     */
public void testRevisionIsOptional() throws Exception {
    final FileJournal journal = new FileJournal();
    journal.setDirectory(journalDirectory.getPath());
    JournalFactory jf = new JournalFactory() {

        public Journal getJournal(NamespaceResolver resolver) {
            return journal;
        }
    };
    ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf);
    SimpleClusterContext context = new SimpleClusterContext(cc, repositoryHome);
    journal.setRepositoryHome(repositoryHome);
    journal.init(CLUSTER_NODE_ID, context.getNamespaceResolver());
    ClusterNode clusterNode = new ClusterNode();
    clusterNode.init(context);
    try {
        File revisionFile = new File(repositoryHome, FileJournal.DEFAULT_INSTANCE_FILE_NAME);
        assertTrue(revisionFile.exists());
    } finally {
        clusterNode.stop();
    }
}
Also used : ClusterNode(org.apache.jackrabbit.core.cluster.ClusterNode) SimpleClusterContext(org.apache.jackrabbit.core.cluster.SimpleClusterContext) NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) File(java.io.File) 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