Java Code Examples for org.kohsuke.stapler.StaplerRequest#bindJSON()

The following examples show how to use org.kohsuke.stapler.StaplerRequest#bindJSON() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GogsProjectProperty.java    From gogs-webhook-plugin with MIT License 6 votes vote down vote up
public JobProperty<?> newInstance(StaplerRequest req, JSONObject formData) {
    GogsProjectProperty tpp = null;

    if (req != null) {
        tpp = req.bindJSON(
                GogsProjectProperty.class,
                formData.getJSONObject(GOGS_PROJECT_BLOCK_NAME)
        );
    }
    if (tpp != null) {
        LOGGER.finest(formData.toString());
        LOGGER.finest(tpp.gogsBranchFilter);

        gogsSecret = tpp.gogsSecret;
        gogsBranchFilter = tpp.gogsBranchFilter;
    }
    return tpp;
}
 
Example 2
Source File: CodeBuilder.java    From aws-codebuild-jenkins-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
    req.bindJSON(this, formData);
    this.minSleepTime = formData.optInt("minSleepTime", 0);
    this.maxSleepTime = formData.optInt("maxSleepTime", 0);
    this.sleepJitter = formData.optInt("sleepJitter", 0);
    save();
    return super.configure(req, formData);
}
 
Example 3
Source File: GitHubTriggerDescriptor.java    From github-integration-plugin with MIT License 5 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
    req.bindJSON(this, formData);

    save();
    return super.configure(req, formData);
}
 
Example 4
Source File: RepairnatorPostBuild.java    From repairnator with MIT License 5 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
    req.bindJSON(this, formData);
    this.useNPEFix = formData.getBoolean("useNPEFix");
    this.useAstorJKali = formData.getBoolean("useAstorJKali");
    this.useAstorJMut = formData.getBoolean("useAstorJMut");
    this.useNPEFixSafe = formData.getBoolean("useNPEFixSafe");
    this.useNopolTestExclusionStrategy = formData.getBoolean("useNopolTestExclusionStrategy");
    this.useSorald = formData.getBoolean("useSorald");

    save();
    return true;
}
 
Example 5
Source File: OpenShift.java    From jenkins-client-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject json)
        throws FormException {

    /**
     * If all cluster configurations are deleted in the UI and saved,
     * binJSON does not set the list. So clear out the list before bind.
     */
    clusterConfigs = null;

    req.bindJSON(this, json.getJSONObject("openshift"));
    save();
    return true;
}
 
Example 6
Source File: PackerPublisher.java    From packer-plugin with MIT License 5 votes vote down vote up
@Override
public PackerPublisher newInstance(StaplerRequest req, JSONObject formData)
        throws hudson.model.Descriptor.FormException {

    PackerPublisher packer = (PackerPublisher) req.bindJSON(clazz,
            formData);

    if (formData.has(TEMPLATE_MODE)) {
        JSONObject opt = formData.getJSONObject(TEMPLATE_MODE);
        packer.setTemplateMode(opt.getString("value"));
        packer.setJsonTemplate(opt.optString("jsonTemplate"));
        packer.setJsonTemplateText(opt.optString("jsonTemplateText"));
    }
    return packer;
}
 
Example 7
Source File: CredentialApi.java    From blueocean-plugin with MIT License 5 votes vote down vote up
@POST
@WebMethod(name = "")
@Deprecated
public CreateResponse create(@JsonBody JSONObject body, StaplerRequest request) throws IOException {

    final IdCredentials credentials = request.bindJSON(IdCredentials.class, body.getJSONObject("credentials"));
    domainWrapper.getStore().addCredentials(domainWrapper.getDomain(), credentials);


    final Domain domain = domainWrapper.getDomain();
    domainWrapper.getStore().addCredentials(domain, credentials);

    return new CreateResponse(new Credential(domainWrapper.getCredentials().get(credentials.getId()), getLink()));
}
 
Example 8
Source File: LambdaPublishPublisher.java    From aws-lambda-jenkins-plugin with MIT License 5 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
    req.bindJSON(this, formData);

    save();

    return super.configure(req,formData);
}
 
Example 9
Source File: LambdaUploadPublisher.java    From aws-lambda-jenkins-plugin with MIT License 5 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
    req.bindJSON(this, formData);

    save();

    return super.configure(req,formData);
}
 
Example 10
Source File: ViolationsToGitHubConfiguration.java    From violation-comments-to-github-plugin with MIT License 4 votes vote down vote up
@Override
public boolean configure(final StaplerRequest req, final JSONObject json) throws FormException {
  req.bindJSON(this, json);
  save();
  return true;
}
 
Example 11
Source File: GlobalConfig.java    From docker-workflow-plugin with MIT License 4 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
    req.bindJSON(this, json);
    save();
    return true;
}
 
Example 12
Source File: DashboardView.java    From jenkins-deployment-dashboard-plugin with MIT License 4 votes vote down vote up
/**
 * Handles the configuration submission. Load view-specific properties here.
 */
@Override
protected synchronized void submit(final StaplerRequest req) throws IOException, ServletException, Descriptor.FormException {
    LOGGER.info("DashboardView submit configuration");
    req.bindJSON(this, req.getSubmittedForm()); // Mapping the JSON directly should work
}
 
Example 13
Source File: DashboardViewDescriptor.java    From jenkins-deployment-dashboard-plugin with MIT License 4 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws Descriptor.FormException {
    req.bindJSON(this, json.getJSONObject("deployment-dashboard"));
    save();
    return true;
}
 
Example 14
Source File: ViolationsToBitbucketServerGlobalConfiguration.java    From violation-comments-to-stash-plugin with MIT License 4 votes vote down vote up
@Override
public boolean configure(final StaplerRequest req, final JSONObject json) throws FormException {
  req.bindJSON(this, json);
  save();
  return true;
}
 
Example 15
Source File: GlobalConfiguration.java    From DotCi with MIT License 4 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws Descriptor.FormException {
    req.bindJSON(this, json);
    save();
    return true;
}
 
Example 16
Source File: SetupConfig.java    From DotCi with MIT License 4 votes vote down vote up
@Override
public boolean configure(final StaplerRequest req, final JSONObject json) throws FormException {
    req.bindJSON(this, json);
    save();
    return true;
}
 
Example 17
Source File: JenkinsComputerConnectorTester.java    From jenkins-test-harness with MIT License 4 votes vote down vote up
public void doConfigSubmit(StaplerRequest req) throws IOException, ServletException {
    connector = req.bindJSON(ComputerConnector.class, req.getSubmittedForm().getJSONObject("connector"));
}
 
Example 18
Source File: CasCGlobalConfig.java    From configuration-as-code-plugin with MIT License 4 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
    req.bindJSON(this, json);
    save();
    return super.configure(req, json);
}
 
Example 19
Source File: GitHubConfiguration.java    From github-branch-source-plugin with MIT License 4 votes vote down vote up
@Override public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
    req.bindJSON(this, json);
    return true;
}
 
Example 20
Source File: BuildStatusConfig.java    From github-autostatus-plugin with MIT License 2 votes vote down vote up
/**
 * Invoked when the global configuration page is submitted
 *
 * @param req Request that represents the form submission
 * @param json The JSON object that captures the configuration data
 * @return always returns true (allow config page to be closed)
 * @throws hudson.model.Descriptor.FormException exception if a form field is invalid
 */
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
    req.bindJSON(this, json);
    return true;
}