Package net.sourceforge.pebble.domain

Examples of net.sourceforge.pebble.domain.CategoryBuilder


   * @param blog    the owning blog
   * @return  a Collection of Category instances
   * @throws  PersistenceException    if categories cannot be loaded
   */
  public Category getCategories(Blog blog) throws PersistenceException {
    CategoryBuilder builder = new CategoryBuilder(blog);
    return builder.getRootCategory();
  }
View Full Code Here


   * @param blog    the owning Blog instance
   * @return  a Collection of Category instances
   * @throws  PersistenceException    if categories cannot be loaded
   */
  public Category getCategories(Blog blog) throws PersistenceException {
    CategoryBuilder categoryBuilder = new CategoryBuilder(blog);
    File source = new File(blog.getRoot(), CATEGORIES_FILE_NAME);
    if (source.exists()) {
      try {
        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);
        e.printStackTrace();
        throw new PersistenceException(e.getMessage());
      }
    }                                                          

    return categoryBuilder.getRootCategory();
  }
View Full Code Here

TOP

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

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.