throw new IdentityException("Cannot add not defined attribute. Use '" + ALLOW_NOT_DEFINED_ATTRIBUTES +
"' option if needed. Attribute name: " + attribute.getName());
}
IdentityObjectAttributeMetaData amd = mdMap.get(attribute.getName());
if (amd != null)
{
if (!amd.isMultivalued() && attribute.getSize() > 1)
{
throw new IdentityException("Cannot add multiply values to single valued attribute: " + attribute.getName());
}
if (amd.isReadonly())
{
throw new IdentityException("Cannot add readonly attribute: " + attribute.getName());
}
String type = amd.getType();
// check if all values have proper type
for (Object value : attribute.getValues())
{
if (type.equals(IdentityObjectAttributeMetaData.TEXT_TYPE) && !(value instanceof String))
{
throw new IdentityException("Cannot add text type attribute with not String type value: "
+ attribute.getName() + " / " + value);
}
if (type.equals(IdentityObjectAttributeMetaData.BINARY_TYPE) && !(value instanceof byte[]))
{
throw new IdentityException("Cannot add binary type attribute with not byte[] type value: "
+ attribute.getName() + " / " + value);
}
}
}
}
HibernateIdentityObject hibernateObject = safeGet(ctx, identity);
for (String name : mappedAttributes.keySet())
{
IdentityObjectAttribute attribute = mappedAttributes.get(name);
IdentityObjectAttributeMetaData amd = mdMap.get(attribute.getName());
// Default to text
String type = amd != null ? amd.getType() : IdentityObjectAttributeMetaData.TEXT_TYPE;
HibernateIdentityObjectAttribute hibernateAttribute = null;
for (HibernateIdentityObjectAttribute storeAttribute : hibernateObject.getAttributes())
{