X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2FBrokerFacade.xtend;h=c57505829c5bde05dffbfda95ad8d21c3ac1ba26;hp=eb1f6165ca23c5bb17deac73f575a06bfc57fc57;hb=7bea173bf1c3c27d5fa366b25a0f83879105c56d;hpb=312e38ea16a563e630b59f12c8459bce8b743eb5 diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.xtend index eb1f6165ca..c57505829c 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.xtend +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/BrokerFacade.xtend @@ -1,6 +1,5 @@ package org.opendaylight.controller.sal.restconf.impl -import javax.ws.rs.WebApplicationException import javax.ws.rs.core.Response import org.opendaylight.controller.md.sal.common.api.data.DataReader import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession @@ -10,9 +9,13 @@ import org.opendaylight.yangtools.yang.common.QName import org.opendaylight.yangtools.yang.common.RpcResult import org.opendaylight.yangtools.yang.data.api.CompositeNode import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier +import org.slf4j.LoggerFactory +import org.opendaylight.controller.sal.core.api.mount.MountInstance class BrokerFacade implements DataReader { + + val static LOG = LoggerFactory.getLogger(BrokerFacade) val static BrokerFacade INSTANCE = new BrokerFacade @Property @@ -33,20 +36,33 @@ class BrokerFacade implements DataReader { private def void checkPreconditions() { if (context === null || dataService === null) { - throw new WebApplicationException(Response.status(Response.Status.SERVICE_UNAVAILABLE) - .entity(RestconfProvider::NOT_INITALIZED_MSG).build()) + throw new ResponseException(Response.Status.SERVICE_UNAVAILABLE, RestconfProvider::NOT_INITALIZED_MSG) } } override readConfigurationData(InstanceIdentifier path) { checkPreconditions + LOG.info("Read Configuration via Restconf: {}", path) return dataService.readConfigurationData(path); } + + def readConfigurationDataBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path) { + checkPreconditions + LOG.info("Read Configuration via Restconf: {}", path) + return mountPoint.readConfigurationData(path); + } override readOperationalData(InstanceIdentifier path) { checkPreconditions + LOG.info("Read Operational via Restconf: {}", path) return dataService.readOperationalData(path); } + + def readOperationalDataBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path) { + checkPreconditions + LOG.info("Read Operational via Restconf: {}", path) + return mountPoint.readOperationalData(path); + } def RpcResult invokeRpc(QName type, CompositeNode payload) { checkPreconditions @@ -57,15 +73,55 @@ class BrokerFacade implements DataReader { def commitConfigurationDataPut(InstanceIdentifier path, CompositeNode payload) { checkPreconditions val transaction = dataService.beginTransaction; + LOG.info("Put Configuration via Restconf: {}", path) transaction.putConfigurationData(path, payload); - return transaction.commit() + return transaction.commit + } + + def commitConfigurationDataPutBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path, CompositeNode payload) { + checkPreconditions + val transaction = mountPoint.beginTransaction; + LOG.info("Put Configuration via Restconf: {}", path) + transaction.putConfigurationData(path, payload); + return transaction.commit } - def commitOperationalDataPut(InstanceIdentifier path, CompositeNode payload) { + def commitConfigurationDataPost(InstanceIdentifier path, CompositeNode payload) { checkPreconditions val transaction = dataService.beginTransaction; - transaction.putOperationalData(path, payload); - return transaction.commit() + transaction.putConfigurationData(path, payload); + if (payload == transaction.createdConfigurationData.get(path)) { + LOG.info("Post Configuration via Restconf: {}", path) + return transaction.commit + } + LOG.info("Post Configuration via Restconf was not executed because data already exists: {}", path) + return null; } + def commitConfigurationDataPostBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path, CompositeNode payload) { + checkPreconditions + val transaction = mountPoint.beginTransaction; + transaction.putConfigurationData(path, payload); + if (payload == transaction.createdConfigurationData.get(path)) { + LOG.info("Post Configuration via Restconf: {}", path) + return transaction.commit + } + LOG.info("Post Configuration via Restconf was not executed because data already exists: {}", path) + return null; + } + + def commitConfigurationDataDelete(InstanceIdentifier path) { + checkPreconditions + val transaction = dataService.beginTransaction; + transaction.removeConfigurationData(path) + return transaction.commit + } + + def commitConfigurationDataDeleteBehindMountPoint(MountInstance mountPoint, InstanceIdentifier path) { + checkPreconditions + val transaction = mountPoint.beginTransaction; + transaction.removeConfigurationData(path) + return transaction.commit + } + }