Search in sources :

Example 6 with NameResolver

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

the class EntryTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    if (superuser instanceof NameResolver) {
        NameResolver resolver = (NameResolver) superuser;
        nodePath = resolver.getJCRName(ACLTemplate.P_NODE_PATH);
        glob = resolver.getJCRName(ACLTemplate.P_GLOB);
    } else {
        throw new NotExecutableException();
    }
    restrictions = new HashMap<String, Value>(2);
    restrictions.put(nodePath, superuser.getValueFactory().createValue("/a/b/c/d", PropertyType.PATH));
    restrictions.put(glob, superuser.getValueFactory().createValue("*"));
    acl = new ACLTemplate(testPrincipal, testPath, (SessionImpl) superuser, superuser.getValueFactory());
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) BooleanValue(org.apache.jackrabbit.value.BooleanValue) Value(javax.jcr.Value) StringValue(org.apache.jackrabbit.value.StringValue) SessionImpl(org.apache.jackrabbit.core.SessionImpl) NameResolver(org.apache.jackrabbit.spi.commons.conversion.NameResolver)

Example 7 with NameResolver

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

the class NamePathResolverImpl method create.

public static NamePathResolver create(NamespaceMappings nsMappings) {
    NameResolver nResolver = new NameResolverImpl(nsMappings);
    PathResolver pResolver = new ParsingPathResolver(PATH_FACTORY, nResolver);
    return new NamePathResolverImpl(nResolver, pResolver);
}
Also used : NamePathResolver(org.apache.jackrabbit.spi.commons.conversion.NamePathResolver) PathResolver(org.apache.jackrabbit.spi.commons.conversion.PathResolver) ParsingPathResolver(org.apache.jackrabbit.spi.commons.conversion.ParsingPathResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) NameResolver(org.apache.jackrabbit.spi.commons.conversion.NameResolver) ParsingPathResolver(org.apache.jackrabbit.spi.commons.conversion.ParsingPathResolver)

Example 8 with NameResolver

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

the class AdministratorTest method testAdminNodeCollidingWithRandomNode.

/**
     * Test for collisions that would prevent from recreate the admin user.
     * - a colliding node somewhere else with the same jcr:uuid.
     *
     * Test if creation of the administrator user forces the removal of some
     * other node in the repository that by change happens to have the same
     * jcr:uuid and thus inhibits the creation of the admininstrator user.
     */
public void testAdminNodeCollidingWithRandomNode() throws RepositoryException, NotExecutableException {
    Authorizable admin = userMgr.getAuthorizable(adminId);
    if (admin == null || !(admin instanceof AuthorizableImpl)) {
        throw new NotExecutableException();
    }
    // access the node corresponding to the admin user and remove it
    NodeImpl adminNode = ((AuthorizableImpl) admin).getNode();
    NodeId nid = adminNode.getNodeId();
    Session s = adminNode.getSession();
    adminNode.remove();
    // use session obtained from the node as usermgr may point to a dedicated
    // system workspace different from the superusers workspace.
    s.save();
    Session s2 = null;
    String collidingPath = null;
    try {
        // create a colliding node outside of the user tree
        NameResolver nr = (SessionImpl) s;
        // NOTE: testRootNode will not be present if users are stored in a distinct wsp.
        //       therefore use root node as start...
        NodeImpl tr = (NodeImpl) s.getRootNode();
        Node n = tr.addNode(nr.getQName("tmpNode"), nr.getQName(testNodeType), nid);
        collidingPath = n.getPath();
        s.save();
        // force recreation of admin user.
        s2 = getHelper().getSuperuserSession();
        admin = userMgr.getAuthorizable(adminId);
        assertNotNull(admin);
        // the colliding node must have been removed.
        assertFalse(s2.nodeExists(collidingPath));
    } finally {
        if (s2 != null) {
            s2.logout();
        }
        if (collidingPath != null && s.nodeExists(collidingPath)) {
            s.getNode(collidingPath).remove();
            s.save();
        }
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) NodeImpl(org.apache.jackrabbit.core.NodeImpl) Node(javax.jcr.Node) NodeId(org.apache.jackrabbit.core.id.NodeId) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) SessionImpl(org.apache.jackrabbit.core.SessionImpl) NameResolver(org.apache.jackrabbit.spi.commons.conversion.NameResolver) Session(javax.jcr.Session)

