Skip to content
Permalink
Browse files
[FIXED JENKINS-10363] Override defaults in manage jenkins
  • Loading branch information
bap2000 committed Jul 21, 2011
1 parent 02b5bc5 commit 9e99dd12c0f9c404d628c60c73e01a235af50574
Showing with 1,262 additions and 29 deletions.
  1. +0 −8 src/main/java/jenkins/plugins/publish_over_ftp/BapFtpRetry.java
  2. +27 −2 src/main/java/jenkins/plugins/publish_over_ftp/descriptor/BapFtpPublisherPluginDescriptor.java
  3. +53 −0 src/main/java/jenkins/plugins/publish_over_ftp/options/FtpDefaults.java
  4. +42 −0 src/main/java/jenkins/plugins/publish_over_ftp/options/FtpOptions.java
  5. +125 −0 src/main/java/jenkins/plugins/publish_over_ftp/options/FtpOverrideDefaults.java
  6. +78 −0 src/main/java/jenkins/plugins/publish_over_ftp/options/FtpOverrideInstanceConfigDefaults.java
  7. +70 −0 src/main/java/jenkins/plugins/publish_over_ftp/options/FtpOverrideParamPublishDefaults.java
  8. +89 −0 src/main/java/jenkins/plugins/publish_over_ftp/options/FtpOverridePublisherDefaults.java
  9. +70 −0 src/main/java/jenkins/plugins/publish_over_ftp/options/FtpOverridePublisherLabelDefaults.java
  10. +86 −0 src/main/java/jenkins/plugins/publish_over_ftp/options/FtpOverrideRetryDefaults.java
  11. +113 −0 src/main/java/jenkins/plugins/publish_over_ftp/options/FtpOverrideTransferDefaults.java
  12. +88 −0 src/main/java/jenkins/plugins/publish_over_ftp/options/FtpPluginDefaults.java
  13. +44 −0 src/main/java/jenkins/plugins/publish_over_ftp/options/FtpPluginDefaultsHandler.java
  14. +33 −0 src/main/java/jenkins/plugins/publish_over_ftp/options/FtpTransferOptions.java
  15. +1 −1 src/main/resources/jenkins/plugins/publish_over_ftp/BapFtpParamPublish/config.jelly
  16. +4 −4 src/main/resources/jenkins/plugins/publish_over_ftp/BapFtpPublisher/config.jelly
  17. +1 −1 src/main/resources/jenkins/plugins/publish_over_ftp/BapFtpPublisherLabel/config.jelly
  18. +5 −3 src/main/resources/jenkins/plugins/publish_over_ftp/BapFtpPublisherPlugin/config.jelly
  19. +7 −0 src/main/resources/jenkins/plugins/publish_over_ftp/BapFtpPublisherPlugin/global.jelly
  20. +2 −2 src/main/resources/jenkins/plugins/publish_over_ftp/BapFtpRetry/config.jelly
  21. +8 −8 src/main/resources/jenkins/plugins/publish_over_ftp/BapFtpTransfer/config.jelly
  22. +38 −0 src/main/resources/jenkins/plugins/publish_over_ftp/options/FtpOverrideDefaults/config.jelly
  23. +41 −0 ...resources/jenkins/plugins/publish_over_ftp/options/FtpOverrideInstanceConfigDefaults/config.jelly
  24. +50 −0 ...main/resources/jenkins/plugins/publish_over_ftp/options/FtpOverridePublisherDefaults/config.jelly
  25. +25 −0 ...resources/jenkins/plugins/publish_over_ftp/options/FtpOverridePublisherDefaults/config.properties
  26. +25 −0 ...ces/jenkins/plugins/publish_over_ftp/options/FtpOverridePublisherDefaults/config_no_BV.properties
  27. +58 −0 src/main/resources/jenkins/plugins/publish_over_ftp/options/FtpOverrideTransferDefaults/config.jelly
  28. +25 −0 .../resources/jenkins/plugins/publish_over_ftp/options/FtpOverrideTransferDefaults/config.properties
  29. +25 −0 ...rces/jenkins/plugins/publish_over_ftp/options/FtpOverrideTransferDefaults/config_no_BV.properties
  30. +29 −0 src/main/resources/jenkins/plugins/publish_over_ftp/options/FtpPluginDefaults/config.jelly
@@ -73,14 +73,6 @@ public String getDisplayName() {
return Messages.retry_descriptor_displayName();
}

public int getDefaultRetries() {
return Retry.DEFAULT_RETRIES;
}

public long getDefaultRetryDelay() {
return Retry.DEFAULT_RETRY_DELAY;
}

