Examples of WeblogMediaResourceRequest


Examples of org.apache.roller.weblogger.ui.rendering.util.WeblogMediaResourceRequest

        Weblog weblog = null;
        String ctx = request.getContextPath();
        String servlet = request.getServletPath();
        String reqURI = request.getRequestURI();

        WeblogMediaResourceRequest resourceRequest = null;
        try {
            // parse the incoming request and extract the relevant data
            resourceRequest = new WeblogMediaResourceRequest(request);

            weblog = resourceRequest.getWeblog();
            if(weblog == null) {
                throw new WebloggerException("unable to lookup weblog: "+
                        resourceRequest.getWeblogHandle());
            }

        } catch(Exception e) {
            // invalid resource request or weblog doesn't exist
            log.debug("error creating weblog resource request", e);
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
   
        long resourceLastMod = 0;
        InputStream resourceStream = null;
        MediaFile mediaFile = null;
       
        try {
            mediaFile = mfMgr.getMediaFile(resourceRequest.getResourceId(), true);
            resourceLastMod = mediaFile.getLastModified();
           
        } catch (Exception ex) {
            // still not found? then we don't have it, 404.
            log.debug("Unable to get resource", ex);
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }

        // Respond with 304 Not Modified if it is not modified.
        if (ModDateHeaderUtil.respondIfNotModified(request, response, resourceLastMod)) {
            return;
        } else {
            // set last-modified date
            ModDateHeaderUtil.setLastModifiedHeader(response, resourceLastMod);
        }
       

        // set the content type based on whatever is in our web.xml mime defs
        if (resourceRequest.isThumbnail()) {
            response.setContentType("image/png");
            try {
                resourceStream = mediaFile.getThumbnailInputStream();
            } catch (Exception e) {
                if (log.isDebugEnabled()) {
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.