// Now we are sure to have document type definition:
if (((DocumentTypeDefinition) typeDef).isVersionable()) {
DocumentVersion version = objectStore.createVersionedDocument(name, propMap,
user, folder, addACEs, removeACEs, contentStream, versioningState);
version.persist();
so = version; // return the version and not the version series to caller
} else {
Document doc = objectStore.createDocument(name, propMap, user, folder, addACEs, removeACEs);
doc.setContent(contentStream, false);
doc.persist();