Response.ResponseBuilder response = request.evaluatePreconditions(etag);
if (response != null) {
return response.build();
}
HDocument doc =
documentDAO.getByDocIdAndIteration(hProjectIteration, id);
if (doc == null || doc.isObsolete()) {
return Response.status(Response.Status.NOT_FOUND)
.entity("document not found").build();
}
Resource entity = new Resource(doc.getDocId());
log.debug("get resource details {}", entity.toString());
resourceUtils.transferToResource(doc, entity);
for (HTextFlow htf : doc.getTextFlows()) {
TextFlow tf =
new TextFlow(htf.getResId(), doc.getLocale().getLocaleId());
resourceUtils.transferToTextFlow(htf, tf);
resourceUtils.transferToTextFlowExtensions(htf,
tf.getExtensions(true), extensions);
entity.getTextFlows().add(tf);
}
// handle extensions
resourceUtils.transferToResourceExtensions(doc,
entity.getExtensions(true), extensions);
log.debug("Get resource :{}", entity.toString());
return Response.ok().entity(entity).tag(etag)
.lastModified(doc.getLastChanged()).build();
}