* First check point in creating a new slave.
*/
public synchronized void doCreateItem( StaplerRequest req, StaplerResponse rsp,
@QueryParameter String name, @QueryParameter String mode,
@QueryParameter String from ) throws IOException, ServletException {
final Jenkins app = Jenkins.getInstance();
app.checkPermission(Computer.CREATE);
if(mode!=null && mode.equals("copy")) {
name = checkName(name);
Node src = app.getNode(from);
if(src==null) {
rsp.setStatus(SC_BAD_REQUEST);
if(Util.fixEmpty(from)==null)
sendError(Messages.ComputerSet_SpecifySlaveToCopy(),req,rsp);
else
sendError(Messages.ComputerSet_NoSuchSlave(from),req,rsp);
return;
}
// copy through XStream
String xml = Jenkins.XSTREAM.toXML(src);
Node result = (Node) Jenkins.XSTREAM.fromXML(xml);
result.setNodeName(name);
result.holdOffLaunchUntilSave = true;
app.addNode(result);
// send the browser to the config page
rsp.sendRedirect2(result.getNodeName()+"/configure");
} else {
// proceed to step 2