Source:
<code>public Response<?> apply(VoteResource rsrc, Input input) throws AuthException, ResourceNotFoundException, OrmException, IOException { ChangeControl ctl = rsrc.getReviewer().getControl(); Change change = rsrc.getReviewer().getChange(); Change.Id changeId = change.getId(); ReviewDb db = dbProvider.get(); ChangeUpdate update = updateFactory.create(ctl); LabelVote labelVote = rsrc.getVote(); Account.Id accountId = rsrc.getReviewer().getUser().getAccountId(); StringBuilder msg = new StringBuilder(); db.changes().beginTransaction(changeId); try { PatchSetApproval psa = null; for (PatchSetApproval a : approvalsUtil.byPatchSetUser( db, ctl, change.currentPatchSetId(), accountId)) { if (ctl.canRemoveReviewer(a)) { if (a.getLabel().equals(labelVote.label()) && a.getValue() == rsrc.getVote().value()) { msg.append("Removed ") .append(a.getLabel()).append(formatLabelValue(a.getValue())) .append(" by ").append(userFactory.create(accountId) .getNameEmail()) .append("\n"); psa = a; <START> a.setValue((short)0); <END> break; } } else { throw new AuthException("delete not permitted"); } } if (psa == null) { throw new ResourceNotFoundException(); } ChangeUtil.bumpRowVersionNotLastUpdatedOn(changeId, db); db.patchSetApprovals().update(Collections.singleton(psa)); if (msg.length() > 0) { ChangeMessage changeMessage = new ChangeMessage(new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db)), ctl.getUser().getAccountId(), TimeUtil.nowTs(), change.currentPatchSetId()); changeMessage.setMessage(msg.toString()); cmUtil.addChangeMessage(db, update, changeMessage); } db.commit(); } finally { db.rollback(); } update.commit(); indexer.index(db, change); return Response.none(); }</code><technical_language>1. Is this needed notedb is enabled? 2. if default is zero is else</technical_language>

Target:
public Response<?> apply(VoteResource rsrc, Input input) throws AuthException, ResourceNotFoundException, OrmException, IOException { ChangeControl ctl = rsrc.getReviewer().getControl(); Change change = rsrc.getReviewer().getChange(); Change.Id changeId = change.getId(); ReviewDb db = dbProvider.get(); ChangeUpdate update = updateFactory.create(ctl); LabelVote labelVote = rsrc.getVote(); Account.Id accountId = rsrc.getReviewer().getUser().getAccountId(); StringBuilder msg = new StringBuilder(); db.changes().beginTransaction(changeId); try { PatchSetApproval psa = null; for (PatchSetApproval a : approvalsUtil.byPatchSetUser( db, ctl, change.currentPatchSetId(), accountId)) { if (ctl.canRemoveReviewer(a)) { if (a.getLabel().equals(labelVote.label()) && a.getValue() == rsrc.getVote().value()) { msg.append("Removed ") .append(a.getLabel()).append(formatLabelValue(a.getValue())) .append(" by ").append(userFactory.create(accountId) .getNameEmail()) .append("\n"); psa = a; a.setValue((short)0); update.putApproval(labelVote.label(), (short)0); break; } } else { throw new AuthException("delete not permitted"); } } if (psa == null) { throw new ResourceNotFoundException(); } ChangeUtil.bumpRowVersionNotLastUpdatedOn(changeId, db); db.patchSetApprovals().update(Collections.singleton(psa)); if (msg.length() > 0) { ChangeMessage changeMessage = new ChangeMessage(new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db)), ctl.getUser().getAccountId(), TimeUtil.nowTs(), change.currentPatchSetId()); changeMessage.setMessage(msg.toString()); cmUtil.addChangeMessage(db, update, changeMessage); } db.commit(); } finally { db.rollback(); } update.commit(); indexer.index(db, change); return Response.none(); }