Package com.appspot.secretcuz.entity

Examples of com.appspot.secretcuz.entity.BlogPost


    String retCursor = query.iterator().getCursor().toWebSafeString();
    return new Builder<BlogPost>().setItems(retList).setNextPageToken(retCursor).build();
  }

  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


    ofy().save().entity(bpc).now();
    return bp;
  }

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

    return bp;
  }

  public void removeBlogPost(@Named("id") Long id, User user) throws OAuthRequestException, NotFoundException {
    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) {
View Full Code Here

  public static List<BlogPost> get() {
    return ofy().load().type(BlogPost.class).order("-date").list();
  }
 
  public static BlogPost get(Long id) {
    BlogPost bp = ofy().load().type(BlogPost.class).id(id).get();
    return bp;
  }
View Full Code Here

TOP

Related Classes of com.appspot.secretcuz.entity.BlogPost

Copyright © 2018 www.massapicom. 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.