Package org.apache.roller.pojos

Examples of org.apache.roller.pojos.WeblogTemplate


    {
        Properties acronyms = new Properties();
        try
        {
            UserManager userMgr = RollerFactory.getRoller().getUserManager();
            WeblogTemplate acronymsPage = userMgr.getPageByName(
                                        website, "_acronyms");
            if (acronymsPage != null)
            {
                acronyms = parseAcronymPage(acronymsPage, acronyms);
            }
View Full Code Here


        // remove associated pages
        Criteria pageQuery = session.createCriteria(WeblogTemplate.class);
        pageQuery.add(Expression.eq("website", website));
        List pages = pageQuery.list();
        for (Iterator iter = pages.iterator(); iter.hasNext();) {
            WeblogTemplate page = (WeblogTemplate) iter.next();
            this.strategy.remove(page);
        }
       
        // remove folders (including bookmarks)
        FolderData rootFolder = bmgr.getRootFolder(website);
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());
                   
                } else {
                    // User does not have page by that name, so create new page.
                    template = new WeblogTemplate( null,
                            website,                            // website
                            theme_template.getName(),           // name
                            theme_template.getDescription(),    // description
                            theme_template.getName(),           // link
                            theme_template.getContents(),       // contents
                            new Date()                          // last mod
                            );
                    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) {
                    mLogger.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) {
                mLogger.debug("Setting default day page to "+dayTemplate.getId());
                website.setWeblogDayPageId(dayTemplate.getId());
            }
           
            // save our updated website
            userMgr.saveWebsite(website);
           
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

                    // ignored ... considered page not found
                }
               
                // User doesn't have one so return the default
                if(page == null) {
                    page = new WeblogTemplate("/popupcomments.vm", website,
                            "Comments", "Comments", "dummy_link",
                            "dummy_template", new Date());
                }
               
                rreq.setPage(page);
View Full Code Here

            RollerSession rses = RollerSession.getRollerSession(request);
            WebsiteData website = rreq.getWebsite();
            if ( rses.isUserAuthorizedToAdmin(website) )
            {
                WeblogTemplateForm form = (WeblogTemplateForm)actionForm;
                WeblogTemplate data = new WeblogTemplate();
                form.copyTo(data, request.getLocale());
                data.setWebsite(website);
                data.setLastModified( new java.util.Date() );
                data.setDescription("");
                data.setContents("");
                validateLink( data );

                UserManager mgr = RollerFactory.getRoller().getUserManager();
                mgr.savePage( data );
                RollerFactory.getRoller().flush();
               
                ActionMessages uiMessages = new ActionMessages();
                uiMessages.add(ActionMessages.GLOBAL_MESSAGE,
                        new ActionMessage("pagesForm.addNewPage.success",
                                data.getName()));
                saveMessages(request, uiMessages);
                   
                actionForm.reset(mapping,request);               
               
                addModelObjects(request, response, mapping, website);
View Full Code Here

        if (name == null || name.length() == 0) {
            throw new ResourceNotFoundException("Need to specify a template name!");
        }
       
        try {
            WeblogTemplate page =
                    RollerFactory.getRoller().getUserManager().getPage(name);
           
            if (page == null) {
                throw new ResourceNotFoundException(
                        "RollerResourceLoader: page \"" +
                        name + "\" not found");
            }
            return new ByteArrayInputStream( page.getContents().getBytes("UTF-8") );
        } catch (UnsupportedEncodingException uex) {
            // This should never actually happen.  We expect UTF-8 in all JRE installation.
            // This rethrows as a Runtime exception after logging.
            mLogger.error(uex);
            throw new RuntimeException(uex);
View Full Code Here

        /*
         *  get the template name from the resource
         */
        String name = resource.getName();
        try {
            WeblogTemplate page =
                    RollerFactory.getRoller().getUserManager().getPage(name);
           
            if (mLogger.isDebugEnabled()) {
                mLogger.debug(name + ": resource=" + resource.getLastModified() +
                        " vs. page=" + page.getLastModified().getTime());
            }
            return page.getLastModified().getTime();
        } catch (RollerException re) {
            mLogger.error( "Error " + i_operation, re );
        }
        return 0;
    }
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.