Package org.apache.roller.weblogger.pojos

Examples of org.apache.roller.weblogger.pojos.WeblogCategory


            return true;
        }
       
        Iterator cats = cat.getWeblogCategories().iterator();
        while (cats.hasNext()) {
            WeblogCategory childCat = (WeblogCategory)cats.next();
            if (childCat.isInUse()) {
                return true;
            }
        }
       
        if (cat.getWebsite().getBloggerCategory().equals(cat)) {
View Full Code Here


        wd1.setStatus(WeblogEntry.PUBLISHED);
        wd1.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        wd1.setPubTime(new Timestamp(System.currentTimeMillis()));
        wd1.setWebsite(TestUtils.getManagedWebsite(testWeblog));

        WeblogCategory cat = wem.getWeblogCategory(testWeblog.getDefaultCategory().getId());
        wd1.setCategory(cat);

        wem.saveWeblogEntry(wd1);
        TestUtils.endSession(true);
        wd1 = TestUtils.getManagedWeblogEntry(wd1);
View Full Code Here

        log.info("BEGIN");
       
        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
       
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
       
        WeblogCategory testCat = new WeblogCategory(testWeblog, null, "root", "root", null);
        assertTrue(root.equals(testCat));
       
        testCat = new WeblogCategory(testWeblog, root, "root", "root", null);
        assertFalse(root.equals(testCat));
       
        log.info("END");
    }
View Full Code Here

    public void testBasicCRUD() throws Exception {
       
        log.info("BEGIN");
       
        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
        WeblogCategory cat = null;
        List cats = null;
       
        // root category is always available
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
       
        // make sure we are starting with 0 categories (beneath root)
        assertEquals(0, root.getWeblogCategories().size());
       
        // add a new category
        WeblogCategory newCat = new WeblogCategory(testWeblog, root, "catTestCategory", null, null);
        mgr.saveWeblogCategory(newCat);
        TestUtils.endSession(true);
       
        // make sure category was added
        cat = null;
        cat = mgr.getWeblogCategory(newCat.getId());
        assertNotNull(cat);
        assertEquals(newCat, cat);
       
        // make sure category count increased
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        root = mgr.getRootWeblogCategory(testWeblog);
        assertEquals(1, root.getWeblogCategories().size());
       
        // update category
        cat.setName("testtest");
        mgr.saveWeblogCategory(cat);
        TestUtils.endSession(true);
       
        // verify category was updated
        cat = null;
        cat = mgr.getWeblogCategory(newCat.getId());
        assertNotNull(cat);
        assertEquals("testtest", cat.getName());
       
        // remove category
        mgr.removeWeblogCategory(cat);
        TestUtils.endSession(true);
       
        // make sure cat was removed
        cat = null;
        cat = mgr.getWeblogCategory(newCat.getId());
        assertNull(cat);
       
        // make sure category count decreased
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        root = mgr.getRootWeblogCategory(testWeblog);
View Full Code Here

       
        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
       
        // root category is always available
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
       
        // add a small category tree /subcat/subcat2
        WeblogCategory subcat = new WeblogCategory(testWeblog, root, "subcatTest1", null, null);
        root.addCategory(subcat);
        mgr.saveWeblogCategory(subcat);
        WeblogCategory subcat2 = new WeblogCategory(testWeblog, subcat, "subcatTest2", null, null);
        subcat.addCategory(subcat2);
        mgr.saveWeblogCategory(subcat2);
        TestUtils.endSession(true);
       
        // check that subcat tree can be navigated
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        root = mgr.getRootWeblogCategory(testWeblog);
        assertEquals(1, root.getWeblogCategories().size());
        subcat = (WeblogCategory) root.getWeblogCategories().iterator().next();
        assertEquals("subcatTest1", subcat.getName());
        assertEquals(1, subcat.getWeblogCategories().size());
        subcat2 = (WeblogCategory) subcat.getWeblogCategories().iterator().next();
        assertEquals("subcatTest2", subcat2.getName());
       
        // now delete category and subcats should be deleted by cascade
        mgr.removeWeblogCategory(subcat);
        TestUtils.endSession(true);
       
View Full Code Here

            emgr.removeWeblogEntry(entry);
        }
        this.strategy.flush();
       
        // remove categories
        WeblogCategory rootCat = emgr.getRootWeblogCategory(website);
        if (null != rootCat) {
            this.strategy.remove(rootCat);
        }
       
        // remove permissions
View Full Code Here

        actions.add(WeblogPermission.ADMIN);
        roller.getUserManager().grantWeblogPermission(
                newWeblog, newWeblog.getCreator(), actions);
       
        // add default category
        WeblogCategory rootCat = new WeblogCategory(
                newWeblog, // newWeblog
                null,      // parent
                "root",    // name
                "root",    // description
                null );    // image
        this.strategy.store(rootCat);
       
        String cats = WebloggerConfig.getProperty("newuser.categories");
        WeblogCategory firstCat = rootCat;
        if (cats != null && cats.trim().length() > 0) {
            String[] splitcats = cats.split(",");
            for (int i=0; i<splitcats.length; i++) {
                WeblogCategory c = new WeblogCategory(
                        newWeblog,       // newWeblog
                        rootCat,         // parent
                        splitcats[i],    // name
                        splitcats[i],    // description
                        null );          // image
View Full Code Here

               
                if (cat.getScheme() != null && cat.getScheme().equals(
                        RollerAtomService.getWeblogCategoryScheme(rollerEntry.getWebsite()))) {
                    String catString = cat.getTerm();
                    if (catString != null) {
                        WeblogCategory rollerCat =
                                roller.getWeblogEntryManager().getWeblogCategoryByPath(
                                rollerEntry.getWebsite(), catString);
                        if (rollerCat != null) {
                            // Found a valid category, so break out
                            rollerEntry.setCategory(rollerCat);
View Full Code Here

        try {
            Hashtable result = new Hashtable();
            WeblogEntryManager weblogMgr = roller.getWeblogEntryManager();
            List cats = weblogMgr.getWeblogCategories(website, false);
            for (Iterator wbcItr = cats.iterator(); wbcItr.hasNext();) {
                WeblogCategory category = (WeblogCategory) wbcItr.next();
                result.put(category.getPath(),
                        createCategoryStruct(category, userid));
            }
            return result;
        } catch (Exception e) {
            String msg = "ERROR in MetaWeblogAPIHandler.getCategories";
View Full Code Here

                entry.setPubTime(new Timestamp(dateCreated.getTime()));
            }
           
            if ( cat != null ) {
                // Use first category specified by request
                WeblogCategory cd =
                        weblogMgr.getWeblogCategoryByPath(entry.getWebsite(), cat);
                entry.setCategory(cd);
            }
           
            // save the entry
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.pojos.WeblogCategory

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.