]
Brian Stansberry updated WFCORE-2531:
-------------------------------------
Summary: Validation of cardinality of attribute groups and object type attributes on
PersistentResourceXMLDescription (was: Validation of attribute groups and object type
attributes on PersistentResourceXMLDescription)
Validation of cardinality of attribute groups and object type
attributes on PersistentResourceXMLDescription
------------------------------------------------------------------------------------------------------------
Key: WFCORE-2531
URL:
https://issues.jboss.org/browse/WFCORE-2531
Project: WildFly Core
Issue Type: Bug
Components: Domain Management
Affects Versions: 3.0.0.Beta8
Reporter: Pedro Igor
Assignee: Brian Stansberry
Currently, the {{org.jboss.as.controller.PersistentResourceXMLDescription}} does not
perform any validation when using attribute groups or object type attribute definitions to
check how many times an attribute was defined.
For instance, when using a resource description with an attribute group like this:
{code}
static final AttributeDefinition clusterAttr1 = create("cluster-attr1",
ModelType.STRING)
.setAttributeGroup("cluster")
.setXmlName("attr1")
.build();
static final AttributeDefinition clusterAttr2 = create("cluster-attr2",
ModelType.STRING)
.setAttributeGroup("cluster")
.setXmlName("attr2")
.build();
{code}
The parser allows a XML declaration as follows:
{code}
<resource name="foo3">
<cluster attr1="bar1" attr2="baz1"/>
<cluster attr1="bar2" attr2="baz2"/>
</resource>
{code}
The declaration does not throws any error and only the second declaration of {{cluster}}
is populated into the model.
A similar problem exists when using object type attribute definitions as follows:
{code}
static final ObjectTypeAttributeDefinition USERS_PROPERTIES =
ObjectTypeAttributeDefinition.Builder.of("user-properties",
create("path", ModelType.STRING, false)
.setAllowExpression(false)
.build(),
create("relative-to", ModelType.STRING, false)
.setAllowExpression(false)
.build())
.build();
{code}
The parser also allows a declaration as follows:
{code}
<object-type-test name="foo5">
<user-properties path="path1"
relative-to="relative1"/>
<user-properties path="path2"
relative-to="relative2"/>
</object-type-test>
{code}
As a result, only the last {{user-properties}} is populated in the model and we don't
get any error.