@Override public QName getQName() { return delegate.getQName(); }
@Override public boolean apply(final RpcDefinition input) { return input.getQName().getLocalName().equals(CreateSubscription.CREATE_SUBSCRIPTION); } }), null);
private Optional<RpcDefinition> getRpcDefinitionFromModule(Module module, URI namespaceURI, String name) { for (RpcDefinition rpcDef : module.getRpcs()) { if (rpcDef.getQName().getNamespace().equals(namespaceURI) && rpcDef.getQName().getLocalName().equals(name)) { return Optional.of(rpcDef); } } return Optional.absent(); }
private Optional<RpcDefinition> getRpcDefinitionFromModule(Module module, URI namespaceURI, String name) { for (RpcDefinition rpcDef : module.getRpcs()) { if (rpcDef.getQName().getNamespace().equals(namespaceURI) && rpcDef.getQName().getLocalName().equals(name)) { return Optional.of(rpcDef); } } return Optional.absent(); }
@Override public void onGlobalContextUpdated(SchemaContext schemaContext) { if (schemaContext != null) { final Collection<RpcDefinition> defs = schemaContext.getOperations(); final Map<QName, RpcDefinition> newMap = new HashMap<>(defs.size()); for (final RpcDefinition operation : defs) { newMap.put(operation.getQName(), operation); } // FIXME: still not completely atomic qnameToRpc.set(ImmutableMap.copyOf(newMap)); setGlobalSchema(schemaContext); } }
@Override public void onGlobalContextUpdated(final SchemaContext context) { if (context != null) { final Collection<RpcDefinition> defs = context.getOperations(); final Map<QName, RpcDefinition> newMap = new HashMap<>(defs.size()); for (final RpcDefinition operation : defs) { newMap.put(operation.getQName(), operation); } // FIXME: still not completely atomic qnameToRpc.set(ImmutableMap.copyOf(newMap)); setGlobalSchema(context); } }
private static Optional<DataNodeContainer> findInputOutput(final RpcDefinition rpc, final String targetType) { final String rpcName = BindingMapping.getClassName(rpc.getQName()); final String rpcInputName = rpcName + BindingMapping.RPC_INPUT_SUFFIX; if (targetType.equals(rpcInputName)) { return Optional.of(rpc.getInput()); } final String rpcOutputName = rpcName + BindingMapping.RPC_OUTPUT_SUFFIX; if (targetType.equals(rpcOutputName)) { return Optional.of(rpc.getOutput()); } return Optional.empty(); }
private static Optional<DataNodeContainer> findInputOutput(final RpcDefinition rpc, final String targetType) { String rpcName = BindingMapping.getClassName(rpc.getQName()); String rpcInputName = rpcName + BindingMapping.RPC_INPUT_SUFFIX; String rpcOutputName = rpcName + BindingMapping.RPC_OUTPUT_SUFFIX; if(targetType.equals(rpcInputName)) { return Optional.<DataNodeContainer>of(rpc.getInput()); } else if (targetType.equals(rpcOutputName)) { return Optional.<DataNodeContainer>of(rpc.getOutput()); } return Optional.absent(); }
private static RpcDefinition getRpcByName(final Module module, final QName name) { for (final RpcDefinition rpc : module.getRpcs()) { if (rpc.getQName().equals(name)) { return rpc; } } return null; }
private static RpcDefinition getRpcByName(final Module module, final QName name) { for (final RpcDefinition rpc : module.getRpcs()) { if (rpc.getQName().equals(name)) { return rpc; } } return null; }
public static RpcRoutingStrategy from(final RpcDefinition rpc) { ContainerSchemaNode input = rpc.getInput(); if (input != null) { for (DataSchemaNode schemaNode : input.getChildNodes()) { Optional<QName> context = getRoutingContext(schemaNode); if (context.isPresent()) { return new RoutedRpcStrategy(rpc.getQName(), context.get(), schemaNode.getQName()); } } } return new GlobalRpcStrategy(rpc.getQName()); }
public static RpcRoutingStrategy from(final RpcDefinition rpc) { ContainerSchemaNode input = rpc.getInput(); if (input != null) { for (DataSchemaNode schemaNode : input.getChildNodes()) { Optional<QName> context = getRoutingContext(schemaNode); if (context.isPresent()) { return new RoutedRpcStrategy(rpc.getQName(), context.get(), schemaNode.getQName()); } } } return new GlobalRpcStrategy(rpc.getQName()); }
public static RpcRoutingStrategy from(final RpcDefinition rpc) { for (DataSchemaNode schemaNode : rpc.getInput().getChildNodes()) { Optional<QName> context = getRoutingContext(schemaNode); if (context.isPresent()) { return new RoutedRpcStrategy(rpc.getQName(), context.get(), schemaNode.getQName()); } } return new GlobalRpcStrategy(rpc.getQName()); }
private static RpcDefinition findRpc(final SchemaContext schemaContext, final String identifierDecoded) { final String[] splittedIdentifier = identifierDecoded.split(":"); if (splittedIdentifier.length != 2) { final String errMsg = identifierDecoded + " couldn't be splitted to 2 parts (module:rpc name)"; LOG.debug(errMsg); throw new RestconfDocumentedException(errMsg, ErrorType.APPLICATION, ErrorTag.INVALID_VALUE); } for (final Module module : schemaContext.getModules()) { if (module.getName().equals(splittedIdentifier[0])) { for (final RpcDefinition rpcDefinition : module.getRpcs()) { if (rpcDefinition.getQName().getLocalName().equals(splittedIdentifier[1])) { return rpcDefinition; } } } } return null; }
private Method findRpcMethod(final Class<? extends RpcService> key, final RpcDefinition rpcDef) throws NoSuchMethodException { final String methodName = BindingMapping.getMethodName(rpcDef.getQName()); if(rpcDef.getInput() != null) { final Class<?> inputClz = runtimeContext().getClassForSchema(rpcDef.getInput()); return key.getMethod(methodName, inputClz); } return key.getMethod(methodName); }
private Method findRpcMethod(final Class<? extends RpcService> key, final RpcDefinition rpcDef) throws NoSuchMethodException { final String methodName = BindingMapping.getMethodName(rpcDef.getQName()); final Class<?> inputClz = runtimeContext().getClassForSchema(rpcDef.getInput()); return key.getMethod(methodName, inputClz); }
private void emitRpc(final RpcDefinition rpc) { super.writer.startRpcNode(rpc.getQName()); emitOperationBody(rpc); super.writer.endNode(); }
ContainerNodeCodecContext<?> createRpcDataContext(final Class<?> key) { checkArgument(DataContainer.class.isAssignableFrom(key)); final QName qname = BindingReflections.findQName(key); final QNameModule qnameModule = qname.getModule(); final Module module = getSchema().findModule(qnameModule) .orElseThrow(() -> new IllegalArgumentException("Failed to find module for " + qnameModule)); final String className = BindingMapping.getClassName(qname); for (final RpcDefinition potential : module.getRpcs()) { final QName potentialQName = potential.getQName(); /* * Check if rpc and class represents data from same module and then checks if rpc local name produces same * class name as class name appended with Input/Output based on QName associated with binding class. * * FIXME: Rework this to have more precise logic regarding Binding Specification. */ if (key.getSimpleName().equals(BindingMapping.getClassName(potentialQName) + className)) { final ContainerSchemaNode schema = SchemaNodeUtils.getRpcDataSchema(potential, qname); checkArgument(schema != null, "Schema for %s does not define input / output.", potential.getQName()); return (ContainerNodeCodecContext<?>) DataContainerCodecPrototype.from(key, schema, factory()).get(); } } throw new IllegalArgumentException("Supplied class " + key + " is not valid RPC class."); }
@SuppressWarnings("checkstyle:illegalCatch") private static Optional<DataNodeContainer> findFirstDataNodeContainerInRpc(final SchemaContext ctx, final Class<? extends DataObject> targetType) { final QNameModule targetModule; try { targetModule = BindingReflections.getModuleInfo(targetType).getName().getModule(); } catch (Exception e) { throw new IllegalArgumentException( String.format("Failed to load module information for class %s", targetType), e); } for (RpcDefinition rpc : ctx.getOperations()) { if (targetModule.equals(rpc.getQName().getModule())) { final Optional<DataNodeContainer> potential = findInputOutput(rpc,targetType.getSimpleName()); if (potential.isPresent()) { return potential; } } } return Optional.empty(); }
private static RpcDefinition findRpcDefinition(final SchemaContext context, final SchemaPath schemaPath) { if (context != null) { final QName qname = schemaPath.getPathFromRoot().iterator().next(); final Module module = context.findModuleByNamespaceAndRevision(qname.getNamespace(), qname.getRevision()); if (module != null && module.getRpcs() != null) { for (RpcDefinition rpc : module.getRpcs()) { if (qname.equals(rpc.getQName())) { return rpc; } } } } return null; }