Examples of ThemeTemplate


Examples of org.apache.roller.pojos.ThemeTemplate

        };
        String[] templates = themedir.list(filter);
       
        // go through each .vm file and read in its contents to a ThemeTemplate
        String template_name = null;
        ThemeTemplate theme_template = null;
        for (int i=0; i < templates.length; i++) {
            // strip off the .vm part
            template_name = templates[i].substring(0, templates[i].length() - 3);           
            File template_file = new File(themepath + File.separator + templates[i]);
           
            // Continue reading theme even if problem encountered with one file
            String msg = "read theme template file ["+template_file+"]";
            if(!template_file.exists() && !template_file.canRead()) {
                mLogger.error("Couldn't " + msg);
                continue;
            }
            char[] chars = null;
            try {
                FileReader reader = new FileReader(template_file);
                chars = new char[(int) template_file.length()];
                reader.read(chars);           
            } catch (Exception noprob) {
                mLogger.error("Exception while attempting to " + msg);
                if (mLogger.isDebugEnabled()) mLogger.debug(noprob);
                continue;
            }

            // construct ThemeTemplate representing this file
            theme_template = new ThemeTemplate(
                    theme_name+":"+template_name,
                    template_name,
                    template_name,
                    new String(chars),
                    template_name,
                    new Date(template_file.lastModified()));

            // add it to the theme
            theme.setTemplate(template_name, theme_template);
        }
       
        // use the last mod date of the last template file
        // as the last mod date of the theme
        theme.setLastModified(theme_template.getLastModified());
       
        return theme;
    }
View Full Code Here

Examples of org.apache.roller.pojos.ThemeTemplate

        try {
            UserManager userMgr = RollerFactory.getRoller().getUserManager();
           
            Collection templates = theme.getTemplates();
            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 );
                }
            }
View Full Code Here

Examples of org.apache.roller.pojos.ThemeTemplate

                throw new ResourceNotFoundException("Invalid ThemeRL key "+name);
           
            // lookup the template from the proper theme
            ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
            Theme theme = themeMgr.getTheme(split[0]);
            ThemeTemplate template = theme.getTemplate(split[1]);
           
            if(template == null)
                throw new ResourceNotFoundException("Template ["+split[1]+
                        "] doesn't seem to be part of theme ["+split[0]+"]");
           
            mLogger.debug("Resource found!");
           
            // return the input stream
            return new ByteArrayInputStream(template.getContents().getBytes("UTF-8"));
           
        } catch (UnsupportedEncodingException uex) {
            // We expect UTF-8 in all JRE installation.
            // This rethrows as a Runtime exception after logging.
            mLogger.error(uex);
View Full Code Here

Examples of org.apache.roller.pojos.ThemeTemplate

                return last_mod;
           
            // lookup the template from the proper theme
            ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
            Theme theme = themeMgr.getTheme(split[0]);
            ThemeTemplate template = theme.getTemplate(split[1]);
           
            if(template == null)
                return last_mod;
           
            last_mod = template.getLastModified().getTime();
           
        } catch (ThemeNotFoundException tnfe) {
            // ignore
        } catch (RollerException re) {
            // we don't like to see this happen, but oh well
View Full Code Here

Examples of org.apache.roller.pojos.ThemeTemplate

        };
        String[] templates = themedir.list(filter);
       
        // go through each .vm file and read in its contents to a ThemeTemplate
        String template_name = null;
        ThemeTemplate theme_template = null;
        for (int i=0; i < templates.length; i++) {
            // strip off the .vm part
            template_name = templates[i].substring(0, templates[i].length() - 3);           
            File template_file = new File(themepath + File.separator + templates[i]);
           
            // Continue reading theme even if problem encountered with one file
            String msg = "read theme template file ["+template_file+"]";
            if(!template_file.exists() && !template_file.canRead()) {
                log.error("Couldn't " + msg);
                continue;
            }
            char[] chars = null;
            int length;
            try {
//                FileReader reader = new FileReader(template_file);
                chars = new char[(int) template_file.length()];
              FileInputStream stream = new FileInputStream(template_file);
              InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
                length = reader.read(chars);           
            } catch (Exception noprob) {
                log.error("Exception while attempting to " + msg);
                if (log.isDebugEnabled()) log.debug(noprob);
                continue;
            }
           
            // Strip "_" from name to form link
            boolean navbar = true;
            String template_link = template_name;
            if (template_name.startsWith("_") && template_name.length() > 1) {
                navbar = false;
                template_link = template_link.substring(1);
                log.debug("--- " + template_link);
            }
           
            String decorator = "_decorator";
            if("_decorator".equals(template_name)) {
                decorator = null;
            }
           
            // construct ThemeTemplate representing this file
            // a few restrictions for now:
            //   - we only allow "velocity" for the template language
            //   - decorator is always "_decorator" or null
            //   - all theme templates are considered not hidden
            theme_template = new ThemeTemplate(
                    theme,
                    theme_name+":"+template_name,
                    template_name,
                    template_name,
                    new String(chars, 0, length),
View Full Code Here

Examples of org.apache.roller.pojos.ThemeTemplate

                throw new ResourceNotFoundException("Invalid ThemeRL key "+name);
           
            // lookup the template from the proper theme
            ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
            Theme theme = themeMgr.getTheme(split[0]);
            ThemeTemplate template = theme.getTemplate(split[1]);
           
            if(template == null)
                throw new ResourceNotFoundException("Template ["+split[1]+
                        "] doesn't seem to be part of theme ["+split[0]+"]");
           
            mLogger.debug("Resource found!");
           
            // return the input stream
            return new ByteArrayInputStream(template.getContents().getBytes("UTF-8"));
           
        } catch (UnsupportedEncodingException uex) {
            // We expect UTF-8 in all JRE installation.
            // This rethrows as a Runtime exception after logging.
            mLogger.error(uex);
View Full Code Here

Examples of org.apache.roller.pojos.ThemeTemplate

                return last_mod;
           
            // lookup the template from the proper theme
            ThemeManager themeMgr = RollerFactory.getRoller().getThemeManager();
            Theme theme = themeMgr.getTheme(split[0]);
            ThemeTemplate template = theme.getTemplate(split[1]);
           
            if(template == null)
                return last_mod;
           
            last_mod = template.getLastModified().getTime();
           
        } catch (ThemeNotFoundException tnfe) {
            // ignore
        } catch (RollerException re) {
            // we don't like to see this happen, but oh well
View Full Code Here

Examples of org.apache.roller.pojos.ThemeTemplate

        try {
            UserManager userMgr = RollerFactory.getRoller().getUserManager();
           
            Collection templates = theme.getTemplates();
            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 );
                }
            }
           
