Examples of ViewHandlerException


Examples of org.ofbiz.webapp.view.ViewHandlerException

                Debug.logInfo("SCVH(0b)- dataResourceId:" + dataResourceId, module);
                dataResource = delegator.findByPrimaryKey("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
             } else {
                GenericValue contentRevisionItem = delegator.findByPrimaryKeyCache("ContentRevisionItem", UtilMisc.toMap("contentId", contentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId));
                if (contentRevisionItem == null) {
                    throw new ViewHandlerException("ContentRevisionItem record not found for contentId=" + contentId
                                                   + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId);
                }
                Debug.logInfo("SCVH(1)- contentRevisionItem:" + contentRevisionItem, module);
                Debug.logInfo("SCVH(2)-contentId=" + contentId
                        + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId, module);
View Full Code Here

Examples of org.ofbiz.webapp.view.ViewHandlerException

                   dataResourceId = content.getString("dataResourceId");
                   Debug.logInfo("SCVH(0b)- dataResourceId:" + dataResourceId, module);
                } else {
                   GenericValue contentRevisionItem = delegator.findByPrimaryKeyCache("ContentRevisionItem", UtilMisc.toMap("contentId", rootContentId, "itemContentId", contentId, "contentRevisionSeqId", contentRevisionSeqId));
                   if (contentRevisionItem == null) {
                       throw new ViewHandlerException("ContentRevisionItem record not found for contentId=" + rootContentId
                                                      + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId);
                   }
                   Debug.logInfo("SCVH(1)- contentRevisionItem:" + contentRevisionItem, module);
                   Debug.logInfo("SCVH(2)-contentId=" + rootContentId
                           + ", contentRevisionSeqId=" + contentRevisionSeqId + ", itemContentId=" + contentId, module);
                   dataResourceId = contentRevisionItem.getString("newDataResourceId");
                   Debug.logInfo("SCVH(3)- dataResourceId:" + dataResourceId, module);
                }
        }
      GenericValue dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", dataResourceId));
        byteWrapper = DataResourceWorker.getContentAsByteWrapper(delegator, dataResourceId, https, webSiteId, locale, rootDir);
        ByteArrayInputStream bais = new ByteArrayInputStream(byteWrapper.getBytes());
            // hack for IE and mime types
            //String userAgent = request.getHeader("User-Agent");
            //if (userAgent.indexOf("MSIE") > -1) {
            //    Debug.log("Found MSIE changing mime type from - " + mimeTypeId, module);
            //    mimeTypeId = "application/octet-stream";
            //}
            // setup chararcter encoding and content type
            String charset = dataResource.getString("characterSetId");
            mimeTypeId = dataResource.getString("mimeTypeId");
            if (UtilValidate.isEmpty(charset)) {
              charset = servletContext.getInitParameter("charset");
            }
            if (UtilValidate.isEmpty(charset)) {
              charset = "ISO-8859-1";
            }

            // setup content type
            String contentType2 = UtilValidate.isNotEmpty(mimeTypeId) ? mimeTypeId + "; charset=" +charset : contentType;

            UtilHttp.streamContentToBrowser(response, bais, byteWrapper.getLength(), contentType2);
      } catch(GenericEntityException e) {
            throw new ViewHandlerException(e.getMessage());
      } catch(IOException e) {
            throw new ViewHandlerException(e.getMessage());
      } catch(GeneralException e) {
            throw new ViewHandlerException(e.getMessage());
      }
     }
View Full Code Here

Examples of org.ofbiz.webapp.view.ViewHandlerException

            // this is the object used to render forms from their definitions
            screens.getContext().put("formStringRenderer", new FoFormRenderer(request, response));
            screens.render(page);
        } catch (Throwable t) {
            throw new ViewHandlerException("Problems with the response writer/output stream", t);
        }

        ByteArrayOutputStream out = new ByteArrayOutputStream();

        TransformerFactory transFactory = TransformerFactory.newInstance();

        try {
            Fop fop = fopFactory.newFop(contentType, out);
            Transformer transformer = transFactory.newTransformer();

            // set the input source (XSL-FO) and generate the output stream of contentType
            Reader reader = new StringReader(writer.toString());
            Source src = new StreamSource(reader);

            /*
            try {
                String buf = writer.toString();
                java.io.FileWriter fw = new java.io.FileWriter(new java.io.File("/tmp/xslfo.out"));
                fw.write(buf.toString());
                fw.close();
            } catch (IOException e) {
                throw new ViewHandlerException("Unable write to browser OutputStream", e);           
            }
            */

            // Get handler that is used in the generation process
            Result res = new SAXResult(fop.getDefaultHandler());

            try {
                // Transform the FOP XML source
                transformer.transform(src, res);

                // We don't want to cache the images that get loaded by the FOP engine
                fopFactory.getImageFactory().clearCaches();

                // set the content type and length
                response.setContentType(contentType);
                response.setContentLength(out.size());

                // write to the browser
                try {
                    out.writeTo(response.getOutputStream());
                    response.getOutputStream().flush();
                } catch (IOException e) {
                    throw new ViewHandlerException("Unable write to browser OutputStream", e);
                }

            } catch (TransformerException e) {
                Debug.logError("FOP transform failed:" + e, module );
                throw new ViewHandlerException("Unable to transform FO to " + contentType, e);
            }

        } catch (TransformerConfigurationException e) {
            Debug.logError("FOP TransformerConfiguration Exception " + e, module);
            throw new ViewHandlerException("Transformer Configuration Error", e);
        } catch (FOPException e) {
            Debug.logError("FOP Exception " + e, module);
            throw new ViewHandlerException("FOP Error", e);
        } finally {
            try {
                out.close();
            } catch (IOException e) {
                Debug.logError("Unable to close output stream " + e, module);
View Full Code Here

Examples of org.ofbiz.webapp.view.ViewHandlerException

            screens.populateContextForRequest(request, response, servletContext);
            // this is the object used to render forms from their definitions
            screens.getContext().put("formStringRenderer", new HtmlFormRenderer(request, response));
            screens.render(page);
        } catch (IOException e) {
            throw new ViewHandlerException("Error in the response writer/output stream: " + e.toString(), e);
        } catch (SAXException e) {
            throw new ViewHandlerException("XML Error rendering page: " + e.toString(), e);
        } catch (ParserConfigurationException e) {
            throw new ViewHandlerException("XML Error rendering page: " + e.toString(), e);
        } catch (GeneralException e) {
            throw new ViewHandlerException("Lower level error rendering page: " + e.toString(), e);
        }
    }
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.