Search in sources :

Example 1 with DataBoundSetter

use of org.kohsuke.stapler.DataBoundSetter in project email-ext-plugin by jenkinsci.

the class ExtendedEmailPublisherDescriptor method setDefaultClasspath.

@DataBoundSetter
public void setDefaultClasspath(List<GroovyScriptPath> defaultClasspath) throws FormException {
    if (Jenkins.get().isUseSecurity()) {
        ScriptApproval approval = ScriptApproval.get();
        ApprovalContext context = ApprovalContext.create().withCurrentUser();
        for (GroovyScriptPath path : defaultClasspath) {
            URL u = path.asURL();
            if (u != null) {
                try {
                    approval.configuring(new ClasspathEntry(u.toString()), context);
                } catch (MalformedURLException e) {
                    throw new FormException(e, "defaultClasspath");
                }
            }
        }
    }
    this.defaultClasspath = defaultClasspath;
}
Also used : ApprovalContext(org.jenkinsci.plugins.scriptsecurity.scripts.ApprovalContext) MalformedURLException(java.net.MalformedURLException) ClasspathEntry(org.jenkinsci.plugins.scriptsecurity.scripts.ClasspathEntry) ScriptApproval(org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval) URL(java.net.URL) DataBoundSetter(org.kohsuke.stapler.DataBoundSetter)

Example 2 with DataBoundSetter

use of org.kohsuke.stapler.DataBoundSetter in project jenkins by jenkinsci.

the class ChoiceParameterDefinition method setChoices.

/**
 * Set the list of choices. Legal arguments are String (in which case the arguments gets split into lines) and Collection
 * which sets the list of legal parameters to the String representations of the argument's non-null entries.
 *
 * See JENKINS-26143 for background.
 *
 * This retains the compatibility with the legacy String 'choices' parameter, while supporting the list type as generated
 * by the snippet generator.
 *
 * @param choices String or Collection representing this parameter definition's possible values.
 *
 * @since 2.112
 */
@DataBoundSetter
// this is terrible enough without being used anywhere
@Restricted(NoExternalUse.class)
public void setChoices(Object choices) {
    if (choices instanceof String) {
        setChoicesText((String) choices);
        return;
    }
    if (choices instanceof List) {
        ArrayList<String> newChoices = new ArrayList<>();
        for (Object o : (List) choices) {
            if (o != null) {
                newChoices.add(o.toString());
            }
        }
        this.choices = newChoices;
        return;
    }
    throw new IllegalArgumentException("expected String or List, but got " + choices.getClass().getName());
}
Also used : ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JSONObject(net.sf.json.JSONObject) Restricted(org.kohsuke.accmod.Restricted) DataBoundSetter(org.kohsuke.stapler.DataBoundSetter)

Example 3 with DataBoundSetter

use of org.kohsuke.stapler.DataBoundSetter in project bitbucket-branch-source-plugin by jenkinsci.

the class BitbucketSCMSource method setBitbucketServerUrl.

@Deprecated
@Restricted(NoExternalUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBitbucketServerUrl(String url) {
    url = BitbucketEndpointConfiguration.normalizeServerUrl(url);
    AbstractBitbucketEndpoint endpoint = BitbucketEndpointConfiguration.get().findEndpoint(url);
    if (endpoint != null) {
        // we have a match
        setServerUrl(endpoint.getServerUrl());
        return;
    }
    LOGGER.log(Level.WARNING, "Call to legacy setBitbucketServerUrl({0}) method is configuring a url missing " + "from the global configuration.", url);
    setServerUrl(url);
}
Also used : AbstractBitbucketEndpoint(com.cloudbees.jenkins.plugins.bitbucket.endpoints.AbstractBitbucketEndpoint) Restricted(org.kohsuke.accmod.Restricted) RestrictedSince(hudson.RestrictedSince) DataBoundSetter(org.kohsuke.stapler.DataBoundSetter)

Example 4 with DataBoundSetter

use of org.kohsuke.stapler.DataBoundSetter in project bitbucket-branch-source-plugin by jenkinsci.

the class BitbucketSCMNavigator method setBitbucketServerUrl.

@Deprecated
@Restricted(DoNotUse.class)
@RestrictedSince("2.2.0")
@DataBoundSetter
public void setBitbucketServerUrl(String url) {
    url = BitbucketEndpointConfiguration.normalizeServerUrl(url);
    AbstractBitbucketEndpoint endpoint = BitbucketEndpointConfiguration.get().findEndpoint(url);
    if (endpoint != null) {
        // we have a match
        setServerUrl(url);
        return;
    }
    LOGGER.log(Level.WARNING, "Call to legacy setBitbucketServerUrl({0}) method is configuring a url missing " + "from the global configuration.", url);
    setServerUrl(url);
}
Also used : AbstractBitbucketEndpoint(com.cloudbees.jenkins.plugins.bitbucket.endpoints.AbstractBitbucketEndpoint) Restricted(org.kohsuke.accmod.Restricted) RestrictedSince(hudson.RestrictedSince) DataBoundSetter(org.kohsuke.stapler.DataBoundSetter)

Example 5 with DataBoundSetter

use of org.kohsuke.stapler.DataBoundSetter in project jms-messaging-plugin by jenkinsci.

the class CIBuildTrigger method setProviders.

@DataBoundSetter
public void setProviders(List<ProviderDataEnvelope> envelopes) {
    ArrayList<ProviderData> providers = new ArrayList<>();
    for (ProviderDataEnvelope envelope : envelopes) {
        ProviderData providerData = envelope.providerData;
        if (providerData == null) {
            log.warning("Empty provider submitted");
            continue;
        }
        providers.add(providerData);
    }
    this.providers = providers;
}
Also used : FedMsgSubscriberProviderData(com.redhat.jenkins.plugins.ci.provider.data.FedMsgSubscriberProviderData) ProviderData(com.redhat.jenkins.plugins.ci.provider.data.ProviderData) ActiveMQSubscriberProviderData(com.redhat.jenkins.plugins.ci.provider.data.ActiveMQSubscriberProviderData) ArrayList(java.util.ArrayList) DataBoundSetter(org.kohsuke.stapler.DataBoundSetter)

Aggregations

DataBoundSetter (org.kohsuke.stapler.DataBoundSetter)6 Restricted (org.kohsuke.accmod.Restricted)3 AbstractBitbucketEndpoint (com.cloudbees.jenkins.plugins.bitbucket.endpoints.AbstractBitbucketEndpoint)2 RestrictedSince (hudson.RestrictedSince)2 ArrayList (java.util.ArrayList)2 ApprovalContext (org.jenkinsci.plugins.scriptsecurity.scripts.ApprovalContext)2 ScriptApproval (org.jenkinsci.plugins.scriptsecurity.scripts.ScriptApproval)2 ActiveMQSubscriberProviderData (com.redhat.jenkins.plugins.ci.provider.data.ActiveMQSubscriberProviderData)1 FedMsgSubscriberProviderData (com.redhat.jenkins.plugins.ci.provider.data.FedMsgSubscriberProviderData)1 ProviderData (com.redhat.jenkins.plugins.ci.provider.data.ProviderData)1 Item (hudson.model.Item)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 List (java.util.List)1 JSONObject (net.sf.json.JSONObject)1 ClasspathEntry (org.jenkinsci.plugins.scriptsecurity.scripts.ClasspathEntry)1 Ancestor (org.kohsuke.stapler.Ancestor)1 StaplerRequest (org.kohsuke.stapler.StaplerRequest)1