use of hudson.util.CopyOnWriteList in project hudson-2.x by hudson.
the class CopyOnWriteListProjectPropertyTest method testClearOriginalValue.
/**
* Verify {@link CopyOnWriteListProjectProperty#clearOriginalValue(hudson.util.CopyOnWriteList)} method.
*/
@Test
public void testClearOriginalValue() {
//Overridden flag should be cleared to false. Pre-set true value
property.setOverridden(true);
assertTrue(property.isOverridden());
CopyOnWriteList originalValue = new CopyOnWriteList(Arrays.asList(new Object()));
property.clearOriginalValue(originalValue);
//Original value should be set with overridden flag == false
assertFalse(property.isOverridden());
assertTrue(originalValue == property.getOriginalValue());
}
use of hudson.util.CopyOnWriteList in project hudson-2.x by hudson.
the class CopyOnWriteListProjectPropertyTest method testReturnOriginalValue.
/**
* Verify {@link CopyOnWriteListProjectProperty#returnOriginalValue()} method.
*/
@Test
public void testReturnOriginalValue() {
//Return cascading is property is not overridden and is empty.
assertFalse(property.returnOriginalValue());
//Return properties' originalValue if it was overridden
property.setOverridden(true);
assertTrue(property.returnOriginalValue());
//If property has not empty value - return it (basically for non-cascadable projects)
property.setOriginalValue(new CopyOnWriteList(Arrays.asList(new Object())), false);
assertTrue(property.returnOriginalValue());
//If property has not empty value and was overridden - return it
property.setOriginalValue(new CopyOnWriteList(Arrays.asList(new Object())), true);
assertTrue(property.returnOriginalValue());
}
use of hudson.util.CopyOnWriteList 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);
}
use of hudson.util.CopyOnWriteList in project hudson-2.x by hudson.
the class Job method getCascadingJobProperties.
/**
* @return list of cascading {@link JobProperty} instances. Includes {@link ParametersDefinitionProperty} and
* children of {@link JobProperty} from external plugins.
*/
private CopyOnWriteList getCascadingJobProperties() {
CopyOnWriteList result = new CopyOnWriteList();
CopyOnWriteList<ParametersDefinitionProperty> definitionProperties = getParameterDefinitionProperties();
if (null != cascadingJobProperties && !cascadingJobProperties.isEmpty()) {
for (String key : cascadingJobProperties) {
IProjectProperty projectProperty = CascadingUtil.getProjectProperty(this, key);
Object value = projectProperty.getValue();
if (null != value) {
result.add(value);
}
}
}
if (null != definitionProperties && !definitionProperties.isEmpty()) {
result.addAll(definitionProperties.getView());
}
return result;
}
use of hudson.util.CopyOnWriteList in project hudson-2.x by hudson.
the class CopyOnWriteListProjectProperty method getDefaultValue.
@Override
public CopyOnWriteList getDefaultValue() {
CopyOnWriteList result = new CopyOnWriteList();
setOriginalValue(result, false);
return result;
}
Aggregations