public Node reconfigure(final StaplerRequest req, JSONObject form) throws FormException { if (form==null) return null; final JSONObject jsonForProperties = form.optJSONObject("nodeProperties"); final AtomicReference<BindInterceptor> old = new AtomicReference<>(); old.set(req.setBindListener(new BindInterceptor() { @Override public Object onConvert(Type targetType, Class targetTypeErasure, Object jsonSource) { if (jsonForProperties != jsonSource) { return old.get().onConvert(targetType, targetTypeErasure, jsonSource); } try { DescribableList<NodeProperty<?>, NodePropertyDescriptor> tmp = new DescribableList<NodeProperty<?>, NodePropertyDescriptor>(Saveable.NOOP,getNodeProperties().toList()); tmp.rebuild(req, jsonForProperties, NodeProperty.all()); return tmp.toList(); } catch (FormException e) { throw new IllegalArgumentException(e); } catch (IOException e) { throw new IllegalArgumentException(e); } } })); try { return getDescriptor().newInstance(req, form); } finally { req.setBindListener(old.get()); } }
/** * Really creates a new agent. */ @RequirePOST public synchronized void doDoCreateItem( StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String type ) throws IOException, ServletException, FormException { final Jenkins app = Jenkins.getInstance(); app.checkPermission(Computer.CREATE); String fixedName = Util.fixEmptyAndTrim(name); checkName(fixedName); JSONObject formData = req.getSubmittedForm(); formData.put("name", fixedName); // TODO type is probably NodeDescriptor.id but confirm Node result = NodeDescriptor.all().find(type).newInstance(req, formData); app.addNode(result); // take the user back to the agent list top page rsp.sendRedirect2("."); }
public Node superNewInstance(StaplerRequest req, JSONObject formData) throws FormException { return super.newInstance(req, formData); }
public Node superNewInstance(StaplerRequest req) throws FormException { return super.newInstance(req); }
@Override public Node newInstance(StaplerRequest req, JSONObject formData) throws FormException { initPython(); if (pexec.isImplemented(15)) { return (Node) pexec.execPython("new_instance", req, formData); } else { return super.newInstance(req, formData); } }
@Override public Node newInstance(StaplerRequest req) throws FormException { initPython(); if (pexec.isImplemented(14)) { return (Node) pexec.execPython("new_instance", req); } else { return super.newInstance(req); } }
public Node reconfigure(final StaplerRequest req, JSONObject form) throws FormException { if (form==null) return null; final JSONObject jsonForProperties = form.optJSONObject("nodeProperties"); final AtomicReference<BindInterceptor> old = new AtomicReference<>(); old.set(req.setBindListener(new BindInterceptor() { @Override public Object onConvert(Type targetType, Class targetTypeErasure, Object jsonSource) { if (jsonForProperties != jsonSource) { return old.get().onConvert(targetType, targetTypeErasure, jsonSource); } try { DescribableList<NodeProperty<?>, NodePropertyDescriptor> tmp = new DescribableList<NodeProperty<?>, NodePropertyDescriptor>(Saveable.NOOP,getNodeProperties().toList()); tmp.rebuild(req, jsonForProperties, NodeProperty.all()); return tmp.toList(); } catch (FormException e) { throw new IllegalArgumentException(e); } catch (IOException e) { throw new IllegalArgumentException(e); } } })); try { return getDescriptor().newInstance(req, form); } finally { req.setBindListener(old.get()); } }
/** * Really creates a new slave. */ public synchronized void doDoCreateItem( StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String type ) throws IOException, ServletException, FormException { final Hudson app = Hudson.getInstance(); app.checkPermission(Hudson.ADMINISTER); // TODO: new permission? checkName(name); Node result = NodeDescriptor.all().find(type).newInstance(req, req.getSubmittedForm()); app.addNode(result); // take the user back to the slave list top page rsp.sendRedirect2("."); }
/** * Really creates a new slave. */ public synchronized void doDoCreateItem( StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String type ) throws IOException, ServletException, FormException { final Hudson app = Hudson.getInstance(); app.checkPermission(Hudson.ADMINISTER); // TODO: new permission? checkName(name); Node result = NodeDescriptor.all().find(type).newInstance(req, req.getSubmittedForm()); app.addNode(result); // take the user back to the slave list top page rsp.sendRedirect2("."); }
/** * Really creates a new slave. */ public synchronized void doDoCreateItem( StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String type ) throws IOException, ServletException, FormException { final Hudson app = Hudson.getInstance(); app.checkPermission(Hudson.ADMINISTER); // TODO: new permission? checkName(name); Node result = NodeDescriptor.all().find(type).newInstance(req, req.getSubmittedForm()); app.addNode(result); // take the user back to the slave list top page rsp.sendRedirect2("."); }
/** * Accepts the update to the node configuration. */ public void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { checkPermission(CONFIGURE); final Hudson app = Hudson.getInstance(); Node result = getNode().getDescriptor().newInstance(req, req.getSubmittedForm()); // replace the old Node object by the new one synchronized (app) { List<Node> nodes = new ArrayList<Node>(app.getNodes()); int i = nodes.indexOf(getNode()); if(i<0) { sendError("This slave appears to be removed while you were editing the configuration",req,rsp); return; } nodes.set(i,result); app.setNodes(nodes); } // take the user back to the slave top page. rsp.sendRedirect2("../"+result.getNodeName()+'/'); }
/** * Accepts the update to the node configuration. */ public void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { checkPermission(CONFIGURE); final Hudson app = Hudson.getInstance(); Node result = getNode().getDescriptor().newInstance(req, req.getSubmittedForm()); // replace the old Node object by the new one synchronized (app) { List<Node> nodes = new ArrayList<Node>(app.getNodes()); int i = nodes.indexOf(getNode()); if(i<0) { sendError("This slave appears to be removed while you were editing the configuration",req,rsp); return; } nodes.set(i,result); app.setNodes(nodes); } // take the user back to the slave top page. rsp.sendRedirect2("../"+result.getNodeName()+'/'); }
/** * Accepts the update to the node configuration. */ public void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException, FormException { checkPermission(CONFIGURE); final Hudson app = Hudson.getInstance(); Node result = getNode().getDescriptor().newInstance(req, req.getSubmittedForm()); // replace the old Node object by the new one synchronized (app) { List<Node> nodes = new ArrayList<Node>(app.getNodes()); int i = nodes.indexOf(getNode()); if(i<0) { sendError("This slave appears to be removed while you were editing the configuration",req,rsp); return; } nodes.set(i,result); app.setNodes(nodes); } // take the user back to the slave top page. rsp.sendRedirect2("../"+result.getNodeName()+'/'); }
/** * Really creates a new agent. */ @RequirePOST public synchronized void doDoCreateItem( StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String type ) throws IOException, ServletException, FormException { final Jenkins app = Jenkins.getInstance(); app.checkPermission(Computer.CREATE); String fixedName = Util.fixEmptyAndTrim(name); checkName(fixedName); JSONObject formData = req.getSubmittedForm(); formData.put("name", fixedName); // TODO type is probably NodeDescriptor.id but confirm Node result = NodeDescriptor.all().find(type).newInstance(req, formData); app.addNode(result); // take the user back to the agent list top page rsp.sendRedirect2("."); }
/** * Really creates a new slave. */ public synchronized void doDoCreateItem(StaplerRequest req, StaplerResponse rsp, @QueryParameter String name, @QueryParameter String type) throws IOException, ServletException, FormException { final Hudson app = Hudson.getInstance(); if (app.getTeamManager().isTeamManagementEnabled()) { app.checkPermission(Computer.CREATE); } else { app.checkPermission(Hudson.ADMINISTER); // TODO: new permission? } checkName(name); Node result = NodeDescriptor.all().find(type).newInstance(req, req.getSubmittedForm()); app.addNode(result); addToTeam(result.getNodeName(), null); // take the user back to the slave list top page rsp.sendRedirect2("."); }
Node result = getNode().getDescriptor().newInstance(req, req.getSubmittedForm());