{
Class<? extends ConfiguredObject> expectedChildConfiguredObjectClass = findExpectedChildConfiguredObjectClass(
fieldName, expectedConfiguredObjectClass);
// assuming it is a child node
ConfigurationEntry entry = toEntry(element, expectedChildConfiguredObjectClass, entries);
childrenIds.add(entry.getId());
}
else
{
if (fieldValues == null)
{
fieldValues = new ArrayList<Object>();
}
fieldValues.add(toObject(element));
}
}
if (fieldValues != null)
{
Object[] array = fieldValues.toArray(new Object[fieldValues.size()]);
if (attributes == null)
{
attributes = new HashMap<String, Object>();
}
attributes.put(fieldName, array);
}
}
else if (fieldNode.isObject())
{
// ignore, in-line objects are not supported yet
}
else
{
// primitive attribute
Object value = toObject(fieldNode);
if (attributes == null)
{
attributes = new HashMap<String, Object>();
}
attributes.put(fieldName, value);
}
}
if (type == null)
{
if (expectedConfiguredObjectClass == null)
{
throw new IllegalConfigurationException("Type attribute is not provided for configuration entry " + parent);
}
else
{
type = expectedConfiguredObjectClass.getSimpleName();
}
}
String name = null;
if (attributes != null)
{
name = (String) attributes.get(ATTRIBUTE_NAME);
}
if ((name == null || "".equals(name)))
{
if (expectedConfiguredObjectClass == Broker.class)
{
name = DEFAULT_BROKER_NAME;
}
else
{
throw new IllegalConfigurationException("Name attribute is not provided for configuration entry " + parent);
}
}
UUID id = null;
if (idAsString == null)
{
id = UUIDGenerator.generateRandomUUID();
_generatedObjectIdDuringLoad = true;
}
else
{
try
{
id = UUID.fromString(idAsString);
}
catch (Exception e)
{
throw new IllegalConfigurationException(
"ID attribute value does not conform to UUID format for configuration entry " + parent);
}
}
ConfigurationEntry entry = new ConfigurationEntry(id, type, attributes, childrenIds, this);
if (entries.containsKey(id))
{
throw new IllegalConfigurationException("Duplicate id is found: " + id
+ "! The following configuration entries have the same id: " + entries.get(id) + ", " + entry);
}