import org.opendaylight.netconf.sal.restconf.impl.PATCHStatusContext;
import org.opendaylight.netconf.sal.restconf.impl.RestconfDocumentedException;
import org.opendaylight.netconf.sal.restconf.impl.RestconfError;
+import org.opendaylight.netconf.sal.restconf.impl.WriterParameters;
import org.opendaylight.restconf.RestConnectorProvider;
import org.opendaylight.restconf.common.references.SchemaContextRef;
import org.opendaylight.restconf.handlers.DOMMountPointServiceHandler;
this.mountPointServiceHandler = mountPointServiceHandler;
}
+ @Override
+ public Response readData(final UriInfo uriInfo) {
+ return readData(null, uriInfo);
+ }
+
@Override
public Response readData(final String identifier, final UriInfo uriInfo) {
- Preconditions.checkNotNull(identifier);
final SchemaContextRef schemaContextRef = new SchemaContextRef(this.schemaContextHandler.get());
-
final InstanceIdentifierContext<?> instanceIdentifier = ParserIdentifier.toInstanceIdentifier(
identifier, schemaContextRef.get(), Optional.of(this.mountPointServiceHandler.get()));
- final DOMMountPoint mountPoint = instanceIdentifier.getMountPoint();
- final String value = uriInfo.getQueryParameters().getFirst(RestconfDataServiceConstant.CONTENT);
+ final WriterParameters parameters = ReadDataTransactionUtil.parseUriParameters(
+ instanceIdentifier, uriInfo);
+
+ final DOMMountPoint mountPoint = instanceIdentifier.getMountPoint();
final DOMTransactionChain transactionChain;
if (mountPoint == null) {
transactionChain = this.transactionChainHandler.get();
transactionChain = transactionChainOfMountPoint(mountPoint);
}
- final TransactionVarsWrapper transactionNode = new TransactionVarsWrapper(instanceIdentifier, mountPoint,
- transactionChain);
- final NormalizedNode<?, ?> node = ReadDataTransactionUtil.readData(value, transactionNode);
+ final TransactionVarsWrapper transactionNode = new TransactionVarsWrapper(
+ instanceIdentifier, mountPoint, transactionChain);
+ final NormalizedNode<?, ?> node = ReadDataTransactionUtil.readData(parameters.getContent(), transactionNode);
if (node == null) {
throw new RestconfDocumentedException(
"Request could not be completed because the relevant data model content does not exist",
+ node.getNodeType().getLocalName() + '"';
final Response resp;
- if ((value == null) || value.contains(RestconfDataServiceConstant.ReadData.CONFIG)) {
- resp = Response.status(200).entity(new NormalizedNodeContext(instanceIdentifier, node)).header("ETag", etag)
- .header("Last-Modified", dateFormatGmt.format(new Date())).build();
+ if ((parameters.getContent().equals(RestconfDataServiceConstant.ReadData.ALL))
+ || parameters.getContent().equals(RestconfDataServiceConstant.ReadData.CONFIG)) {
+ resp = Response.status(200)
+ .entity(new NormalizedNodeContext(instanceIdentifier, node, parameters))
+ .header("ETag", etag)
+ .header("Last-Modified", dateFormatGmt.format(new Date()))
+ .build();
} else {
- resp = Response.status(200).entity(new NormalizedNodeContext(instanceIdentifier, node)).build();
+ resp = Response.status(200)
+ .entity(new NormalizedNodeContext(instanceIdentifier, node, parameters))
+ .build();
}
+
return resp;
}