Examples of BlogPostContent


Examples of com.appspot.secretcuz.entity.BlogPostContent

  public BlogPost getBlogPost(@Named("id") Long id) throws NotFoundException {
    BlogPost bp = ofy().load().type(BlogPost.class).id(id).get();
    if (bp == null) {
      throw new NotFoundException("No entity with the id " + id + " exists.");
    }
    BlogPostContent bpc = ofy().load().type(BlogPostContent.class).id(id).get();
    if (bpc == null) {
      throw new NotFoundException("No entity with the id " + id + " exists.");
    }
    bp.setContent(bpc.getContent());
    return bp;
  }
View Full Code Here

Examples of com.appspot.secretcuz.entity.BlogPostContent

    bp.setContent(bpc.getContent());
    return bp;
  }

  public BlogPost insertBlogPost(BlogPost bp) {
    BlogPostContent bpc = new BlogPostContent();
    bpc.setContent(bp.getContent());
    //save BlogPost without content
    bp.setContent("");
    ofy().save().entity(bp).now();
    bpc.setId(bp.getId());
    ofy().save().entity(bpc).now();
    return bp;
  }
View Full Code Here

Examples of com.appspot.secretcuz.entity.BlogPostContent

  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;
  }
View Full Code Here

Examples of com.appspot.secretcuz.entity.BlogPostContent

    if (user != null) {
      BlogPost deletedBp = ofy().load().type(BlogPost.class).id(id).get();
      if (deletedBp == null) {
        throw new NotFoundException("No entity with the id " + id + " exists.");
      }
      BlogPostContent deletedBpc = ofy().load().type(BlogPostContent.class).id(id).get();
      if (deletedBpc == null) {
        throw new NotFoundException("No entity with the id " + id + " exists.");
      }
      ofy().delete().entity(deletedBp);
      ofy().delete().entity(deletedBpc);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.