Package net.sourceforge.pebble.domain

Examples of net.sourceforge.pebble.domain.Category


      try {
        BufferedReader reader = new BufferedReader(new FileReader(indexFile));
        String indexEntry = reader.readLine();
        while (indexEntry != null) {
          String[] tuple = indexEntry.split("=");
          Category category = blog.getCategory(tuple[0]);

          if (tuple.length > 1 && tuple[1] != null) {
            String[] blogEntries = tuple[1].split(",");
            for (String blogEntry : blogEntries) {
              category.addBlogEntry(blogEntry);
            }
          }

          indexEntry = reader.readLine();
        }
View Full Code Here


    Blog blog = getBlogWithBlogId(blogid);
    authenticate(blog, username, password);

    Hashtable categories = new Hashtable();
    Iterator it = blog.getCategories().iterator();
    Category category;
    while (it.hasNext()) {
      category = (Category)it.next();
      if (!category.isRootCategory()) {
        Hashtable struct = new Hashtable();
        struct.put(DESCRIPTION, category.getId());
        struct.put(HTML_URL, category.getPermalink());
        struct.put(RSS_URL, blog.getUrl() + "rss.xml?category=" + category.getId());
        categories.put(category.getId(), struct);
      }
    }

    return categories;
  }
View Full Code Here

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

    if (id != null && id.length() > 0) {
      Category category = blog.getCategory(id);
      getModel().put(Constants.CATEGORY_KEY, category);
    }
    getModel().put(Constants.CATEGORIES, blog.getCategories());

    return new CategoriesView(true);
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 {
    getModel().put(Constants.CATEGORY_KEY, new Category());

    return new ForwardView("/viewCategories.secureaction");
  }
View Full Code Here

    entry.setTitle("My Title");
    entry.setAuthor("author");
    entry.setBody("body");
    entry.setDate(new Date(1000));

    Category category = new Category("categoryId", "category");
    category.setBlog(blog);
    entry.setCategories(Collections.singleton(category));

    model.put(Constants.BLOG_KEY, blog);
    model.put(Constants.BLOG_ENTRIES, Collections.singleton(entry));

    SyndFeed feed = feedView.getFeed();
    MockHttpServletResponse response = new MockHttpServletResponse();
    response.setWriter(new PrintWriter(System.out));
    feedView.dispatch(new MockHttpServletRequest(), response, null);
    assertEquals("tag:www.yourdomain.com,0000-00-00:default", feed.getUri());
    assertEquals("My blog", feed.getTitle());
    assertEquals(1, feed.getEntries().size());
    SyndEntry feedEntry = (SyndEntry) feed.getEntries().get(0);
    assertEquals("tag:www.yourdomain.com,1970-01-01:default/1000", feedEntry.getUri());
    assertEquals(new Date(1000), feedEntry.getPublishedDate());
    assertEquals("body", ((SyndContent)feedEntry.getContents().get(0)).getValue());
    assertEquals("My Title", feedEntry.getTitle());
    assertEquals(entry.getPermalink(), feedEntry.getLink());
    assertEquals(1, feedEntry.getCategories().size());
    SyndCategory syndCategory = (SyndCategory) feedEntry.getCategories().get(0);
    assertEquals("category", syndCategory.getName());
    assertEquals(category.getPermalink(), syndCategory.getTaxonomyUri());
  }
View Full Code Here

    } 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

    String id = request.getParameter("id");
    String name = request.getParameter("name");
    String tags = request.getParameter("tags");

    if (id != null && id.trim().length() > 0) {
      Category category = blog.getCategory(id);
      if (category == null) {
        // this is a new category
        category = new Category();
        category.setId(id);
        category.setName(name);
        blog.addCategory(category);
        category.setTags(tags);
        try {
          // add it to the persistent store
          DAOFactory factory = DAOFactory.getConfiguredFactory();
          CategoryDAO dao = factory.getCategoryDAO();
          dao.addCategory(category, blog);
        } catch (PersistenceException pe) {
          pe.printStackTrace();
        }
      } else {
        // updating an existing category
        category.setName(name);
        category.setTags(tags);
        try {
          // add it to the persistent store
          DAOFactory factory = DAOFactory.getConfiguredFactory();
          CategoryDAO dao = factory.getCategoryDAO();
          dao.updateCategory(category, blog);
View Full Code Here

  }

  public void testProcess() throws Exception {
    View view = action.process(request, response);

    assertEquals(new Category(), action.getModel().get(Constants.CATEGORY_KEY));
    assertTrue(view instanceof ForwardView);
    assertEquals("/viewCategories.secureaction", ((ForwardView)view).getUri());
  }
View Full Code Here

        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        JAXBElement<CategoriesType> controller = (JAXBElement)unmarshaller.unmarshal(source);
        CategoriesType categoriesType = controller.getValue();

        for (CategoryType categoryType : categoriesType.getCategory()) {
          Category category = new Category(categoryType.getId(), categoryType.getName());
          category.setBlog(blog);
          category.setTags(categoryType.getTags());

          categoryBuilder.addCategory(category);
        }
      } catch (Exception e) {
        log.error(e.getMessage(), e);
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);
    getModel().put(Constants.CATEGORY_KEY, new Category());
    getModel().put(Constants.CATEGORIES, blog.getCategories());
    return new CategoriesView(true);
  }
View Full Code Here

TOP

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

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.