use of org.opendaylight.yangtools.yang.common.RpcError in project controller by opendaylight.
the class MdsalLowLevelTestProvider method unregisterSingletonConstant.
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public Future<RpcResult<Void>> unregisterSingletonConstant() {
LOG.debug("unregister-singleton-constant");
if (getSingletonConstantRegistration == null) {
LOG.debug("No get-singleton-constant registration present.");
final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "missing-registration", "No get-singleton-constant rpc registration present.");
final RpcResult<Void> result = RpcResultBuilder.<Void>failed().withRpcError(rpcError).build();
return Futures.immediateFuture(result);
}
try {
getSingletonConstantRegistration.close();
getSingletonConstantRegistration = null;
return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
} catch (Exception e) {
LOG.debug("There was a problem closing the singleton constant service", e);
final RpcError rpcError = RpcResultBuilder.newError(ErrorType.APPLICATION, "error-closing", "There was a problem closing get-singleton-constant");
final RpcResult<Void> result = RpcResultBuilder.<Void>failed().withRpcError(rpcError).build();
return Futures.immediateFuture(result);
}
}
use of org.opendaylight.yangtools.yang.common.RpcError in project controller by opendaylight.
the class MdsalLowLevelTestProvider method registerSingletonConstant.
@Override
public Future<RpcResult<Void>> registerSingletonConstant(final RegisterSingletonConstantInput input) {
LOG.debug("Received register-singleton-constant rpc, input: {}", input);
if (input.getConstant() == null) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Invalid input.", "Constant value is null");
return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
}
getSingletonConstantRegistration = SingletonGetConstantService.registerNew(singletonService, domRpcService, input.getConstant());
return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
use of org.opendaylight.yangtools.yang.common.RpcError in project controller by opendaylight.
the class MdsalLowLevelTestProvider method subscribeDtcl.
@Override
public Future<RpcResult<Void>> subscribeDtcl() {
if (dtclReg != null) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Registration present.", "There is already dataTreeChangeListener registered on id-ints list.");
return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
}
idIntsListener = new IdIntsListener();
dtclReg = domDataTreeChangeService.registerDataTreeChangeListener(new org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier(CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID), idIntsListener);
return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
use of org.opendaylight.yangtools.yang.common.RpcError in project controller by opendaylight.
the class MdsalLowLevelTestProvider method registerConstant.
@Override
public Future<RpcResult<Void>> registerConstant(final RegisterConstantInput input) {
LOG.debug("Received register-constant rpc, input: {}", input);
if (input.getConstant() == null) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Invalid input.", "Constant value is null");
return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
}
if (globalGetConstantRegistration != null) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Registration present.", "There is already a get-constant rpc registered.");
return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
}
globalGetConstantRegistration = GetConstantService.registerNew(domRpcService, input.getConstant());
return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
use of org.opendaylight.yangtools.yang.common.RpcError in project controller by opendaylight.
the class MdsalLowLevelTestProvider method registerBoundConstant.
@Override
public Future<RpcResult<Void>> registerBoundConstant(final RegisterBoundConstantInput input) {
LOG.debug("register-bound-constant: {}", input);
if (input.getContext() == null) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Invalid input.", "Context value is null");
return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
}
if (input.getConstant() == null) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Invalid input.", "Constant value is null");
return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
}
if (routedRegistrations.containsKey(input.getContext())) {
final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Registration present.", "There is already a rpc registered for context: " + input.getContext());
return Futures.immediateFuture(RpcResultBuilder.<Void>failed().withRpcError(error).build());
}
final DOMRpcImplementationRegistration<RoutedGetConstantService> rpcRegistration = RoutedGetConstantService.registerNew(bindingNormalizedNodeSerializer, domRpcService, input.getConstant(), input.getContext());
routedRegistrations.put(input.getContext(), rpcRegistration);
return Futures.immediateFuture(RpcResultBuilder.<Void>success().build());
}
Aggregations