private static boolean isRoutableMethod(@Nonnull Method m) { for (Annotation a : m.getDeclaredAnnotations()) { if (WebMethodConstants.WEB_METHOD_ANNOTATION_NAMES.contains(a.annotationType().getName())) { return true; } if (a.annotationType().isAnnotationPresent(InterceptorAnnotation.class)) { // This is a Stapler interceptor annotation like RequirePOST or JsonResponse return true; } } for (Annotation[] set : m.getParameterAnnotations()) { for (Annotation a : set) { if (WebMethodConstants.WEB_METHOD_PARAMETER_ANNOTATION_NAMES.contains(a.annotationType().getName())) { return true; } } } for (Class<?> parameterType : m.getParameterTypes()) { if (WebMethodConstants.WEB_METHOD_PARAMETERS_NAMES.contains(parameterType.getName())) { return true; } } return WebApp.getCurrent().getFilterForDoActions().keep(new Function.InstanceFunction(m)); }
/** * Do we need to show the upgrade wizard prompt? */ public boolean isDue() { if (isUpToDate) return false; // only admin users should see this if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) return false; // only show when Jenkins is fully up & running WebApp wa = WebApp.getCurrent(); if (wa==null || !(wa.getApp() instanceof Jenkins)) return false; return System.currentTimeMillis() > SetupWizard.getUpdateStateFile().lastModified(); }
/** * 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); } }
if (stapler != null) { try { WebApp webapp = WebApp.getCurrent(); MetaClass meta = webapp.getMetaClass(this); Script s = meta.loadTearOff(JellyClassTearOff.class).findScript("newInstanceDetail");
public ContextMenu from(ModelObjectWithContextMenu self, StaplerRequest request, StaplerResponse response, String view) throws JellyException, IOException { WebApp webApp = WebApp.getCurrent(); final Script s = webApp.getMetaClass(self).getTearOff(JellyClassTearOff.class).findScript(view); if (s!=null) { JellyFacet facet = webApp.getFacet(JellyFacet.class); request.setAttribute("taskTags",this); // <l:task> will look for this variable and populate us request.setAttribute("mode","side-panel"); // run sidepanel but ignore generated HTML facet.scriptInvoker.invokeScript(request,response,new Script() { public Script compile() throws JellyException { return this; } public void run(JellyContext context, XMLOutput output) throws JellyTagException { Functions.initPageVariables(context); s.run(context,output); } },self,new XMLOutput(new DefaultHandler())); } else if (self instanceof Actionable) { // fallback this.addAll(((Actionable)self).getAllActions()); } return this; } }
public JellyRequestDispatcher(Object it, Script script) { this.it = it; this.script = script; facet = WebApp.getCurrent().getFacet(JellyFacet.class); }
public JellyRequestDispatcher(Object it, Script script) { this.it = it; this.script = script; facet = WebApp.getCurrent().getFacet(JellyFacet.class); }
public JellyClassTearOff(MetaClass owner) { super(owner,JellyClassLoaderTearOff.class); facet = WebApp.getCurrent().getFacet(JellyFacet.class); }
/** * Loads the resource bundle associated with the Jelly script. */ public static ResourceBundle load(String jellyUrl) { if(jellyUrl.endsWith(".jelly")) // cut the trailing .jelly jellyUrl = jellyUrl.substring(0,jellyUrl.length()-".jelly".length()); JellyFacet facet = WebApp.getCurrent().getFacet(JellyFacet.class); return facet.resourceBundleFactory.create(jellyUrl); } }
/** * Loads the resource bundle associated with the Jelly script. */ public static ResourceBundle load(String jellyUrl) { if(jellyUrl.endsWith(".jelly")) // cut the trailing .jelly jellyUrl = jellyUrl.substring(0,jellyUrl.length()-".jelly".length()); JellyFacet facet = WebApp.getCurrent().getFacet(JellyFacet.class); return facet.resourceBundleFactory.create(jellyUrl); }
public Script parseScript(URL res) throws IOException { return WebApp.getCurrent().getFacet(JRubyFacet.class).parseScript(res); }
@Override public boolean dispatch(RequestImpl req, ResponseImpl rsp, Object node) throws IOException, ServletException { try { if (req.tokens.hasMore()) return false; if(LOGGER.isLoggable(FINE)) LOGGER.fine("Invoking index"+ rt.getDefaultScriptExtension()+" on " + node); WebApp.getCurrent().getFacet(JellyFacet.class).scriptInvoker.invokeScript(req, rsp, script, node); return true; } catch (JellyTagException e) { throw new ServletException(e); } }
/** * Do we need to show the upgrade wizard prompt? */ public boolean isDue() { if (isUpToDate) return false; // only admin users should see this if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) return false; // only show when Jenkins is fully up & running WebApp wa = WebApp.getCurrent(); if (wa==null || !(wa.getApp() instanceof Jenkins)) return false; return System.currentTimeMillis() > SetupWizard.getUpdateStateFile().lastModified(); }
/** * Returns true if this descriptor has <tt>config.jelly</tt>. */ public final boolean hasConfigScreen() { MetaClass c = WebApp.getCurrent().getMetaClass(getClass()); try { JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class); return tearOff.findScript(getConfigPage())!=null; } catch(JellyException e) { return false; } }
/** * Returns true if this descriptor has <tt>config.jelly</tt>. */ public final boolean hasConfigScreen() { MetaClass c = WebApp.getCurrent().getMetaClass(getClass()); try { JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class); return tearOff.findScript(getConfigPage())!=null; } catch(JellyException e) { return false; } }
/** * Returns true if this descriptor has <tt>config.jelly</tt>. */ public final boolean hasConfigScreen() { MetaClass c = WebApp.getCurrent().getMetaClass(getClass()); try { JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class); return tearOff.findScript(getConfigPage())!=null; } catch(JellyException e) { return false; } }
/** * Returns true if this descriptor has <tt>config.jelly</tt>. */ public final boolean hasConfigScreen() { MetaClass c = WebApp.getCurrent().getMetaClass(getClass()); try { JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class); return tearOff.findScript(getConfigPage())!=null; } catch(JellyException e) { return false; } }
/** * Returns true if this descriptor has <tt>config.jelly</tt>. */ public final boolean hasConfigScreen() { MetaClass c = WebApp.getCurrent().getMetaClass(getClass()); try { JellyClassTearOff tearOff = c.loadTearOff(JellyClassTearOff.class); return tearOff.findScript(getConfigPage())!=null; } catch(JellyException e) { return false; } }
public void doIndex(StaplerResponse rsp) throws IOException { rsp.setContentType("text/html"); PrintWriter w = rsp.getWriter(); w.println("<html><body><script src='prototype'></script><script src='script'></script>"); w.println("<script>var v = "+ WebApp.getCurrent().boundObjectTable.bind(this).getProxyScript()+";</script>"); w.println("<script>var callback = function(t){var x=t.responseObject(); alert(Object.toJSON(x)); };</script>"); w.println("</body></html>"); }
public void doBindAnonymous(StaplerResponse rsp) throws IOException { rsp.setContentType("text/html"); PrintWriter w = rsp.getWriter(); w.println("<html><body><script src='prototype'></script><script src='script'></script>"); w.println("<script>var v = "+ WebApp.getCurrent().boundObjectTable.bind(anonymous).getProxyScript()+";</script>"); w.println("</body></html>"); }