WorkspaceId workspaceId = action.getWorkspaceId();
HProject project =
securityServiceImpl.checkWorkspaceStatus(workspaceId);
HTextFlowTarget hTextFlowTarget =
textFlowTargetDAO.getTextFlowTarget(action.getTransUnitId()
.getValue(), workspaceId.getLocaleId());
if (hTextFlowTarget == null
|| hTextFlowTarget.getState().isUntranslated()) {
throw new ActionException(
"comment on untranslated message is pointless!");
}
HLocale locale =
localeServiceImpl.getByLocaleId(workspaceId.getLocaleId());
identity.checkPermission("review-comment", locale, project);
TranslationWorkspace workspace =
translationWorkspaceManager.getOrRegisterWorkspace(workspaceId);
HTextFlowTargetReviewComment hComment =
hTextFlowTarget.addReviewComment(action.getContent(),
authenticatedAccount.getPerson());
textFlowTargetReviewCommentsDAO.makePersistent(hComment);
textFlowTargetReviewCommentsDAO.flush();
AddReviewComment commentEvent = new AddReviewComment(
new TransUnitId(hTextFlowTarget.getTextFlow().getId()),
hTextFlowTarget.getReviewComments().size());
workspace.publish(commentEvent);
return new AddReviewCommentResult(toDTO(hComment));
}