Search in sources :

Example 26 with DefaultNamePathResolver

use of org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver 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 27 with DefaultNamePathResolver

use of org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver 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 28 with DefaultNamePathResolver

use of org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver in project jackrabbit-oak by apache.

the class RepositoryTest method addAlienBinaryProperty.

@Test
public void addAlienBinaryProperty() throws RepositoryException, IOException {
    Session session = getAdminSession();
    QValue qValue = QValueFactoryImpl.getInstance().create("binaryValue".getBytes());
    Value value = new QValueValue(qValue, new DefaultNamePathResolver(session));
    getNode(TEST_PATH).setProperty("binary", value);
    session.save();
    Value valueAgain = getNode(TEST_PATH).getProperty("binary").getValue();
    assertEqualStream(value.getBinary().getStream(), valueAgain.getBinary().getStream());
}
Also used : QValueValue(org.apache.jackrabbit.spi.commons.value.QValueValue) QValue(org.apache.jackrabbit.spi.QValue) QValueValue(org.apache.jackrabbit.spi.commons.value.QValueValue) QValue(org.apache.jackrabbit.spi.QValue) Value(javax.jcr.Value) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) Session(javax.jcr.Session) Test(org.junit.Test)

Aggregations

DefaultNamePathResolver (org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)28 NamespaceResolver (org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver)12 NamePathResolver (org.apache.jackrabbit.spi.commons.conversion.NamePathResolver)10 RepositoryException (javax.jcr.RepositoryException)8 AbstractNamespaceResolver (org.apache.jackrabbit.spi.commons.namespace.AbstractNamespaceResolver)8 Batch (org.apache.jackrabbit.spi.Batch)6 QValue (org.apache.jackrabbit.spi.QValue)5 DummyNamespaceResolver (org.apache.jackrabbit.spi.commons.conversion.DummyNamespaceResolver)4 Value (javax.jcr.Value)3 Session (javax.jcr.Session)2 Path (org.apache.jackrabbit.spi.Path)2 PathResolver (org.apache.jackrabbit.spi.commons.conversion.PathResolver)2 ValueFactoryQImpl (org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl)2 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 Principal (java.security.Principal)1 HashMap (java.util.HashMap)1 ValueFactory (javax.jcr.ValueFactory)1