import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-class ShardDataTreeSnapshot implements DataTreeSnapshot {
+/**
+ * The PruningShardDataTreeSnapshot returns a PruningDataTreeModification when a newModification is created
+ */
+class PruningShardDataTreeSnapshot implements DataTreeSnapshot {
private final DataTreeSnapshot dataTreeSnapshot;
private final Set<URI> validNamespaces;
- public ShardDataTreeSnapshot(DataTreeSnapshot dataTreeSnapshot, Set<URI> validNamespaces) {
+ public PruningShardDataTreeSnapshot(DataTreeSnapshot dataTreeSnapshot, Set<URI> validNamespaces) {
this.dataTreeSnapshot = dataTreeSnapshot;
this.validNamespaces = validNamespaces;
}
@Override
public ReadOnlyShardDataTreeTransaction newReadOnlyTransaction(String txId, String chainId) {
return new ReadOnlyShardDataTreeTransaction(txId,
- new ShardDataTreeSnapshot(dataTree.takeSnapshot(), validNamespaces));
+ new PruningShardDataTreeSnapshot(dataTree.takeSnapshot(), validNamespaces));
}
@Override
public ReadWriteShardDataTreeTransaction newReadWriteTransaction(String txId, String chainId) {
return new ReadWriteShardDataTreeTransaction(ShardDataTree.this, txId,
- new ShardDataTreeSnapshot(dataTree.takeSnapshot(), validNamespaces).newModification());
+ new PruningShardDataTreeSnapshot(dataTree.takeSnapshot(), validNamespaces).newModification());
}
}
import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModificationCursor;
+import org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public void delete(YangInstanceIdentifier yangInstanceIdentifier) {
try {
delegate.delete(yangInstanceIdentifier);
- } catch(IllegalArgumentException e){
+ } catch(SchemaValidationFailedException e){
LOG.warn("Node at path : {} does not exist ignoring delete", yangInstanceIdentifier);
}
}
public void merge(YangInstanceIdentifier yangInstanceIdentifier, NormalizedNode<?, ?> normalizedNode) {
try {
delegate.merge(yangInstanceIdentifier, normalizedNode);
- } catch (IllegalArgumentException e){
+ } catch (SchemaValidationFailedException e){
if(!isValidYangInstanceIdentifier(yangInstanceIdentifier)){
LOG.warn("Invalid node identifier {} ignoring merge", yangInstanceIdentifier);
return;
public void write(YangInstanceIdentifier yangInstanceIdentifier, NormalizedNode<?, ?> normalizedNode) {
try {
delegate.write(yangInstanceIdentifier, normalizedNode);
- } catch (IllegalArgumentException e){
+ } catch (SchemaValidationFailedException e){
if(!isValidYangInstanceIdentifier(yangInstanceIdentifier)){
LOG.warn("Invalid node identifier {} ignoring write", yangInstanceIdentifier);
return;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
-public class ShardDataTreeSnapshotTest {
+public class PruningShardDataTreeSnapshotTest {
@Mock
DataTreeSnapshot dataTreeSnapshot;
@Test
public void testNewModification(){
- ShardDataTreeSnapshot snapshot1
- = new ShardDataTreeSnapshot(dataTreeSnapshot, validNamespaces);
+ PruningShardDataTreeSnapshot snapshot1
+ = new PruningShardDataTreeSnapshot(dataTreeSnapshot, validNamespaces);
DataTreeModification dataTreeModification1 = snapshot1.newModification();
@Test
public void testReadNode(){
- ShardDataTreeSnapshot snapshot
- = new ShardDataTreeSnapshot(dataTreeSnapshot, validNamespaces);
+ PruningShardDataTreeSnapshot snapshot
+ = new PruningShardDataTreeSnapshot(dataTreeSnapshot, validNamespaces);
snapshot.readNode(CarsModel.BASE_PATH);
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModificationCursor;
+import org.opendaylight.yangtools.yang.data.impl.schema.tree.SchemaValidationFailedException;
public class PruningDataTreeModificationTest {
@Test
public void testDeleteOnException(){
YangInstanceIdentifier path = CarsModel.BASE_PATH;
- doThrow(IllegalArgumentException.class).when(delegate).delete(path);
+ doThrow(SchemaValidationFailedException.class).when(delegate).delete(path);
pruningDataTreeModification.delete(path);
NormalizedNode<?, ?> normalizedNode = CarsModel.create();
YangInstanceIdentifier path = CarsModel.BASE_PATH;
- doThrow(IllegalArgumentException.class).when(delegate).merge(path, normalizedNode);
+ doThrow(SchemaValidationFailedException.class).when(delegate).merge(path, normalizedNode);
doReturn(true).when(validNamespaces).contains(any(YangInstanceIdentifier.PathArgument.class));
pruningDataTreeModification.merge(path, normalizedNode);
NormalizedNode<?, ?> normalizedNode = CarsModel.create();
YangInstanceIdentifier path = CarsModel.BASE_PATH;
- doThrow(IllegalArgumentException.class).when(delegate).write(path, normalizedNode);
+ doThrow(SchemaValidationFailedException.class).when(delegate).write(path, normalizedNode);
doReturn(true).when(validNamespaces).contains(any(YangInstanceIdentifier.PathArgument.class));
pruningDataTreeModification.write(path, normalizedNode);