Examples of BlogPost


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

Examples of com.appspot.secretcuz.entity.BlogPost

    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

Examples of com.appspot.secretcuz.entity.BlogPost

    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

Examples of com.appspot.secretcuz.entity.BlogPost

  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

Examples of com.eniac.blog.dao.domain.BlogPost

  private SessionFactory factory;

  public void addPost(String post) {
    final Session session = factory.openSession();
    try{
      BlogPost blogPost = new BlogPost();
      blogPost.setEntry(post);
      session.save(blogPost);
      System.out.println();
    } finally {
      session.close();
    }
View Full Code Here

Examples of com.eniac.blog.dao.domain.BlogPost

  }

  public void addComment(final int postId, final String comment) {
    final Session session = factory.openSession();
    try{
      final BlogPost post = (BlogPost) session.load(BlogPost.class, postId);
      final BlogPostComment postComment = post.addComment(comment);
      session.save(postComment);
    } finally {
      session.close();
    }
  }
View Full Code Here

Examples of com.lissenberg.blog.domain.BlogPost

  private UserService userService;

    @Test
    public void testInsertBlog() throws Exception {
    // upgrader should have inserted first post
    BlogPost firstPost = blogService.getLatestPost();
        Assert.assertNotNull(firstPost);

    User user = new User();
    user.setUsername("test_user_" + System.currentTimeMillis());
    user.setName("Test user");
    user.setRole(UserRole.WRITER);
    userService.saveUser(user, "secret");

    BlogPost newPost = new BlogPost();
    newPost.setAuthor(user);
    newPost.setPosted(new Date());
    newPost.setTitle("Test title");
    newPost.setText("This is a test post.");
    blogService.savePost(newPost);
   
    BlogPost latestPost = blogService.getLatestPost();
    Assert.assertNotSame(firstPost.getId(), latestPost.getId());
    Assert.assertEquals(newPost.getId(), latestPost.getId());

    }
View Full Code Here

Examples of com.lissenberg.blog.domain.BlogPost

    public void testInsertBlog() {
        User user = new User();
        user.setName("name");
        user.setUsername("username");
        user.setRole(UserRole.WRITER);
        BlogPost post = new BlogPost();
        post.setAuthor(user);
        post.setPosted(new Date());
        post.setText("Lorum Ipsum");
        post.setTitle("Test post title");

        entityTransaction.begin();
        entityManager.persist(user);
        entityManager.persist(post);
        entityTransaction.commit();
        assertNotNull(post.getId());

        List<BlogPost> posts = blogService.getLatestPosts(0, 10);
        assertEquals(1, posts.size());
        assertEquals(post.getId(), posts.get(0).getId());

    }
View Full Code Here

Examples of com.lissenberg.blog.domain.BlogPost

        admin.setPasswordHash(securityService.createHash("secret"));
        entityManager.persist(admin);

        LOG.info("Inserting first post");
        // create first post
        BlogPost post = new BlogPost();
        post.setAuthor(admin);
        post.setTitle("First post!");
        post.setText("Java EE 6 is almost 2 years old and I never got the change to work with it in a " +
                "professional environment. All current projects my company runs still use old and trusted frameworks.<br/>" +
                "I decided to take matters into my own hands and started this quest to learn Java EE 6." +
                " Wanting to do a little bit more than just a Hello World application and decided to build" +
                " blogging software using nothing but plain vanilla Java EE 6 (and perhaps a JSF component library)" +
                " and at the same time use it to blog about my adventures.<br/>" +
View Full Code Here

Examples of com.tuscanyscatours.blog.BlogPost

        // A proper implementation would load all blog posts from some resource
        // such as files or a database.
        List<BlogPost> blogEntries = new ArrayList<BlogPost>();

        // Create a sample entry
        final BlogPost samplePost =
            new BlogPost(
                         FEED_AUTHOR,
                         "Apache Tuscany in Action book features SCA Tours",
                         "We are famous as SCA Tours has been featured in the Apache Tuscany in Action book published by Manning",
                         new Date(), "http://www.manning.com/laws/", null);
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.