use of com.google.gerrit.server.notedb.ChangeNoteUtil.ParsedPatchSetApproval in project gerrit by GerritCodeReview.
the class ChangeNotesParser method parseCopiedApproval.
/**
* Parses copied {@link PatchSetApproval}.
*/
private void parseCopiedApproval(PatchSet.Id psId, Instant ts, String line) throws ConfigInvalidException {
ParsedPatchSetApproval parsedPatchSetApproval = ChangeNoteUtil.parseCopiedApproval(line);
checkFooter(parsedPatchSetApproval.accountIdent().isPresent(), FOOTER_COPIED_LABEL, parsedPatchSetApproval.footerLine());
PersonIdent accountIdent = RawParseUtils.parsePersonIdent(parsedPatchSetApproval.accountIdent().get());
checkFooter(accountIdent != null, FOOTER_COPIED_LABEL, parsedPatchSetApproval.footerLine());
Account.Id accountId = parseIdent(accountIdent);
Account.Id realAccountId = null;
if (parsedPatchSetApproval.realAccountIdent().isPresent()) {
PersonIdent realIdent = RawParseUtils.parsePersonIdent(parsedPatchSetApproval.realAccountIdent().get());
checkFooter(realIdent != null, FOOTER_COPIED_LABEL, parsedPatchSetApproval.footerLine());
realAccountId = parseIdent(realIdent);
}
LabelVote l;
try {
l = LabelVote.parseWithEquals(parsedPatchSetApproval.labelVote());
} catch (IllegalArgumentException e) {
ConfigInvalidException pe = parseException("invalid %s: %s", FOOTER_COPIED_LABEL, parsedPatchSetApproval.footerLine());
pe.initCause(e);
throw pe;
}
PatchSetApproval.Builder psa = PatchSetApproval.builder().key(PatchSetApproval.key(psId, accountId, LabelId.create(l.label()))).uuid(parsedPatchSetApproval.uuid().map(PatchSetApproval::uuid)).value(l.value()).granted(ts).tag(parsedPatchSetApproval.tag()).copied(true);
if (realAccountId != null) {
psa.realAccountId(realAccountId);
}
approvals.putIfAbsent(psa.key(), psa);
bufferedApprovals.add(psa);
}
use of com.google.gerrit.server.notedb.ChangeNoteUtil.ParsedPatchSetApproval in project gerrit by GerritCodeReview.
the class ChangeNotesParser method parseApproval.
private void parseApproval(PatchSet.Id psId, Account.Id accountId, Account.Id realAccountId, Instant ts, String line) throws ConfigInvalidException {
if (accountId == null) {
throw parseException("patch set %s requires an identified user as uploader", psId.get());
}
PatchSetApproval.Builder psa;
ParsedPatchSetApproval parsedPatchSetApproval = ChangeNoteUtil.parseApproval(line);
if (line.startsWith("-")) {
psa = parseRemoveApproval(psId, accountId, realAccountId, ts, parsedPatchSetApproval);
} else {
psa = parseAddApproval(psId, accountId, realAccountId, ts, parsedPatchSetApproval);
}
bufferedApprovals.add(psa);
}
use of com.google.gerrit.server.notedb.ChangeNoteUtil.ParsedPatchSetApproval in project gerrit by GerritCodeReview.
the class ChangeNotesParser method parseAddApproval.
/**
* Parses {@link PatchSetApproval} out of the {@link ChangeNoteUtil#FOOTER_LABEL} value.
*/
private PatchSetApproval.Builder parseAddApproval(PatchSet.Id psId, Account.Id committerId, Account.Id realAccountId, Instant ts, ParsedPatchSetApproval parsedPatchSetApproval) throws ConfigInvalidException {
Account.Id approverId = parseApprover(committerId, parsedPatchSetApproval);
LabelVote l;
try {
l = LabelVote.parseWithEquals(parsedPatchSetApproval.labelVote());
} catch (IllegalArgumentException e) {
ConfigInvalidException pe = parseException("invalid %s: %s", FOOTER_LABEL, parsedPatchSetApproval.footerLine());
pe.initCause(e);
throw pe;
}
PatchSetApproval.Builder psa = PatchSetApproval.builder().key(PatchSetApproval.key(psId, approverId, LabelId.create(l.label()))).uuid(parsedPatchSetApproval.uuid().map(PatchSetApproval::uuid)).value(l.value()).granted(ts).tag(Optional.ofNullable(tag));
if (!Objects.equals(realAccountId, committerId)) {
psa.realAccountId(realAccountId);
}
approvals.putIfAbsent(psa.key(), psa);
return psa;
}
Aggregations