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