Package org.apache.roller.weblogger.pojos

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


        /*
         *  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

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

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

        validate(blogid, userid,password);
       
        try {
            Weblogger roller = WebloggerFactory.getWeblogger();
            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

               
                if(getTemplate() == null) {
                    log.debug("custom stylesheet not found, creating it");
                   
                    // template doesn't exist yet, so create it
                    WeblogTemplate stylesheetTmpl = new WeblogTemplate();
                    stylesheetTmpl.setWebsite(getActionWeblog());
                    stylesheetTmpl.setAction(stylesheet.ACTION_CUSTOM);
                    stylesheetTmpl.setName(stylesheet.getName());
                    stylesheetTmpl.setDescription(stylesheet.getDescription());
                    stylesheetTmpl.setLink(stylesheet.getLink());
                    stylesheetTmpl.setContents(stylesheet.getContents());
                    stylesheetTmpl.setHidden(false);
                    stylesheetTmpl.setNavbar(false);
                    stylesheetTmpl.setLastModified(new Date());
                    stylesheetTmpl.setTemplateLanguage(stylesheet.getTemplateLanguage());
                   
                    mgr.savePage(stylesheetTmpl);
                    WebloggerFactory.getWeblogger().flush();
                   
                    setTemplate(stylesheetTmpl);
View Full Code Here

        // validation
        myValidate();
       
        if(!hasActionErrors()) try {
           
            WeblogTemplate newTemplate = new WeblogTemplate();
            newTemplate.setWebsite(getActionWeblog());
            newTemplate.setAction(getNewTmplAction());
            newTemplate.setName(getNewTmplName());
            newTemplate.setDescription(newTemplate.getName());
            newTemplate.setContents(getText("pageForm.newTemplateContent"));
            newTemplate.setHidden(false);
            newTemplate.setNavbar(false);
            newTemplate.setLastModified( new Date() );
           
            // all templates start out as velocity templates
            newTemplate.setTemplateLanguage("velocity");
           
            // for now, all templates just use _decorator
            if(!"_decorator".equals(newTemplate.getName())) {
                newTemplate.setDecoratorName("_decorator");
            }
           
            // save the new Template
            WebloggerFactory.getWeblogger().getWeblogManager().savePage( newTemplate );
           
            // if this person happened to create a Weblog template from
            // scratch then make sure and set the defaultPageId
            if(WeblogTemplate.DEFAULT_PAGE.equals(newTemplate.getName())) {
                getActionWeblog().setDefaultPageId(newTemplate.getId());
                WebloggerFactory.getWeblogger().getWeblogManager().saveWeblog(getActionWeblog());
            }
           
            // flush results to db
            WebloggerFactory.getWeblogger().flush();
View Full Code Here

            addError("TemplateEdit.error.actionNull");
        }
       
        // check if template by that name already exists
        try {
            WeblogTemplate existingPage = WebloggerFactory.getWeblogger().getWeblogManager().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

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

Related Classes of org.apache.roller.weblogger.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.