use of hudson.util.CopyOnWriteList in project hudson-2.x by hudson.
the class Job method onLoad.
@Override
@SuppressWarnings("unchecked")
public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException {
super.onLoad(parent, name);
cascadingProject = (JobT) Functions.getItemByName(Hudson.getInstance().getAllItems(this.getClass()), cascadingProjectName);
initAllowSave();
TextFile f = getNextBuildNumberFile();
if (f.exists()) {
// assume that nextBuildNumber was read from config.xml
try {
synchronized (this) {
this.nextBuildNumber = Integer.parseInt(f.readTrim());
}
} catch (NumberFormatException e) {
throw new IOException2(f + " doesn't contain a number", e);
}
} else {
// From the old Hudson, or doCreateItem. Create this file now.
saveNextBuildNumber();
// and delete it from the config.xml
save();
}
if (// didn't exist < 1.72
properties == null)
properties = new CopyOnWriteList<JobProperty<? super JobT>>();
if (cascadingChildrenNames == null) {
cascadingChildrenNames = new CopyOnWriteArraySet<String>();
}
buildProjectProperties();
for (JobProperty p : getAllProperties()) {
p.setOwner(this);
}
}
use of hudson.util.CopyOnWriteList in project hudson-2.x by hudson.
the class Job method getAllProperties.
/**
* List of all {@link JobProperty} exposed primarily for the remoting API.
* List contains cascadable {@link JobProperty} if any.
* @since 2.2.0
*/
@Exported(name = "property", inline = true)
public List<JobProperty<? super JobT>> getAllProperties() {
CopyOnWriteList cascadingJobProperties = getCascadingJobProperties();
List<JobProperty<? super JobT>> result = properties.getView();
if (null != cascadingJobProperties && !cascadingJobProperties.isEmpty()) {
result = Collections.unmodifiableList(ListUtils.union(result, cascadingJobProperties.getView()));
}
return result;
}
use of hudson.util.CopyOnWriteList 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);
}
}
use of hudson.util.CopyOnWriteList in project hudson-2.x by hudson.
the class CopyOnWriteListProjectPropertyTest method testGetDefaultValue.
/**
* Verify {@link CopyOnWriteListProjectProperty#getDefaultValue()} method.
*/
@Test
public void testGetDefaultValue() {
CopyOnWriteList defaultValue = property.getDefaultValue();
assertNotNull(defaultValue);
//Default value should be initialized and stored as original value
assertTrue(property.getOriginalValue() == defaultValue);
assertFalse(property.isOverridden());
}
use of hudson.util.CopyOnWriteList in project hudson-2.x by hudson.
the class CopyOnWriteListProjectPropertyTest method testGetOriginalValue.
/**
* Verify {@link CopyOnWriteListProjectProperty#getOriginalValue()} method.
*/
@Test
public void testGetOriginalValue() {
//Original value is not initialized. Default value will be used instead. Shouldn't be null
CopyOnWriteList originalValue = property.getOriginalValue();
assertNotNull(originalValue);
//Value was set, so return it without modification
assertTrue(originalValue == property.getOriginalValue());
}
Aggregations