Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.WeblogTemplate


     * Test basic persistence operations ... Create, Update, Delete
     */
    public void testTemplateCRUD() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WeblogTemplate template = null;
       
        // create template
        mgr.savePage(testPage);
        TestUtils.endSession(true);
       
        // check that create was successful
        template = null;
        template = mgr.getPageByName(testWeblog, testPage.getName());
        assertNotNull(template);
        assertEquals(testPage.getContents(), template.getContents());
       
        // update template
        template.setName("testtesttest");
        mgr.savePage(template);
        TestUtils.endSession(true);
       
        // check that update was successful
        template = null;
        template = mgr.getPageByName(testWeblog, "testtesttest");
        assertNotNull(template);
        assertEquals(testPage.getContents(), template.getContents());
       
        // delete template
        mgr.removePage(template);
        TestUtils.endSession(true);
       
View Full Code Here


     * Test lookup mechanisms ... id, name, link, weblog
     */
    public void testPermissionsLookups() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WeblogTemplate page = null;
       
        // create page
        mgr.savePage(testPage);
        String id = testPage.getId();
        TestUtils.endSession(true);
       
        // lookup by id
        page = mgr.getPage(id);
        assertNotNull(page);
        assertEquals(testPage.getContents(), page.getContents());
       
        // lookup by name
        page = null;
        page = mgr.getPageByName(testWeblog, testPage.getName());
        assertNotNull(page);
        assertEquals(testPage.getContents(), page.getContents());
       
        // lookup by link
        page = null;
        page = mgr.getPageByLink(testWeblog, testPage.getLink());
        assertNotNull(page);
        assertEquals(testPage.getContents(), page.getContents());
       
        // lookup all pages for weblog
        List pages = mgr.getPages(testWeblog);
        assertNotNull(pages);
        assertEquals(1, pages.size());
