Mercurial > hg > eSciDocImport
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c6929e63b0b8 |
---|---|
1 package de.mpiwg.itgroup.eSciDoc.Tools; | |
2 import java.io.File; | |
3 import java.io.FileWriter; | |
4 import java.io.IOException; | |
5 import java.net.MalformedURLException; | |
6 import java.net.URL; | |
7 | |
8 import org.apache.http.HttpResponse; | |
9 import org.apache.http.client.ClientProtocolException; | |
10 | |
11 | |
12 public class SendFileToeSciDoc { | |
13 | |
14 | |
15 //private static final String ESCIDOC_SERVER = "xserve07.mpiwg-berlin.mpg.de"; | |
16 private static final String ESCIDOC_SERVER = "escidoc-test.mpiwg-berlin.mpg.de"; | |
17 | |
18 /** | |
19 * @param args | |
20 * @throws IOException | |
21 * @throws IllegalStateException | |
22 */ | |
23 | |
24 public static void main(String[] args) throws IllegalStateException, IOException { | |
25 if (args.length<4){ | |
26 System.out.println("Usage: sendfile command urlOfFile user password"); | |
27 return; | |
28 } | |
29 | |
30 EScidocBasicHandler handler = new EScidocBasicHandler(ESCIDOC_SERVER,8080,args[2],args[3]); | |
31 URL url; | |
32 HttpResponse ret; | |
33 try { | |
34 url = new URL(args[1]); | |
35 } catch (MalformedURLException e) { | |
36 | |
37 e.printStackTrace(); | |
38 return; | |
39 } | |
40 try { | |
41 ret = handler.eScidocPut(args[0], url); | |
42 } catch (ClientProtocolException e) { | |
43 // TODO Auto-generated catch block | |
44 e.printStackTrace(); | |
45 return; | |
46 } catch (IOException e) { | |
47 // TODO Auto-generated catch block | |
48 e.printStackTrace(); | |
49 return; | |
50 } | |
51 | |
52 System.out.println(ret.getStatusLine()); | |
53 String outTXT = EScidocBasicHandler.convertStreamToString(ret.getEntity().getContent()); | |
54 System.out.println(outTXT); | |
55 | |
56 // File nf = new File("/tmp/out.log"); | |
57 // FileWriter fw = new FileWriter(nf); | |
58 // fw.append(outTXT); | |
59 // fw.close(); | |
60 | |
61 | |
62 | |
63 } | |
64 | |
65 } |