Example 9 with NameResolver

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

the class ValueFormatTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    idResolver = new IdentifierResolver() {

        public Path getPath(String identifier) throws MalformedPathException {
            throw new UnsupportedOperationException();
        }

        public void checkFormat(String identifier) throws MalformedPathException {
        // nop
        }
    };
    NameResolver nResolver = new ParsingNameResolver(NameFactoryImpl.getInstance(), new DummyNamespaceResolver());
    PathResolver pResolver = new ParsingPathResolver(PathFactoryImpl.getInstance(), nResolver, idResolver);
    resolver = new DefaultNamePathResolver(nResolver, pResolver);
    qvFactory = QValueFactoryImpl.getInstance();
    vFactory = new ValueFactoryQImpl(qvFactory, resolver);
}
Also used : IdentifierResolver(org.apache.jackrabbit.spi.commons.conversion.IdentifierResolver) Path(org.apache.jackrabbit.spi.Path) ParsingNameResolver(org.apache.jackrabbit.spi.commons.conversion.ParsingNameResolver) DummyNamespaceResolver(org.apache.jackrabbit.spi.commons.conversion.DummyNamespaceResolver) MalformedPathException(org.apache.jackrabbit.spi.commons.conversion.MalformedPathException) NamePathResolver(org.apache.jackrabbit.spi.commons.conversion.NamePathResolver) PathResolver(org.apache.jackrabbit.spi.commons.conversion.PathResolver) ParsingPathResolver(org.apache.jackrabbit.spi.commons.conversion.ParsingPathResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) DefaultNamePathResolver(org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver) NameResolver(org.apache.jackrabbit.spi.commons.conversion.NameResolver) ParsingNameResolver(org.apache.jackrabbit.spi.commons.conversion.ParsingNameResolver) ParsingPathResolver(org.apache.jackrabbit.spi.commons.conversion.ParsingPathResolver)

Example 10 with NameResolver

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

the class UserManagerImplTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    if (!(userMgr instanceof UserManagerImpl)) {
        throw new NotExecutableException("UserManagerImpl expected -> cannot perform test.");
    }
    NameResolver resolver = (SessionImpl) superuser;
    pPrincipalName = resolver.getJCRName(UserConstants.P_PRINCIPAL_NAME);
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) SessionImpl(org.apache.jackrabbit.core.SessionImpl) NameResolver(org.apache.jackrabbit.spi.commons.conversion.NameResolver)

Aggregations

NameResolver (org.apache.jackrabbit.spi.commons.conversion.NameResolver)10 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)5 SessionImpl (org.apache.jackrabbit.core.SessionImpl)4 ParsingPathResolver (org.apache.jackrabbit.spi.commons.conversion.ParsingPathResolver)3 PathResolver (org.apache.jackrabbit.spi.commons.conversion.PathResolver)3 DefaultNamePathResolver (org.apache.jackrabbit.spi.commons.conversion.DefaultNamePathResolver)2 NamePathResolver (org.apache.jackrabbit.spi.commons.conversion.NamePathResolver)2 NamespaceException (javax.jcr.NamespaceException)1 Node (javax.jcr.Node)1 Session (javax.jcr.Session)1 Value (javax.jcr.Value)1 NodeType (javax.jcr.nodetype.NodeType)1 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)1 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)1 NodeImpl (org.apache.jackrabbit.core.NodeImpl)1 NodeId (org.apache.jackrabbit.core.id.NodeId)1 Name (org.apache.jackrabbit.spi.Name)1 Path (org.apache.jackrabbit.spi.Path)1 CachingPathResolver (org.apache.jackrabbit.spi.commons.conversion.CachingPathResolver)1 DummyNamespaceResolver (org.apache.jackrabbit.spi.commons.conversion.DummyNamespaceResolver)1