Source:
private BasicDocumentRevision deleteDocumentInQueue(SQLDatabase db, final String docId, final String prevRevId) throws ConflictException, DocumentNotFoundException { Preconditions.checkState(this.isOpen(), "Database is closed"); Preconditions.checkArgument(!Strings.isNullOrEmpty(docId), "Input document id can not be empty"); Preconditions.checkArgument(!Strings.isNullOrEmpty(prevRevId), "Input previous revision id can not be empty"); CouchUtils.validateRevisionId(prevRevId); BasicDocumentRevision deletedRevision = null; BasicDocumentRevision preRevision; try { preRevision = getDocumentInQueue(db, docId, prevRevId); } catch (AttachmentException e){ throw new DocumentNotFoundException(e); } DocumentRevisionTree revisionTree; try { revisionTree = getAllRevisionsOfDocumentInQueue(db, docId); } catch(AttachmentException e){ throw new DocumentNotFoundException(e); } if (!revisionTree.leafRevisionIds().contains(prevRevId)) { throw new ConflictException("Revision to be deleted is not a leaf node:" + prevRevId); } if (!preRevision.isDeleted()) { setCurrent(db, preRevision, false); String newRevisionId = CouchUtils.generateNextRevisionId(preRevision.getRevision()); InsertRevisionOptions options = new InsertRevisionOptions(); options.docNumericId = preRevision.getInternalNumericId(); options.revId = newRevisionId; options.parentSequence = preRevision.getSequence(); options.deleted = true; options.current = preRevision.isCurrent(); options.data = JSONUtils.EMPTY_JSON; options.available = false; options.copyAttachments = false; try { insertRevision(db, options); } catch (AttachmentException e) { throw new RuntimeException("Attachments should not be copied for a delete op",e); } try { return getDocumentInQueue(db, preRevision.getId(), newRevisionId); } catch (AttachmentException e){ throw new DocumentNotFoundException(e); } } else { throw new DocumentNotFoundException("Previous Revision is already deleted"); } }

Target:
private BasicDocumentRevision deleteDocumentInQueue(SQLDatabase db, final String docId, final String prevRevId) throws ConflictException, DocumentNotFoundException, DatastoreException { Preconditions.checkState(this.isOpen(), "Database is closed"); Preconditions.checkArgument(!Strings.isNullOrEmpty(docId), "Input document id can not be empty"); Preconditions.checkArgument(!Strings.isNullOrEmpty(prevRevId), "Input previous revision id can not be empty"); CouchUtils.validateRevisionId(prevRevId); BasicDocumentRevision prevRevision; try { prevRevision = getDocumentInQueue(db, docId, prevRevId); } catch (AttachmentException e){ throw new DocumentNotFoundException(e); } DocumentRevisionTree revisionTree; try { revisionTree = getAllRevisionsOfDocumentInQueue(db, docId); } catch(AttachmentException e){ throw new DocumentNotFoundException(e); } if (!revisionTree.leafRevisionIds().contains(prevRevId)) { throw new ConflictException("Document has newer revisions than the revision " + "passed to delete; get the newest revision of the document and try again."); } if (prevRevision.isDeleted()) { throw new DocumentNotFoundException("Previous Revision is already deleted"); } setCurrent(db, prevRevision, false); String newRevisionId = CouchUtils.generateNextRevisionId(prevRevision.getRevision()); InsertRevisionOptions options = new InsertRevisionOptions(); options.docNumericId = prevRevision.getInternalNumericId(); options.revId = newRevisionId; options.parentSequence = prevRevision.getSequence(); options.deleted = true; options.current = prevRevision.isCurrent(); options.data = JSONUtils.EMPTY_JSON; options.available = false; insertRevision(db, options); try { return getDocumentInQueue(db, prevRevision.getId(), newRevisionId); } catch (AttachmentException e){ throw new DocumentNotFoundException(e); } }