jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Young Li <Young...@morningstar.com>
Subject Question on Activity
Date Mon, 09 Dec 2013 06:17:36 GMT
Dear All,

I am confused on the concept Activity in JCR.  By the introduction of it, it uses to record
some changes on the session and that could be used to reused in other workspaces.

I try to build a simple demo to check the function of Activity, but it failed.   Attaching
my code here, please give me some guide.  Thanks.

         //create a Activity node
Node activity = vm.getActivity();
        if (null == activity) {
            activity = vm.createActivity("test_act_default_3333");
        }
        System.out.println(activity.getUUID());
        Node root = adminSession.getRootNode();
        Node testNode = root.addNode("test");

        testNode.addMixin("mix:versionable");
        adminSession.save();

        vm.setActivity(activity);//set activity and begin to record the changes
        vm.checkout("/test");
        testNode.addNode("test_sub1");
        testNode.addNode("test_sub2");
        adminSession.save();
        vm.setActivity(null);// stop the activity and the activity should contains the addition
of two child nodes.
        vm.checkin("/test");

After above code, I try to reuse the activity in another workspace 'test'.

Session test_session = rep.login(new SimpleCredentials("admin",
                "admin".toCharArray()), "test");
         //Create a similar root node here
         Node root = test_session.getRootNode();
        Node testNode = root.addNode("test");
        testNode.addMixin("mix:versionable");
        test_session.save();

        VersionManagerImpl vm = (VersionManagerImpl)adminSession.getWorkspace().getVersionManager();
        String uuid_act = "6047919f-2740-426c-ba91-94c1cc60e4bd";//this is UUID of activity
node previously created.
        Node activity_node = test_session.getNodeByUUID(uuid_act);
         NodeIterator nit = vm.merge(activity_node);//merge, but there is no anything changes
to be taken effect.

It is really appreciated if any suggestion is received.  Thanks.

Best regards,

Young


Mime
View raw message