Package net.sourceforge.pebble.domain

Examples of net.sourceforge.pebble.domain.StaticPage


   * Gets the title of this view.
   *
   * @return the title as a String
   */
  public String getTitle() {
    StaticPage staticPage = (StaticPage)getModel().get(Constants.STATIC_PAGE_KEY);
    return staticPage.getTitle();
  }
View Full Code Here


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

   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    String name = request.getParameter("name");

    StaticPage staticPage = new StaticPage(blog);
    staticPage.setName(name);
    staticPage.setTitle("Title");
    staticPage.setBody("<p>\n\n</p>");
    staticPage.setAuthor(SecurityUtils.getUsername());

    getModel().put(Constants.STATIC_PAGE_KEY, staticPage);

    return new StaticPageFormView();
  }
View Full Code Here

    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

    }

    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);
    } catch (StaticPageServiceException e) {
      throw new ServletException(e);
    }
View Full Code Here

    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

        }
    });
   
    if (files != null) {
      for (File file : files) {
        StaticPage staticPage = loadStaticPage(blog, file.getName());
        if (staticPage != null) {
          list.add(staticPage);
        }
      }
    }
View Full Code Here

   *          if the static page can't be loaded
   */
  private StaticPage loadStaticPage(Blog blog, File source) throws PersistenceException {
    if (source.exists()) {
      log.debug("Loading static page from " + source.getAbsolutePath());
      StaticPage staticPage = new StaticPage(blog);

      try {
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        JAXBElement<StaticPageType> controller = (JAXBElement)unmarshaller.unmarshal(source);
        StaticPageType spt = controller.getValue();

        staticPage.setTitle(spt.getTitle());
        staticPage.setSubtitle(spt.getSubtitle());
        staticPage.setBody(spt.getBody());
        staticPage.setTags(spt.getTags());
        staticPage.setAuthor(spt.getAuthor());
        staticPage.setOriginalPermalink(spt.getOriginalPermalink());
        staticPage.setName(spt.getStaticName());
        StaticPageDateConverter converter = new StaticPageDateConverter(staticPage);
        staticPage.setDate(converter.parse(spt.getDate()));
        staticPage.setTemplate(spt.getTemplate());

      } catch (Exception e) {
        log.error(e.getMessage(), e);
        e.printStackTrace();
        throw new PersistenceException(e.getMessage());
      }

      // and is the page locked?
      staticPage.setLockedBy(getUsernameHoldingLock(staticPage));

      return staticPage;
    } else {
      return null;
    }
View Full Code Here

    File source = new File(TEST_RESOURCE_LOCATION, "1152083300843.xml");
    File destination = new File(blog.getRoot(), "pages/1152083300843");
    destination.mkdirs();
    FileUtils.copyFile(source, new File(destination, "1152083300843.xml"));

    StaticPage page = dao.loadStaticPage(blog, "1152083300843");

    // test that the static page properties were loaded okay
    assertEquals("Static page title", page.getTitle());
    assertEquals("Static page subtitle", page.getSubtitle());
    assertEquals("<p>Static page body.</p>", page.getBody());
    assertEquals("some tags", page.getTags());
    assertEquals(1152083300843L, page.getDate().getTime());
    assertEquals("http://pebble.sourceforge.net", page.getOriginalPermalink());
  }
View Full Code Here

    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");
    }

    return new RedirectView(staticPage.getLocalPermalink());
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.pebble.domain.StaticPage

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.