I have been trying versioning  and restore of tree, As Seen in attached
picture i have following hierarchy of node.

 Please refer attached image

Root Node

                |

 Custom Child node of Type nt:folder, mix:versionable

    |

Child Node of nt:folder Type

    |

Custome Childe Node of nt:file type, mix:versionable



Im able to perform versiong of node, in following way

Step 1:

I checkout custome child node,

get node of nt:folder type

get node of custom childe node of nt:file type, set new content of file
type.



above operation is sucessfull, i can see and get new content from versioned
file,



Now in Step 2 I want to do restore to version 1.0 and whole hierarchy to be
set to 1.0

below is code for that,



final VersionManager versionManager =
session.getWorkspace().getVersionManager();

        final Node node = session.getRootNode().getNode(Custom Child node
of Type nt:folder);  //Get the custom folder node

        final VersionHistory verHis =
versionManager.getVersionHistory(node.getPath());

        final VersionIterator verItr = verHis.getAllVersions();

        while (verItr.hasNext()) {

           final Version version = verItr.nextVersion();

           if(versionLabel.equals(version.getName())){

               log.info("Restoring Version : "+versionLabel);

               log.info(version.getFrozenNode().getPath());

               versionManager.restore(version, true);

               return;

           }



        }





                                On Restore it fails with following
exception for Custom File Node at leaves  :






javax.jcr.nodetype.ConstraintViolationException: No matching node
definition found for Custome File Name.go.xml

                at
org.apache.jackrabbit.oak.plugins.nodetype.EffectiveNodeTypeImpl.getNodeDefinition(EffectiveNodeTypeImpl.java:454)

                at
org.apache.jackrabbit.oak.plugins.nodetype.ReadOnlyNodeTypeManager.getDefinition(ReadOnlyNodeTypeManager.java:396)

                at
org.apache.jackrabbit.oak.plugins.version.VersionableState.getOPV(VersionableState.java:569)

                at
org.apache.jackrabbit.oak.plugins.version.VersionableState.restoreChildren(VersionableState.java:396)

                at
org.apache.jackrabbit.oak.plugins.version.VersionableState.restoreFrozen(VersionableState.java:319)

                at
org.apache.jackrabbit.oak.plugins.version.VersionableState.restoreState(VersionableState.java:261)

                at
org.apache.jackrabbit.oak.plugins.version.VersionableState.restoreChildren(VersionableState.java:402)

                at
org.apache.jackrabbit.oak.plugins.version.VersionableState.restoreFrozen(VersionableState.java:319)

                at
org.apache.jackrabbit.oak.plugins.version.VersionableState.restore(VersionableState.java:229)

                ... 73 common frames omitted



Any help will be great..

Thanks

Reply via email to