Examples of WeblogTemplate


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

        // validation
        myValidate();
       
        if(!hasActionErrors()) try {
           
            WeblogTemplate template = getTemplate();
            getBean().copyTo(template);
            template.setLastModified(new Date());
           
            if (getBean().getAutoContentType() == null ||
                    !getBean().getAutoContentType().booleanValue()) {
                template.setOutputContentType(getBean().getManualContentType());
            } else {
                // empty content-type indicates that template uses auto content-type detection
                template.setOutputContentType(null);
            }
           
            // save template and flush
            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
            mgr.savePage(template);
            WebloggerFactory.getWeblogger().flush();
           
            // notify caches
            CacheManager.invalidate(template);
           
            // success message
            addMessage("pageForm.save.success", template.getName());
           
        } catch (WebloggerException ex) {
            log.error("Error updating page - "+getBean().getId(), ex);
            // TODO: i18n
            addError("Error saving template");
View Full Code Here

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

        }
       
        // check if template by that name already exists
        try {
            UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
            WeblogTemplate existingPage = umgr.getPageByName(getActionWeblog(), getNewTmplName());
            if(existingPage != null) {
                addError("pagesForm.error.alreadyExists", getNewTmplName());
            }
        } catch (WebloggerException ex) {
            log.error("Error checking for existing template", ex);
View Full Code Here

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

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

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

     * Test basic persistence operations ... Create, Update, Delete
     */
    public void testTemplateCRUD() throws Exception {
       
        UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
        WeblogTemplate template = null;
       
        // create template
        mgr.savePage(testPage);
        TestUtils.endSession(true);
       
        // check that create was successful
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        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;
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        template = mgr.getPageByName(testWeblog, "testtesttest");
        assertNotNull(template);
        assertEquals(testPage.getContents(), template.getContents());
       
        // delete template
        mgr.removePage(template);
        TestUtils.endSession(true);
       
View Full Code Here

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

     * Test lookup mechanisms ... id, name, link, weblog
     */
    public void testPermissionsLookups() throws Exception {
       
        UserManager mgr = WebloggerFactory.getWeblogger().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 action
        page = null;
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        page = mgr.getPageByAction(testWeblog, testPage.getAction());
        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

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

            return ERROR;
        }
       
        if(!hasActionErrors()) try {
           
            WeblogTemplate stylesheet = getTemplate();
           
            stylesheet.setLastModified(new Date());
            stylesheet.setContents(getContents());
           
            // save template and flush
            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
            mgr.savePage(stylesheet);
            WebloggerFactory.getWeblogger().flush();
           
            // notify caches
            CacheManager.invalidate(stylesheet);
           
            // success message
            addMessage("stylesheetEdit.save.success", stylesheet.getName());
           
        } catch (WebloggerException ex) {
            log.error("Error updating stylesheet template for weblog - "+getActionWeblog().getHandle(), ex);
            // TODO: i18n
            addError("Error saving template");
View Full Code Here

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

            addError("stylesheetEdit.error.customTheme");
        }
       
        if(!hasActionErrors()) try {
           
            WeblogTemplate stylesheet = getTemplate();
           
            // lookup the theme used by this weblog
            ThemeManager tmgr = WebloggerFactory.getWeblogger().getThemeManager();
            Theme theme = tmgr.getTheme(getActionWeblog().getEditorTheme());
           
            // lookup
            stylesheet.setLastModified(new Date());
            stylesheet.setContents(theme.getStylesheet().getContents());
           
            // save template and flush
            UserManager mgr = WebloggerFactory.getWeblogger().getUserManager();
            mgr.savePage(stylesheet);
            WebloggerFactory.getWeblogger().flush();
           
            // notify caches
            CacheManager.invalidate(stylesheet);
           
            // success message
            addMessage("stylesheetEdit.revert.success", stylesheet.getName());
           
        } catch (WebloggerException ex) {
            log.error("Error updating stylesheet template for weblog - "+getActionWeblog().getHandle(), ex);
            // TODO: i18n
            addError("Error saving template");
View Full Code Here

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

            ThemeTemplate stylesheetTemplate = theme.getStylesheet();
            Iterator iter = theme.getTemplates().iterator();
            while ( iter.hasNext() ) {
                themeTemplate = (ThemeTemplate) iter.next();
               
                WeblogTemplate template = null;
               
                // if template is an action, lookup by action
                if(themeTemplate.getAction() != null &&
                        !themeTemplate.getAction().equals(WeblogTemplate.ACTION_CUSTOM)) {
                    template = userMgr.getPageByAction(website, themeTemplate.getAction());
                    if(template != null) {
                        importedActionTemplates.add(themeTemplate.getAction());
                    }
                   
                // otherwise, lookup by name
                } else {
                    template = userMgr.getPageByName(website, themeTemplate.getName());
                }
               
                // Weblog does not have this template, so create it.
                boolean newTmpl = false;
                if (template == null) {
                    template = new WeblogTemplate();
                    template.setWebsite(website);
                    newTmpl = true;
                }

                // TODO: fix conflict situation
                // it's possible that someone has defined a theme template which
                // matches 2 existing templates, 1 by action, the other by name
               
                // update template attributes
                // NOTE: we don't want to copy the template data for an existing stylesheet
                if(newTmpl || !themeTemplate.equals(stylesheetTemplate)) {
                    template.setAction(themeTemplate.getAction());
                    template.setName(themeTemplate.getName());
                    template.setDescription(themeTemplate.getDescription());
                    template.setLink(themeTemplate.getLink());
                    template.setContents(themeTemplate.getContents());
                    template.setHidden(themeTemplate.isHidden());
                    template.setNavbar(themeTemplate.isNavbar());
                    template.setTemplateLanguage(themeTemplate.getTemplateLanguage());
                    // NOTE: decorators are deprecated starting in 4.0
                    template.setDecoratorName(null);
                    template.setLastModified(new Date());
                   
                    // save it
                    userMgr.savePage( template );
                }
            }
           
            // now, see if the weblog has left over action templates that
            // need to be deleted because they aren't in their new theme
            for(int i=0; i < WeblogTemplate.ACTIONS.length; i++) {
                String action = WeblogTemplate.ACTIONS[i];
               
                // if we didn't import this action then see if it should be deleted
                if(!importedActionTemplates.contains(action)) {
                    WeblogTemplate toDelete = userMgr.getPageByAction(website, action);
                    if(toDelete != null) {
                        log.debug("Removing stale action template "+toDelete.getId());
                        userMgr.removePage(toDelete);
                    }
                }
            }
           
View Full Code Here

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

        if (name == null || name.length() == 0) {
            throw new ResourceNotFoundException("Need to specify a template name!");
        }
       
        try {
            WeblogTemplate page =
                    WebloggerFactory.getWeblogger().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

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

        /*
         *  get the template name from the resource
         */
        String name = resource.getName();
        try {
            WeblogTemplate page =
                    WebloggerFactory.getWeblogger().getUserManager().getPage(name);
           
            if (mLogger.isDebugEnabled()) {
                mLogger.debug(name + ": resource=" + resource.getLastModified() +
                        " vs. page=" + page.getLastModified().getTime());
            }
            return page.getLastModified().getTime();
        } catch (WebloggerException re) {
            mLogger.error( "Error " + i_operation, re );
        }
        return 0;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.