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()); } }
@Override public Set<Attribute<Jenkins,?>> describe() { final Set<Attribute<Jenkins,?>> attributes = super.describe(); // Add remoting security, all legwork will be done by a configurator attributes.add(new Attribute<Jenkins, AdminWhitelistRule>("remotingSecurity", AdminWhitelistRule.class) .getter( j -> j.getInjector().getInstance(AdminWhitelistRule.class) ) .setter( noop() )); // Override "nodes" getter so we don't export Nodes registered by Cloud plugins Attribute.<Jenkins,List<Node>>get(attributes, "nodes").ifPresent(a -> a.getter(j -> j.getNodes().stream() .filter(node -> node.getDescriptor().isInstantiable()) .collect(Collectors.toList()) ) ); return attributes; }
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()); } }
@Override public Set<Attribute<Jenkins,?>> describe() { final Set<Attribute<Jenkins,?>> attributes = super.describe(); // Add remoting security, all legwork will be done by a configurator attributes.add(new Attribute<Jenkins, AdminWhitelistRule>("remotingSecurity", AdminWhitelistRule.class) .getter( j -> j.getInjector().getInstance(AdminWhitelistRule.class) ) .setter( noop() )); // Override "nodes" getter so we don't export Nodes registered by Cloud plugins Attribute.<Jenkins,List<Node>>get(attributes, "nodes").ifPresent(a -> a.getter(j -> j.getNodes().stream() .filter(node -> node.getDescriptor().isInstantiable()) .collect(Collectors.toList()) ) ); return attributes; }
/** * 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()+'/'); }
Node result = getNode().getDescriptor().newInstance(req, req.getSubmittedForm());