Package net.sourceforge.pebble.service

Examples of net.sourceforge.pebble.service.StaticPageService


   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    StaticPageService service = new StaticPageService();
    StaticPage staticPage = null;
    try {
      staticPage = service.getStaticPageById(blog, request.getParameter("page"));
    } catch (StaticPageServiceException e) {
      throw new ServletException(e);
    }

    if (staticPage == null) {
      return new NotFoundView();
    } else {
      getModel().put(Constants.STATIC_PAGE_KEY, staticPage);
      if (service.lock(staticPage)) {
        return new StaticPageFormView();
      } else {
        return new StaticPageLockedView();
      }
    }
View Full Code Here


   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    StaticPageService service = new StaticPageService();
    try {
      getModel().put("staticPages", service.getStaticPages(blog));
    } catch (StaticPageServiceException e) {
      throw new ServletException(e);
    }

    return new StaticPagesView();
View Full Code Here

   * @param request  the HttpServletRequest instance
   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    StaticPageService service = new StaticPageService();
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    String name = request.getParameter("name");

    StaticPage staticPage;
    try {
      staticPage = service.getStaticPageByName(blog, name);
    } catch (StaticPageServiceException e) {
      throw new ServletException(e);
    }
    if (staticPage == null) {
      // the page cannot be found - it may have been removed or the
View Full Code Here

   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    StaticPageService service = new StaticPageService();

    String id = request.getParameter("page");
    if (id != null) {
      try {
        StaticPage staticPage = service.getStaticPageById(blog, id);
        if (staticPage != null) {
          service.unlock(staticPage);
          blog.info("Static page <a href=\"" + staticPage.getLocalPermalink() + "\">" + staticPage.getTitle() + "</a> unlocked.");
        }
      } catch (StaticPageServiceException e) {
        blog.warn(e.getClass().getName() + " Error while unlocking static page - " + StringUtils.transformHTML(e.getMessage()));
        log.warn("Error while unlocking static page", e);
View Full Code Here

      getModel().put("allUsers", PebbleContext.getInstance().getConfiguration().getSecurityRealm().getUsers());
    } catch (SecurityRealmException sre) {
      throw new ServletException("Could not get list of users", sre);
    }

    StaticPageService service = new StaticPageService();
    try {
      List staticPages = service.getStaticPages(blog);
      StaticPage defaultPage = new StaticPage(blog);
      defaultPage.setName("");
      defaultPage.setTitle("Default - recent blog entries");
      staticPages.add(0, defaultPage);
      getModel().put("staticPages", staticPages);
View Full Code Here

   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    String ids[] = request.getParameterValues("page");
    StaticPageService service = new StaticPageService();

    if (ids != null) {
      for (String id : ids) {
        StaticPage staticPage = null;
        try {
          staticPage = service.getStaticPageById(blog, id);
        } catch (StaticPageServiceException e) {
          throw new ServletException(e);
        }
        if (staticPage != null) {
          try {
            if (service.lock(staticPage)) {
              service.removeStaticPage(staticPage);
              blog.info("Static page \"" + staticPage.getTitle() + "\" removed.");
              service.unlock(staticPage);
            }
          } catch (StaticPageServiceException e) {
            throw new ServletException(e);
          }
        }
View Full Code Here

    return new StaticPageFormView();
  }

  private View unlockPage(HttpServletRequest request) throws ServletException {
    StaticPage staticPage = getStaticPage(request);
    StaticPageService service = new StaticPageService();
    service.unlock(staticPage);

    if (staticPage.isPersistent()) {
      return new RedirectView(staticPage.getLocalPermalink());
    } else {
      return new RedirectView(staticPage.getBlog().getUrl() + "viewStaticPages.secureaction");
View Full Code Here

      return new RedirectView(staticPage.getBlog().getUrl() + "viewStaticPages.secureaction");
    }
  }

  private View savePage(HttpServletRequest request) throws ServletException {
    StaticPageService service = new StaticPageService();
    StaticPage staticPage = getStaticPage(request);
    populateStaticPage(staticPage, request);
    getModel().put(Constants.STATIC_PAGE_KEY, staticPage);

    ValidationContext validationContext = new ValidationContext();
    staticPage.validate(validationContext);

    if (validationContext.hasErrors())  {
      getModel().put("validationContext", validationContext);
      return new StaticPageFormView();
    } else {
      try {
        service.putStaticPage(staticPage);
        staticPage.getBlog().info("Static page <a href=\"" + staticPage.getLocalPermalink() + "\">" + staticPage.getTitle() + "</a> saved.");
        service.unlock(staticPage);
        return new RedirectView(staticPage.getLocalPermalink());
      } catch (StaticPageServiceException e) {
        log.error(e.getMessage(), e);

        return new StaticPageFormView();
View Full Code Here

    String id = request.getParameter("page");
    String persistent = request.getParameter("persistent");

    if (persistent != null && persistent.equalsIgnoreCase("true")) {
      try {
        StaticPageService service = new StaticPageService();
        return service.getStaticPageById(blog, id);
      } catch (StaticPageServiceException e) {
        throw new ServletException(e);
      }
    } else {
      return new StaticPage(blog);
View Full Code Here

    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    String id = request.getParameter("page");
    String confirm = request.getParameter("confirm");
    String submit = request.getParameter("submit");

    StaticPageService service = new StaticPageService();
    StaticPage staticPage = null;
    try {
      staticPage = service.getStaticPageById(blog, id);
    } catch (StaticPageServiceException e) {
      throw new ServletException(e);
    }

    if (staticPage == null) {
      return new NotFoundView();
    }

    if (submit.equals("Edit")) {
      return new ForwardView("/editStaticPage.secureaction?page=" + id);
    } else if (submit.equalsIgnoreCase("Remove") && confirm != null && confirm.equals("true")) {
      try {
        if (service.lock(staticPage)) {
          service.removeStaticPage(staticPage);
          blog.info("Static page \"" + staticPage.getTitle() + "\" removed.");
          service.unlock(staticPage);
        } else {
          getModel().put(Constants.STATIC_PAGE_KEY, staticPage);
          return new StaticPageLockedView();
        }

        return new RedirectView(blog.getUrl() + "viewStaticPages.secureaction");
      } catch (StaticPageServiceException e) {
        throw new ServletException(e);
      }
    } else if (submit.equalsIgnoreCase("Unlock") && confirm != null && confirm.equals("true")) {
        service.unlock(staticPage);
        blog.info("Static page <a href=\"" + staticPage.getLocalPermalink() + "\">" + staticPage.getTitle() + "</a> unlocked.");

        return new RedirectView(blog.getUrl() + "viewStaticPages.secureaction");
    }
View Full Code Here

TOP

Related Classes of net.sourceforge.pebble.service.StaticPageService

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.