/// <summary> /// Applies the handler mappings /// </summary> /// <param name="g">Graph</param> /// <param name="handlers">Handlers Collection</param> private void ApplyHandlerMappings(IGraph g, IHttpListenerHandlerCollection handlers) { INode rdfType = g.CreateUriNode(UriFactory.Create(RdfSpecsHelper.RdfType)); INode httpHandler = g.CreateUriNode(UriFactory.Create(ConfigurationLoader.ClassHttpHandler)); INode dnrType = g.CreateUriNode(UriFactory.Create(ConfigurationLoader.PropertyType)); foreach (Triple t in g.GetTriplesWithPredicateObject(rdfType, httpHandler)) { INode pathNode = t.Subject; if (pathNode.NodeType == NodeType.Uri) { Uri pathUri = ((IUriNode)pathNode).Uri; if (pathUri.Scheme.Equals("dotnetrdf")) { // Check declared handler type INode handlerType = g.GetTriplesWithSubjectPredicate(pathNode, dnrType).Select(x => x.Object).FirstOrDefault(); if (handlerType != null) { if (handlerType.NodeType != NodeType.Literal) { throw new DotNetRdfConfigurationException("The dnr:type given for the <" + pathUri + "> handler declaration must be a literal node"); } String typeStr = ((ILiteralNode)handlerType).Value; if (!typeStr.StartsWith("VDS.RDF.Web.SparqlServer")) { throw new DotNetRdfConfigurationException("rdfServer only supports HTTP handlers of type VDS.RDF.Web.SparqlServer, the declared type " + typeStr + " is not supported"); } } String path = pathUri.AbsoluteUri.Substring(10); if (!path.EndsWith("/*")) { throw new DotNetRdfConfigurationException("The path given for a HTTP handler via the <" + pathUri + "> URI must end with /* as SPARQL Servers listen on wildcard paths"); } handlers.AddMapping(new HttpRequestMapping(HttpRequestMapping.AllVerbs, path, typeof(SparqlServerHandler))); } } else { continue; } } }
/// <summary> /// Applies the handler mappings /// </summary> /// <param name="g">Graph</param> /// <param name="handlers">Handlers Collection</param> private void ApplyHandlerMappings(IGraph g, IHttpListenerHandlerCollection handlers) { INode rdfType = g.CreateUriNode(UriFactory.Create(RdfSpecsHelper.RdfType)); INode httpHandler = g.CreateUriNode(UriFactory.Create(ConfigurationLoader.ClassHttpHandler)); foreach (Triple t in g.GetTriplesWithPredicateObject(rdfType, httpHandler)) { INode pathNode = t.Subject; if (pathNode.NodeType == NodeType.Uri) { Uri pathUri = ((IUriNode)pathNode).Uri; if (pathUri.Scheme.Equals("dotnetrdf")) { String path = pathUri.AbsoluteUri.Substring(10); handlers.AddMapping(new HttpRequestMapping(HttpRequestMapping.AllVerbs, path, typeof(SparqlServerHandler))); } } else { continue; } } }