[Mulgara-general] load RDF/XML post

Chuck Borromeo cborromeo3 at yahoo.com
Tue Oct 27 14:51:28 UTC 2009


[Using Mulgara 2.1.4 binary dist]

Hello,
  I have developed some Java code to load an RDF file using Http POST.  I have been able to load over 30 RDF files using this method.  However, one of the files I attempt to load does not insert its data into the graph.  The URL for the problematic file is:

http://hsresweb01.ucdmc.ucdavis.edu/RDF/UCSanFrancisco.rdf
My code does not throw any error message.  I cannot find any errors in any of the mulgara logs files or the itql file.  I have opened the RDF file in the W3C RDF validator and the file appears valid.  Here are some files that load successfully:

http://hsresweb01.ucdmc.ucdavis.edu/RDF/UWisconsinMadison.rdf
http://hsresweb01.ucdmc.ucdavis.edu/RDF/Duke.rdf
Here is my code (adapted from Paul Gearon) :
    public String loadRDF(URL rdfURL, String graphname) {
        HttpClient client = new DefaultHttpClient();

        HttpPost post = new HttpPost(generateServerName());

        client.getParams().setBooleanParameter(
                CoreProtocolPNames.USE_EXPECT_CONTINUE, false);

        try {
            createGraph(graphname);
            String data = "";
            InputStream is = rdfURL.openStream();
            data = convertStreamToString(is);
            MultipartEntity e = new MultipartEntity();
            e.addPart("default-graph-uri", new StringBody(graphname));
            e.addPart("data", new Body(data, rdfURL.toString(), Charset
                    .forName("UTF-8")));
            post.setEntity(e);

            HttpResponse response = client.execute((HttpUriRequest) post);
            StatusLine status = response.getStatusLine();
            System.out.println("code: " + status.getStatusCode() + ": "
                    + status.getReasonPhrase());
            HttpEntity entity = response.getEntity();

            if (entity != null) {
                InputStream instream = entity.getContent();
                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(instream));
                System.out.println("Got response:");
                String line;
                while ((line = reader.readLine()) != null)
                    System.out.println(line);
            } else {
                System.out.println("No entity in response");
            }
            System.out.println("Done loading file");
        } catch (UnsupportedEncodingException e) {
            System.err.println("Unable to encode data: " + e.getMessage());
        } catch (ClientProtocolException cpe) {
            System.err.println("Error in protocol: " + cpe.getMessage());
        } catch (IOException ioe) {
            System.err.println("Error executing POST: " + ioe.getMessage());
        } catch (Exception ge) {
            System.err.println("Error executing load rdf: " + ge.getMessage());
            
        }

        return "";
    }


Is there some logging to turn on to capture more information from mulgara?
Thanks,
Chuck



      



More information about the Mulgara-general mailing list