/// <summary> /// Processes a POST operation /// </summary> /// <param name="context">HTTP Context</param> public override void ProcessPost(IHttpContext context) { // Get the payload assuming there is one IGraph g = ParsePayload(context); if (g == null) { // Q: What should the behaviour be when the payload is null for a POST? Assuming a 200 OK response return; } // Get the Graph URI of the Graph to be added Uri graphUri = ResolveGraphUri(context, g); // First we need a // Generate an INSERT DATA command for the POST StringBuilder insert = new StringBuilder(); if (graphUri != null) { insert.AppendLine("INSERT DATA { GRAPH @graph {"); } else { insert.AppendLine("INSERT DATA {"); } TurtleFormatter formatter = new TurtleFormatter(g.NamespaceMap); foreach (Triple t in g.Triples) { insert.AppendLine(t.ToString(formatter)); } if (graphUri != null) { insert.AppendLine("} }"); } else { insert.AppendLine("}"); } // Parse and evaluate the command SparqlParameterizedString insertCmd = new SparqlParameterizedString(insert.ToString()); insertCmd.Namespaces = g.NamespaceMap; if (graphUri != null) { insertCmd.SetUri("graph", graphUri); } SparqlUpdateCommandSet cmds = _parser.ParseFromString(insertCmd); _updateProcessor.ProcessCommandSet(cmds); _updateProcessor.Flush(); }