Search in sources :

Example 1 with NamespaceResolver

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

the class BatchTest 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 2 with NamespaceResolver

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

the class FileJournalTest method testClusterInitIncompleteMissingParam.

/**
     * Verify that <code>ClusterNode.stop</code> can be invoked even when
     * <code>ClusterNode.init</code> throws because the journal can not
     * be initialized. Note: this is done by omitting the required argument
     * <code>directory</code>.
     *
     * @throws Exception
     */
public void testClusterInitIncompleteMissingParam() throws Exception {
    JournalFactory jf = new JournalFactory() {

        public Journal getJournal(NamespaceResolver resolver) throws RepositoryException {
            try {
                FileJournal journal = new FileJournal();
                // no setDirectory() call here
                journal.init(CLUSTER_NODE_ID, resolver);
                return journal;
            } catch (JournalException e) {
                throw new RepositoryException("Expected failure", e);
            }
        }
    };
    ClusterConfig cc = new ClusterConfig(CLUSTER_NODE_ID, SYNC_DELAY, jf);
    SimpleClusterContext context = new SimpleClusterContext(cc);
    ClusterNode clusterNode = new ClusterNode();
    try {
        clusterNode.init(context);
        fail("Bad cluster configuration.");
    } catch (Exception e) {
    }
    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) RepositoryException(javax.jcr.RepositoryException) RepositoryException(javax.jcr.RepositoryException) ClusterConfig(org.apache.jackrabbit.core.config.ClusterConfig)

Example 3 with NamespaceResolver

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

the class ValueConstraintTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    valueFactory = QValueFactoryImpl.getInstance();
    resolver = new DefaultNamePathResolver(new NamespaceResolver() {

        public String getURI(String prefix) throws NamespaceException {
            return prefix;
        }

        public String getPrefix(String uri) throws NamespaceException {
            return uri;
        }
    });
}
Also used : NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)

Example 4 with NamespaceResolver

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

the class RepositoryServiceImpl method getRepositoryDescriptors.

/**
     * {@inheritDoc}
     */
public Map<String, QValue[]> getRepositoryDescriptors() throws RepositoryException {
    Map<String, QValue[]> descriptors = new HashMap<String, QValue[]>();
    for (String key : repository.getDescriptorKeys()) {
        if (key.equals(Repository.OPTION_TRANSACTIONS_SUPPORTED)) {
            descriptors.put(key, new QValue[] { qValueFactory.create(false) });
        } else {
            Value[] vs = repository.getDescriptorValues(key);
            QValue[] qvs = new QValue[vs.length];
            for (int i = 0; i < vs.length; i++) {
                // Name and path resolver that uses a dummy namespace resolver
                // as Name/Path values are not expected to occur in the
                // descriptors. TODO: check again.
                NamePathResolver resolver = new DefaultNamePathResolver(new NamespaceResolver() {

                    public String getURI(String prefix) {
                        return prefix;
                    }

                    public String getPrefix(String uri) {
                        return uri;
                    }
                });
                qvs[i] = ValueFormat.getQValue(vs[i], resolver, qValueFactory);
            }
            descriptors.put(key, qvs);
        }
    }
    return descriptors;
}
Also used : NamePathResolver(org.apache.jackrabbit.spi.commons.conversion.NamePathResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) QValue(org.apache.jackrabbit.spi.QValue) HashMap(java.util.HashMap) QValue(org.apache.jackrabbit.spi.QValue) Value(javax.jcr.Value) NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)

Example 5 with NamespaceResolver

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

the class ExtensionTest 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);
}
Also used : AbstractNamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver) NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) AbstractNamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver)

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