View Full Code Here

       
        try {
            Roller roller = RollerFactory.getRoller();
            UserManager userMgr = roller.getUserManager();
           
            WeblogTemplate page = userMgr.getPage(templateType);
            page.setContents(templateData);
            userMgr.savePage(page);
            flushPageCache(page.getWebsite());
           
            return true;
        } catch (RollerException e) {
            String msg = "ERROR in BlooggerAPIHander.setTemplate";
            mLogger.error(msg,e);
View Full Code Here

        validate(blogid, userid,password);
       
        try {
            Roller roller = RollerFactory.getRoller();
            UserManager userMgr = roller.getUserManager();
            WeblogTemplate page = userMgr.getPage(templateType);
           
            if ( null == page ) {
                throw new XmlRpcException(UNKNOWN_EXCEPTION,"Template not found");
            } else {
                return page.getContents();
            }
        } catch (Exception e) {
            String msg = "ERROR in BlooggerAPIHander.getTemplate";
            mLogger.error(msg,e);
            throw new XmlRpcException(UNKNOWN_EXCEPTION,msg);
View Full Code Here

        } catch (Exception ex) {
            log.error(ex);
            throw new Exception("Test setup failed", ex);
        }
       
        testPage = new WeblogTemplate();
        testPage.setName("testTemplate");
        testPage.setDescription("Test Weblog Template");
        testPage.setLink("testTemp");
        testPage.setContents("a test weblog template.");
        testPage.setLastModified(new java.util.Date());
View Full Code Here

     * Test basic persistence operations ... Create, Update, Delete
     */
    public void testTemplateCRUD() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WeblogTemplate template = null;
       
        // create template
        mgr.savePage(testPage);
        TestUtils.endSession(true);
       
        // check that create was successful
        template = null;
        template = mgr.getPageByName(testWeblog, testPage.getName());
        assertNotNull(template);
        assertEquals(testPage.getContents(), template.getContents());
       
        // update template
        template.setName("testtesttest");
        mgr.savePage(template);
        TestUtils.endSession(true);
       
        // check that update was successful
        template = null;
        template = mgr.getPageByName(testWeblog, "testtesttest");
        assertNotNull(template);
        assertEquals(testPage.getContents(), template.getContents());
       
        // delete template
        mgr.removePage(template);
        TestUtils.endSession(true);
       
View Full Code Here

     * Test lookup mechanisms ... id, name, link, weblog
     */
    public void testPermissionsLookups() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WeblogTemplate page = null;
       
        // create page
        mgr.savePage(testPage);
        String id = testPage.getId();
        TestUtils.endSession(true);
       
        // lookup by id
        page = mgr.getPage(id);
        assertNotNull(page);
        assertEquals(testPage.getContents(), page.getContents());
       
        // lookup by name
        page = null;
        page = mgr.getPageByName(testWeblog, testPage.getName());
        assertNotNull(page);
        assertEquals(testPage.getContents(), page.getContents());
       
        // lookup by link
        page = null;
        page = mgr.getPageByLink(testWeblog, testPage.getLink());
        assertNotNull(page);
        assertEquals(testPage.getContents(), page.getContents());
       
        // lookup all pages for weblog
        List pages = mgr.getPages(testWeblog);
        assertNotNull(pages);
        assertEquals(1, pages.size());
View Full Code Here

     */
    private Properties loadAcronyms(WebsiteData website) {
        Properties acronyms = new Properties();
        try {
            UserManager userMgr = RollerFactory.getRoller().getUserManager();
            WeblogTemplate acronymsPage = userMgr.getPageByName(
                    website, "_acronyms");
            if (acronymsPage != null) {
                acronyms = parseAcronymPage(acronymsPage, acronyms);
            }
        } catch (RollerException e) {
View Full Code Here

            Iterator iter = templates.iterator();
            ThemeTemplate theme_template = null;
            while ( iter.hasNext() ) {
                theme_template = (ThemeTemplate) iter.next();
               
                WeblogTemplate template = null;
               
                if(theme_template.getName().equals(WeblogTemplate.DEFAULT_PAGE)) {
                    // this is the main Weblog template
                    try {
                        template = userMgr.getPage(website.getDefaultPageId());
                    } catch(Exception e) {
                        // user may not have a default page yet
                    }
                } else {
                    // any other template
                    template = userMgr.getPageByName(website, theme_template.getName());
                }
               
               
                if (template != null) {
                    // User already has page by that name, so overwrite it.
                    template.setContents(theme_template.getContents());
                    template.setLink(theme_template.getLink());
                   
                } else {
                    // User does not have page by that name, so create new page.
                    template = new WeblogTemplate(
                            null,                               // id
                            website,                            // website
                            theme_template.getName(),           // name
                            theme_template.getDescription(),    // description
                            theme_template.getLink(),           // link
                            theme_template.getContents(),       // contents
                            new Date(),                         // last mod
                            theme_template.getTemplateLanguage(), // temp lang
                            theme_template.isHidden(),          // hidden
                            theme_template.isNavbar(),          // navbar
                            theme_template.getDecoratorName()   // decorator
                            );
                    userMgr.savePage( template );
                }
            }
           
            // now update this website's theme to custom
            website.setEditorTheme(Theme.CUSTOM);
           
            // if this is the first time someone is customizing a theme then
            // we need to set a default page
            if(website.getDefaultPageId() == null ||
                    website.getDefaultPageId().trim().equals("") ||
                    website.getDefaultPageId().equals("dummy")) {
                // we have to go back to the db to figure out the id
                WeblogTemplate template = userMgr.getPageByName(website, "Weblog");
                if(template != null) {
                    log.debug("Setting default page to "+template.getId());
                    website.setDefaultPageId(template.getId());
                }
            }
           
            // we also want to set the weblogdayid
            WeblogTemplate dayTemplate = userMgr.getPageByName(website, "_day");
            if(dayTemplate != null) {
                log.debug("Setting default day page to "+dayTemplate.getId());
                website.setWeblogDayPageId(dayTemplate.getId());
            }
           
            // save our updated website
            userMgr.saveWebsite(website);
           
View Full Code Here

       
        try {
            Roller roller = RollerFactory.getRoller();
            UserManager userMgr = roller.getUserManager();
           
            WeblogTemplate page = userMgr.getPage(templateType);
            page.setContents(templateData);
            userMgr.savePage(page);
            flushPageCache(page.getWebsite());
           
            return true;
        } catch (RollerException e) {
            String msg = "ERROR in BlooggerAPIHander.setTemplate";
            mLogger.error(msg,e);
View Full Code Here

TOP

Related Classes of org.apache.roller.pojos.WeblogTemplate

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.