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%2FRestconfImpl.xtend;h=fc0dd1017fea6fbb9e77cd5f3b5a84d616b9e58f;hp=0b0ebc592259b5c89a8fb29ff9a2c9026b9d95a9;hb=b5daa3678322a764f9b0e2483f82781f4d39d263;hpb=530f16aabf749e45477e8467d73ad0921fc7bb99 diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend index 0b0ebc5922..fc0dd1017f 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend @@ -1,29 +1,31 @@ package org.opendaylight.controller.sal.restconf.impl -import org.opendaylight.controller.sal.core.api.model.SchemaService import org.opendaylight.yangtools.yang.data.api.CompositeNode - -import static com.google.common.base.Preconditions.* +import org.opendaylight.controller.sal.rest.api.RestconfService class RestconfImpl implements RestconfService { + + val static RestconfImpl INSTANCE = new RestconfImpl @Property BrokerFacade broker @Property extension ControllerContext controllerContext - - val JsonMapper jsonMapper = new JsonMapper; - - def init(SchemaService schemaService) { - checkState(broker !== null) - checkState(controllerContext !== null) - checkState(schemaService !== null) - controllerContext.schemas = schemaService.globalContext + + private new() { + if (INSTANCE != null) { + throw new IllegalStateException("Already instantiated"); + } + } + + static def getInstance() { + return INSTANCE } override readAllData() { - return broker.readOperationalData("".removePrefixes.toInstanceIdentifier.getInstanceIdentifier); +// return broker.readOperationalData("".toInstanceIdentifier.getInstanceIdentifier); + throw new UnsupportedOperationException("TODO: auto-generated method stub") } override getModules() { @@ -36,26 +38,24 @@ class RestconfImpl implements RestconfService { } override readData(String identifier) { - val instanceIdentifierWithSchemaNode = identifier.removePrefixes.toInstanceIdentifier + val instanceIdentifierWithSchemaNode = identifier.toInstanceIdentifier val data = broker.readOperationalData(instanceIdentifierWithSchemaNode.getInstanceIdentifier); - jsonMapper.convert(instanceIdentifierWithSchemaNode.getSchemaNode, data) + return new StructuredData(data, instanceIdentifierWithSchemaNode.schemaNode) } override createConfigurationData(String identifier, CompositeNode payload) { - return broker.commitConfigurationDataCreate(identifier.removePrefixes.toInstanceIdentifier.getInstanceIdentifier, payload); +// return broker.commitConfigurationDataCreate(identifier.toInstanceIdentifier.getInstanceIdentifier, payload); + throw new UnsupportedOperationException("TODO: auto-generated method stub") } override updateConfigurationData(String identifier, CompositeNode payload) { - return broker.commitConfigurationDataCreate(identifier.removePrefixes.toInstanceIdentifier.getInstanceIdentifier, payload); +// return broker.commitConfigurationDataCreate(identifier.toInstanceIdentifier.getInstanceIdentifier, payload); + throw new UnsupportedOperationException("TODO: auto-generated method stub") } override invokeRpc(String identifier, CompositeNode payload) { - val rpcResult = broker.invokeRpc(identifier.removePrefixes.toRpcQName, payload); - jsonMapper.convert(identifier.removePrefixes.toInstanceIdentifier.getSchemaNode, rpcResult.result); - } - - private def String removePrefixes(String path) { - return path; + val rpcResult = broker.invokeRpc(identifier.toRpcQName, payload); + return new StructuredData(rpcResult.result, identifier.toInstanceIdentifier.getSchemaNode) } }