Package org.apache.roller.ui.rendering.util

Examples of org.apache.roller.ui.rendering.util.WeblogPreviewRequest


       
        log.debug("Entering");
       
        WebsiteData weblog = null;
       
        WeblogPreviewRequest previewRequest = null;
        try {
            previewRequest = new WeblogPreviewRequest(request);
           
            // lookup weblog specified by preview request
            weblog = previewRequest.getWeblog();
            if(weblog == null) {
                throw new RollerException("unable to lookup weblog: "+
                        previewRequest.getWeblogHandle());
            }
        } catch (Exception e) {
            // some kind of error parsing the request or getting weblog
            log.error("error creating preview request", e);
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
        // try getting the preview theme
        log.debug("preview theme = "+previewRequest.getThemeName());
        Theme previewTheme = previewRequest.getTheme();
       
        // construct a temporary Website object for this request
        // and set the EditorTheme to our previewTheme
        WebsiteData tmpWebsite = new WebsiteData();
        tmpWebsite.setData(weblog);
        if(previewTheme != null && previewTheme.isEnabled()) {
            tmpWebsite.setEditorTheme(previewTheme.getName());
        } else if(Theme.CUSTOM.equals(previewRequest.getThemeName())) {
            tmpWebsite.setEditorTheme(Theme.CUSTOM);
        }
       
        // we've got to set the weblog in our previewRequest because that's
        // the object that gets referenced during rendering operations
        previewRequest.setWeblog(tmpWebsite);
       
       
        Template page = null;
        try {
            // we just want to show the default view
            page = tmpWebsite.getDefaultPage();
           
            if(page == null) {
                throw new RollerException("No default page for weblog: "+tmpWebsite.getHandle());
            }
        } catch(RollerException re) {
            // couldn't get page
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            log.error("Error getting default page for preview", re);
            return;
        }
       
        log.debug("preview page found, dealing with it");
       
        // set the content type
        String pageLink = previewRequest.getWeblogPageName();
        String mimeType = pageLink !=  null ? RollerContext.getServletContext().getMimeType(pageLink) : null;       
        String contentType = "text/html; charset=utf-8";
        if(mimeType != null) {
            // we found a match ... set the content type
            contentType = mimeType+"; charset=utf-8";
        } else if ("_css".equals(previewRequest.getWeblogPageName())) {
            // TODO: store content-type for each page so this hack is unnecessary
            contentType = "text/css; charset=utf-8";
        }
       
        // looks like we need to render content
View Full Code Here


       
        log.debug("Entering");
       
        WebsiteData weblog = null;
       
        WeblogPreviewRequest previewRequest = null;
        try {
            previewRequest = new WeblogPreviewRequest(request);
           
            // lookup weblog specified by preview request
            weblog = previewRequest.getWeblog();
            if(weblog == null) {
                throw new RollerException("unable to lookup weblog: "+
                        previewRequest.getWeblogHandle());
            }
        } catch (Exception e) {
            // some kind of error parsing the request or getting weblog
            log.error("error creating preview request", e);
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
       
        // try getting the preview theme
        log.debug("preview theme = "+previewRequest.getThemeName());
        Theme previewTheme = previewRequest.getTheme();
       
        // construct a temporary Website object for this request
        // and set the EditorTheme to our previewTheme
        WebsiteData tmpWebsite = new WebsiteData();
        tmpWebsite.setData(weblog);
        if(previewTheme != null && previewTheme.isEnabled()) {
            tmpWebsite.setEditorTheme(previewTheme.getName());
        } else if(Theme.CUSTOM.equals(previewRequest.getThemeName())) {
            tmpWebsite.setEditorTheme(Theme.CUSTOM);
        }
       
        // we've got to set the weblog in our previewRequest because that's
        // the object that gets referenced during rendering operations
        previewRequest.setWeblog(tmpWebsite);
       
       
        Template page = null;
        try {
            // we just want to show the default view
            page = tmpWebsite.getDefaultPage();
           
            if(page == null) {
                throw new RollerException("No default page for weblog: "+tmpWebsite.getHandle());
            }
        } catch(RollerException re) {
            // couldn't get page
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            log.error("Error getting default page for preview", re);
            return;
        }
       
        log.debug("preview page found, dealing with it");
       
        // set the content type
        String pageLink = previewRequest.getWeblogPageName();
        String mimeType = RollerContext.getServletContext().getMimeType(pageLink);
        String contentType = "text/html; charset=utf-8";
        if(mimeType != null) {
            // we found a match ... set the content type
            contentType = mimeType+"; charset=utf-8";
        } else if ("_css".equals(previewRequest.getWeblogPageName())) {
            // TODO: store content-type for each page so this hack is unnecessary
            contentType = "text/css; charset=utf-8";
        }
       
        // looks like we need to render content
View Full Code Here

TOP

Related Classes of org.apache.roller.ui.rendering.util.WeblogPreviewRequest

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.