import java.util.Date;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.Future;
import javax.ws.rs.core.Response;
final DataNodeContainer schema, final MountInstance mountPoint,
final QName currentAugment ) {
final List<NodeWrapper<?>> children = compositeNodeBuilder.getValues();
+ checkNodeMultiplicityAccordingToSchema(schema,children);
for (final NodeWrapper<? extends Object> child : children) {
final List<DataSchemaNode> potentialSchemaNodes =
this.controllerContext.findInstanceDataChildrenByName(
}
}
+ private void checkNodeMultiplicityAccordingToSchema(final DataNodeContainer dataNodeContainer,
+ final List<NodeWrapper<?>> nodes) {
+ Map<String, Integer> equalNodeNamesToCounts = new HashMap<String, Integer>();
+ for (NodeWrapper<?> child : nodes) {
+ Integer count = equalNodeNamesToCounts.get(child.getLocalName());
+ equalNodeNamesToCounts.put(child.getLocalName(), count == null ? 1 : ++count);
+ }
+
+ for (DataSchemaNode childSchemaNode : dataNodeContainer.getChildNodes()) {
+ if (childSchemaNode instanceof ContainerSchemaNode || childSchemaNode instanceof LeafSchemaNode) {
+ String localName = childSchemaNode.getQName().getLocalName();
+ Integer count = equalNodeNamesToCounts.get(localName);
+ if (count != null && count > 1) {
+ throw new RestconfDocumentedException(
+ "Multiple input data elements were specified for '"
+ + childSchemaNode.getQName().getLocalName()
+ + "'. The data for this element type can only be specified once.",
+ ErrorType.APPLICATION, ErrorTag.BAD_ELEMENT);
+ }
+ }
+ }
+ }
+
private QName normalizeNodeName(final NodeWrapper<? extends Object> nodeBuilder,
final DataSchemaNode schema, final QName previousAugment,
final MountInstance mountPoint) {