View Full Code Here

Examples of org.apache.roller.pojos.ThemeTemplate

        };
        String[] templates = themedir.list(filter);
       
        // go through each .vm file and read in its contents to a ThemeTemplate
        String template_name = null;
        ThemeTemplate theme_template = null;
        for (int i=0; i < templates.length; i++) {
            // strip off the .vm part
            template_name = templates[i].substring(0, templates[i].length() - 3);           
            File template_file = new File(themepath + File.separator + templates[i]);
           
            // Continue reading theme even if problem encountered with one file
            String msg = "read theme template file ["+template_file+"]";
            if(!template_file.exists() && !template_file.canRead()) {
                log.error("Couldn't " + msg);
                continue;
            }
            char[] chars = null;
            int length;
            try {
//                FileReader reader = new FileReader(template_file);
                chars = new char[(int) template_file.length()];
              FileInputStream stream = new FileInputStream(template_file);
              InputStreamReader reader = new InputStreamReader(stream, "UTF-8");
                length = reader.read(chars);           
            } catch (Exception noprob) {
                log.error("Exception while attempting to " + msg);
                if (log.isDebugEnabled()) log.debug(noprob);
                continue;
            }
           
            // Strip "_" from name to form link
            boolean navbar = true;
            String template_link = template_name;
            if (template_name.startsWith("_") && template_name.length() > 1) {
                navbar = false;
                template_link = template_link.substring(1);
                log.debug("--- " + template_link);
            }
           
            String decorator = "_decorator";
            if("_decorator".equals(template_name)) {
                decorator = null;
            }
           
            // construct ThemeTemplate representing this file
            // a few restrictions for now:
            //   - we only allow "velocity" for the template language
            //   - decorator is always "_decorator" or null
            //   - all theme templates are considered not hidden
            theme_template = new ThemeTemplate(
                    theme,
                    theme_name+":"+template_name,
                    template_name,
                    template_name,
                    new String(chars, 0, length),
                    template_link,
                    new Date(template_file.lastModified()),
                    "velocity",
                    false,
                    navbar,
                    decorator);

            // add it to the theme
            theme.setTemplate(template_name, theme_template);
        }
       
        // use the last mod date of the last template file
        // as the last mod date of the theme
        theme.setLastModified(theme_template.getLastModified());
       
        return theme;
    }
View Full Code Here

Examples of org.apache.roller.pojos.ThemeTemplate

        try {
            UserManager userMgr = RollerFactory.getRoller().getUserManager();
           
            Collection templates = theme.getTemplates();
            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 );
                }
            }
           
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.