code: public void restore(Version version, boolean removeExisting) throws VersionException, ItemExistsException,
        UnsupportedRepositoryOperationException, LockException, RepositoryException, InvalidItemStateException
     {
        checkValid();
  
        if (!session.getAccessManager().hasPermission(getACL(),
           new String[]{PermissionType.ADD_NODE, PermissionType.SET_PROPERTY}, session.getUserState().getIdentity()))
        {
           throw new AccessDeniedException("Access denied: restore operation " + getPath() + " for: "
              + session.getUserID() + " item owner " + getACL().getOwner());
        }
  
        if (!this.isNodeType(Constants.MIX_VERSIONABLE))
        {
           throw new UnsupportedRepositoryOperationException("Node is not versionable " + getPath());
        }
  
        if (session.hasPendingChanges())
        {
           throw new InvalidItemStateException("Session has pending changes ");
        }
  
        if (((VersionImpl)version).getInternalName().equals(Constants.JCR_ROOTVERSION))
        {
           throw new VersionException("It is illegal to call restore() on jcr:rootVersion");
        }
  
        if (!versionHistory(false).isVersionBelongToThis(version))
        {
           throw new VersionException("Bad version " + version.getPath());
        }
  
        // Check locking
        if (!checkLocking())
        {
           throw new LockException("Node " + getPath() + " is locked ");
        }
  
        NodeData destParent = (NodeData)dataManager.getItemData(nodeData().getParentIdentifier());
        ((VersionImpl)version).restore(this.getSession(), destParent, nodeData().getQPath().getName(), removeExisting);
     }
docs: {@inheritDoc}