Package org.apache.jackrabbit.core

Examples of org.apache.jackrabbit.core.UserTransactionImpl


        Privilege[] privileges = privilegesFromName(Privilege.JCR_ALL);
        givePrivileges(path, privileges, getRestrictions(superuser, path));

        // create new node and lock it
        Session s = getTestSession();
        UserTransaction utx = new UserTransactionImpl(s);
        utx.begin();

        // add node and save it
        Node n = s.getNode(childNPath);
        if (n.hasNode(nodeName1)) {
            Node c = n.getNode(nodeName1);
            c.remove();
            s.save();
        }

        // create node and save
        Node n2 = n.addNode(nodeName1);
        s.save(); // -> node is NEW -> no failure

        // create child node
        Node n3 = n2.addNode(nodeName2);
        s.save()// -> used to fail because n2 was saved (EXISTING) but not committed.

        n3.remove();
        n2.remove();

        // recreate n2 // -> another area where ItemManager#getItem is called in the ItemSaveOperation
        n2 = n.addNode(nodeName1);
        s.save();

        // set a property on a child node of an uncommited parent
        n2.setProperty(propertyName1, "testSetProperty");
        s.save()// -> used to fail because PropertyImpl#getParent called from PropertyImpl#checkSetValue
                   //    was checking read permission on the not yet commited parent

        // commit
        utx.commit();
    }
View Full Code Here


        Privilege[] privileges = privilegesFromName(Privilege.JCR_ALL);
        givePrivileges(path, privileges, getRestrictions(superuser, path));

        // create new node and lock it
        Session s = getTestSession();
        UserTransaction utx = new UserTransactionImpl(s);
        utx.begin();

        // add node and save it
        Node n = s.getNode(childNPath);
        if (n.hasNode(nodeName1)) {
            Node c = n.getNode(nodeName1);
            c.remove();
            s.save();
        }

        // create node and save
        Node n2 = n.addNode(nodeName1);
        s.save(); // -> node is NEW -> no failure

        // create child node
        Node n3 = n2.addNode(nodeName2);
        s.save()// -> used to fail because n2 was saved (EXISTING) but not committed.

        n3.remove();
        n2.remove();

        // recreate n2 // -> another area where ItemManager#getItem is called in the ItemSaveOperation
        n2 = n.addNode(nodeName1);
        s.save();

        // set a property on a child node of an uncommited parent
        n2.setProperty(propertyName1, "testSetProperty");
        s.save()// -> used to fail because PropertyImpl#getParent called from PropertyImpl#checkSetValue
                   //    was checking read permission on the not yet commited parent

        // commit
        utx.commit();
    }
