Package org.jbpm.formapi.server.render

Examples of org.jbpm.formapi.server.render.RendererException


            StreamResult result = new StreamResult(writer);
            StreamSource inputSource = new StreamSource(toInputString(inputData));
            transformer.transform(inputSource, result);
            return writer.toString();
        } catch (IOException e) {
            throw new RendererException("I/O problem rendering " + url, e);
        } catch (TransformerConfigurationException e) {
            throw new RendererException("transformer configuration problem rendering " + url, e);
        } catch (TransformerException e) {
            throw new RendererException("transformer problem rendering " + url, e);
        } finally {
            new File(url.getFile()).delete();
        }
    }
View Full Code Here


    }
   
    @Override
    public Object render(URL url, Map<String, Object> inputData) throws RendererException {
        if (velocityTemplate == null) {
            throw new RendererException("Couldn't find index.vm");
        }
        synchronized (this) {
            if (template == null) {
                template = engine.getTemplate("index.vm");
            }
        }
        try {
            String formContent = IOUtils.toString(url.openStream());
            JsonObject json = new JsonObject();
            json.addProperty("formjson", formContent);
            String contextPath = (String) inputData.remove(BASE_CONTEXT_PATH);
            json.add("formData", toJsonObject(inputData));
            json.addProperty("contextPath", contextPath);
            VelocityContext context = new VelocityContext();
            context.put("contextPath", contextPath);
            context.put("formContent", json.toString());
            StringWriter writer = new StringWriter();
            template.merge(context, writer);
            return writer.toString();
        } catch (IOException e) {
            throw new RendererException("Problem reading index.vm", e);
        }
    }
View Full Code Here

            StringWriter out = new StringWriter();
            Template temp = new Template(name, new InputStreamReader(url.openStream()), cfg);
            temp.process(inputData, out);
            return out.toString();
        } catch (IOException e) {
            throw new RendererException("I/O problem rendering " + url, e);
        } catch (TemplateException e) {
            throw new RendererException("Template problem rendering " + url, e);
        }
    }
View Full Code Here

    //test response to a non existing Renderer for RESTFormService.getFormPreview(...)
    public void testGetFormPreviewRendererNotFound() throws Exception {
        final Translator translator = EasyMock.createMock(Translator.class);
        final ServletContext context = EasyMock.createMock(ServletContext.class);
        final HttpServletRequest request = EasyMock.createMock(HttpServletRequest.class);
        RESTFormService restService = emulateRESTFormService(translator, null, null, new RendererException("not finding a renderer"));
        restService.setFormService(new MockFormDefinitionService());
       
        FormPreviewDTO dto = new FormPreviewDTO();
        FormRepresentation form = createMockForm("myForm", "key1", "key2");
        String jsonBody = FormEncodingFactory.getEncoder().encode(form);
View Full Code Here

       
        FormRepresentation form = createMockForm("myForm", "key1", "key2");
        FormPreviewDTO dto = createFormPreviewDTO(form);
       
        EasyMock.expect(translator.translateForm(EasyMock.eq(form))).andReturn(new URL("http://www.redhat.com")).once();
        RendererException exception = new RendererException("Something going wrong");
        @SuppressWarnings("unchecked")
        Map<String, Object> anyObject = EasyMock.anyObject(Map.class);
        EasyMock.expect(renderer.render(EasyMock.anyObject(URL.class), anyObject)).andThrow(exception).once();
        EasyMock.expect(context.getContextPath()).andReturn("/").anyTimes();
        EasyMock.expect(request.getLocale()).andReturn(Locale.getDefault()).once();
View Full Code Here

TOP

Related Classes of org.jbpm.formapi.server.render.RendererException

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.