Search in sources :

Example 1 with BaseProjectProperty

use of org.hudsonci.model.project.property.BaseProjectProperty in project hudson-2.x by hudson.

the class Job method submit.

/**
     * Derived class can override this to perform additional config submission
     * work.
     */
protected void submit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
    JSONObject json = req.getSubmittedForm();
    description = req.getParameter("description");
    keepDependencies = req.getParameter("keepDependencies") != null;
    properties.clear();
    setCascadingProjectName(StringUtils.trimToNull(req.getParameter("cascadingProjectName")));
    CopyOnWriteList parameterDefinitionProperties = new CopyOnWriteList();
    int i = 0;
    for (JobPropertyDescriptor d : JobPropertyDescriptor.getPropertyDescriptors(Job.this.getClass())) {
        if (!CascadingUtil.isCascadableJobProperty(d)) {
            String name = "jobProperty" + i;
            JSONObject config = json.getJSONObject(name);
            JobProperty prop = d.newInstance(req, config);
            if (null != prop) {
                prop.setOwner(this);
                if (prop instanceof AuthorizationMatrixProperty) {
                    properties.add(prop);
                } else if (prop instanceof ParametersDefinitionProperty) {
                    parameterDefinitionProperties.add(prop);
                }
            }
        } else {
            BaseProjectProperty property = CascadingUtil.getBaseProjectProperty(this, d.getJsonSafeClassName());
            JobProperty prop = d.newInstance(req, json.getJSONObject(d.getJsonSafeClassName()));
            if (null != prop) {
                prop.setOwner(this);
            }
            property.setValue(prop);
            addCascadingJobProperty(property);
        }
        i++;
    }
    setParameterDefinitionProperties(parameterDefinitionProperties);
    LogRotator logRotator = null;
    if (null != req.getParameter("logrotate")) {
        logRotator = LogRotator.DESCRIPTOR.newInstance(req, json.getJSONObject("logrotate"));
    }
    setLogRotator(logRotator);
}
Also used : BaseProjectProperty(org.hudsonci.model.project.property.BaseProjectProperty) JSONObject(net.sf.json.JSONObject) LogRotator(hudson.tasks.LogRotator) CopyOnWriteList(hudson.util.CopyOnWriteList) AuthorizationMatrixProperty(hudson.security.AuthorizationMatrixProperty) ExtensionPoint(hudson.ExtensionPoint)

Example 2 with BaseProjectProperty

use of org.hudsonci.model.project.property.BaseProjectProperty in project hudson-2.x by hudson.

the class Job method convertCascadingJobProperties.

/**
     * Method converts JobProperties to cascading values.
     * <p/>
     * If property is {@link AuthorizationMatrixProperty} - it will be skipped.
     * If property is {@link ParametersDefinitionProperty} - it will be added to list of parameterDefinition properties.
     * All the rest properties will be converted to {@link BaseProjectProperty} classes and added
     * to cascadingJobProperties set.
     *
     * @param properties list of {@link JobProperty}
     */
private void convertCascadingJobProperties(CopyOnWriteList<JobProperty<? super JobT>> properties) {
    CopyOnWriteList parameterDefinitionProperties = new CopyOnWriteList();
    for (JobProperty property : properties) {
        if (property instanceof AuthorizationMatrixProperty) {
            continue;
        }
        if (property instanceof ParametersDefinitionProperty) {
            parameterDefinitionProperties.add(property);
            continue;
        }
        BaseProjectProperty projectProperty = CascadingUtil.getBaseProjectProperty(this, property.getDescriptor().getJsonSafeClassName());
        addCascadingJobProperty(projectProperty);
    }
    if (null == getProperty(PARAMETERS_DEFINITION_JOB_PROPERTY_PROPERTY_NAME)) {
        setParameterDefinitionProperties(parameterDefinitionProperties);
    }
}
Also used : BaseProjectProperty(org.hudsonci.model.project.property.BaseProjectProperty) CopyOnWriteList(hudson.util.CopyOnWriteList) AuthorizationMatrixProperty(hudson.security.AuthorizationMatrixProperty)

Aggregations

AuthorizationMatrixProperty (hudson.security.AuthorizationMatrixProperty)2 CopyOnWriteList (hudson.util.CopyOnWriteList)2 BaseProjectProperty (org.hudsonci.model.project.property.BaseProjectProperty)2 ExtensionPoint (hudson.ExtensionPoint)1 LogRotator (hudson.tasks.LogRotator)1 JSONObject (net.sf.json.JSONObject)1