Examples of BloggingService


Examples of org.apache.aries.samples.blog.api.BloggingService

    // the id of the blog entry to which this comment is associated
    long postId = Long.parseLong(req.getParameter("postId"));
    // the text of the comment
    String text = req.getParameter("text");

    BloggingService service = JNDIHelper.getBloggingService();

    // retrieve the blog entry and create the associated comment

    if (service.getBlogAuthor(email) != null) {
      service.createBlogComment(text, email, postId);
      resp.sendRedirect("ViewBlog");
    } else {

      if (email.equals(""))
        addError(req, "The email field is required.");
View Full Code Here

Examples of org.apache.aries.samples.blog.api.BloggingService

  @Override
  protected String getPageTitle(HttpServletRequest req) throws IOException
  {
    String pageTitle = "Create Author";
   
    BloggingService service = JNDIHelper.getBloggingService();
    String email = getEmail(req);
   
    if (email != null && !!!"".equals(email)) {
      BlogAuthor author = service.getBlogAuthor(email);
      if (author != null) {
        pageTitle = "Update " + author.getName() + "'s profile";
      }
    }
   
View Full Code Here

Examples of org.apache.aries.samples.blog.api.BloggingService

    String nickName = retrieveOrEmpty(req, "nickName");
    String bio = retrieveOrEmpty(req, "bio");
    String dob = retrieveOrEmpty(req, "dob");
    String email = getEmail(req);
   
    BloggingService service = JNDIHelper.getBloggingService();
   
    if (email != null && !!!"".equals(email)) {
      BlogAuthor author = service.getBlogAuthor(email);
     
      if ("".equals(name))
        name = author.getFullName();
      if ("".equals(nickName))
        nickName = author.getName();
View Full Code Here

Examples of org.apache.aries.samples.blog.api.BloggingService

        storeParam(req, "dob", dob);
       
      FormServlet.addError(req, "The email field is not properly formatted");
        resp.sendRedirect("EditAuthorForm")
    } else {
      BloggingService service = JNDIHelper.getBloggingService();

      if (service.getBlogAuthor(email) != null) {
        // do an update
        service.updateBlogAuthor(email, nickName, name, bio, dob);
      } else {
        // do a create
        service.createBlogAuthor(email, nickName, name, bio, dob);
      }
      RequestDispatcher dispatch = getServletContext().getRequestDispatcher("/ViewAuthor");
      dispatch.forward(req, resp);
    }
  }
View Full Code Here

Examples of org.apache.aries.samples.blog.api.BloggingService

    if (email == null || "".equals(email)) {
      // TODO dispatch to another page
    } else {
      PrintWriter out = resp.getWriter();
     
      BloggingService service = JNDIHelper.getBloggingService();
     
      BlogAuthor author = service.getBlogAuthor(email);
     
      HTMLOutput.writeHTMLHeaderPartOne(out, author.getName());
     
      HTMLOutput.writeHTMLHeaderPartTwo(out);
View Full Code Here

Examples of org.apache.aries.samples.blog.api.BloggingService

  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
      IOException
  {
    PrintWriter out = resp.getWriter();

    BloggingService service = JNDIHelper.getBloggingService();
   
    String blogTitle = service.getBlogTitle();

    // TODO cope with the service being null, redirect elsewhere.

    HTMLOutput.writeHTMLHeaderPartOne(out, blogTitle);
    HTMLOutput.writeDojoUses(out, "dojo.parser");
   
   

    HTMLOutput.writeHTMLHeaderPartTwo(out);

    int maxPage = (service.getNoOfEntries()-1) / POSTS_PER_PAGE;
    int pageNoInt = 0;
   
    String pageNo = req.getParameter("page");
    if (pageNo != null) {
      try {
        pageNoInt = Integer.parseInt(pageNo)-1;

        if (pageNoInt > maxPage)
          pageNoInt = maxPage;
        else if (pageNoInt < 0)
          pageNoInt = 0;
       
      } catch (NumberFormatException e) {
        e.printStackTrace();
      }
    }
 
    Iterator<? extends BlogEntry> posts = service.getBlogEntries(pageNoInt * POSTS_PER_PAGE, POSTS_PER_PAGE).iterator();
   
    out.println("<div class=\"links\"><a href=\"CreateBlogEntryForm\">Create New Post</a> <a href=\"EditAuthorForm\">Create Author</a></div>");
   
    Date currentDate = null;

    for (int i = 0; posts.hasNext(); i++) {
      BlogEntry post = posts.next();
     
      if (doesNotMatch(post.getPublishDate(), currentDate)) {
        currentDate = post.getPublishDate();
        out.print("<div class=\"postDate\">");
        //out.print(DateFormat.getDateInstance(DateFormat.FULL).format(currentDate));
        if (currentDate != null) {
           out.print(DateFormat.getDateInstance(DateFormat.FULL).format(currentDate));         
        }

        out.println("</div>");
      }
     
      out.print("\t\t<div class=\"post\" id=\"");
      out.print(i);
      out.println("\">");

      out.print("\t\t\t<div class=\"postTitle\">");
      out.print(post.getTitle());
      out.print("</div>");
      out.print("\t\t\t<div class=\"postBody\">");
      out.print(post.getBody());
      out.println("</div>");
      out.print("\t\t\t<div class=\"postAuthor\"><a href=\"ViewAuthor?email=");
      out.print(post.getAuthorEmail());
      out.print("\">");
      out.print(post.getAuthor().getFullName());
      out.println("</a></div>");
     
      if (service.isCommentingAvailable()) {

      out.print("<div class=\"links\"><a href=\"AddCommentForm?postId=");
      out.print(post.getId());
      out.print("\">Add Comment</a></div>");

      List<? extends BlogComment> comments = service
          .getCommentsForEntry(post);
      int size = comments.size();
      out.print("<div class=\"commentTitle\"");
      if (size > 0) {
        out.print("onclick=\"expand(");
View Full Code Here

Examples of org.apache.aries.samples.blog.api.BloggingService

    String email = req.getParameter("email");
    String title = req.getParameter("title");
    String text = req.getParameter("text");
    String tags = req.getParameter("tags");
   
    BloggingService service = JNDIHelper.getBloggingService();
   
    if (service.getBlogAuthor(email) != null) {
      service.createBlogEntry(email, title, text, tags);
      resp.sendRedirect("ViewBlog");
    } else {
      storeParam(req, "email", email);
      storeParam(req, "title", title);
      storeParam(req, "text", text);
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.