+ @Override
+ public NormalizedNodeContext invokeRpc(final String identifier, final String noPayload, final UriInfo uriInfo) {
+ if (noPayload != null && !CharMatcher.WHITESPACE.matchesAllOf(noPayload)) {
+ throw new RestconfDocumentedException("Content must be empty.", ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
+ }
+
+ String identifierEncoded = null;
+ DOMMountPoint mountPoint = null;
+ final SchemaContext schemaContext;
+ if (identifier.contains(ControllerContext.MOUNT)) {
+ // mounted RPC call - look up mount instance.
+ final InstanceIdentifierContext<?> mountPointId = this.controllerContext.toMountPointIdentifier(identifier);
+ mountPoint = mountPointId.getMountPoint();
+ schemaContext = mountPoint.getSchemaContext();
+ final int startOfRemoteRpcName =
+ identifier.lastIndexOf(ControllerContext.MOUNT) + ControllerContext.MOUNT.length() + 1;
+ final String remoteRpcName = identifier.substring(startOfRemoteRpcName);
+ identifierEncoded = remoteRpcName;
+
+ } else if (identifier.indexOf("/") != CHAR_NOT_FOUND) {
+ final String slashErrorMsg = String.format(
+ "Identifier %n%s%ncan\'t contain slash "
+ + "character (/).%nIf slash is part of identifier name then use %%2F placeholder.",
+ identifier);
+ LOG.debug(slashErrorMsg);
+ throw new RestconfDocumentedException(slashErrorMsg, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE);
+ } else {
+ identifierEncoded = identifier;
+ schemaContext = this.controllerContext.getGlobalSchema();
+ }
+
+ final String identifierDecoded = this.controllerContext.urlPathArgDecode(identifierEncoded);
+
+ RpcDefinition rpc = null;
+ if (mountPoint == null) {
+ rpc = this.controllerContext.getRpcDefinition(identifierDecoded, null);
+ } else {
+ rpc = findRpc(mountPoint.getSchemaContext(), identifierDecoded);
+ }
+
+ if (rpc == null) {
+ LOG.debug("RPC " + identifierDecoded + " does not exist.");
+ throw new RestconfDocumentedException("RPC does not exist.", ErrorType.RPC, ErrorTag.UNKNOWN_ELEMENT);
+ }
+
+ if (!rpc.getInput().getChildNodes().isEmpty()) {
+ LOG.debug("RPC " + rpc + " does not need input value.");
+ // FIXME : find a correct Error from specification
+ throw new IllegalStateException("RPC " + rpc + " does'n need input value!");
+ }
+
+ final CheckedFuture<DOMRpcResult, DOMRpcException> response;
+ if (mountPoint != null) {
+ final Optional<DOMRpcService> mountRpcServices = mountPoint.getService(DOMRpcService.class);
+ if (!mountRpcServices.isPresent()) {
+ throw new RestconfDocumentedException("Rpc service is missing.");
+ }
+ response = mountRpcServices.get().invokeRpc(rpc.getPath(), null);
+ } else {
+ response = this.broker.invokeRpc(rpc.getPath(), null);
+ }
+
+ final DOMRpcResult result = checkRpcResponse(response);
+
+ return new NormalizedNodeContext(new InstanceIdentifierContext<>(null, rpc, mountPoint, schemaContext),
+ result.getResult(), QueryParametersParser.parseWriterParameters(uriInfo));
+ }
+