Package com.google.gerrit.server
Class ChangeMessagesUtil
- java.lang.Object
-
- com.google.gerrit.server.ChangeMessagesUtil
-
public class ChangeMessagesUtil extends Object
Utility functions to manipulate ChangeMessages.These methods either query for and update ChangeMessages in the NoteDb or ReviewDb, depending on the state of the NotesMigration.
-
-
Field Summary
Fields Modifier and Type Field Description static String
AUTOGENERATED_TAG_PREFIX
static String
TAG_ABANDON
static String
TAG_CHERRY_PICK_CHANGE
static String
TAG_DELETE_ASSIGNEE
static String
TAG_DELETE_REVIEWER
static String
TAG_DELETE_VOTE
static String
TAG_MERGED
static String
TAG_MOVE
static String
TAG_RESTORE
static String
TAG_REVERT
static String
TAG_SET_ASSIGNEE
static String
TAG_SET_DESCRIPTION
static String
TAG_SET_HASHTAGS
static String
TAG_SET_PRIVATE
static String
TAG_SET_READY
static String
TAG_SET_TOPIC
static String
TAG_SET_WIP
static String
TAG_UNSET_PRIVATE
static String
TAG_UPLOADED_PATCH_SET
static String
TAG_UPLOADED_WIP_PATCH_SET
-
Constructor Summary
Constructors Constructor Description ChangeMessagesUtil(NotesMigration migration)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChangeMessage(ReviewDb db, ChangeUpdate update, ChangeMessage changeMessage)
List<ChangeMessage>
byChange(ReviewDb db, ChangeNotes notes)
static ChangeMessageInfo
createChangeMessageInfo(ChangeMessage message, AccountLoader accountLoader)
static boolean
isAutogenerated(String tag)
static ChangeMessage
newMessage(PatchSet.Id psId, CurrentUser user, Timestamp when, String body, String tag)
static ChangeMessage
newMessage(ChangeContext ctx, String body, String tag)
void
replaceChangeMessage(ReviewDb db, ChangeUpdate update, int targetMessageIdx, String newMessage)
Replace an existing change message with the provided new message.static String
uploadedPatchSetTag(boolean workInProgress)
-
-
-
Field Detail
-
AUTOGENERATED_TAG_PREFIX
public static final String AUTOGENERATED_TAG_PREFIX
- See Also:
- Constant Field Values
-
TAG_ABANDON
public static final String TAG_ABANDON
- See Also:
- Constant Field Values
-
TAG_CHERRY_PICK_CHANGE
public static final String TAG_CHERRY_PICK_CHANGE
- See Also:
- Constant Field Values
-
TAG_DELETE_ASSIGNEE
public static final String TAG_DELETE_ASSIGNEE
- See Also:
- Constant Field Values
-
TAG_DELETE_REVIEWER
public static final String TAG_DELETE_REVIEWER
- See Also:
- Constant Field Values
-
TAG_DELETE_VOTE
public static final String TAG_DELETE_VOTE
- See Also:
- Constant Field Values
-
TAG_MERGED
public static final String TAG_MERGED
- See Also:
- Constant Field Values
-
TAG_MOVE
public static final String TAG_MOVE
- See Also:
- Constant Field Values
-
TAG_RESTORE
public static final String TAG_RESTORE
- See Also:
- Constant Field Values
-
TAG_REVERT
public static final String TAG_REVERT
- See Also:
- Constant Field Values
-
TAG_SET_ASSIGNEE
public static final String TAG_SET_ASSIGNEE
- See Also:
- Constant Field Values
-
TAG_SET_DESCRIPTION
public static final String TAG_SET_DESCRIPTION
- See Also:
- Constant Field Values
-
TAG_SET_HASHTAGS
public static final String TAG_SET_HASHTAGS
- See Also:
- Constant Field Values
-
TAG_SET_PRIVATE
public static final String TAG_SET_PRIVATE
- See Also:
- Constant Field Values
-
TAG_SET_READY
public static final String TAG_SET_READY
- See Also:
- Constant Field Values
-
TAG_SET_TOPIC
public static final String TAG_SET_TOPIC
- See Also:
- Constant Field Values
-
TAG_SET_WIP
public static final String TAG_SET_WIP
- See Also:
- Constant Field Values
-
TAG_UNSET_PRIVATE
public static final String TAG_UNSET_PRIVATE
- See Also:
- Constant Field Values
-
TAG_UPLOADED_PATCH_SET
public static final String TAG_UPLOADED_PATCH_SET
- See Also:
- Constant Field Values
-
TAG_UPLOADED_WIP_PATCH_SET
public static final String TAG_UPLOADED_WIP_PATCH_SET
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ChangeMessagesUtil
@Inject public ChangeMessagesUtil(NotesMigration migration)
-
-
Method Detail
-
newMessage
public static ChangeMessage newMessage(ChangeContext ctx, String body, String tag)
-
newMessage
public static ChangeMessage newMessage(PatchSet.Id psId, CurrentUser user, Timestamp when, String body, String tag)
-
uploadedPatchSetTag
public static String uploadedPatchSetTag(boolean workInProgress)
-
byChange
public List<ChangeMessage> byChange(ReviewDb db, ChangeNotes notes) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
addChangeMessage
public void addChangeMessage(ReviewDb db, ChangeUpdate update, ChangeMessage changeMessage) throws com.google.gwtorm.server.OrmException
- Throws:
com.google.gwtorm.server.OrmException
-
replaceChangeMessage
public void replaceChangeMessage(ReviewDb db, ChangeUpdate update, int targetMessageIdx, String newMessage) throws com.google.gwtorm.server.OrmException
Replace an existing change message with the provided new message.The ID of a change message is different between NoteDb and ReviewDb. In NoteDb, it's the commit SHA-1, but in ReviewDb it's generated randomly. To make sure the change message can be deleted from both NoteDb and ReviewDb, the index of the change message must be used rather than its ID.
- Parameters:
db
- theReviewDb
instance to update.update
- change update.targetMessageIdx
- the index of the target change message.newMessage
- the new message which is going to replace the old.- Throws:
com.google.gwtorm.server.OrmException
-
isAutogenerated
public static boolean isAutogenerated(String tag)
- Parameters:
tag
- value of a tag, or null.- Returns:
- whether the tag starts with the autogenerated prefix.
-
createChangeMessageInfo
public static ChangeMessageInfo createChangeMessageInfo(ChangeMessage message, AccountLoader accountLoader)
-
-