Package net.sourceforge.pebble.domain

Examples of net.sourceforge.pebble.domain.Blog


   * @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 ids[] = request.getParameterValues("entry");
    String submit = request.getParameter("submit");

    if (ids != null) {
      for (String id : ids) {
        BlogService service = new BlogService();
        BlogEntry blogEntry = null;
        try {
          blogEntry = service.getBlogEntry(blog, id);
        } catch (BlogServiceException e) {
          throw new ServletException(e);
        }

        if (blogEntry != null) {
          if (submit.equalsIgnoreCase("Remove")) {
            try {
              service.removeBlogEntry(blogEntry);
              blog.info("Blog entry \"" + StringUtils.transformHTML(blogEntry.getTitle()) + "\" removed.");
            } catch (BlogServiceException be) {
              throw new ServletException(be);
            }
          } else if (submit.equals("Publish")) {
            // this publishes the entry as-is (i.e. with the same
            // date/time it already has)
            try {
              blogEntry.setPublished(true);
              service.putBlogEntry(blogEntry);
              blog.info("Blog entry <a href=\"" + blogEntry.getLocalPermalink() + "\">" + blogEntry.getTitle() + "</a> published.");
            } catch (BlogServiceException be) {
              throw new ServletException(be);
            }
          }
        }
      }
    }

    String redirectUrl = request.getParameter("redirectUrl");
    if (redirectUrl != null && redirectUrl.trim().length() > 0) {
      return new RedirectView(redirectUrl);
    } else {
      return new RedirectView(blog.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 submit = request.getParameter("submit");
    if (submit != null && submit.length() > 0) {
      String currentTimeZone = blog.getProperty(Blog.TIMEZONE_KEY);

      Enumeration params = request.getParameterNames();
      while (params.hasMoreElements()) {
        String key = (String)params.nextElement();
        String value = request.getParameter(key);

        if (key.equals("submit")) {
          // this is the parameter representing the submit button - do nothing
        } else {
          // this is an existing parameter - save or remove it
          if (value == null || value.length() == 0) {
            blog.removeProperty(key);
          } else {
            blog.setProperty(key, value);
          }
        }
      }

      // and now the checkboxes
      String name = "richTextEditorForBlogEntriesEnabled";
      String checkbox = request.getParameter(name);
      if (checkbox == null) {
        blog.setProperty(name, "false");
      }
      name = "richTextEditorForStaticPagesEnabled";
      checkbox = request.getParameter(name);
      if (checkbox == null) {
        blog.setProperty(name, "false");
      }
      name = "richTextEditorForCommentsEnabled";
      checkbox = request.getParameter(name);
      if (checkbox == null) {
        blog.setProperty(name, "false");
      }
      name = "gravatarSupportForCommentsEnabled";
      checkbox = request.getParameter(name);
      if (checkbox == null) {
        blog.setProperty(name, "false");
      }

      try {
        blog.storeProperties();
        blog.info("Blog properties saved.");
      } catch (BlogServiceException e) {
        throw new ServletException(e);
      }

      // if the following properties have changed, reload the blog
      //  - timezone
      String newTimeZone = blog.getProperty(Blog.TIMEZONE_KEY);

      if (!currentTimeZone.equals(newTimeZone)) {
        return new ForwardView("/reindexBlog.secureaction");
      }

    }

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

                      HttpServletResponse response)
      throws ServletException {

    AbstractBlog abstractBlog = (AbstractBlog)getModel().get(Constants.BLOG_KEY);
    if (abstractBlog instanceof Blog) {
      Blog blog = (Blog)abstractBlog;
      String homePage = blog.getHomePage();
      if (homePage != null && !homePage.equals("")) {
        return new ForwardView("/viewStaticPage.action?name=" + homePage);
      }
    }
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);
    String query = request.getParameter("query");

    if (query == null || query.trim().length() == 0) {
      if (blog instanceof Blog) {
        return new AdvancedSearchView();
      }
    }

    String pageAsString = request.getParameter("page");
    int page = 1;
    if (pageAsString == null || pageAsString.length() == 0) {
      page = 1;
    } else {
      try {
        page = Integer.parseInt(pageAsString);
      } catch (NumberFormatException nfe) {
      }
    }

    try {
      SearchResults results = blog.getSearchIndex().search(query);

      if (results.getNumberOfHits() == 1) {
        // if there is only one hit, redirect the user to it without the
        // search results page
        SearchHit hit = (SearchHit)results.getHits().get(0);
        return new RedirectView(hit.getPermalink());
      } else {
        // show all results on the search results page
        String sort = request.getParameter("sort");
        if (sort != null && sort.equalsIgnoreCase("date")) {
          results.sortByDateDescending();
        } else {
          results.sortByScoreDescending();
        }

        Pageable pageable = new Pageable(results.getHits());
        pageable.setPageSize(PAGE_SIZE);
        pageable.setPage(page);

        try {
          getModel().put("searchResults", results);
          getModel().put("pageable", pageable);
          getModel().put("query", java.net.URLEncoder.encode(query, blog.getCharacterEncoding()));
        } catch (UnsupportedEncodingException uee) {
          log.error(uee);
        }

        return new SearchResultsView();
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);

    Collection<Request> requests = log.getRequests();
    Set<String> uniqueIps = new HashSet<String>();
    Set<String> uniqueIpsForNewsFeeds = new HashSet<String>();
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 submit = request.getParameter("submit");
    if (submit != null && submit.length() > 0) {
      Properties pluginProperties = blog.getPluginProperties().getProperties();
      Enumeration params = request.getParameterNames();
      while (params.hasMoreElements()) {
        String key = (String)params.nextElement();

        if (key.equals("submit")) {
          // this is the parameter representing the submit button - do nothing
        } else if (key.startsWith(PluginConfigType.PLUGIN_PROPERTY_NAME_PREFIX)) {
          String value = request.getParameterValues(key)[0];
          String property = key.substring(PluginConfigType.PLUGIN_PROPERTY_NAME_PREFIX.length());
          if (value == null || value.length() == 0) {
            pluginProperties.remove(property);
          } else {
            pluginProperties.setProperty(property, value);
          }
        } else if (key.startsWith(PLUGIN_TYPE_PLACEHOLDER_PREFIX)) {
          // Place holder for checking if all plugins of a particular type have been disabled
          String pluginType = key.substring(PLUGIN_TYPE_PLACEHOLDER_PREFIX.length());
          if (request.getParameter(pluginType) == null) {
            blog.setProperty(pluginType, "");
          }
        } else {
          // this is an existing parameter - save or remove it
          String[] values = request.getParameterValues(key);
          StringBuilder builder = new StringBuilder();
          String separator = "";
          for (String value : values) {
            builder.append(separator).append(value);
            separator = "\n";
          }
          blog.setProperty(key, builder.toString());
        }
      }

      try {
        blog.storeProperties();
        blog.getPluginProperties().store();
      } catch (BlogServiceException e) {
        throw new ServletException(e);
      }
    }

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);
    getModel().put("categories", blog.getCategories());

    return new FeedsView();
  }
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 action = request.getParameter("action");
    if (action == null) {
      // do nothing
    } else if (action.equalsIgnoreCase("ipAddressListener")) {
      Utilities.buildIpAddressLists(blog);
      return new ForwardView("/reloadBlog.secureaction");
    } else if (action.equalsIgnoreCase("fixHtmlInResponses")) {
      Utilities.fixHtmlInResponses(blog);
      return new ForwardView("/reloadBlog.secureaction");
    } else if (action.equalsIgnoreCase("buildIndexes")) {
      Utilities.buildIndexes(blog);
      return new ForwardView("/reloadBlog.secureaction");
    } else if (action.equalsIgnoreCase("convertCategories")) {
      Utilities.convertCategories(blog);
      return new ForwardView("/reloadBlog.secureaction");
    } else if (action.equalsIgnoreCase("restructureBlogToGMT")) {
      Utilities.restructureBlogToGMT(blog);
      Utilities.buildIndexes(blog);
      return new ForwardView("/reloadBlog.secureaction");
    } else if (action.equalsIgnoreCase("moveBlogEntriesFromCategory")) {
      Category from = blog.getCategory(request.getParameter("from"));
      Category to = blog.getCategory(request.getParameter("to"));
      if (from != null && to != null) {
        Utilities.moveBlogEntriesFromCategory(blog, from, to);
      }
    }

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);
    getModel().put("entries", blog.getNewsFeedEntries());
   
    return new CommunityView();
  }
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 type = request.getParameter("type");
    String path = request.getParameter("path");

    // if there is no path, we're looking at the root
    if (path == null || path.length() == 0) {
      path = "/";
    }

    try {
      String filename;
      if (type.equals(FileMetaData.BLOG_DATA)) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        if (path.equals("/logs")) {
          filename = blog.getId() + "-logs-" + sdf.format(blog.getCalendar().getTime()) + ".zip";
        } else {
          filename = blog.getId() + "-" + sdf.format(blog.getCalendar().getTime()) + ".zip";
        }
      } else {
        filename = "export.zip";
      }

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.