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%2Frpc%2Fimpl%2FMountPointRpcExecutor.java;h=efb3e0a1d3924d914afe4dcc286ad783d94de8e0;hp=da19a0034de26103afd793e0ebb4a5d002f3bffa;hb=43f89a73d733c3c43a875b3724b5a68470894450;hpb=ec82a960337ba51c2e896863a668dcf8fbcfcb6b diff --git a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/rpc/impl/MountPointRpcExecutor.java b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/rpc/impl/MountPointRpcExecutor.java index da19a0034d..efb3e0a1d3 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/rpc/impl/MountPointRpcExecutor.java +++ b/opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/rpc/impl/MountPointRpcExecutor.java @@ -1,37 +1,43 @@ /* -* Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. -* -* This program and the accompanying materials are made available under the -* terms of the Eclipse Public License v1.0 which accompanies this distribution, -* and is available at http://www.eclipse.org/legal/epl-v10.html -*/ + * Copyright (c) 2014 Brocade Communications Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.sal.restconf.rpc.impl; -import org.opendaylight.controller.sal.core.api.mount.MountInstance; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import java.util.concurrent.Future; +import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint; +import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; -import com.google.common.base.Preconditions; - /** * Provides an implementation which invokes rpc methods via a mounted yang data model. + * * @author Devin Avery * */ public class MountPointRpcExecutor extends AbstractRpcExecutor { - private final MountInstance mountPoint; + private final DOMMountPoint mountPoint; - public MountPointRpcExecutor(RpcDefinition rpcDef, MountInstance mountPoint) { - super( rpcDef ); + public MountPointRpcExecutor(RpcDefinition rpcDef, DOMMountPoint mountPoint) { + super(rpcDef); this.mountPoint = mountPoint; - Preconditions.checkNotNull( mountPoint, "MountInstance can not be null." ); + Preconditions.checkNotNull(mountPoint, "MountInstance can not be null."); } @Override - public RpcResult invokeRpc( CompositeNode rpcRequest ) - throws RestconfDocumentedException { - return getRpcResult( mountPoint.rpc( getRpcDefinition().getQName(), rpcRequest ) ); + protected Future> invokeRpcUnchecked(CompositeNode rpcRequest) { + Optional service = mountPoint.getService(RpcProvisionRegistry.class); + if (service.isPresent()) { + return service.get().invokeRpc(getRpcDefinition().getQName(), rpcRequest); + } + throw new RestconfDocumentedException("Rpc service is missing."); } } \ No newline at end of file