Hi Sashikiran,

If the HttpURLconnection method does not allow authentication details to be 
passed which is required when inserting into DAV, then why not perform your 
inserts against the SPARQL  endpoint suitably setup to allow inserts as 
detailed at:

http://virtuoso.openlinksw.com/dataspace/dav/wiki/Main/VirtRDFInsert#SPARQL%20Insert%20via%20/sparql%20endpoint

Best Regards
Hugh Williams
Professional Services
OpenLink Software
Web: http://www.openlinksw.com
Support: http://support.openlinksw.com
Forums: http://boards.openlinksw.com/support
Twitter: http://twitter.com/OpenLink

On 18 Mar 2010, at 17:59, Rameswara Sashi Kiran Challa wrote:

> Hi
> 
> Apologies if I am not supposed to POST this here. If somebody has already 
> done this please help me to do this.
> 
> I am trying to post rdf files into Virtuoso using HttpURLconnection in Java. 
> I have my instance of virtuoso up and running.
> 
> Using curl, this is how I did it earlier from command line.
> 
> curl -i -T bio2rdfdemo.rdf 
> http://gf18.ucs.indiana.edu:8890/DAV/home/schalla/rdf_sink/bio2rdfdemo.rdf -u 
> "username:password"
> 
> Now I am trying to do it in Java
> 
> String rdfcontent = "";
> String response = "";
> HttpURLConnection con = null;
> try{
>    File rdffile = new 
> File("C:\\Users\\LaxmiR\\Desktop\\ORECHEM\\ATOMGRDDL\\bio2rdfdemo.rdf");
>    BufferedReader input =  new BufferedReader(new FileReader(rdffile));
>    String line =null;
>    while((line = input.readLine())!=null){
>       line = line +"\n";
>       rdfcontent = rdfcontent + line;
>    }
>   input.close();
>   String username = "username";
>   String password = "password";
>   Authenticator.setDefault(new SimpleAuthenticator(username,password));
>   con = (HttpURLConnection) new 
> URL("http://gf18.ucs.indiana.edu:8890/DAV/home/schalla/rdf_sink";).openConnection();
>    con.setRequestMethod("POST");
>    con.setDoOutput(true);
>    OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream());
>    out.write(rdfcontent);
>    out.close();
>                       
>   InputStream in = con.getInputStream();
>   BufferedReader rd = new BufferedReader(new InputStreamReader(in));
>   String line2;
>                      
>  while((line2 = rd.readLine()) != null) {
>        response = response + line2;
>                       //response.append('\r');
>   }
>   rd.close();
>                     
> }catch (IOException e) {
>       e.printStackTrace();
> }finally{
>       con.disconnect();
> }
> System.out.println(response);
> 
> 0) Am I using the correct URL to post into rdf_sink ??
> 1) Is Authenticator required for virtuoso ?
> 2) how do I do curl -u in Java, i.e. provide username and password.
> 3) I am actually Posting the string from a file, how do I directly POST the 
> file
> 
> Thanks in advance
> 
> Regards
> 
> 
> -- 
> Sashikiran Challa
> 
> 
> 
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev_______________________________________________
> Virtuoso-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/virtuoso-users

Reply via email to