Package net.sf.toxicity

Examples of net.sf.toxicity.ToxicityException


            xmlOutput.flush();
           
            return XmlUtil.getDomFromInputStream(new ByteArrayInputStream(baos.toByteArray()));
           
        } catch (Exception e) {
            throw new ToxicityException(pIn, e);
        }
       
    }
View Full Code Here


       
        response.setContentType("text/html");
       
        Document in = null;
        if(t instanceof ToxicityException) {
            ToxicityException e = (ToxicityException)t;
            t = e.getThrowable();
            in = e.getDocument();
        }
       
        PrintWriter writer = response.getWriter();
        writer.print("<html>\n<head>\n<title>\nToxicity Error Page</title>\n</head>\n"
                + "<body><h2>");
View Full Code Here

                Document mTemplateDocument = null;
                try {
                    mTemplateDocument = XmlUtil.getDomFromInputStream(mResource.getInputStream());
                } catch (SAXException e) {
                    log.error(e.getMessage(), e);
                    throw new ToxicityException(in, e);
                } catch (IOException e) {
                    log.error(e.getMessage(), e);
                    throw new ToxicityException(in, e);
                }
                mTemplate = new DOMSource(mTemplateDocument);
            }
           
            // create transformer from document
            Document out = XmlUtil.getNewDocument();
            Transformer t = getTransformer();
           
            // set transformer parameters
            if(mExportParameters) {
                HttpServletRequest request = ToxicityRequestFilter.getCurrentRequest();
                ServletContext servletContext = ToxicityRequestFilter.getCurrentServletContext();
                VariableManagerHelper mgr = new VariableManagerHelper(request, request.getSession(false), servletContext);
                mgr.initObject(t, new VariableManagerHelper.VariableSetter() {
                   public void setVariable(Object obj, String attrName, Object attrValue) {
                       if(attrValue == null) return;
                       Transformer ctx = (Transformer)obj;
                       ctx.setParameter(attrName, attrValue);
                   }
                });
            }
           
            // execute and return
            t.transform(new DOMSource(in), new DOMResult(out));
            return out;

        } catch(TransformerException e) {
            log.error(e.getMessage(), e);
            throw new ToxicityException(in, e);
        }
    }
View Full Code Here

        Document pollDoc;
        try {
            pollDoc = XmlUtil.getDomFromInputStream(mPollDocument.getInputStream());
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new ToxicityException(pIn, e);
        }
       
        //
        // increase count on selected item (if any)
        //
        XPath xpath = XmlUtil.newXPath();
        xpath.setNamespaceContext(new NamespaceContext("http://toxicity.sf.net/ns/examples/nuke/poll", "p"));
        if(mSelectedPollItem != null) {
            Element pollItem = pollDoc.getElementById(mSelectedPollItem);
            try {
                pollItem = (Element) xpath.evaluate("/p:poll-collection/p:poll/p:item[@id='" + mSelectedPollItem + "']",
                        pollDoc, XPathConstants.NODE);
            } catch (XPathExpressionException e) {
                log.error(e.getMessage(), e);
                throw new ToxicityException(pIn, e);
            }
            String scount = pollItem.getAttribute("count");
            int count = Integer.parseInt(scount);
            pollItem.setAttribute("count", String.valueOf(count+1));
        }
       
        //
        // return the requested poll
        //
        // 1) import all nodes of the selected poll
        // 2) hide actual poll result until the user submited an option
        //    if this example would be productive you could also make this
        //    decisions based on a ip-addrr. mapping or on the user session       
        //
        Document ret = XmlUtil.getNewDocument();
        Element pollRoot = null;
        try {
            pollRoot = (Element) xpath.evaluate("/p:poll-collection/p:poll[@id='" + mPollId + "']",
                    pollDoc, XPathConstants.NODE);
        } catch (XPathExpressionException e) {
            log.error(e.getMessage(), e);
            throw new ToxicityException(pIn, e);
        }
       
        pollRoot = (Element)ret.importNode(pollRoot, true);
        if(mSelectedPollItem == null) {
            NodeList nl = pollRoot.getChildNodes();
View Full Code Here

TOP

Related Classes of net.sf.toxicity.ToxicityException

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.