Search in sources :

Example 1 with SchemaValidationFailedException

use of org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException in project controller by opendaylight.

the class DistributedShardChangePublisher method applyChanges.

synchronized DataTreeCandidate applyChanges(final YangInstanceIdentifier listenerPath, final Collection<DataTreeCandidate> changes) throws DataValidationFailedException {
    final DataTreeModification modification = dataTree.takeSnapshot().newModification();
    for (final DataTreeCandidate change : changes) {
        try {
            DataTreeCandidates.applyToModification(modification, change);
        } catch (SchemaValidationFailedException e) {
            LOG.error("Validation failed {}", e);
        }
    }
    modification.ready();
    final DataTreeCandidate candidate;
    dataTree.validate(modification);
    // strip nodes we dont need since this listener doesn't have to be registered at the root of the DataTree
    candidate = dataTree.prepare(modification);
    dataTree.commit(candidate);
    DataTreeCandidateNode modifiedChild = candidate.getRootNode();
    for (final PathArgument pathArgument : listenerPath.getPathArguments()) {
        modifiedChild = modifiedChild.getModifiedChild(pathArgument);
    }
    if (modifiedChild == null) {
        modifiedChild = new EmptyDataTreeCandidateNode(dataTree.getRootPath().getLastPathArgument());
    }
    return DataTreeCandidates.newDataTreeCandidate(dataTree.getRootPath(), modifiedChild);
}
Also used : DataTreeModification(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification) DataTreeCandidate(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate) DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode) PathArgument(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument) SchemaValidationFailedException(org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException)

Aggregations

PathArgument (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument)1 DataTreeCandidate (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate)1 DataTreeCandidateNode (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode)1 DataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification)1 SchemaValidationFailedException (org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException)1