Projection projection,
ReadBranchRequest request,
Location parent,
List<Location> children,
Map<Name, Property> propertiesByName ) {
Path ancestorPath = ancestorInFederation.getPath();
if (projection == null) {
// This is a placeholder node ...
if (children != null) {
// Add the children (to any existing children) ...
List<Location> existing = request.getChildren(parent);
if (existing == null) existing = new ArrayList<Location>(children.size());
for (Location child : children) {
existing.add(child);
}
request.setChildren(parent, existing);
}
if (propertiesByName != null) {
// Add the properties to any existing properties ...
Map<Name, Property> propsByName = request.getPropertiesFor(parent);
if (propsByName == null) propsByName = new HashMap<Name, Property>();
for (Property property : propertiesByName.values()) {
Property existingProperty = propsByName.get(property.getName());
if (existingProperty != null) {
// Merge the property values ...
property = merge(existingProperty, property, propertyFactory, true);
}
propsByName.put(property.getName(), property);
}
request.setProperties(parent, propsByName.values());
}
return;
}
for (Path path : projection.getPathsInRepository(parent.getPath(), pathFactory)) {
if (!path.isAtOrBelow(ancestorPath)) continue;
// Determine the list of children ...
Location parentInFederation = parent.with(path);
if (children != null) {
// Add the children to any existing children ...
List<Location> existing = request.getChildren(parentInFederation);
if (existing == null) existing = new ArrayList<Location>(children.size());
for (Location child : children) {
Path childPath = pathFactory.create(path, child.getPath().getLastSegment());
existing.add(child.with(childPath));
}
request.setChildren(parentInFederation, existing);
}