From 6fc699ff7406628271bbab7038b552481653436e Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 31 Mar 2011 15:09:23 -0700 Subject: [PATCH 001/221] - making context richer - simplifying Jelly view and submission handling --- core/src/main/java/hudson/model/View.java | 35 +++++++++---------- .../main/java/hudson/model/ViewProperty.java | 6 +++- .../hudson/model/ViewPropertyDescriptor.java | 5 ++- .../hudson/model/View/configure.jelly | 15 +------- 4 files changed, 26 insertions(+), 35 deletions(-) diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java index 81c4eb3074..ed40898026 100644 --- a/core/src/main/java/hudson/model/View.java +++ b/core/src/main/java/hudson/model/View.java @@ -29,6 +29,8 @@ import hudson.ExtensionPoint; import hudson.Util; import hudson.model.Descriptor.FormException; import hudson.model.Node.Mode; +import hudson.model.labels.LabelAtomProperty; +import hudson.model.labels.LabelAtomPropertyDescriptor; import hudson.scm.ChangeLogSet.Entry; import hudson.search.CollectionSearchIndex; import hudson.search.SearchIndexBuilder; @@ -205,6 +207,19 @@ public abstract class View extends AbstractModelObject implements AccessControll return properties; } + /** + * Returns all the {@link LabelAtomPropertyDescriptor}s that can be potentially configured + * on this label. + */ + public List getApplicablePropertyDescriptors() { + List r = new ArrayList(); + for (ViewPropertyDescriptor pd : ViewProperty.all()) { + if (pd.isEnabledFor(this)) + r.add(pd); + } + return r; + } + public void save() throws IOException { // persistence is a part of the owner // due to initialization timing issue, it can be null when this method is called @@ -620,25 +635,7 @@ public abstract class View extends AbstractModelObject implements AccessControll JSONObject json = req.getSubmittedForm(); - List props = new ArrayList(); - int i = 0; - for (ViewPropertyDescriptor d: ViewProperty.all()) { - ViewProperty p = properties.get(d.clazz); - - JSONObject o = json.optJSONObject("viewProperty" + (i++)); - if (o != null) { - if (p != null) { - p = p.reconfigure(req, o); - } else { - p = d.newInstance(req, o); - } - } - - if (p != null) { - props.add(p); - } - } - properties.replaceBy(props); + properties.rebuild(req, req.getSubmittedForm(), getApplicablePropertyDescriptors()); save(); diff --git a/core/src/main/java/hudson/model/ViewProperty.java b/core/src/main/java/hudson/model/ViewProperty.java index 74cdb40a67..2c576a652e 100644 --- a/core/src/main/java/hudson/model/ViewProperty.java +++ b/core/src/main/java/hudson/model/ViewProperty.java @@ -25,9 +25,14 @@ package hudson.model; import hudson.DescriptorExtensionList; import hudson.ExtensionPoint; +import hudson.console.ConsoleAnnotator; +import hudson.console.ConsoleAnnotatorFactory; import net.sf.json.JSONObject; import org.kohsuke.stapler.StaplerRequest; +import java.util.ArrayList; +import java.util.List; + /** * Extensible property of {@link View}. * @@ -68,5 +73,4 @@ public class ViewProperty implements Describable, ExtensionPoint { public ViewProperty reconfigure(StaplerRequest req, JSONObject form) throws Descriptor.FormException { return getDescriptor().newInstance(req, form); } - } diff --git a/core/src/main/java/hudson/model/ViewPropertyDescriptor.java b/core/src/main/java/hudson/model/ViewPropertyDescriptor.java index b7c474b47f..f073050f57 100644 --- a/core/src/main/java/hudson/model/ViewPropertyDescriptor.java +++ b/core/src/main/java/hudson/model/ViewPropertyDescriptor.java @@ -67,8 +67,11 @@ public abstract class ViewPropertyDescriptor extends Descriptor { *

* This mechanism is useful if the availability of the property is * contingent of some other settings. + * + * @param view + * View for which this property is considered. Never null. */ - public boolean isEnabled() { + public boolean isEnabledFor(View view) { return true; } } diff --git a/core/src/main/resources/hudson/model/View/configure.jelly b/core/src/main/resources/hudson/model/View/configure.jelly index acee8d3038..a648febb2a 100644 --- a/core/src/main/resources/hudson/model/View/configure.jelly +++ b/core/src/main/resources/hudson/model/View/configure.jelly @@ -51,20 +51,7 @@ THE SOFTWARE. - - - - - - - - - - - - - - + From ef7b9d84fdaa9ec35213a5c324e397ff389dd561 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 31 Mar 2011 15:50:41 -0700 Subject: [PATCH 002/221] generalized the reconfigure concept. --- .../model/ReconfigurableDescribable.java | 81 +++++++++++++++++++ .../main/java/hudson/model/ViewProperty.java | 4 +- .../java/hudson/util/DescribableList.java | 20 ++++- 3 files changed, 100 insertions(+), 5 deletions(-) create mode 100644 core/src/main/java/hudson/model/ReconfigurableDescribable.java diff --git a/core/src/main/java/hudson/model/ReconfigurableDescribable.java b/core/src/main/java/hudson/model/ReconfigurableDescribable.java new file mode 100644 index 0000000000..7738089b1d --- /dev/null +++ b/core/src/main/java/hudson/model/ReconfigurableDescribable.java @@ -0,0 +1,81 @@ +/* + * The MIT License + * + * Copyright (c) 2011, CloudBees, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package hudson.model; + +import hudson.model.Descriptor.FormException; +import hudson.slaves.NodeProperty; +import net.sf.json.JSONObject; +import org.kohsuke.stapler.StaplerRequest; + +/** + * Marks modern {@link Describable}s that allow the current instances to pass information down to the next + * instance when the configuration is submitted. + * + *

+ * As the generics signature implies, it isn't up to individual {@link Describable} implementation to + * implement this. Rather, it is up to the designer of an extension point to mark the extension point + * as {@link ReconfigurableDescribable}, as it requires coordination at the owner of the extension point. + * + *

Use Cases

+ *

Invisible Property

+ *

+ * This mechanism can be used to create an entirely invisible {@link Describable}, which is handy + * for {@link NodeProperty}, {@link JobProperty}, etc. To do so, define a descriptor with null + * {@linkplain Descriptor#getDisplayName() display name} and empty config.jelly to prevent it from + * showing up in the config UI, then implement {@link #reconfigure(StaplerRequest, JSONObject)} + * and simply return {@code this}. + * + *

Passing some values without going through clients

+ *

+ * Sometimes your {@link Describable} object may have some expensive objects that you might want to + * hand over to the next instance. This hook lets you do that. + * + * @author Kohsuke Kawaguchi + * @since 1.406 + */ +public interface ReconfigurableDescribable> extends Describable { + + /** + * When a parent/owner object of a Describable gets a config form submission and instances are + * recreated, this method is invoked on the existing instance (meaning the 'this' reference + * points to the existing instance) to create a new instance to be added to the parent/owner object. + * + *

+ * The default implementation of this should be the following: + *

+     * return form==null ? null : getDescriptor().newInstance(req, form);
+     * 
+ * + * @param req + * The current HTTP request being processed. + * @param form + * JSON fragment that corresponds to this describable object. + * If the newly submitted form doesn't include a fragment for this describable + * (meaning the user has de-selected your descriptor), then this argument is null. + * + * @return + * The new instance. To not to create an instance of a describable, return null. + */ + T reconfigure(StaplerRequest req, JSONObject form) throws FormException; +} diff --git a/core/src/main/java/hudson/model/ViewProperty.java b/core/src/main/java/hudson/model/ViewProperty.java index 2c576a652e..4820d3affc 100644 --- a/core/src/main/java/hudson/model/ViewProperty.java +++ b/core/src/main/java/hudson/model/ViewProperty.java @@ -50,7 +50,7 @@ import java.util.List; * @author Stephen Connolly * @since 1.406 */ -public class ViewProperty implements Describable, ExtensionPoint { +public class ViewProperty implements ReconfigurableDescribable, ExtensionPoint { /** * The view object that owns this property. * This value will be set by the core code. @@ -71,6 +71,6 @@ public class ViewProperty implements Describable, ExtensionPoint { } public ViewProperty reconfigure(StaplerRequest req, JSONObject form) throws Descriptor.FormException { - return getDescriptor().newInstance(req, form); + return form==null ? null : getDescriptor().newInstance(req, form); } } diff --git a/core/src/main/java/hudson/util/DescribableList.java b/core/src/main/java/hudson/util/DescribableList.java index 52eecdd985..6e7c9270a6 100644 --- a/core/src/main/java/hudson/util/DescribableList.java +++ b/core/src/main/java/hudson/util/DescribableList.java @@ -36,8 +36,10 @@ import hudson.model.DependencyGraph; import hudson.model.Describable; import hudson.model.Descriptor; import hudson.model.Descriptor.FormException; +import hudson.model.ReconfigurableDescribable; import hudson.model.Saveable; import net.sf.json.JSONObject; +import org.apache.avalon.framework.configuration.Reconfigurable; import org.kohsuke.stapler.StaplerRequest; import java.io.IOException; @@ -141,11 +143,23 @@ public class DescribableList, D extends Descriptor> List newList = new ArrayList(); for (Descriptor d : descriptors) { + T existing = get((D)d); String name = d.getJsonSafeClassName(); - if (json.has(name)) { - T instance = d.newInstance(req, json.getJSONObject(name)); - newList.add(instance); + JSONObject o = json.optJSONObject(name); + + T instance = null; + if (o!=null) { + if (existing instanceof ReconfigurableDescribable) + instance = (T)((ReconfigurableDescribable)existing).reconfigure(req,o); + else + instance = d.newInstance(req, o); + } else { + if (existing instanceof ReconfigurableDescribable) + instance = (T)((ReconfigurableDescribable)existing).reconfigure(req,null); } + + if (instance!=null) + newList.add(instance); } replaceBy(newList); From a66959d76db62f06c65ee0e5d66a398a5ca5787f Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 31 Mar 2011 16:15:25 -0700 Subject: [PATCH 003/221] degrade to rowSet, which works nicely with descriptorList --- .../resources/lib/form/optionalBlock.jelly | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/core/src/main/resources/lib/form/optionalBlock.jelly b/core/src/main/resources/lib/form/optionalBlock.jelly index 5602254766..37039e0e2a 100644 --- a/core/src/main/resources/lib/form/optionalBlock.jelly +++ b/core/src/main/resources/lib/form/optionalBlock.jelly @@ -35,6 +35,10 @@ THE SOFTWARE. Human readable text that follows the checkbox. + + If this field is null, the checkbox degrades to a <f:rowSet>, which provides + a grouping at JSON level but on the UI there's no checkbox (and you always see + the body of it.) Used for databinding. TBD. Either this or @name/@title combo is required. @@ -59,21 +63,31 @@ THE SOFTWARE. value="${descriptor.getHelpFile(attrs.field)}" /> - - - - - - - Help for feature: ${title} - - - - - - - - - + + + + + + + + + Help for feature: ${title} + + + + + + + + + + + + + + + + + \ No newline at end of file From ebd6981dd1dfbfec1dbb795f742b7da9dae12373 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 31 Mar 2011 16:27:42 -0700 Subject: [PATCH 004/221] This concept is unique to View, so I think it's fair to implement this by default --- core/src/main/java/hudson/model/ViewPropertyDescriptor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/model/ViewPropertyDescriptor.java b/core/src/main/java/hudson/model/ViewPropertyDescriptor.java index f073050f57..da0e0bbb51 100644 --- a/core/src/main/java/hudson/model/ViewPropertyDescriptor.java +++ b/core/src/main/java/hudson/model/ViewPropertyDescriptor.java @@ -53,7 +53,9 @@ public abstract class ViewPropertyDescriptor extends Descriptor { * @return null * if the implementation choose not to add any property object for such view. */ - public abstract ViewProperty newInstance(View view); + public ViewProperty newInstance(View view) { + return null; + } /** * Whether or not the described property is enabled in the current context. From 982be4783c2d151ae9e3c186ab254229239588fc Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 31 Mar 2011 16:45:33 -0700 Subject: [PATCH 005/221] added a convenience method --- test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index d44b8635a6..e5a7a7aeed 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -787,6 +787,11 @@ public abstract class HudsonTestCase extends TestCase implements RootAction { return (C)computerConnectorTester.connector; } + protected V configRoundtrip(V view) throws Exception { + submit(createWebClient().getPage(view, "configure").getFormByName("viewConfig")); + return view; + } + /** * Asserts that the outcome of the build is a specific outcome. From 2b5c2cc6dfa7b4076302c9a4126bf460cebeb795 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 31 Mar 2011 17:02:26 -0700 Subject: [PATCH 006/221] Use CSS to create space instead of nbsp --- core/src/main/resources/lib/form/checkbox.jelly | 5 +---- core/src/main/resources/lib/form/radioBlock.jelly | 1 - core/src/main/resources/lib/hudson/newFromList/form.jelly | 2 -- war/src/main/webapp/css/style.css | 4 ++++ 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/core/src/main/resources/lib/form/checkbox.jelly b/core/src/main/resources/lib/form/checkbox.jelly index c587791405..2b6e2f6e0b 100644 --- a/core/src/main/resources/lib/form/checkbox.jelly +++ b/core/src/main/resources/lib/form/checkbox.jelly @@ -59,9 +59,6 @@ THE SOFTWARE. checkUrl="${attrs.checkUrl}" json="${attrs.json}" checked="${(attrs.checked ?: instance[attrs.field] ?: attrs.default) ? 'true' : null}"/> - + \ No newline at end of file diff --git a/core/src/main/resources/lib/form/radioBlock.jelly b/core/src/main/resources/lib/form/radioBlock.jelly index 2d59dc32ec..e042ffafe5 100644 --- a/core/src/main/resources/lib/form/radioBlock.jelly +++ b/core/src/main/resources/lib/form/radioBlock.jelly @@ -52,7 +52,6 @@ THE SOFTWARE. - diff --git a/core/src/main/resources/lib/hudson/newFromList/form.jelly b/core/src/main/resources/lib/hudson/newFromList/form.jelly index 1598e08341..387d6a3a2a 100644 --- a/core/src/main/resources/lib/hudson/newFromList/form.jelly +++ b/core/src/main/resources/lib/hudson/newFromList/form.jelly @@ -45,7 +45,6 @@ THE SOFTWARE. - @@ -56,7 +55,6 @@ THE SOFTWARE. - diff --git a/war/src/main/webapp/css/style.css b/war/src/main/webapp/css/style.css index 0fb7965faf..39f9673140 100644 --- a/war/src/main/webapp/css/style.css +++ b/war/src/main/webapp/css/style.css @@ -456,6 +456,10 @@ div.behavior-loading { filter: alpha(opacity=50); } +LABEL.attach-previous { + margin-left: 0.5em; +} + /* ======================== error/warning message (mainly in the form.) Use them on block elements ======================== */ .error { color: #CC0000; From 9905132fff6153050ea77b077b8542ea790fbc58 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 31 Mar 2011 17:02:41 -0700 Subject: [PATCH 007/221] Added a test case for ViewProperty --- .../java/hudson/model/ViewPropertyTest.java | 71 +++++++++++++++++++ .../ViewPropertyImpl/config.jelly | 5 ++ 2 files changed, 76 insertions(+) create mode 100644 test/src/test/java/hudson/model/ViewPropertyTest.java create mode 100644 test/src/test/resources/hudson/model/ViewPropertyTest/ViewPropertyImpl/config.jelly diff --git a/test/src/test/java/hudson/model/ViewPropertyTest.java b/test/src/test/java/hudson/model/ViewPropertyTest.java new file mode 100644 index 0000000000..db682a8a0c --- /dev/null +++ b/test/src/test/java/hudson/model/ViewPropertyTest.java @@ -0,0 +1,71 @@ +/* + * The MIT License + * + * Copyright (c) 2011, CloudBees, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package hudson.model; + +import com.gargoylesoftware.htmlunit.html.HtmlForm; +import com.gargoylesoftware.htmlunit.html.HtmlLabel; +import org.jvnet.hudson.test.HudsonTestCase; +import org.jvnet.hudson.test.TestExtension; +import org.kohsuke.stapler.DataBoundConstructor; + +/** + * @author Kohsuke Kawaguchi + */ +public class ViewPropertyTest extends HudsonTestCase { + public void testRoundtrip() throws Exception { + ListView foo = new ListView("foo"); + hudson.addView(foo); + + // make sure it renders as optionalBlock + HtmlForm f = createWebClient().getPage(foo, "configure").getFormByName("viewConfig"); + ((HtmlLabel)f.selectSingleNode(".//LABEL[text()='Debug Property']")).click(); + submit(f); + ViewPropertyImpl vp = foo.getProperties().get(ViewPropertyImpl.class); + assertEquals("Duke",vp.name); + + // make sure it roundtrips correctly + vp.name = "Kohsuke"; + configRoundtrip(foo); + ViewPropertyImpl vp2 = foo.getProperties().get(ViewPropertyImpl.class); + assertNotSame(vp,vp2); + assertEqualDataBoundBeans(vp,vp2); + } + + public static class ViewPropertyImpl extends ViewProperty { + public String name; + + @DataBoundConstructor + public ViewPropertyImpl(String name) { + this.name = name; + } + + @TestExtension + public static class DescriptorImpl extends ViewPropertyDescriptor { + @Override + public String getDisplayName() { + return "Debug Property"; + } + } + } +} diff --git a/test/src/test/resources/hudson/model/ViewPropertyTest/ViewPropertyImpl/config.jelly b/test/src/test/resources/hudson/model/ViewPropertyTest/ViewPropertyImpl/config.jelly new file mode 100644 index 0000000000..777a376b64 --- /dev/null +++ b/test/src/test/resources/hudson/model/ViewPropertyTest/ViewPropertyImpl/config.jelly @@ -0,0 +1,5 @@ + + + + + From 8fcb00f2dd71fd0dcaace1cdcbd8c1fdb9376dbd Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 31 Mar 2011 17:08:55 -0700 Subject: [PATCH 008/221] added a test case for invisible ViewProperty --- .../java/hudson/model/ViewPropertyTest.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/src/test/java/hudson/model/ViewPropertyTest.java b/test/src/test/java/hudson/model/ViewPropertyTest.java index db682a8a0c..cb04bf277a 100644 --- a/test/src/test/java/hudson/model/ViewPropertyTest.java +++ b/test/src/test/java/hudson/model/ViewPropertyTest.java @@ -25,9 +25,12 @@ package hudson.model; import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlLabel; +import hudson.model.Descriptor.FormException; +import net.sf.json.JSONObject; import org.jvnet.hudson.test.HudsonTestCase; import org.jvnet.hudson.test.TestExtension; import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.StaplerRequest; /** * @author Kohsuke Kawaguchi @@ -68,4 +71,37 @@ public class ViewPropertyTest extends HudsonTestCase { } } } + + public void testInvisibleProperty() throws Exception { + ListView foo = new ListView("foo"); + hudson.addView(foo); + + // test the rendering (or the lack thereof) of an invisible property + configRoundtrip(foo); + assertNull(foo.getProperties().get(InvisiblePropertyImpl.class)); + + // do the same but now with a configured instance + InvisiblePropertyImpl vp = new InvisiblePropertyImpl(); + foo.getProperties().add(vp); + configRoundtrip(foo); + assertSame(vp,foo.getProperties().get(InvisiblePropertyImpl.class)); + } + + public static class InvisiblePropertyImpl extends ViewProperty { + InvisiblePropertyImpl() { + } + + @Override + public ViewProperty reconfigure(StaplerRequest req, JSONObject form) throws FormException { + return this; + } + + @TestExtension + public static class DescriptorImpl extends ViewPropertyDescriptor { + @Override + public String getDisplayName() { + return null; + } + } + } } From 5e3c88727e39416edf883f8697a3d034339fc3fe Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 31 Mar 2011 17:24:06 -0700 Subject: [PATCH 009/221] noting legacy stuff --- core/src/main/java/hudson/model/Job.java | 1 + core/src/main/resources/hudson/model/Job/configure.jelly | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index 8991cf7c25..5c1a9aa012 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -139,6 +139,7 @@ public abstract class Job, RunT extends Run> properties = new CopyOnWriteList>(); protected Job(ItemGroup parent, String name) { diff --git a/core/src/main/resources/hudson/model/Job/configure.jelly b/core/src/main/resources/hudson/model/Job/configure.jelly index 5b28d467c0..cdef885d32 100644 --- a/core/src/main/resources/hudson/model/Job/configure.jelly +++ b/core/src/main/resources/hudson/model/Job/configure.jelly @@ -52,7 +52,7 @@ THE SOFTWARE. - + From e6b90c74f3ae2afaa9cf711c66e79dfd8067be75 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 31 Mar 2011 18:18:38 -0700 Subject: [PATCH 010/221] - modified to use for better reuse&consistency. - support invisible JobProperty --- core/src/main/java/hudson/model/Job.java | 22 ++++++++----------- .../main/java/hudson/model/JobProperty.java | 9 +++++++- .../hudson/model/Job/configure.jelly | 12 +--------- .../resources/lib/form/descriptorList.jelly | 5 ++++- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index 5c1a9aa012..2a02712d6a 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -26,6 +26,7 @@ package hudson.model; import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST; import static javax.servlet.http.HttpServletResponse.SC_NO_CONTENT; +import com.google.common.collect.Iterables; import com.infradna.tool.bridge_method_injector.WithBridgeMethods; import hudson.ExtensionPoint; import hudson.PermalinkList; @@ -46,6 +47,7 @@ import hudson.util.ChartUtil; import hudson.util.ColorPalette; import hudson.util.CopyOnWriteList; import hudson.util.DataSetBuilder; +import hudson.util.DescribableList; import hudson.util.IOException2; import hudson.util.RunList; import hudson.util.ShiftedCategoryAxis; @@ -936,25 +938,19 @@ public abstract class Job, RunT extends Run, JobPropertyDescriptor> t = new DescribableList, JobPropertyDescriptor>(NOOP,getAllProperties()); + t.rebuild(req,json.optJSONObject("properties"),JobPropertyDescriptor.getPropertyDescriptors(Job.this.getClass())); + properties.clear(); + for (JobProperty p : t) { + p.setOwner(this); + properties.add(p); } submit(req, rsp); diff --git a/core/src/main/java/hudson/model/JobProperty.java b/core/src/main/java/hudson/model/JobProperty.java index 3d0292315f..f22835ce51 100644 --- a/core/src/main/java/hudson/model/JobProperty.java +++ b/core/src/main/java/hudson/model/JobProperty.java @@ -26,6 +26,7 @@ package hudson.model; import hudson.ExtensionPoint; import hudson.Launcher; import hudson.Plugin; +import hudson.model.Descriptor.FormException; import hudson.model.queue.SubTask; import hudson.tasks.BuildStep; import hudson.tasks.Builder; @@ -36,6 +37,8 @@ import java.io.IOException; import java.util.Collection; import java.util.Collections; +import net.sf.json.JSONObject; +import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.export.ExportedBean; /** @@ -69,7 +72,7 @@ import org.kohsuke.stapler.export.ExportedBean; * @since 1.72 */ @ExportedBean -public abstract class JobProperty> implements Describable>, BuildStep, ExtensionPoint { +public abstract class JobProperty> implements ReconfigurableDescribable>, BuildStep, ExtensionPoint { /** * The {@link Job} object that owns this property. * This value will be set by the Hudson code. @@ -169,6 +172,10 @@ public abstract class JobProperty> implements Describable reconfigure(StaplerRequest req, JSONObject form) throws FormException { + return form==null ? null : getDescriptor().newInstance(req,form); + } + /** * Contributes {@link SubTask}s to {@link AbstractProject#getSubTasks()} * diff --git a/core/src/main/resources/hudson/model/Job/configure.jelly b/core/src/main/resources/hudson/model/Job/configure.jelly index cdef885d32..67d67d77a3 100644 --- a/core/src/main/resources/hudson/model/Job/configure.jelly +++ b/core/src/main/resources/hudson/model/Job/configure.jelly @@ -53,17 +53,7 @@ THE SOFTWARE. - - - - - - - - - - - + diff --git a/core/src/main/resources/lib/form/descriptorList.jelly b/core/src/main/resources/lib/form/descriptorList.jelly index 5edae295bd..3a3d1b7457 100644 --- a/core/src/main/resources/lib/form/descriptorList.jelly +++ b/core/src/main/resources/lib/form/descriptorList.jelly @@ -50,6 +50,9 @@ THE SOFTWARE. the type for which descriptors will be configured. default to ${it.class} + + If specified, instead of a sequence of <f:optionalBlock>s, draw a sequence of <rowSet>s. + @@ -73,7 +76,7 @@ THE SOFTWARE. + title="${attrs.forceRowSet!=null?null:d.displayName}" checked="${instances.get(d)!=null}"> From ea0295b5096a3cc76297e7d7030b54d44f3dc472 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Thu, 31 Mar 2011 18:19:13 -0700 Subject: [PATCH 011/221] added test cases --- .../java/hudson/model/JobPropertyTest.java | 75 ++++++++++++++++--- .../JobPropertyWithConfigImpl/config.jelly | 5 ++ 2 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 test/src/test/resources/hudson/model/JobPropertyTest/JobPropertyWithConfigImpl/config.jelly diff --git a/test/src/test/java/hudson/model/JobPropertyTest.java b/test/src/test/java/hudson/model/JobPropertyTest.java index 3d76df4502..9e8db1df75 100644 --- a/test/src/test/java/hudson/model/JobPropertyTest.java +++ b/test/src/test/java/hudson/model/JobPropertyTest.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt + * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt, CloudBees, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -27,13 +27,20 @@ import com.gargoylesoftware.htmlunit.WebAssert; import com.gargoylesoftware.htmlunit.html.HtmlPage; import hudson.matrix.MatrixProject; import hudson.maven.MavenModuleSet; +import hudson.model.Descriptor.FormException; +import net.sf.json.JSONObject; +import org.jvnet.hudson.test.Bug; import org.jvnet.hudson.test.HudsonTestCase; +import org.jvnet.hudson.test.TestExtension; +import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.StaplerRequest; public class JobPropertyTest extends HudsonTestCase { /** * Asserts that rfe#2398 is fixed. */ + @Bug(2398) public void testJobPropertySummaryIsShownInMavenModuleSetIndexPage() throws Exception { assertJobPropertySummaryIsShownInIndexPage(MavenModuleSet.DESCRIPTOR); } @@ -54,7 +61,6 @@ public class JobPropertyTest extends HudsonTestCase { } public static class JobPropertyImpl extends JobProperty> { - public static DescriptorImpl DESCRIPTOR = new DescriptorImpl(); private final String propertyString; public JobPropertyImpl(String propertyString) { this.propertyString = propertyString; @@ -64,13 +70,8 @@ public class JobPropertyTest extends HudsonTestCase { return propertyString; } - @Override - public JobPropertyDescriptor getDescriptor() { - return DESCRIPTOR; - } - - @SuppressWarnings("unchecked") - private static class DescriptorImpl extends JobPropertyDescriptor { + @TestExtension + public static class DescriptorImpl extends JobPropertyDescriptor { @Override public boolean isApplicable(Class jobType) { return false; @@ -82,4 +83,60 @@ public class JobPropertyTest extends HudsonTestCase { } } } + + /** + * Make sure that the UI rendering works as designed. + */ + public void testConfigRoundtrip() throws Exception { + FreeStyleProject p = createFreeStyleProject(); + JobPropertyWithConfigImpl before = new JobPropertyWithConfigImpl("Duke"); + p.addProperty(before); + configRoundtrip(p); + JobPropertyWithConfigImpl after = p.getProperty(JobPropertyWithConfigImpl.class); + assertNotSame(after,before); + assertEqualDataBoundBeans(before, after); + } + + public static class JobPropertyWithConfigImpl extends JobProperty> { + public String name; + + @DataBoundConstructor + public JobPropertyWithConfigImpl(String name) { + this.name = name; + } + + @TestExtension("testConfigRoundtrip") + public static class DescriptorImpl extends JobPropertyDescriptor { + @Override + public String getDisplayName() { return null; } + } + } + + + + public void testInvisibleProperty() throws Exception { + FreeStyleProject p = createFreeStyleProject(); + InvisibleImpl before = new InvisibleImpl(); + p.addProperty(before); + configRoundtrip(p); + InvisibleImpl after = p.getProperty(InvisibleImpl.class); + assertSame(after,before); + } + + public static class InvisibleImpl extends JobProperty> { + public String name; + + InvisibleImpl() {} + + @Override + public JobProperty reconfigure(StaplerRequest req, JSONObject form) throws FormException { + return this; + } + + @TestExtension("testInvisibleProperty") + public static class DescriptorImpl extends JobPropertyDescriptor { + @Override + public String getDisplayName() { return null; } + } + } } diff --git a/test/src/test/resources/hudson/model/JobPropertyTest/JobPropertyWithConfigImpl/config.jelly b/test/src/test/resources/hudson/model/JobPropertyTest/JobPropertyWithConfigImpl/config.jelly new file mode 100644 index 0000000000..8dc663c544 --- /dev/null +++ b/test/src/test/resources/hudson/model/JobPropertyTest/JobPropertyWithConfigImpl/config.jelly @@ -0,0 +1,5 @@ + + + + + From f2ebd01bbdb1c4c965fc15345ffa89b7264f6872 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 1 Apr 2011 09:51:52 -0700 Subject: [PATCH 012/221] Node now supports ReconfigurableDescribable --- core/src/main/java/hudson/model/Computer.java | 2 +- core/src/main/java/hudson/model/Node.java | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/hudson/model/Computer.java b/core/src/main/java/hudson/model/Computer.java index e37f696f3e..59bf7f476f 100644 --- a/core/src/main/java/hudson/model/Computer.java +++ b/core/src/main/java/hudson/model/Computer.java @@ -1029,7 +1029,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces final Hudson app = Hudson.getInstance(); - Node result = getNode().getDescriptor().newInstance(req, req.getSubmittedForm()); + Node result = getNode().reconfigure(req, req.getSubmittedForm()); // replace the old Node object by the new one synchronized (app) { diff --git a/core/src/main/java/hudson/model/Node.java b/core/src/main/java/hudson/model/Node.java index a0546893f8..c79d336907 100644 --- a/core/src/main/java/hudson/model/Node.java +++ b/core/src/main/java/hudson/model/Node.java @@ -30,6 +30,7 @@ import hudson.ExtensionPoint; import hudson.FilePath; import hudson.FileSystemProvisioner; import hudson.Launcher; +import hudson.model.Descriptor.FormException; import hudson.model.Queue.Task; import hudson.model.labels.LabelAtom; import hudson.model.queue.CauseOfBlockage; @@ -56,7 +57,9 @@ import java.util.Set; import java.util.List; import java.util.logging.Logger; +import net.sf.json.JSONObject; import org.kohsuke.stapler.Stapler; +import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.export.ExportedBean; import org.kohsuke.stapler.export.Exported; @@ -71,7 +74,7 @@ import org.kohsuke.stapler.export.Exported; * @see NodeDescriptor */ @ExportedBean -public abstract class Node extends AbstractModelObject implements Describable, ExtensionPoint, AccessControlled { +public abstract class Node extends AbstractModelObject implements ReconfigurableDescribable, ExtensionPoint, AccessControlled { private static final Logger LOGGER = Logger.getLogger(Node.class.getName()); @@ -362,6 +365,10 @@ public abstract class Node extends AbstractModelObject implements Describable Date: Fri, 1 Apr 2011 14:22:41 -0700 Subject: [PATCH 013/221] added a convenience method --- .../java/org/jvnet/hudson/test/HudsonTestCase.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index e5a7a7aeed..711d291313 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -787,6 +787,16 @@ public abstract class HudsonTestCase extends TestCase implements RootAction { return (C)computerConnectorTester.connector; } + protected User configRoundtrip(User u) throws Exception { + submit(createWebClient().goTo(u.getUrl()+"/configure").getFormByName("config")); + return u; + } + + protected N configRoundtrip(N node) throws Exception { + submit(createWebClient().goTo("/computer/"+node.getNodeName()+"/configure").getFormByName("config")); + return (N)hudson.getNode(node.getNodeName()); + } + protected V configRoundtrip(V view) throws Exception { submit(createWebClient().getPage(view, "configure").getFormByName("viewConfig")); return view; From 88ea8de45f5d6ae846d64d7cad9b8432fb111357 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 1 Apr 2011 14:25:46 -0700 Subject: [PATCH 014/221] added a mechanism for creating invisible node properties --- core/pom.xml | 2 +- core/src/main/java/hudson/model/Node.java | 30 ++++++- .../main/java/hudson/slaves/NodeProperty.java | 10 ++- .../java/hudson/slaves/NodePropertyTest.java | 81 +++++++++++++++++++ .../PropertyImpl/config.jelly | 5 ++ 5 files changed, 124 insertions(+), 4 deletions(-) create mode 100644 test/src/test/java/hudson/slaves/NodePropertyTest.java create mode 100644 test/src/test/resources/hudson/slaves/NodePropertyTest/PropertyImpl/config.jelly diff --git a/core/pom.xml b/core/pom.xml index f8b3788390..a8ce5808ca 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -382,7 +382,7 @@ THE SOFTWARE. org.kohsuke.stapler stapler-jelly - 1.155 + 1.161 commons-jelly diff --git a/core/src/main/java/hudson/model/Node.java b/core/src/main/java/hudson/model/Node.java index c79d336907..4d75381c96 100644 --- a/core/src/main/java/hudson/model/Node.java +++ b/core/src/main/java/hudson/model/Node.java @@ -51,6 +51,7 @@ import hudson.util.TagCloud; import hudson.util.TagCloud.WeightFunction; import java.io.IOException; +import java.lang.reflect.Type; import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -58,6 +59,7 @@ import java.util.List; import java.util.logging.Logger; import net.sf.json.JSONObject; +import org.kohsuke.stapler.BindInterceptor; import org.kohsuke.stapler.Stapler; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.export.ExportedBean; @@ -365,8 +367,32 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable return getACL().hasPermission(permission); } - public Node reconfigure(StaplerRequest req, JSONObject form) throws FormException { - return form==null ? null : getDescriptor().newInstance(req, form); + public Node reconfigure(final StaplerRequest req, JSONObject form) throws FormException { + if (form==null) return null; + + final JSONObject jsonForProperties = form.optJSONObject("nodeProperties"); + BindInterceptor old = req.setBindListener(new BindInterceptor() { + @Override + public Object onConvert(Type targetType, Class targetTypeErasure, Object jsonSource) { + if (jsonForProperties!=jsonSource) return DEFAULT; + + try { + DescribableList, NodePropertyDescriptor> tmp = new DescribableList, 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); + } } public abstract NodeDescriptor getDescriptor(); diff --git a/core/src/main/java/hudson/slaves/NodeProperty.java b/core/src/main/java/hudson/slaves/NodeProperty.java index 1319238887..59322ea832 100644 --- a/core/src/main/java/hudson/slaves/NodeProperty.java +++ b/core/src/main/java/hudson/slaves/NodeProperty.java @@ -26,6 +26,8 @@ package hudson.slaves; import hudson.ExtensionPoint; import hudson.Launcher; import hudson.DescriptorExtensionList; +import hudson.model.Descriptor.FormException; +import hudson.model.ReconfigurableDescribable; import hudson.model.queue.CauseOfBlockage; import hudson.scm.SCM; import hudson.model.AbstractBuild; @@ -35,6 +37,8 @@ import hudson.model.Environment; import hudson.model.Hudson; import hudson.model.Node; import hudson.model.Queue.Task; +import net.sf.json.JSONObject; +import org.kohsuke.stapler.StaplerRequest; import java.io.IOException; import java.util.List; @@ -63,7 +67,7 @@ import java.util.List; * * @since 1.286 */ -public abstract class NodeProperty implements Describable>, ExtensionPoint { +public abstract class NodeProperty implements ReconfigurableDescribable>, ExtensionPoint { protected transient N node; @@ -109,6 +113,10 @@ public abstract class NodeProperty implements Describable reconfigure(StaplerRequest req, JSONObject form) throws FormException { + return form==null ? null : getDescriptor().newInstance(req, form); + } + /** * Lists up all the registered {@link NodeDescriptor}s in the system. */ diff --git a/test/src/test/java/hudson/slaves/NodePropertyTest.java b/test/src/test/java/hudson/slaves/NodePropertyTest.java new file mode 100644 index 0000000000..b8be591998 --- /dev/null +++ b/test/src/test/java/hudson/slaves/NodePropertyTest.java @@ -0,0 +1,81 @@ +package hudson.slaves; + +import com.gargoylesoftware.htmlunit.html.HtmlForm; +import com.gargoylesoftware.htmlunit.html.HtmlLabel; +import hudson.model.Descriptor.FormException; +import hudson.model.Slave; +import net.sf.json.JSONObject; +import org.jvnet.hudson.test.HudsonTestCase; +import org.jvnet.hudson.test.TestExtension; +import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.StaplerRequest; + +/** + * @author Kohsuke Kawaguchi + */ +public class NodePropertyTest extends HudsonTestCase { + public void testInvisibleProperty() throws Exception { + DumbSlave s = createSlave(); + InvisibleProperty before = new InvisibleProperty(); + s.getNodeProperties().add(before); + assertFalse(before.reconfigured); + + + DumbSlave s2 = configRoundtrip(s); + assertNotSame(s,s2); + InvisibleProperty after = s2.getNodeProperties().get(InvisibleProperty.class); + + assertSame(before,after); + assertTrue(after.reconfigured); + } + + public static class InvisibleProperty extends NodeProperty { + boolean reconfigured = false; + @Override + public NodeProperty reconfigure(StaplerRequest req, JSONObject form) throws FormException { + reconfigured = true; + return this; + } + + @TestExtension + public static class DescriptorImpl extends NodePropertyDescriptor { + @Override + public String getDisplayName() { + return null; + } + } + } + + public void testBasicConfigRoundtrip() throws Exception { + DumbSlave s = createSlave(); + HtmlForm f = createWebClient().goTo("/computer/" + s.getNodeName() + "/configure").getFormByName("config"); + ((HtmlLabel)f.selectSingleNode(".//LABEL[text()='Some Property']")).click(); + submit(f); + PropertyImpl p = hudson.getNode(s.getNodeName()).getNodeProperties().get(PropertyImpl.class); + assertEquals("Duke",p.name); + + p.name = "Kohsuke"; + configRoundtrip(s); + + PropertyImpl p2 = hudson.getNode(s.getNodeName()).getNodeProperties().get(PropertyImpl.class); + assertNotSame(p,p2); + assertEqualDataBoundBeans(p,p2); + } + + public static class PropertyImpl extends NodeProperty { + public String name; + + @DataBoundConstructor + public PropertyImpl(String name) { + this.name = name; + } + + @TestExtension("testBasicConfigRoundtrip") + public static class DescriptorImpl extends NodePropertyDescriptor { + @Override + public String getDisplayName() { + return "Some Property"; + } + } + } +} diff --git a/test/src/test/resources/hudson/slaves/NodePropertyTest/PropertyImpl/config.jelly b/test/src/test/resources/hudson/slaves/NodePropertyTest/PropertyImpl/config.jelly new file mode 100644 index 0000000000..4bcbab93c4 --- /dev/null +++ b/test/src/test/resources/hudson/slaves/NodePropertyTest/PropertyImpl/config.jelly @@ -0,0 +1,5 @@ + + + + + From 36cfac2fdd63828b29d98d47aeda2dacab9a0f99 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 1 Apr 2011 15:06:48 -0700 Subject: [PATCH 015/221] recording changes in ad343a68075e64ee91bf66d84a8dea727f60bf84 --- changelog.html | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog.html b/changelog.html index 086f4e6f3c..af19d42f47 100644 --- a/changelog.html +++ b/changelog.html @@ -67,6 +67,10 @@ Upcoming changes Added an extension point to allow associating custom properties with views.
  • Actions can now override their rendering in the parent model object. +
  • + Added a mechanism for plugins to write an invisible job property +
  • + Added a mechanism for plugins to write an invisible node property From 2960207cb89687d8a69061f17d73b86eba1df278 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 1 Apr 2011 15:13:56 -0700 Subject: [PATCH 016/221] needs to have @title due to f8e136ed4902d6c625fa4a7b9bfc7c99cfbb46c8 --- .../lib/form/AdvancedButtonTest/testNestedOptionalBlock.jelly | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src/test/resources/lib/form/AdvancedButtonTest/testNestedOptionalBlock.jelly b/test/src/test/resources/lib/form/AdvancedButtonTest/testNestedOptionalBlock.jelly index 227cfd1504..14179ade02 100644 --- a/test/src/test/resources/lib/form/AdvancedButtonTest/testNestedOptionalBlock.jelly +++ b/test/src/test/resources/lib/form/AdvancedButtonTest/testNestedOptionalBlock.jelly @@ -36,7 +36,7 @@ THE SOFTWARE. - + From 2ae9e56b8d93b508c704a3eea2390e0a0c173377 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Fri, 1 Apr 2011 15:23:59 -0700 Subject: [PATCH 017/221] crap, merge error --- core/src/main/java/hudson/model/Node.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/model/Node.java b/core/src/main/java/hudson/model/Node.java index 4d75381c96..9d4f7f9d4d 100644 --- a/core/src/main/java/hudson/model/Node.java +++ b/core/src/main/java/hudson/model/Node.java @@ -367,7 +367,7 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable return getACL().hasPermission(permission); } - public Node reconfigure(final StaplerRequest req, JSONObject form) throws FormException { + public Node reconfigure(StaplerRequest req, JSONObject form) throws FormException { if (form==null) return null; final JSONObject jsonForProperties = form.optJSONObject("nodeProperties"); From 2b7ebb54375c73b35e091769aa916a5627842396 Mon Sep 17 00:00:00 2001 From: Seiji Sogabe Date: Sat, 2 Apr 2011 08:14:01 +0900 Subject: [PATCH 018/221] fix compilation error. --- core/src/main/java/hudson/model/Node.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/model/Node.java b/core/src/main/java/hudson/model/Node.java index 9d4f7f9d4d..4d75381c96 100644 --- a/core/src/main/java/hudson/model/Node.java +++ b/core/src/main/java/hudson/model/Node.java @@ -367,7 +367,7 @@ public abstract class Node extends AbstractModelObject implements Reconfigurable return getACL().hasPermission(permission); } - public Node reconfigure(StaplerRequest req, JSONObject form) throws FormException { + public Node reconfigure(final StaplerRequest req, JSONObject form) throws FormException { if (form==null) return null; final JSONObject jsonForProperties = form.optJSONObject("nodeProperties"); From 642632d16bc8c682d9e5fd9abd3eb68300aa7891 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Tue, 5 Apr 2011 10:20:44 +0200 Subject: [PATCH 019/221] Use LinkedBlockingQueue to support unbounded requests. Previously this was limited to the max thread pool size (of ten). --- .../java/org/jvnet/hudson/test/HudsonTestCase.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index 0e540ec85e..b264e53c16 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -128,14 +128,7 @@ import java.util.List; import java.util.Locale; import java.util.Set; import java.util.UUID; -import java.util.concurrent.Callable; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.SynchronousQueue; -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; import java.util.jar.Manifest; import java.util.logging.Filter; import java.util.logging.Level; @@ -447,7 +440,8 @@ public abstract class HudsonTestCase extends TestCase implements RootAction { context.setMimeTypes(MIME_TYPES); SocketConnector connector = new SocketConnector(); - server.setThreadPool(new ThreadPoolImpl(new ThreadPoolExecutor(1, 10, 10L, TimeUnit.SECONDS, new SynchronousQueue(),new ThreadFactory() { + + server.setThreadPool(new ThreadPoolImpl(new ThreadPoolExecutor(10, 10, 10L, TimeUnit.SECONDS, new LinkedBlockingQueue(),new ThreadFactory() { public Thread newThread(Runnable r) { Thread t = new Thread(r); t.setName("Jetty Thread Pool"); From 9ff7bffdb0566f3e5c6302c911579fdb2cdf21b0 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 11 Apr 2011 14:19:31 -0700 Subject: [PATCH 020/221] Jenkins! --- core/src/main/java/hudson/init/Initializer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/hudson/init/Initializer.java b/core/src/main/java/hudson/init/Initializer.java index 5d5bea4526..d693314b7c 100644 --- a/core/src/main/java/hudson/init/Initializer.java +++ b/core/src/main/java/hudson/init/Initializer.java @@ -36,7 +36,7 @@ import static hudson.init.InitMilestone.STARTED; import static hudson.init.InitMilestone.COMPLETED; /** - * Placed on static methods to indicate that this method is to be run during the Hudson start up to perform + * Placed on static methods to indicate that this method is to be run during the Jenkins start up to perform * some sort of initialization tasks. * *

    Example

    From 3d5b33e4191cfefe301d7774e9c5b1ab40ffddd4 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Mon, 11 Apr 2011 22:30:08 -0700 Subject: [PATCH 021/221] added Jelly PI after manual inspection --- core/src/main/resources/lib/foo.jelly | 1 + core/src/main/resources/lib/hudson/artifactList.jelly | 4 +++- core/src/main/resources/lib/hudson/buildHealth.jelly | 1 + core/src/main/resources/lib/hudson/buildLink.jelly | 1 + core/src/main/resources/lib/hudson/buildListTable.jelly | 1 + core/src/main/resources/lib/hudson/buildStatusSummary.jelly | 5 +++-- core/src/main/resources/lib/hudson/iconSize.jelly | 1 + core/src/main/resources/lib/hudson/jobLink.jelly | 1 + core/src/main/resources/lib/hudson/newFromList/form.jelly | 1 + core/src/main/resources/lib/hudson/node.jelly | 1 + core/src/main/resources/lib/hudson/progressiveText.jelly | 1 + .../main/resources/lib/hudson/project/build-permalink.jelly | 1 + core/src/main/resources/lib/hudson/project/matrix.jelly | 1 + .../resources/lib/hudson/project/upstream-downstream.jelly | 1 + core/src/main/resources/lib/hudson/projectViewNested.jelly | 1 + core/src/main/resources/lib/hudson/queue.jelly | 1 + core/src/main/resources/lib/hudson/test-result.jelly | 1 + core/src/main/resources/lib/layout/pane.jelly | 1 + core/src/main/resources/lib/layout/renderOnDemand.jelly | 1 + core/src/main/resources/lib/layout/tab.jelly | 1 + core/src/main/resources/lib/layout/task.jelly | 1 + core/src/main/resources/lib/test/bar.jelly | 1 + .../resources/hudson/maven/MavenBuild/executedMojos.jelly | 1 + .../hudson/maven/MavenModuleSet/configure-entries.jelly | 1 + .../resources/hudson/maven/MavenModuleSet/disabled.jelly | 1 + .../main/resources/hudson/maven/MavenModuleSet/index.jelly | 1 + .../resources/hudson/maven/MavenProbeAction/threads.jelly | 1 + .../maven/reporters/SurefireAggregatedReport/index.jelly | 1 + .../hudson/model/DownloadServiceTest/testPost.jelly | 1 + .../model/JobPropertyTest/JobPropertyImpl/summary.jelly | 1 + .../hudson/model/JobTest/JobPropertyImpl/summary.jelly | 1 + .../hudson/model/UserTestCase/UserPropertyImpl/summary.jelly | 1 + .../resources/hudson/tasks/test/TrivialTestResult/body.jelly | 1 + 33 files changed, 37 insertions(+), 3 deletions(-) diff --git a/core/src/main/resources/lib/foo.jelly b/core/src/main/resources/lib/foo.jelly index 211b7d2eca..cffa14e994 100644 --- a/core/src/main/resources/lib/foo.jelly +++ b/core/src/main/resources/lib/foo.jelly @@ -22,4 +22,5 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> + JELLY TAG FILE ${value} \ No newline at end of file diff --git a/core/src/main/resources/lib/hudson/artifactList.jelly b/core/src/main/resources/lib/hudson/artifactList.jelly index 745e07d6c7..cdd0f7a559 100644 --- a/core/src/main/resources/lib/hudson/artifactList.jelly +++ b/core/src/main/resources/lib/hudson/artifactList.jelly @@ -22,6 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --> + + Generates a listing of the build artifacts. @@ -48,7 +50,7 @@ THE SOFTWARE.