Mercurial > hg > digilibservice
comparison client/src/main/java/info/textgrid/middleware/digilib/clients/cli/DigilibCli.java @ 7:39c4892724ae
new version with maven modules for service and client.
author | casties |
---|---|
date | Thu, 16 Jun 2011 17:33:06 +0200 |
parents | |
children | 99bd25677ba8 |
comparison
equal
deleted
inserted
replaced
6:913bc132ed96 | 7:39c4892724ae |
---|---|
1 /** | |
2 * | |
3 */ | |
4 package info.textgrid.middleware.digilib.clients.cli; | |
5 | |
6 import java.io.File; | |
7 import java.io.FileOutputStream; | |
8 import java.io.IOException; | |
9 import java.io.OutputStream; | |
10 | |
11 import javax.xml.ws.Holder; | |
12 | |
13 import info.textgrid.namespaces.middleware.digilib.services.digilibservice.DigilibService; | |
14 import info.textgrid.namespaces.middleware.digilib.services.digilibservice.DigilibServicePortType; | |
15 | |
16 /** | |
17 * @author casties | |
18 * | |
19 */ | |
20 public class DigilibCli { | |
21 | |
22 /** | |
23 * @param args | |
24 */ | |
25 public static void main(String[] args) { | |
26 if (args.length != 4) { | |
27 System.err.println("use: DgibilibCli SID URI QUERY FILENAME"); | |
28 System.exit(1); | |
29 } | |
30 String sid = args[0]; | |
31 String uri = args[1]; | |
32 String query = args[2]; | |
33 String filename = args[3]; | |
34 // call service | |
35 byte[] imageData = getScaledImage(sid, uri, query); | |
36 // try to copy to file | |
37 System.out.println("writing " + filename); | |
38 File f = new File(filename); | |
39 try { | |
40 OutputStream ostream = new FileOutputStream(f); | |
41 ostream.write(imageData); | |
42 ostream.close(); | |
43 } catch (IOException e) { | |
44 // TODO Auto-generated catch block | |
45 e.printStackTrace(); | |
46 } | |
47 System.out.println("Done."); | |
48 } | |
49 | |
50 public static byte[] getScaledImage(String sid, String uri, String query) { | |
51 DigilibService service = new DigilibService(); | |
52 DigilibServicePortType port = service.getDigilibServicePort(); | |
53 String logParam = null; | |
54 // Holder for return data | |
55 Holder<String> mimeType = new Holder<String>(); | |
56 Holder<byte[]> imageData = new Holder<byte[]>(); | |
57 Holder<Integer> width = new Holder<Integer>(); | |
58 Holder<Integer> height = new Holder<Integer>(); | |
59 // call service -- fills Holder | |
60 port.getScaledImage(sid, uri, query, logParam, mimeType, imageData, width, height); | |
61 System.out.println("mimeType="+mimeType.value); | |
62 System.out.println("imageData="+imageData.value); | |
63 System.out.println("width="+width.value); | |
64 System.out.println("height="+height.value); | |
65 return imageData.value; | |
66 } | |
67 | |
68 } |