public FormValidation doCheckRetries(@QueryParameter final String value) {
return FormValidation.validateNonNegativeInteger(value);
}
@@ -32,14 +32,16 @@
import hudson.tasks.Publisher;
import hudson.util.CopyOnWriteList;
import hudson.util.FormValidation;
import hudson.util.VersionNumber;
import jenkins.plugins.publish_over.BPBuildInfo;
import jenkins.plugins.publish_over.BPInstanceConfig;
import jenkins.plugins.publish_over.BPPlugin;
import jenkins.plugins.publish_over.BPPluginDescriptor;
import jenkins.plugins.publish_over.JenkinsCapabilities;
import jenkins.plugins.publish_over_ftp.BapFtpHostConfiguration;
import jenkins.plugins.publish_over_ftp.BapFtpPublisherPlugin;
import jenkins.plugins.publish_over_ftp.Messages;
import jenkins.plugins.publish_over_ftp.options.FtpDefaults;
import jenkins.plugins.publish_over_ftp.options.FtpPluginDefaults;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
@@ -54,10 +56,17 @@
/** null - prevent complaints from xstream */
private Class hostConfigClass;
private final CopyOnWriteList<BapFtpHostConfiguration> hostConfigurations = new CopyOnWriteList<BapFtpHostConfiguration>();
private FtpDefaults defaults;

public BapFtpPublisherPluginDescriptor() {
super(BapFtpPublisherPlugin.class);
load();
if (defaults == null)
defaults = new FtpPluginDefaults();
}

public FtpDefaults getDefaults() {
return defaults;
}

public String getDisplayName() {
@@ -83,18 +92,24 @@ public BapFtpHostConfiguration getConfiguration(final String name) {

public boolean configure(final StaplerRequest request, final JSONObject formData) {
hostConfigurations.replaceBy(request.bindJSONToList(BapFtpHostConfiguration.class, formData.get("instance")));
if (isEnableOverrideDefaults())
defaults = request.bindJSON(FtpDefaults.class, formData.getJSONObject("defaults"));
save();
return true;
}

public boolean canSetMasterNodeName() {
return Hudson.getVersion().isOlderThan(new VersionNumber(BPInstanceConfig.MASTER_GETS_NODE_NAME_IN_VERSION));
return JenkinsCapabilities.missing(JenkinsCapabilities.MASTER_HAS_NODE_NAME);
}

public String getDefaultMasterNodeName() {
return BPInstanceConfig.DEFAULT_MASTER_NODE_NAME;
}

public boolean isEnableOverrideDefaults() {
return JenkinsCapabilities.available(JenkinsCapabilities.SIMPLE_DESCRIPTOR_SELECTOR);
}

public BapFtpPublisherDescriptor getPublisherDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapFtpPublisherDescriptor.class);
}
@@ -103,10 +118,18 @@ public BapFtpHostConfigurationDescriptor getHostConfigurationDescriptor() {
return Hudson.getInstance().getDescriptorByType(BapFtpHostConfigurationDescriptor.class);
}

public FtpPluginDefaults.FtpPluginDefaultsDescriptor getPluginDefaultsDescriptor() {
return Hudson.getInstance().getDescriptorByType(FtpPluginDefaults.FtpPluginDefaultsDescriptor.class);
}

public jenkins.plugins.publish_over.view_defaults.BPInstanceConfig.Messages getCommonFieldNames() {
return new jenkins.plugins.publish_over.view_defaults.BPInstanceConfig.Messages();
}

public jenkins.plugins.publish_over.view_defaults.manage_jenkins.Messages getCommonManageMessages() {
return new jenkins.plugins.publish_over.view_defaults.manage_jenkins.Messages();
}

