code: public static void createVersion(Node nodeVersioning) throws Exception {
  
      if(!nodeVersioning.isNodeType(NT_FILE)) {
        if(log.isDebugEnabled()){
          log.debug("Version history is not impact with non-nt:file documents, there'is not any version created.");
        }
        return;
      }
  
      if(!nodeVersioning.isNodeType(MIX_VERSIONABLE)){
        if(nodeVersioning.canAddMixin(MIX_VERSIONABLE)) {
          nodeVersioning.addMixin(MIX_VERSIONABLE);
          nodeVersioning.save();
        }
        return;
      }
       if (!nodeVersioning.isCheckedOut())
       {
          nodeVersioning.checkout();
       }
       else
       {
          nodeVersioning.checkin();
          nodeVersioning.checkout();
       }
  
      if(maxAllowVersion!= DOCUMENT_AUTO_DEFAULT_VERSION_MAX || maxLiveTime != DOCUMENT_AUTO_DEFAULT_VERSION_EXPIRED) {
        removeRedundant(nodeVersioning);
      }
      nodeVersioning.save();
    }
docs: Create new version and clear redundant versions
  
  @param nodeVersioning