/** * Evaluates the Jelly script submitted by the client. * * This is useful for system administration as well as unit testing. */ @RequirePOST public void doEval(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { checkPermission(RUN_SCRIPTS); try { MetaClass mc = WebApp.getCurrent().getMetaClass(getClass()); Script script = mc.classLoader.loadTearOff(JellyClassLoaderTearOff.class).createContext().compileScript(new InputSource(req.getReader())); new JellyRequestDispatcher(this,script).forward(req,rsp); } catch (JellyException e) { throw new ServletException(e); } }
@Override protected void runTest() throws Exception { jct.createContext().compileScript(jelly); Document dom = new SAXReader().read(jelly); checkLabelFor(dom); // TODO: what else can we check statically? use of taglibs? }
@Override protected void runTest() throws Exception { jct.createContext().compileScript(jelly); Document dom = new SAXReader().read(jelly); checkLabelFor(dom); // TODO: what else can we check statically? use of taglibs? }
@Override protected void runTest() throws Exception { jct.createContext().compileScript(jelly); Document dom = new SAXReader().read(jelly); checkLabelFor(dom); // TODO: what else can we check statically? use of taglibs? }
private Script loadJellyScript(URL res) throws JellyException { // compile script JellyContext context = new CustomJellyContext(master); context.setClassLoader(classLoader); return context.compileScript(res); } }
private Script loadJellyScript(URL res) throws JellyException { // compile script JellyContext context = new CustomJellyContext(master); context.setClassLoader(classLoader); return context.compileScript(res); } }
@Override protected void runTest() throws Exception { jct.createContext().compileScript(jelly); Document dom = new SAXReader().read(jelly); checkLabelFor(dom); if (requirePI) { ProcessingInstruction pi = dom.processingInstruction("jelly"); if (pi==null || !pi.getText().contains("escape-by-default")) throw new AssertionError("<?jelly escape-by-default='true'?> is missing in "+jelly); } // TODO: what else can we check statically? use of taglibs? }
protected Script parseScript(URL res) throws JellyException { return new JellyViewScript(owner.clazz, res, classLoader.createContext().compileScript(res)); }
protected Script parseScript(URL res) throws JellyException { return new JellyViewScript(owner.klass, res, classLoader.createContext().compileScript(res)); }
/** * Builds an adjunct. * * @param name * Fully qualified name of the adjunct. * @param classLoader * This is where adjuncts are loaded from. */ public Adjunct(AdjunctManager manager, String name, final ClassLoader classLoader) throws IOException { this.manager = manager; this.name = name; this.slashedName = name.replace('.','/'); this.packageName = slashedName.substring(0, Math.max(0,slashedName.lastIndexOf('/'))); this.hasCss = parseOne(classLoader, slashedName+".css"); this.hasJavaScript = parseOne(classLoader,slashedName+".js"); this.inclusionFragment = parseHtml(classLoader,slashedName+".html"); URL jelly = classLoader.getResource(slashedName + ".jelly"); if (jelly!=null) { try { script = MetaClassLoader.get(classLoader).loadTearOff(JellyClassLoaderTearOff.class).createContext().compileScript(jelly); } catch (JellyException e) { throw new IOException("Failed to load "+jelly,e); } } else { script = null; } if(!hasCss && !hasJavaScript && inclusionFragment==null && script==null) throw new NoSuchAdjunctException("Neither "+ name +".css, .js, .html, nor .jelly were found"); }
private String renderContent(@Nonnull Run<?, ?> build, InputStream inputStream, @Nonnull TaskListener listener) throws JellyException, IOException { String rawScript = IOUtils.toString(inputStream); if (inputStream instanceof UserProvidedContentInputStream) { Item parent = build.getParent(); ScriptApproval.get().configuring(rawScript, JellyLanguage.get(), ApprovalContext.create().withItem(parent)); ScriptApproval.get().using(rawScript, JellyLanguage.get()); } JellyContext context = createContext(new ScriptContentBuildWrapper(build), build, listener); Script script = context.compileScript(new InputSource(new StringReader(rawScript))); if (script != null) { return convert(build, context, script); } return null; }
/** * Evaluates the Jelly script submitted by the client. * * This is useful for system administration as well as unit testing. */ @RequirePOST public void doEval(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { checkPermission(RUN_SCRIPTS); try { MetaClass mc = WebApp.getCurrent().getMetaClass(getClass()); Script script = mc.classLoader.loadTearOff(JellyClassLoaderTearOff.class).createContext().compileScript(new InputSource(req.getReader())); new JellyRequestDispatcher(this,script).forward(req,rsp); } catch (JellyException e) { throw new ServletException(e); } }
/** * Builds an adjunct. * * @param name * Fully qualified name of the adjunct. * @param classLoader * This is where adjuncts are loaded from. */ public Adjunct(AdjunctManager manager, String name, final ClassLoader classLoader) throws IOException { this.manager = manager; this.name = name; this.slashedName = name.replace('.','/'); this.packageName = slashedName.substring(0, Math.max(0,slashedName.lastIndexOf('/'))); this.hasCss = parseOne(classLoader, slashedName+".css"); this.hasJavaScript = parseOne(classLoader,slashedName+".js"); this.inclusionFragment = parseHtml(classLoader,slashedName+".html"); URL jelly = classLoader.getResource(slashedName + ".jelly"); if (jelly!=null) { try { script = MetaClassLoader.get(classLoader).loadTearOff(JellyClassLoaderTearOff.class).createContext().compileScript(jelly); } catch (JellyException e) { throw new IOException2("Failed to load "+jelly,e); } } else { script = null; } if(!hasCss && !hasJavaScript && inclusionFragment==null && script==null) throw new NoSuchAdjunctException("Neither "+ name +".css, .js, .html, nor .jelly were found"); }
/** * Evaluates the Jelly script submitted by the client. * * This is useful for system administration as well as unit testing. */ public void doEval(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { checkPermission(ADMINISTER); requirePOST(); try { MetaClass mc = WebApp.getCurrent().getMetaClass(getClass()); Script script = mc.classLoader.loadTearOff(JellyClassLoaderTearOff.class).createContext().compileScript(new InputSource(req.getReader())); new JellyRequestDispatcher(this, script).forward(req, rsp); } catch (JellyException e) { throw new ServletException(e); } }
/** * Evaluates the Jelly script submitted by the client. * * This is useful for system administration as well as unit testing. */ public void doEval(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { checkPermission(ADMINISTER); requirePOST(); try { MetaClass mc = WebApp.getCurrent().getMetaClass(getClass()); Script script = mc.classLoader.loadTearOff(JellyClassLoaderTearOff.class).createContext().compileScript(new InputSource(req.getReader())); new JellyRequestDispatcher(this, script).forward(req, rsp); } catch (JellyException e) { throw new ServletException(e); } }
/** * Evaluates the Jelly script submitted by the client. * * This is useful for system administration as well as unit testing. */ public void doEval(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { checkPermission(ADMINISTER); requirePOST(); try { MetaClass mc = WebApp.getCurrent().getMetaClass(getClass()); Script script = mc.classLoader.loadTearOff(JellyClassLoaderTearOff.class).createContext().compileScript(new InputSource(req.getReader())); new JellyRequestDispatcher(this, script).forward(req, rsp); } catch (JellyException e) { throw new ServletException(e); } }
/** * Evaluates the Jelly script submitted by the client. * * This is useful for system administration as well as unit testing. */ public void doEval(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { checkPermission(ADMINISTER); requirePOST(); try { MetaClass mc = WebApp.getCurrent().getMetaClass(getClass()); Script script = mc.classLoader.loadTearOff(JellyClassLoaderTearOff.class).createContext().compileScript(new InputSource(req.getReader())); new JellyRequestDispatcher(this, script).forward(req, rsp); } catch (JellyException e) { throw new ServletException(e); } }
Script script = compileScript(source);
Script script = compileScript(source);
Script script = compileScript(source);