Package pt.ist.fenixWebFramework.servlets.filters.contentRewrite

Examples of pt.ist.fenixWebFramework.servlets.filters.contentRewrite.ResponseWrapper


        if ("doOperation".equals(request.getParameter("method"))
                && "PRINT_ALL_DOCUMENTS".equals(request.getParameter("operationType"))) {

            try {
                ResponseWrapper response = (ResponseWrapper) arg1;
                // clean the response html and make a DOM document out of it
                String responseHtml = clean(response.getContent());
                DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                Document doc = builder.parse(new ByteArrayInputStream(responseHtml.getBytes()));

                // alter paths of link/img tags so itext can use them properly
                patchLinks(doc, request);

                // structure pdf document
                ITextRenderer renderer = new ITextRenderer();
                renderer.setDocument(doc, "");
                renderer.layout();

                // create the pdf
                ByteArrayOutputStream pdfStream = new ByteArrayOutputStream();
                renderer.createPDF(pdfStream);

                // concatenate with other docs
                final Person person = (Person) request.getAttribute("person");
                final StudentCandidacy candidacy = getCandidacy(request);
                ByteArrayOutputStream finalPdfStream = concatenateDocs(pdfStream.toByteArray(), person);
                byte[] pdfByteArray = finalPdfStream.toByteArray();

                // associate the summary file to the candidacy
                associateSummaryFile(pdfByteArray, person.getStudent().getNumber().toString(), candidacy);

                // redirect user to the candidacy summary page
                response.reset();
                response.sendRedirect(buildRedirectURL(request, candidacy));

                response.flushBuffer();
            } catch (ParserConfigurationException e) {
                logger.error(e.getMessage(), e);
            } catch (SAXException e) {
                logger.error(e.getMessage(), e);
            } catch (DocumentException e) {
View Full Code Here

TOP

Related Classes of pt.ist.fenixWebFramework.servlets.filters.contentRewrite.ResponseWrapper

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.