return Response.ok(transUnits).build();
}
@Override
public Response put(String localeId, TranslationData data) {
TranslationData requestData = data;
HLocale locale = localeDAO.findByLocaleId(new LocaleId(localeId));
HTextFlow textFlow =
textFlowDAO.findById(requestData.getId().longValue());
if (textFlow == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
identity.checkPermission("modify-translation",
textFlow.getDocument().getProjectIteration().getProject(),
locale);
// //Only support 1 translation update for the moment
TransUnitUpdateRequest request =
new TransUnitUpdateRequest(new TransUnitId(requestData.getId()
.longValue()), requestData.getContents(),
requestData.getStatus(), requestData.getRevision());
List<TranslationResult> translationResults =
translationServiceImpl.translate(new LocaleId(localeId),
Lists.newArrayList(request));
TranslationResult result = translationResults.get(0);
if (result.isVersionNumConflict()) {
return Response.status(Response.Status.CONFLICT).build();
} else if (!result.isTranslationSuccessful()) {
return Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.build();
} else {
requestData.setStatus(result.getTranslatedTextFlowTarget()
.getState());
requestData.setRevision(result.getTranslatedTextFlowTarget()
.getVersionNum());
return Response.ok(requestData).build();
}
}