public FormValidation doTestConnection(final StaplerRequest request, final StaplerResponse response) {
final BapFtpHostConfiguration hostConfig = request.bindParameters(BapFtpHostConfiguration.class, "");
final BPBuildInfo buildInfo = createDummyBuildInfo();
@@ -135,6 +158,8 @@ public Object readResolve() {
// nuke the legacy config
msg = null;
hostConfigClass = null;
if (defaults == null)
defaults = new FtpPluginDefaults();
return this;
}

@@ -0,0 +1,53 @@
/*
* The MIT License
*
* Copyright (C) 2010-2011 by Anthony Robinson
*
* 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 jenkins.plugins.publish_over_ftp.options;

import hudson.DescriptorExtensionList;
import hudson.ExtensionPoint;
import hudson.model.Describable;
import hudson.model.Descriptor;
import hudson.model.Hudson;

public abstract class FtpDefaults implements Describable<FtpDefaults>, ExtensionPoint, FtpOptions {

public static DescriptorExtensionList<FtpDefaults, FtpDefaultsDescriptor> all() {
return Hudson.getInstance().<FtpDefaults, FtpDefaultsDescriptor>getDescriptorList(FtpDefaults.class);
}

public FtpDefaultsDescriptor getDescriptor() {
return (FtpDefaultsDescriptor) Hudson.getInstance().getDescriptor(getClass());
}

public static abstract class FtpDefaultsDescriptor extends Descriptor<FtpDefaults> {

protected FtpDefaultsDescriptor() { }

protected FtpDefaultsDescriptor(Class<? extends FtpDefaults> clazz) {
super(clazz);
}

}

}
@@ -0,0 +1,42 @@
/*
* The MIT License
*
* Copyright (C) 2010-2011 by Anthony Robinson
*
* 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 jenkins.plugins.publish_over_ftp.options;

import jenkins.plugins.publish_over.options.InstanceConfigOptions;
import jenkins.plugins.publish_over.options.ParamPublishOptions;
import jenkins.plugins.publish_over.options.PublisherLabelOptions;
import jenkins.plugins.publish_over.options.PublisherOptions;
import jenkins.plugins.publish_over.options.RetryOptions;

public interface FtpOptions {

InstanceConfigOptions getInstanceConfig();
ParamPublishOptions getParamPublish();
PublisherOptions getPublisher();
PublisherLabelOptions getPublisherLabel();
RetryOptions getRetry();
FtpTransferOptions getTransfer();

}
@@ -0,0 +1,125 @@
/*
* The MIT License
*
* Copyright (C) 2010-2011 by Anthony Robinson
*
* 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 jenkins.plugins.publish_over_ftp.options;

import hudson.Extension;
import jenkins.plugins.publish_over.options.InstanceConfigOptions;
import jenkins.plugins.publish_over.options.ParamPublishOptions;
import jenkins.plugins.publish_over.options.PublisherLabelOptions;
import jenkins.plugins.publish_over.options.PublisherOptions;
import jenkins.plugins.publish_over.options.RetryOptions;
import jenkins.plugins.publish_over.view_defaults.manage_jenkins.Messages;
import org.kohsuke.stapler.DataBoundConstructor;

public class FtpOverrideDefaults extends FtpDefaults {

private final FtpOverrideInstanceConfigDefaults overrideInstanceConfig;
private final FtpOverrideParamPublishDefaults overrideParamPublish;
private final FtpOverridePublisherDefaults overridePublisher;
private final FtpOverridePublisherLabelDefaults overridePublisherLabel;
private final FtpOverrideRetryDefaults overrideRetry;
private final FtpOverrideTransferDefaults overrideTransfer;

@DataBoundConstructor
public FtpOverrideDefaults(final FtpOverrideInstanceConfigDefaults overrideInstanceConfig,
final FtpOverrideParamPublishDefaults overrideParamPublish,
final FtpOverridePublisherDefaults overridePublisher,
final FtpOverridePublisherLabelDefaults overridePublisherLabel,
final FtpOverrideRetryDefaults overrideRetry,
final FtpOverrideTransferDefaults overrideTransfer) {
this.overrideInstanceConfig = overrideInstanceConfig;
this.overrideParamPublish = overrideParamPublish;
this.overridePublisher = overridePublisher;
this.overridePublisherLabel = overridePublisherLabel;
this.overrideRetry = overrideRetry;
this.overrideTransfer = overrideTransfer;
}

// prevent the property type being clobbered in the descriptor map by using different names from the IF
public FtpOverrideInstanceConfigDefaults getOverrideInstanceConfig() {
return overrideInstanceConfig;
}

public FtpOverrideParamPublishDefaults getOverrideParamPublish() {
return overrideParamPublish;
}

public FtpOverridePublisherDefaults getOverridePublisher() {
return overridePublisher;
}

public FtpOverridePublisherLabelDefaults getOverridePublisherLabel() {
return overridePublisherLabel;
}

public FtpOverrideRetryDefaults getOverrideRetry() {
return overrideRetry;
}

public FtpOverrideTransferDefaults getOverrideTransfer() {
return overrideTransfer;
}

public InstanceConfigOptions getInstanceConfig() {
return overrideInstanceConfig;
}

public ParamPublishOptions getParamPublish() {
return overrideParamPublish;
}

public PublisherOptions getPublisher() {
return overridePublisher;
}

public PublisherLabelOptions getPublisherLabel() {
return overridePublisherLabel;
}

public RetryOptions getRetry() {
return overrideRetry;
}

public FtpTransferOptions getTransfer() {
return overrideTransfer;
}

@Extension
public static class FtpOverrideDefaultsDescriptor extends FtpDefaultsDescriptor {

private static final FtpPluginDefaults PLUGIN_DEFAULTS = new FtpPluginDefaults();

@Override
public String getDisplayName() {
return Messages.defaults_overrideDefaults();
}

public FtpPluginDefaults getPluginDefaults() {
return PLUGIN_DEFAULTS;
}

}

}

0 comments on commit 9e99dd1

Please sign in to comment.