Package net.sourceforge.pebble.domain

Examples of net.sourceforge.pebble.domain.Blog


   * @return  a BlogEntry instance, or null if one can't be found
   */
  public BlogEntry getBlogEntry(String uri) {
    // uri is of the form /1234567890123.html, so extract the 13-digit ID
    // and use it to find the correct blog entry
    Blog blog = getBlog();
    BlogService service = new BlogService();
    try {
      return service.getBlogEntry(blog, uri.substring(1, 14));
    } catch (BlogServiceException e) {
      return null;
View Full Code Here


  public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
    AbstractBlog abstractBlog = (AbstractBlog)request.getAttribute(Constants.BLOG_KEY);

    if (abstractBlog instanceof Blog) {
      Blog blog = (Blog)abstractBlog;
      if (SecurityUtils.isUserAuthorisedForBlogAsBlogPublisher(blog)) {
        return EVAL_BODY_INCLUDE;
      }
    }
View Full Code Here

   * Gets the content type of this view.
   *
   * @return the content type as a String
   */
  public String getContentType() {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    return "application/xml; charset=" + blog.getCharacterEncoding();
  }
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 {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    String name = StringUtils.filterHTML(request.getParameter("name"));
    String type = request.getParameter("type");
    String path = request.getParameter("path");

    FileManager fileManager = new FileManager(blog, type);
    FileMetaData directory = fileManager.getFileMetaData(path);
    try {
      fileManager.createDirectory(path, name);

      // if it's a theme file, also create a directory in blog.dir/theme
      if (type.equals(FileMetaData.THEME_FILE)) {
        fileManager = new FileManager(blog, FileMetaData.BLOG_DATA);
        fileManager.createDirectory("/theme" + path, name);
      }

      blog.info("Directory \"" + name + "\" created.");
    } catch (IllegalFileAccessException e) {
      return new ForbiddenView();
    }

    return new RedirectView(blog.getUrl() + directory.getUrl());
  }
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 {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    String name = request.getParameter("name");
    String oldName = StringUtils.filterHTML(name);
    String type = request.getParameter("type");
    String path = request.getParameter("path");
    String newName = StringUtils.filterHTML(request.getParameter("newName"));
    String submit = request.getParameter("submit");

    FileManager fileManager = new FileManager(blog, type);
    FileMetaData directory = fileManager.getFileMetaData(path);
    try {
      if (submit.equalsIgnoreCase("rename")) {
        fileManager.renameFile(path, name, newName);

        // if it's a theme file, also rename the copy in blog.dir/theme
        if (type.equals(FileMetaData.THEME_FILE)) {
          fileManager = new FileManager(blog, FileMetaData.BLOG_DATA);
          fileManager.renameFile("/theme" + path, name, newName);
        }

        blog.info("File \"" + oldName + "\" renamed to \"" + newName + "\".");
      } else {
        if (FileManager.hasEnoughSpace(blog, fileManager.getFileMetaData(path, name).getSizeInKB())) {
          fileManager.copyFile(path, name, newName);

          // if it's a theme file, also create a copy in blog.dir/theme
          if (type.equals(FileMetaData.THEME_FILE)) {
            fileManager = new FileManager(blog, FileMetaData.BLOG_DATA);
            fileManager.copyFile("/theme" + path, name, newName);
          }

          blog.info("File \"" + oldName + "\" copied to \"" + newName + "\".");
        } else {
          return new NotEnoughSpaceView();
        }
      }
    } catch (IllegalFileAccessException e) {
      return new ForbiddenView();
    } catch (IOException ioe) {
      throw new ServletException(ioe);
    }

    return new RedirectView(blog.getUrl() + directory.getUrl());
  }
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 {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    String email = request.getParameter("email");
    email = StringUtils.filterHTML(email);
    if (email != null && email.length() > 0) {
      blog.getEmailSubscriptionList().addEmailAddress(email);
      blog.info(email + " has subscribed to this blog.");

      getModel().put("email", email);
      return new SubscribedView();
    }

View Full Code Here

  public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest)pageContext.getRequest();
    AbstractBlog abstractBlog = (AbstractBlog)request.getAttribute(Constants.BLOG_KEY);

    if (abstractBlog instanceof Blog) {
      Blog blog = (Blog)abstractBlog;
      if (SecurityUtils.isUserAuthorisedForBlogAsBlogContributor(blog)) {
        return EVAL_BODY_INCLUDE;
      }
    }
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 {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    List blogEntries = blog.getUnpublishedBlogEntries();
    Collections.sort(blogEntries, new PageBasedContentByTitleComparator());
    getModel().put("unpublishedBlogEntries", blogEntries);

    return new UnpublishedBlogEntriesView();
  }
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 {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    Log log = getLog(request, response);

    // work out requests per hour
    int[] requestsPerHour = new int[24];
    Set<String>[] uniqueIpsPerHourAsSet = new Set[24];
    for (int hour = 0; hour < 24; hour++) {
      requestsPerHour[hour] = 0;
      uniqueIpsPerHourAsSet[hour] = new HashSet<String>();
    }
    for (LogEntry logEntry : log.getLogEntries()) {
      Calendar logTime = blog.getCalendar();
      logTime.setTime(logEntry.getDate());
      int hour = logTime.get(Calendar.HOUR_OF_DAY);
      requestsPerHour[hour] = requestsPerHour[hour]+1;
      uniqueIpsPerHourAsSet[hour].add(logEntry.getHost());

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 {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    Log log = getLog(request, response);

    Map<String, Integer> userAgents = new TreeMap<String, Integer>(new Comparator<String>() {
      public int compare(String s1, String s2) {
        return s1 != null ? s1.compareToIgnoreCase(s2) : -1;
View Full Code Here

TOP

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

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.