public BlogPost updateBlogPost(@Named("id") Long id, BlogPost bp) throws NotFoundException {
BlogPost updatedBp = ofy().load().type(BlogPost.class).id(id).get();
if (updatedBp == null) {
throw new NotFoundException("No entity with the id " + id + " exists.");
}
BlogPostContent updatedBpc = ofy().load().type(BlogPostContent.class).id(id).get();
if (updatedBpc == null) {
throw new NotFoundException("No entity with the id " + id + " exists.");
}
if (bp.getTitle() != null) {
updatedBp.setTitle(bp.getTitle());
}
if (bp.getMeta() != null) {
updatedBp.setMeta(bp.getMeta());
}
if (bp.getDate() != null) {
updatedBp.setDate(bp.getDate());
}
if (bp.getAuthor() != null) {
updatedBp.setAuthor(bp.getAuthor());
}
if (bp.getContent() != null) {
updatedBpc.setContent(bp.getContent());
}
ofy().save().entity(updatedBp).now();
ofy().save().entity(updatedBpc).now();
//return BlogPost with content
bp.setContent(updatedBpc.getContent());
return bp;
}