Mercurial > hg > eSciDocImport
view src/de/mpiwg/itgroup/eSciDoc/Tools/SendFileToeSciDoc.java @ 0:c6929e63b0b8
first import
author | dwinter |
---|---|
date | Wed, 24 Nov 2010 16:52:07 +0100 |
parents | |
children | a844f6948dd8 |
line wrap: on
line source
package de.mpiwg.itgroup.eSciDoc.Tools; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; public class SendFileToeSciDoc { //private static final String ESCIDOC_SERVER = "xserve07.mpiwg-berlin.mpg.de"; private static final String ESCIDOC_SERVER = "escidoc-test.mpiwg-berlin.mpg.de"; /** * @param args * @throws IOException * @throws IllegalStateException */ public static void main(String[] args) throws IllegalStateException, IOException { if (args.length<4){ System.out.println("Usage: sendfile command urlOfFile user password"); return; } EScidocBasicHandler handler = new EScidocBasicHandler(ESCIDOC_SERVER,8080,args[2],args[3]); URL url; HttpResponse ret; try { url = new URL(args[1]); } catch (MalformedURLException e) { e.printStackTrace(); return; } try { ret = handler.eScidocPut(args[0], url); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); return; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return; } System.out.println(ret.getStatusLine()); String outTXT = EScidocBasicHandler.convertStreamToString(ret.getEntity().getContent()); System.out.println(outTXT); // File nf = new File("/tmp/out.log"); // FileWriter fw = new FileWriter(nf); // fw.append(outTXT); // fw.close(); } }