docs: private InternalDocumentRevision createDocumentBody(SQLDatabase db, String docId, final DocumentBody
              body)
              throws AttachmentException, ConflictException, DocumentStoreException {
          Misc.checkState(this.isOpen(), "Database is closed");
          CouchUtils.validateDocumentId(docId);
          Misc.checkNotNull(body, "Input document body");
          this.validateDBBody(body);
  
          // check if the docid exists first:
  
          // if it does exist:
          // * if winning leaf deleted, root the 'created' document there
          // * else raise error
          // if it does not exist:
          // * normal insert logic for a new document
  
          InsertRevisionCallable callable = new InsertRevisionCallable();
          InternalDocumentRevision potentialParent = null;
  
          try {
              potentialParent = new GetDocumentCallable(docId, null, this.attachmentsDir, this.attachmentStreamFactory).call(db);
          } catch (DocumentNotFoundException e) {
              //this is an expected exception, it just means we are
              // resurrecting the document
          }
  
          if (potentialParent != null) {
              if (!potentialParent.isDeleted()) {
                  // current winner not deleted, can't insert
                  throw new ConflictException(String.format("Cannot create doc, document with id %s" +
                          " already exists "
                          , docId));
              }
              // if we got here, parent rev was deleted
              new SetCurrentCallable(potentialParent.getSequence(), false).call(db);
              callable.revId = CouchUtils.generateNextRevisionId(potentialParent.getRevision());
              callable.docNumericId = potentialParent.getInternalNumericId();
              callable.parentSequence = potentialParent.getSequence();
          } else {
              // otherwise we are doing a normal create document
              long docNumericId = new InsertDocumentIDCallable(docId).call(db);
              callable.revId = CouchUtils.getFirstRevisionId();
              callable.docNumericId = docNumericId;
              callable.parentSequence = -1l;
          }
          callable.deleted = false;
          callable.current = true;
          callable.data = body.asBytes();
          callable.available = true;
          callable.call(db);
  
          try {
              InternalDocumentRevision doc = new GetDocumentCallable(docId, callable.revId, this.attachmentsDir, this.attachmentStreamFactory).call(db);
              logger.finer("New document created: " + doc.toString());
              return doc;
          } catch (DocumentNotFoundException e) {
              throw new RuntimeException(String.format("Could not get document we just inserted " +
                      "(id: %s); this should not happen, please file an issue with as much detail " +
                      "as possible.", docId), e);
          }
  
      }