AnsweredAssumed Answered

Revert Code

Question asked by thaneshk on Apr 11, 2006
Latest reply on Apr 12, 2006 by thaneshk
Hi,

CAn someone tell me whether i am going on the right path.



 
         NodeService nodeService = registry.getNodeService();
         
         CheckOutCheckInService check = registry.getCheckOutCheckInService();
         
         VersionService version = registry.getVersionService();
         
         ContentService contentService = registry.getContentService();

NodeRef nodeRef = JCRNodeRef.getNodeRef(contentNode);

                        
            
            NodeRef workingCopy1 = check.checkout(nodeRef);      
            
            ContentWriter tempWriter = contentService.getWriter(workingCopy1, ContentModel.PROP_CONTENT, false);
            //assertNotNull(tempWriter);
            tempWriter.putContent(CONTENT_2);
            String contentUrl = tempWriter.getContentUrl();
                        
            System.out.println("Conent is going to be checked back in - MAJOR VERSION");
            Map<String, Serializable> versionProperties3 = new HashMap<String, Serializable>();
            versionProperties3.put(Version.PROP_DESCRIPTION, "description");
            versionProperties3.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR);
            
            
            NodeRef nodeRef2 = check.checkin(workingCopy1, versionProperties3, contentUrl, false);   
            //contentNode.save();
            contentNode.save();
            
            System.out.println("Going to be checked out Again  -2 ");
            
            NodeRef workingCopy2 = check.checkout(nodeRef2);
            
            ContentWriter tempWriter2 = contentService.getWriter(workingCopy2, ContentModel.PROP_CONTENT, false);
            //assertNotNull(tempWriter);
            tempWriter2.putContent(CONTENT_3);
            String contentUrl2 = tempWriter2.getContentUrl();
            
            System.out.println("Conent is going to be checked back in - MAJOR VERSION");
            Map<String, Serializable> versionProperties4 = new HashMap<String, Serializable>();
            versionProperties4.put(Version.PROP_DESCRIPTION, "description");
            versionProperties4.put(VersionModel.PROP_VERSION_TYPE, VersionType.MAJOR);
            NodeRef contentNode3 = check.checkin(workingCopy2, versionProperties4, contentUrl2, false);   
            
            System.out.println("1");
            
            
            version.revert(contentNode3);


What i am worried abt is whther i am using version.revert(contentNode3) properly. Should i be passing some other variable to be testing this?

Cheers

-Thanesh

Outcomes