1 package org.opendaylight.controller.sal.restconf.impl
3 import org.opendaylight.controller.md.sal.common.api.data.DataReader
5 import org.opendaylight.yangtools.yang.data.api.CompositeNode
6 import org.opendaylight.controller.sal.core.api.data.DataBrokerService
7 import org.opendaylight.controller.sal.core.api.model.SchemaService
8 import static com.google.common.base.Preconditions.*;
9 import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession
10 import org.opendaylight.yangtools.yang.common.RpcResult
11 import org.opendaylight.controller.md.sal.common.api.data.DataModificationTransactionFactory
13 class BrokerFacade implements DataReader<String, CompositeNode> {
16 private ConsumerSession context;
19 private DataBrokerService dataService;
22 private SchemaService schemaService;
25 private extension ControllerContext schemaContext;
29 checkState(dataService !== null)
30 checkState(schemaService !== null)
31 schemaContext = new ControllerContext();
32 schemaContext.schemas = schemaService.globalContext;
35 override readConfigurationData(String path) {
36 val processedPath = path.removePrefixes();
37 return dataService.readConfigurationData(processedPath.toInstanceIdentifier);
40 override readOperationalData(String path) {
41 val processedPath = path.removePrefixes();
42 return dataService.readOperationalData(processedPath.toInstanceIdentifier);
45 def RpcResult<CompositeNode> invokeRpc(String type,CompositeNode payload) {
46 val future = context.rpc(type.toRpcQName(),payload);
50 def commitConfigurationDataUpdate(String path, CompositeNode payload) {
51 val transaction = dataService.beginTransaction;
52 transaction.putConfigurationData(path.toInstanceIdentifier,payload);
53 return transaction.commit()
56 def commitConfigurationDataCreate(String path, CompositeNode payload) {
57 val transaction = dataService.beginTransaction;
58 transaction.putConfigurationData(path.toInstanceIdentifier,payload);
59 return transaction.commit()
62 private def String removePrefixes(String path) {