Refine search
public Expression createExpression(String text) throws JellyException { try { return new JexlExpression( org.apache.commons.jexl.ExpressionFactory.createExpression(text) ); } catch (Exception e) { throw new JellyException("Unable to create expression: " + text, e); } }
Script script = compileScript(source); newJellyContextURL = getJellyContextURL(source); } catch (MalformedURLException e) { throw new JellyException(e.toString()); JellyContext newJellyContext = newJellyContext(); newJellyContext.setRootURL( newJellyContextURL ); newJellyContext.setCurrentURL( newJellyContextURL );
/** * Parses the script from the given uri using the * JellyContext.getResource() API then compiles it and runs it. * * @return the new child context that was used to run the script */ public JellyContext runScript(String uri, XMLOutput output, boolean export, boolean inherit) throws JellyException { URL url = null; try { url = getResource(uri); } catch (MalformedURLException e) { throw new JellyException(e.toString()); } if (url == null) { throw new JellyException("Could not find Jelly script: " + url); } return runScript(url, output, export, inherit); }
cmdLine = parseCommandLineOptions(args); } catch (ParseException e) { throw new JellyException(e); throw new JellyException("Script file " + scriptFile + " not found"); context.setVariable("args", args); context.setVariable("commandLine", cmdLine); if (runInSwingThread) { javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { throw new JellyException(e);
URL rootURL = context.getRootURL(); URL currentURL = context.getCurrentURL(); final Object oldParent=context.getVariables().get(PARENT_TAG); try { Tag tag = getTag(context); throw new JellyException("This tag does not understand the '" + name + "' attribute" );
/** * Request Handler for the feed itself. This will always return an empty feed since the feed is created from the JIRA cache * * @param request the {@link org.kohsuke.stapler.StaplerRequest} * @param response the {@link org.kohsuke.stapler.StaplerResponse} * @throws Exception in case of errors */ public void doFeed(StaplerRequest request, StaplerResponse response) throws Exception { JellyContext context = new JellyContext(); context.setVariable("request", request); DateTime now = new DateTime(); context.setVariable("timezone", timeZoneFormatter.withZone(now.getZone()).print(now)); context.setVariable("date", dateTimeFormatter.print(now.toDateTime(DateTimeZone.UTC))); try { response.setStatus(HttpServletResponse.SC_OK); response.setContentType("application/atom+xml"); context.runScript(getClass().getResource("feed.jelly"), XMLOutput.createXMLOutput(response.getWriter())); } catch (JellyException e) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); e.printStackTrace(response.getWriter()); } }
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() ); }
/** * Parses the script from the given file then compiles it and runs it. * * @return the new child context that was used to run the script */ public JellyContext runScript(File file, XMLOutput output, boolean export, boolean inherit) throws JellyException { try { return runScript(file.toURL(), output, export, inherit); } catch (MalformedURLException e) { throw new JellyException(e.toString()); } }
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()); } } }
/** * Attempts to parse the script from the given InputSource using the * {@link #getResource} method then returns the compiled script. */ public Script compileScript(InputSource source) throws JellyException { XMLParser parser = getXMLParser(); parser.setContext(this); Script script = null; try { script = parser.parse(source); } catch (IOException e) { throw new JellyException(JellyContext.BAD_PARSE+" : "+source.getSystemId(), e); } catch (SAXException e) { throw new JellyException(JellyContext.BAD_PARSE+" : "+source.getSystemId(), e); } return script.compile(); }
/** * Attempts to parse the script from the given uri using the * {@link #getResource} method then returns the compiled script. */ public Script compileScript(String uri) throws JellyException { XMLParser parser = getXMLParser(); parser.setContext(this); InputStream in = getResourceAsStream(uri); if (in == null) { throw new JellyException("Could not find Jelly script: " + uri); } Script script = null; try { script = parser.parse(in); } catch (IOException e) { throw new JellyException(JellyContext.BAD_PARSE, e); } catch (SAXException e) { throw new JellyException(JellyContext.BAD_PARSE, e); } return script.compile(); }
public void doTag(XMLOutput output) throws JellyTagException { Class throwableClass = null; try { throwableClass = getThrowableClass(); invokeBody(output); } catch (Throwable t) { if (t instanceof JellyException) { // unwrap Jelly exceptions which wrap other exceptions JellyException je = (JellyException) t; if (je.getCause() != null) { t = je.getCause(); } } if (var != null) { context.setVariable(var, t); } if (throwableClass != null && !throwableClass.isAssignableFrom(t.getClass())) { fail("Unexpected exception: " + t); } else { return; } } fail("No exception was thrown."); }
private TagScript createTagScript(JellyContext context, String uri, String name) throws JellyException { TagLibrary lib = context.getTagLibrary(uri); if (lib==null) throw new JellyException("Undefined tag library namespace URI: "+uri); TagScript tagScript = lib.createTagScript(name, null/*this parameter appears to be unused.*/); if (tagScript!=null) return tagScript; tagScript = lib.createTagScript(name.replace('_','-'), null); if (tagScript!=null) return tagScript; throw new JellyException(String.format("name '%s' not found for '%s'", name, uri)); } }
/** * Usage: jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval] */ public static void main(String[] args) throws Exception { try { if (args.length <= 0) { System.out.println("Usage: jelly [scriptFile] [-script scriptFile -o outputFile -Dsysprop=syspropval]"); return; } // parse the command line options using CLI // using a separate class to avoid unnecessary // dependencies CommandLineParser.getInstance().invokeCommandLineJelly(args); } catch (JellyException e) { Throwable cause = e.getCause(); if (cause == null) { e.printStackTrace(); } else { cause.printStackTrace(); } } }
if ( jellyEx.getCause() == null ) LOGGER.info( MavenUtils.getMessage( "exception.cause" ) + jellyEx.getReason() ); LOGGER.info( MavenUtils.getMessage( "build.jellyException.file", jellyEx.getFileName() ) ); LOGGER.info( MavenUtils.getMessage( "build.jellyException.element", jellyEx.getElementName() ) ); LOGGER.info( MavenUtils.getMessage( "build.jellyException.line", Integer.toString( jellyEx.getLineNumber() ) ) ); LOGGER.info( MavenUtils.getMessage( "build.jellyException.column", Integer.toString( jellyEx.getColumnNumber() ) ) );
public void printStackTrace() { super.printStackTrace(); if (cause != null && !isChainingSupported()) { System.out.println("Root cause"); cause.printStackTrace(); } }
@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); } }
Script script = compileScript(source); newJellyContextURL = getJellyContextURL(source); } catch (MalformedURLException e) { throw new JellyException(e.toString()); JellyContext newJellyContext = newJellyContext(); newJellyContext.setRootURL( newJellyContextURL ); newJellyContext.setCurrentURL( newJellyContextURL );
/** * Parses the script from the given uri using the * JellyContext.getResource() API then compiles it and runs it. * * @return the new child context that was used to run the script */ public JellyContext runScript(String uri, XMLOutput output) throws JellyException { URL url = null; try { url = getResource(uri); } catch (MalformedURLException e) { throw new JellyException(e.toString()); } if (url == null) { throw new JellyException("Could not find Jelly script: " + url); } return runScript(url, output, JellyContext.DEFAULT_EXPORT, JellyContext.DEFAULT_INHERIT); }