Search in sources :

Example 1 with Session

use of javax.jcr.Session in project jackrabbit-oak by apache.

the class WikipediaImport method run.

private void run(Repository repository) throws Exception {
    Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
    try {
        int before = importWikipedia(session);
        int after = new Traversal().traverse(session);
        checkState(before == after, "Import vs. traverse mismatch");
    } finally {
        session.logout();
    }
}
Also used : SimpleCredentials(javax.jcr.SimpleCredentials) Session(javax.jcr.Session)

Example 2 with Session

use of javax.jcr.Session in project jackrabbit-oak by apache.

the class RemoveMembersTest method beforeSuite.

@Override
public void beforeSuite() throws Exception {
    super.beforeSuite();
    Session s = loginAdministrative();
    try {
        UserManager userManager = ((JackrabbitSession) s).getUserManager();
        createUsers(userManager);
        for (int i = 0; i <= GROUP_CNT; i++) {
            Group g = userManager.createGroup(new PrincipalImpl(GROUP + i), REL_TEST_PATH);
            groupPaths.add(g.getPath());
            List<String> ids = new ArrayList<String>();
            for (int j = 0; j <= numberOfMembers; j++) {
                ids.add(USER + j);
            }
            g.addMembers(ids.toArray(new String[ids.size()]));
            s.save();
        }
    } finally {
        s.logout();
    }
    System.out.println("setup done");
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) UserManager(org.apache.jackrabbit.api.security.user.UserManager) ArrayList(java.util.ArrayList) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) PrincipalImpl(org.apache.jackrabbit.oak.spi.security.principal.PrincipalImpl) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Example 3 with Session

use of javax.jcr.Session in project jackrabbit-oak by apache.

the class SequentialCreateNodesTest method beforeTest.

@Override
public void beforeTest() throws Exception {
    Session session = loginWriter();
    Node root = session.getRootNode().addNode(ROOT_NODE_NAME, "nt:unstructured");
    for (int i = 0; i < NODE_COUNT; i++) {
        Node node = root.addNode("node" + i, "nt:unstructured");
        session.save();
    }
}
Also used : Node(javax.jcr.Node) Session(javax.jcr.Session)

Example 4 with Session

use of javax.jcr.Session in project jackrabbit-oak by apache.

the class SetPropertyTest method beforeTest.

@Override
public void beforeTest() throws RepositoryException {
    Map<Thread, Node> nodes = getOrCreateNodesMap();
    Thread t = Thread.currentThread();
    Node node = nodes.get(t);
    if (node == null) {
        Session s = getRepository().login(getCredentials());
        node = s.getRootNode().getNode(testNodeName).addNode(UUID.randomUUID().toString());
        node.setProperty("count", -1);
        s.save();
        nodes.put(t, node);
        map.put(getCurrentFixture().toString(), nodes);
    }
}
Also used : Node(javax.jcr.Node) Session(javax.jcr.Session)

Example 5 with Session

use of javax.jcr.Session in project jackrabbit-oak by apache.

the class ScalabilityNodeRelationshipSuite method beforeSuite.

@Override
protected void beforeSuite() throws Exception {
    Session session = loginWriter();
    Node root = session.getRootNode();
    root.addNode(ROOT_NODE_NAME);
    session.save();
    users = Lists.newArrayList();
    groups = Lists.newArrayList();
    if (CUSTOM_TYPE) {
        NodeTypeUtils.createNodeType(session, CUSTOM_ACT_NODE_TYPE, new String[] { TITLE_PROP, CREATED, ACTION, SOURCE_ID }, new int[] { PropertyType.STRING, PropertyType.DATE, PropertyType.STRING, PropertyType.STRING }, new String[0], new String[] { NodeTypeConstants.NT_OAK_UNSTRUCTURED }, null, false);
        NodeTypeUtils.createNodeType(session, CUSTOM_REL_NODE_TYPE, new String[] { CREATED, SOURCE_ID, TARGET_ID }, new int[] { PropertyType.DATE, PropertyType.STRING, PropertyType.STRING }, new String[0], null, null, false);
        nodeTypes.add(CUSTOM_ACT_NODE_TYPE);
        nodeTypes.add(CUSTOM_REL_NODE_TYPE);
    }
    if (INDEX) {
        createIndexes(session);
    }
}
Also used : Node(javax.jcr.Node) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession)

Aggregations

Session (javax.jcr.Session)1419 Node (javax.jcr.Node)780 Test (org.junit.Test)387 RepositoryException (javax.jcr.RepositoryException)319 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)162 Property (javax.jcr.Property)95 SimpleCredentials (javax.jcr.SimpleCredentials)88 Privilege (javax.jcr.security.Privilege)84 JackrabbitNode (org.apache.jackrabbit.api.JackrabbitNode)77 Value (javax.jcr.Value)72 Query (javax.jcr.query.Query)69 NodeIterator (javax.jcr.NodeIterator)68 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)65 QueryManager (javax.jcr.query.QueryManager)63 ArrayList (java.util.ArrayList)57 HashMap (java.util.HashMap)57 IOException (java.io.IOException)56 AccessControlManager (javax.jcr.security.AccessControlManager)55 AbstractRepositoryTest (org.apache.jackrabbit.oak.jcr.AbstractRepositoryTest)52 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)49