added a hook to customize custom node creation.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@32052 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
kohsuke committed 2010-06-15 18:00:18 +00:00
1 parent 1b441d4579
commit 12c4cc253d
2 files changed
+19 -4

No files matched your search

@@ -207,8 +207,8 @@ public final class ComputerSet extends AbstractModelObject {
* First check point in creating a new slave.
*/
public synchronized void doCreateItem( StaplerRequest req, StaplerResponse rsp,
@QueryParameter("name") String name, @QueryParameter("mode") String mode,
@QueryParameter("from") String from ) throws IOException, ServletException {
@QueryParameter String name, @QueryParameter String mode,
@QueryParameter String from ) throws IOException, ServletException {
final Hudson app = Hudson.getInstance();
app.checkPermission(Hudson.ADMINISTER); // TODO: new permission?
@@ -248,8 +248,8 @@ public final class ComputerSet extends AbstractModelObject {
return;
}
req.setAttribute("descriptor", NodeDescriptor.all().find(mode));
req.getView(this,"_new.jelly").forward(req,rsp);
NodeDescriptor d = NodeDescriptor.all().find(mode);
d.handleNewNodePage(this,req,rsp);
}
}
@@ -23,6 +23,7 @@
*/
package hudson.slaves;
import hudson.model.ComputerSet;
import hudson.model.Descriptor;
import hudson.model.Slave;
import hudson.model.Node;
@@ -32,10 +33,15 @@ import hudson.util.FormValidation;
import hudson.DescriptorExtensionList;
import hudson.Util;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import javax.servlet.ServletException;
/**
* {@link Descriptor} for {@link Slave}.
@@ -70,6 +76,15 @@ public abstract class NodeDescriptor extends Descriptor<Node> {
return '/'+clazz.getName().replace('.','/').replace('$','/')+"/newInstanceDetail.jelly";
}
/**
* Handles the form submission from the "/computer/new" page, which is the first form for creating a new node.
* By default, it shows the configuration page for entering details, but subtypes can override this differently.
*/
public void handleNewNodePage(ComputerSet computerSet, StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
req.setAttribute("descriptor", this);
req.getView(computerSet,"_new.jelly").forward(req,rsp);
}
@Override
public String getConfigPage() {
return getViewPage(clazz, "configure-entries.jelly");