import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
-
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.CheckedFuture;
if (domDataBrokerService.isPresent()) {
return readDataViaTransaction(domDataBrokerService.get().newReadOnlyTransaction(), CONFIGURATION, path);
}
- throw new RestconfDocumentedException("DOM data broker service isn't available for mount point.");
+ final String errMsg = "DOM data broker service isn't available for mount point " + path;
+ LOG.warn(errMsg);
+ throw new RestconfDocumentedException(errMsg);
}
// READ operational
if (domDataBrokerService.isPresent()) {
return readDataViaTransaction(domDataBrokerService.get().newReadOnlyTransaction(), OPERATIONAL, path);
}
- throw new RestconfDocumentedException("DOM data broker service isn't available for mount point.");
+ final String errMsg = "DOM data broker service isn't available for mount point " + path;
+ LOG.warn(errMsg);
+ throw new RestconfDocumentedException(errMsg);
}
// PUT configuration
return putDataViaTransaction(domDataBrokerService.get().newReadWriteTransaction(), CONFIGURATION, path,
payload, mountPoint.getSchemaContext());
}
- throw new RestconfDocumentedException("DOM data broker service isn't available for mount point.");
+ final String errMsg = "DOM data broker service isn't available for mount point " + path;
+ LOG.warn(errMsg);
+ throw new RestconfDocumentedException(errMsg);
}
// POST configuration
return postDataViaTransaction(domDataBrokerService.get().newReadWriteTransaction(), CONFIGURATION, path,
payload, mountPoint.getSchemaContext());
}
- throw new RestconfDocumentedException("DOM data broker service isn't available for mount point.");
+ final String errMsg = "DOM data broker service isn't available for mount point " + path;
+ LOG.warn(errMsg);
+ throw new RestconfDocumentedException(errMsg);
}
// DELETE configuration
if (domDataBrokerService.isPresent()) {
return deleteDataViaTransaction(domDataBrokerService.get().newWriteOnlyTransaction(), CONFIGURATION, path);
}
- throw new RestconfDocumentedException("DOM data broker service isn't available for mount point.");
+ final String errMsg = "DOM data broker service isn't available for mount point " + path;
+ LOG.warn(errMsg);
+ throw new RestconfDocumentedException(errMsg);
}
// RPC
LOG.debug("Reading result data from transaction.");
optional = listenableFuture.get();
} catch (InterruptedException | ExecutionException e) {
+ LOG.warn("Exception by reading " + datastore.name() + " via Restconf: {}", path, e);
throw new RestconfDocumentedException("Problem to get data from transaction.", e.getCause());
}
private CheckedFuture<Void, TransactionCommitFailedException> postDataViaTransaction(
final DOMDataReadWriteTransaction rWTransaction, final LogicalDatastoreType datastore,
- final YangInstanceIdentifier parentPath, final NormalizedNode<?, ?> payload, final SchemaContext schemaContext) {
+ final YangInstanceIdentifier path, final NormalizedNode<?, ?> payload, final SchemaContext schemaContext) {
// FIXME: This is doing correct post for container and list children
// not sure if this will work for choice case
if(payload instanceof MapNode) {
- final YangInstanceIdentifier mapPath = parentPath.node(payload.getIdentifier());
- final NormalizedNode<?, ?> emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, mapPath);
+ final NormalizedNode<?, ?> emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path);
rWTransaction.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
- ensureParentsByMerge(datastore, mapPath, rWTransaction, schemaContext);
+ ensureParentsByMerge(datastore, path, rWTransaction, schemaContext);
for(final MapEntryNode child : ((MapNode) payload).getValue()) {
- final YangInstanceIdentifier childPath = mapPath.node(child.getIdentifier());
+ final YangInstanceIdentifier childPath = path.node(child.getIdentifier());
checkItemDoesNotExists(rWTransaction, datastore, childPath);
rWTransaction.put(datastore, childPath, child);
}
} else {
- final YangInstanceIdentifier path;
- if(payload instanceof MapEntryNode) {
- path = parentPath.node(payload.getNodeType()).node(payload.getIdentifier());
- } else {
- path = parentPath.node(payload.getIdentifier());
- }
checkItemDoesNotExists(rWTransaction,datastore, path);
ensureParentsByMerge(datastore, path, rWTransaction, schemaContext);
rWTransaction.put(datastore, path, payload);
try {
if (futureDatastoreData.get()) {
final String errMsg = "Post Configuration via Restconf was not executed because data already exists";
- LOG.debug(errMsg + ":{}", path);
+ LOG.trace(errMsg + ":{}", path);
rWTransaction.cancel();
throw new RestconfDocumentedException("Data already exists for path: " + path, ErrorType.PROTOCOL,
ErrorTag.DATA_EXISTS);
}
} catch (InterruptedException | ExecutionException e) {
- LOG.trace("It wasn't possible to get data loaded from datastore at path " + path);
+ LOG.warn("It wasn't possible to get data loaded from datastore at path " + path, e);
}
}