Package com.google.gerrit.server.notedb
Class ChangeDraftNotesUpdate
java.lang.Object
com.google.gerrit.server.notedb.AbstractChangeUpdate
com.google.gerrit.server.notedb.ChangeDraftNotesUpdate
- All Implemented Interfaces:
ChangeDraftUpdate
A single delta to apply atomically to a change.
This delta contains only draft comments on a single patch set of a change by a single author. This delta will become a single commit in the All-Users repository.
This class is not thread safe.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface com.google.gerrit.server.ChangeDraftUpdate
ChangeDraftUpdate.ChangeDraftUpdateFactory
-
Field Summary
Fields inherited from class com.google.gerrit.server.notedb.AbstractChangeUpdate
accountId, authorIdent, noteUtil, psId, realAccountId, serverIdent, when
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAllDraftCommentsForDeletion
(List<Comment> comments) Marks all comments for deletion.void
Marks a comment for deletion.protected org.eclipse.jgit.lib.CommitBuilder
applyImpl
(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectInserter ins, org.eclipse.jgit.lib.ObjectId curr) Create a commit containing the contents of this update.static Optional<ChangeDraftNotesUpdate>
boolean
protected Project.NameKey
Returns the NameKey for the project where the update will be stored, which is not necessarily the same as the change's project.protected String
boolean
isEmpty()
Whether no updates have been done.void
Marks a comment for deletion.void
Creates a draft comment.protected void
setParentCommit
(org.eclipse.jgit.lib.CommitBuilder cb, org.eclipse.jgit.lib.ObjectId parentCommitId) Methods inherited from class com.google.gerrit.server.notedb.AbstractChangeUpdate
allowWriteToNewRef, bypassMaxUpdates, getAccountId, getChange, getId, getNotes, getNullableAccountId, getPatchSetId, getRealAccountId, getWhen, setPatchSetId
-
Method Details
-
putDraftComment
Description copied from interface:ChangeDraftUpdate
Creates a draft comment.- Specified by:
putDraftComment
in interfaceChangeDraftUpdate
-
markDraftCommentAsPublished
Description copied from interface:ChangeDraftUpdate
Marks a comment for deletion. Called when the comment is deleted because the user published it.NOTE for implementers: The actual deletion of a published draft should only happen after the published comment is successfully updated. For more context, see
NoteDbUpdateManager.execute(boolean)
.TODO(nitzan) - add generalized support for the above sync issue. The implementation should support deletion of published drafts from multiple ChangeDraftUpdateFactory instances.
- Specified by:
markDraftCommentAsPublished
in interfaceChangeDraftUpdate
-
addDraftCommentForDeletion
Description copied from interface:ChangeDraftUpdate
Marks a comment for deletion. Called when the comment is deleted because the user removed it.- Specified by:
addDraftCommentForDeletion
in interfaceChangeDraftUpdate
-
addAllDraftCommentsForDeletion
Description copied from interface:ChangeDraftUpdate
Marks all comments for deletion. Called when there are inconsistencies between the published comments storage and the drafts one.- Specified by:
addAllDraftCommentsForDeletion
in interfaceChangeDraftUpdate
-
canRunAsync
public boolean canRunAsync() -
applyImpl
protected org.eclipse.jgit.lib.CommitBuilder applyImpl(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectInserter ins, org.eclipse.jgit.lib.ObjectId curr) throws IOException Description copied from class:AbstractChangeUpdate
Create a commit containing the contents of this update.- Specified by:
applyImpl
in classAbstractChangeUpdate
ins
- inserter to write to; callers should not flush.- Returns:
- a new commit builder representing this commit, or null to indicate the meta ref should
be deleted as a result of this update. The parent, author, and committer fields in the
return value are always overwritten. The tree ID may be unset by this method, which
indicates to the caller that it should be copied from the parent commit. To indicate that
this update is a no-op (but this could not be determined by
AbstractChangeUpdate.isEmpty()
), return the sentinelAbstractChangeUpdate.NO_OP_UPDATE
. - Throws:
IOException
- if a lower-level error occurred.
-
getProjectName
Description copied from class:AbstractChangeUpdate
Returns the NameKey for the project where the update will be stored, which is not necessarily the same as the change's project.- Specified by:
getProjectName
in classAbstractChangeUpdate
-
getRefName
- Specified by:
getRefName
in classAbstractChangeUpdate
-
setParentCommit
protected void setParentCommit(org.eclipse.jgit.lib.CommitBuilder cb, org.eclipse.jgit.lib.ObjectId parentCommitId) - Overrides:
setParentCommit
in classAbstractChangeUpdate
-
isEmpty
public boolean isEmpty()Description copied from class:AbstractChangeUpdate
Whether no updates have been done.- Specified by:
isEmpty
in classAbstractChangeUpdate
-
asChangeDraftNotesUpdate
-