View Full Code Here

                    n.addMixin(mixLockable);
                    session.save();
                    for (i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
                        Lock lock = n.lock(false, true);

                        final UserTransaction utx = new UserTransactionImpl(test.getSession());
                        utx.begin();
                        lock.refresh();
                        utx.commit();

                        n.unlock();
                    }
                } catch (Exception e) {
                    final String threadName = Thread.currentThread().getName();
View Full Code Here

            public void execute(Session session, Node test)
                    throws RepositoryException {
                // add versionable nodes
                for (int i = 0; i < NUM_OPERATIONS / CONCURRENCY; i++) {
                    try {
                        final UserTransaction utx = new UserTransactionImpl(test.getSession());
                        utx.begin();
                        Node n = test.addNode("test" + i);
                        n.addMixin(mixLockable);
                        session.save();
                        Lock l = n.lock(false, true);
                        n.unlock();
                        utx.commit();
                    } catch (Exception e) {
                        final String threadName = Thread.currentThread().getName();
                        final Throwable deepCause = getLevel2Cause(e);
                        if (deepCause != null && deepCause instanceof StaleItemStateException) {
                            // ignore
View Full Code Here

        n.addMixin(mixLockable);
        s.save();

        UserTransaction utx = null;
        if (xa) {
            utx = new UserTransactionImpl(s);
            utx.begin();
        }

        javax.jcr.lock.LockManager lm = s.getWorkspace().getLockManager();
View Full Code Here

        Privilege[] privileges = privilegesFromName(Privilege.JCR_ALL);
        givePrivileges(path, privileges, getRestrictions(superuser, path));

        // create new node and lock it
        Session s = getTestSession();
        UserTransaction utx = new UserTransactionImpl(s);
        utx.begin();

        // add node and save it
        Node n = s.getNode(childNPath);
        if (n.hasNode(nodeName1)) {
            Node c = n.getNode(nodeName1);
            c.remove();
            s.save();
        }

        // create node and save
        Node n2 = n.addNode(nodeName1);
        s.save(); // -> node is NEW -> no failure

        // create child node
        Node n3 = n2.addNode(nodeName2);
        s.save()// -> used to fail because n2 was saved (EXISTING) but not committed.

        n3.remove();
        n2.remove();

        // recreate n2 // -> another area where ItemManager#getItem is called in the ItemSaveOperation
        n2 = n.addNode(nodeName1);
        s.save();

        // set a property on a child node of an uncommited parent
        n2.setProperty(propertyName1, "testSetProperty");
        s.save()// -> used to fail because PropertyImpl#getParent called from PropertyImpl#checkSetValue
                   //    was checking read permission on the not yet commited parent

        // commit
        utx.commit();
    }
View Full Code Here

     * Tests error reported in JCR-2613
     *
     * @throws Exception if an error occurs
     */
    public void testRemoveVersionAndCheckinXA() throws Exception {
        UserTransaction tx = new UserTransactionImpl(superuser);
        tx.begin();
        Node n = testRootNode.addNode(nodeName1);
        n.addMixin(mixVersionable);
        n.addMixin(mixReferenceable);
        testRootNode.save();
        String uuid = n.getUUID();
        // create two versions
        String v1 = n.checkin().getName();
        n.checkout();
        n.checkin();
        n.checkout();
        tx.commit();

        tx = new UserTransactionImpl(superuser);
        tx.begin();
        // remove one version
        n = superuser.getNodeByUUID(uuid);
        n.getVersionHistory().removeVersion(v1);
        n.save();
        tx.commit();

        // new session
        Session session = getHelper().getSuperuserSession();
        tx = new UserTransactionImpl(session);
        tx.begin();
        n = session.getNodeByUUID(uuid);
        n.checkin();
        tx.commit();
    }
View Full Code Here

     * Tests error reported in JCR-2613
     *
     * @throws Exception if an error occurs
     */
    public void testRemoveVersionAndCheckinXA_JCR2() throws Exception {
        UserTransaction tx = new UserTransactionImpl(superuser);
        tx.begin();
        Node n = testRootNode.addNode(nodeName1);
        n.addMixin(mixVersionable);
        superuser.save();

        // create two versions
        String path = n.getPath();
        String v1 = superuser.getWorkspace().getVersionManager().checkpoint(path).getName();
        String v2 = superuser.getWorkspace().getVersionManager().checkpoint(path).getName();
        tx.commit();

        tx = new UserTransactionImpl(superuser);
        tx.begin();
        // remove one version
        superuser.getWorkspace().getVersionManager().getVersionHistory(path).removeVersion(v1);
        tx.commit();

        // new session
        Session session = getHelper().getSuperuserSession();
        tx = new UserTransactionImpl(session);
        tx.begin();
        session.getWorkspace().getVersionManager().checkin(path);
        tx.commit();
    }
View Full Code Here

        EventResult listener = new EventResult(log);
        addEventListener(listener, Event.NODE_ADDED);

        // use a transaction
        UserTransaction utx = new UserTransactionImpl(superuser);
        // start transaction
        utx.begin();
        Version v = n1.checkin();
        // commit transaction
        utx.commit();

        removeEventListener(listener);

        Event[] events = listener.getEvents(1000);
        Set paths = new HashSet();
View Full Code Here

        EventResult listener = new EventResult(log);
        addEventListener(listener, Event.NODE_REMOVED);

        // use a transaction
        UserTransaction utx = new UserTransactionImpl(superuser);
        // start transaction
        utx.begin();
        v.getContainingHistory().removeVersion(v.getName());
        // commit transaction
        utx.commit();

        removeEventListener(listener);

        Event[] events = listener.getEvents(1000);
        Set paths = new HashSet();
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.UserTransactionImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.