@Override public String evaluate(@Nonnull Run<?, ?> run, FilePath workspace, @Nonnull TaskListener listener, String macroName) throws MacroEvaluationException, IOException, InterruptedException { InputStream inputStream = null; try { inputStream = getFileInputStream(workspace, template, JELLY_EXTENSION); return renderContent(run, inputStream, listener); } catch (JellyException e) { return "JellyException: " + e.getMessage(); } catch (FileNotFoundException e) { return generateMissingFile("Jelly", template); } finally { IOUtils.closeQuietly(inputStream); } }
/** * Creates a {@link RequestDispatcher} that forwards to the jelly view, if available. */ public RequestDispatcher createDispatcher(Object it, String viewName) throws IOException { try { // backward compatible behavior that expects full file name including ".jelly" Script script = findScript(viewName); if(script!=null) return new JellyRequestDispatcher(it,script); // this is what the look up was really supposed to be. script = findScript(viewName+".jelly"); if(script!=null) return new JellyRequestDispatcher(it,script); return null; } catch (JellyException e) { IOException io = new IOException(e.getMessage()); io.initCause(e); throw io; } }
/** * Creates a {@link RequestDispatcher} that forwards to the jelly view, if available. */ public RequestDispatcher createDispatcher(Object it, String viewName) throws IOException { try { // backward compatible behavior that expects full file name including ".jelly" Script script = findScript(viewName); if(script!=null) return new JellyRequestDispatcher(it,script); // this is what the look up was really supposed to be. script = findScript(viewName+".jelly"); if(script!=null) return new JellyRequestDispatcher(it,script); return null; } catch (JellyException e) { IOException io = new IOException(e.getMessage()); io.initCause(e); throw io; } }
public void testDoctypeDefinitionXXEDefaultMode() throws JellyException { JellyContext context = new JellyContext(); URL url = this.getClass().getResource("doctypeDefinitionXXE.jelly"); try { context.runScript(url, null); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause instanceof java.net.ConnectException) { fail("doctypeDefinitionXXE.jelly attempted to connect to http://127.0.0.1:4444"); } else if (cause instanceof org.xml.sax.SAXParseException) { // Success. } else { fail("Unknown exception: " + e.getMessage()); } } }
public void testDoctypeDefinitionXXEAllowDTDCalls() throws JellyException { JellyContext context = new JellyContext(); context.setAllowDtdToCallExternalEntities(true); URL url = this.getClass().getResource("doctypeDefinitionXXE.jelly"); try { context.runScript(url, null); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause instanceof java.net.ConnectException) { //success } else if (cause instanceof org.xml.sax.SAXParseException) { fail("doctypeDefinitionXXE.jelly did not attempt to connect to http://127.0.0.1:4444"); } else { fail("Unknown exception: " + e.getMessage()); } } } }
public void testInvokeThatDoesNotHandleException() throws Exception { setUpScript( "testInvokeStaticTag.jelly" ); Script script = getJelly().compileScript(); getJellyContext().setVariable("test.invokeThatDoesNotHandleException",Boolean.TRUE); script.run(getJellyContext(),getXMLOutput()); String exceptionMessage = (String) getJellyContext().getVariable("exceptionMessage"); assertNotNull( exceptionMessage ); JellyException jellyException = (JellyException) getJellyContext().getVariable("jellyException"); assertNotNull( jellyException ); assertTrue( "messages are the same", ! exceptionMessage.equals(jellyException.getMessage()) ); assertTrue( "exception '" + jellyException.getMessage() + "' does not ends with '" + exceptionMessage+"'", jellyException.getMessage().endsWith(exceptionMessage) ); assertNotNull( jellyException.getCause() ); assertEquals( exceptionMessage, jellyException.getCause().getMessage() ); }
public void testInvokeThatDoesNotHandleException() throws Exception { setUpScript("testInvokeTag.jelly"); Script script = getJelly().compileScript(); getJellyContext().setVariable("test.invokeThatDoesNotHandleException",Boolean.TRUE); script.run(getJellyContext(),getXMLOutput()); String exceptionMessage = (String) getJellyContext().getVariable("exceptionMessage"); assertNotNull( exceptionMessage ); assertNotNull( getJellyContext().getVariable("exceptionBean")); JellyException jellyException = (JellyException) getJellyContext().getVariable("jellyException"); assertNotNull( jellyException ); assertTrue( "messages are the same", ! exceptionMessage.equals(jellyException.getMessage()) ); assertTrue( "exception '" + jellyException.getMessage() + "' does not ends with '" + exceptionMessage+"'", jellyException.getMessage().endsWith(exceptionMessage) ); assertNotNull( jellyException.getCause() ); assertEquals( exceptionMessage, jellyException.getCause().getMessage() ); }