//ok, now we can update the bindingSets property with the update set of binding sets
ManagedProperty bindingSetsProperty = bindingManagerComponent.getProperty(Util.BINDING_SETS_PROPERTY);
//check that the provided binding set name is unique
CollectionValue bindingSets = (CollectionValue) bindingSetsProperty.getValue();
String newBindingSetName = Util.getValue(newBindingSet, "name", String.class);
for (MetaValue bindingSet : bindingSets) {
CompositeValue bindingSetComposite = (CompositeValue)bindingSet;
String bindingSetName = Util.getValue(bindingSetComposite, "name", String.class);
if (newBindingSetName.equals(bindingSetName)) {
report.setErrorMessage("A binding set with the provided name already exists.");
report.setStatus(CreateResourceStatus.FAILURE);
return report;
}
}
// Create a new array that's one element larger than the original array.
MetaValue[] newBindingSets = new MetaValue[bindingSets.getSize() + 1];
// Copy the original array into the new array.
System.arraycopy(bindingSets.getElements(), 0, newBindingSets, 0, bindingSets.getSize());
// Add the new one as the last element of the new array.
newBindingSets[bindingSets.getSize()] = newBindingSet;
CollectionValueSupport newBindingSetsValue = new CollectionValueSupport(bindingSets.getMetaType());
newBindingSetsValue.setElements(newBindingSets);
bindingSetsProperty.setValue(newBindingSetsValue);
updateBindingManager(bindingManagerComponent);