Search in sources :

Example 16 with DefaultNamePathResolver

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

the class AbstractJournal method init.

/**
     * {@inheritDoc}
     */
public void init(String id, NamespaceResolver resolver) throws JournalException {
    this.id = id;
    this.resolver = resolver;
    this.npResolver = new DefaultNamePathResolver(resolver, true);
}
Also used : DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)

Example 17 with DefaultNamePathResolver

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

the class TestAll method getDefaultValue.

/**
     * Returns the string value of the identified property default value.
     *
     * @param def property definition
     * @param index default value index
     * @return default value
     */
private String getDefaultValue(QPropertyDefinition def, int index) {
    try {
        QValue[] values = def.getDefaultValues();
        NamespaceResolver nsResolver = new AdditionalNamespaceResolver(registry);
        NamePathResolver resolver = new DefaultNamePathResolver(nsResolver);
        ValueFactoryQImpl factory = new ValueFactoryQImpl(InternalValueFactory.getInstance(), resolver);
        return factory.createValue(values[index]).getString();
    } catch (RepositoryException e) {
        throw new AssertionFailedError(e.getMessage());
    }
}
Also used : NamePathResolver(org.apache.jackrabbit.spi.commons.conversion.NamePathResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) QValue(org.apache.jackrabbit.spi.QValue) NamespaceResolver(org.apache.jackrabbit.spi.commons.namespace.NamespaceResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) RepositoryException(javax.jcr.RepositoryException) ValueFactoryQImpl(org.apache.jackrabbit.spi.commons.value.ValueFactoryQImpl) AssertionFailedError(junit.framework.AssertionFailedError)

Example 18 with DefaultNamePathResolver

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

the class RepositoryUpgrade method createPropertyDefinitionTemplate.

private PropertyDefinitionTemplate createPropertyDefinitionTemplate(ValueFactory valueFactory, NodeTypeManager ntMgr, QPropertyDefinition def) throws RepositoryException {
    PropertyDefinitionTemplate tmpl = ntMgr.createPropertyDefinitionTemplate();
    Name name = def.getName();
    if (name != null) {
        tmpl.setName(getOakName(name));
    }
    tmpl.setAutoCreated(def.isAutoCreated());
    tmpl.setMandatory(def.isMandatory());
    tmpl.setOnParentVersion(def.getOnParentVersion());
    tmpl.setProtected(def.isProtected());
    tmpl.setRequiredType(def.getRequiredType());
    tmpl.setMultiple(def.isMultiple());
    tmpl.setAvailableQueryOperators(def.getAvailableQueryOperators());
    tmpl.setFullTextSearchable(def.isFullTextSearchable());
    tmpl.setQueryOrderable(def.isQueryOrderable());
    QValueConstraint[] qConstraints = def.getValueConstraints();
    if (qConstraints != null && qConstraints.length > 0) {
        String[] constraints = new String[qConstraints.length];
        for (int i = 0; i < qConstraints.length; i++) {
            constraints[i] = qConstraints[i].getString();
        }
        tmpl.setValueConstraints(constraints);
    }
    QValue[] qValues = def.getDefaultValues();
    if (qValues != null) {
        NamePathResolver npResolver = new DefaultNamePathResolver(source.getNamespaceRegistry());
        Value[] vs = new Value[qValues.length];
        for (int i = 0; i < qValues.length; i++) {
            vs[i] = ValueFormat.getJCRValue(qValues[i], npResolver, valueFactory);
        }
        tmpl.setDefaultValues(vs);
    }
    return tmpl;
}
Also used : NamePathResolver(org.apache.jackrabbit.spi.commons.conversion.NamePathResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) QValue(org.apache.jackrabbit.spi.QValue) QValueConstraint(org.apache.jackrabbit.spi.QValueConstraint) QValueConstraint(org.apache.jackrabbit.spi.QValueConstraint) Name(org.apache.jackrabbit.spi.Name) PropertyDefinitionTemplate(javax.jcr.nodetype.PropertyDefinitionTemplate) QValue(org.apache.jackrabbit.spi.QValue) Value(javax.jcr.Value) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)

Example 19 with DefaultNamePathResolver

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

the class SessionImpl method setNamespacePrefix.

/**
     * @see javax.jcr.Session#setNamespacePrefix(String, String)
     */
@Override
public void setNamespacePrefix(String prefix, String uri) throws RepositoryException {
    super.setNamespacePrefix(prefix, uri);
    // Reset name and path caches
    npResolver = new DefaultNamePathResolver(this, true);
}
Also used : DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)

Example 20 with DefaultNamePathResolver

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

the class AccessControlListImplTest method setUp.

@Override
public void setUp() throws Exception {
    super.setUp();
    resolver = new DefaultNamePathResolver(superuser);
    vFactory = QValueFactoryImpl.getInstance();
    unknownPrincipal = getHelper().getUnknownPrincipal(superuser);
    knownPrincipal = new Principal() {

        @Override
        public String getName() {
            return "everyone";
        }
    };
}
Also used : DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) Principal(java.security.Principal)

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