Search in sources :

Example 1 with ObjectComponentDescriptor

use of com.cloudbees.jenkins.support.api.ObjectComponentDescriptor in project support-core-plugin by jenkinsci.

the class SupportObjectAction method parseRequest.

/**
 * Parse the stapler JSON output and retrieve configured components.
 *
 * @param req the request
 * @return the {@link DescribableList} of components
 */
protected final List<ObjectComponent<T>> parseRequest(StaplerRequest req) throws ServletException, Descriptor.FormException {
    // Inspired by https://github.com/jenkinsci/workflow-job-plugin/blob/workflow-job-2.35/src/main/java/org/jenkinsci/plugins/workflow/job/properties/PipelineTriggersJobProperty.java
    DescribableList<ObjectComponent<T>, ObjectComponentDescriptor<T>> components = new DescribableList<>(Saveable.NOOP);
    try {
        JSONObject componentsSection = req.getSubmittedForm().getJSONObject("components");
        components.rebuild(req, componentsSection, getApplicableComponentsDescriptors());
    } catch (IOException e) {
        throw new Descriptor.FormException(e, "components");
    }
    return components;
}
Also used : ObjectComponent(com.cloudbees.jenkins.support.api.ObjectComponent) JSONObject(net.sf.json.JSONObject) DescribableList(hudson.util.DescribableList) ObjectComponentDescriptor(com.cloudbees.jenkins.support.api.ObjectComponentDescriptor) Descriptor(hudson.model.Descriptor) IOException(java.io.IOException) ObjectComponentDescriptor(com.cloudbees.jenkins.support.api.ObjectComponentDescriptor)

Aggregations

ObjectComponent (com.cloudbees.jenkins.support.api.ObjectComponent)1 ObjectComponentDescriptor (com.cloudbees.jenkins.support.api.ObjectComponentDescriptor)1 Descriptor (hudson.model.Descriptor)1 DescribableList (hudson.util.DescribableList)1 IOException (java.io.IOException)1 JSONObject (net.sf.json.JSONObject)1