Source:
<code>public ReviewResult call() throws NoSuchChangeException, OrmException { final ReviewResult result = new ReviewResult(); final Change.Id changeId = patchSetId.getParentKey(); result.setChangeId(changeId); final ChangeControl control = changeControlFactory.validateFor(changeId); final PatchSet patch = db.patchSets().get(patchSetId); if (patch == null) { throw new NoSuchChangeException(changeId); } if (!patch.isDraft()) { result.addError(new ReviewResult.Error( ReviewResult.Error.Type.NOT_A_DRAFT)); return result; } if (!control.canPublish(db)) { result.addError(new ReviewResult.Error( ReviewResult.Error.Type.PUBLISH_NOT_PERMITTED)); } else { db.patchSets().atomicUpdate(patchSetId, new AtomicUpdate<PatchSet>() { @Override public PatchSet update(PatchSet patchset) { if (patchset.isDraft()) { patchset.setDraft(false); } return null; } }); final Change change = db.changes().get(changeId); if (change.getStatus() == Change.Status.DRAFT) { final Change updatedChange = db.changes().atomicUpdate(changeId, new AtomicUpdate<Change>() { @Override public Change update(Change change) { if (change.getStatus() == Change.Status.DRAFT) { change.setStatus(Change.Status.NEW); ChangeUtil.updated(change); return change; } else { return null; } } }); if ((updatedChange != null) && (updatedChange.getStatus() == Change.Status.NEW)) { <START> hooks.doDraftPublishedHook(updatedChange, patch, db); <END> } } } return result; }</code><technical_language>Calling hook creates a draft-published event patch-set of a change uploaded draft published, change status switches DRAFT NEW. if a new draft patch set is uploaded for a change is in review this patch set published, event is fired (since change is more in DRAFT state do enter if in line 88). I ensure event is fired if a draft patch set a change in review is published</technical_language>

Target:
public ReviewResult call() throws NoSuchChangeException, OrmException { final ReviewResult result = new ReviewResult(); final Change.Id changeId = patchSetId.getParentKey(); result.setChangeId(changeId); final ChangeControl control = changeControlFactory.validateFor(changeId); final PatchSet patch = db.patchSets().get(patchSetId); if (patch == null) { throw new NoSuchChangeException(changeId); } if (!patch.isDraft()) { result.addError(new ReviewResult.Error( ReviewResult.Error.Type.NOT_A_DRAFT)); return result; } if (!control.canPublish(db)) { result.addError(new ReviewResult.Error( ReviewResult.Error.Type.PUBLISH_NOT_PERMITTED)); } else { boolean published = false; final PatchSet updatedPatch = db.patchSets().atomicUpdate(patchSetId, new AtomicUpdate<PatchSet>() { @Override public PatchSet update(PatchSet patchset) { if (patchset.isDraft()) { patchset.setDraft(false); return patchset; } return null; } }); if ((updatedPatch != null) && (!updatedPatch.isDraft())) { published = true; } final Change change = db.changes().get(changeId); if (change.getStatus() == Change.Status.DRAFT) { final Change updatedChange = db.changes().atomicUpdate(changeId, new AtomicUpdate<Change>() { @Override public Change update(Change change) { if (change.getStatus() == Change.Status.DRAFT) { change.setStatus(Change.Status.NEW); ChangeUtil.updated(change); return change; } else { return null; } } }); if ((updatedChange != null) && (updatedChange.getStatus() == Change.Status.NEW)) { published = true; } } if (published) { hooks.doDraftPublishedHook(change, patch, db); } } return result; }