source: vanHelsing/branches/guitechdemo/src/de/dass_it/vanhelsing/gui/Client.java@ 953

Last change on this file since 953 was 847, checked in by tobias, on Mar 19, 2010 at 5:51:31 PM

displays key value pairs as part of the tree

File size: 2.9 KB
Line 
1package de.dass_it.vanhelsing.gui;
2
3import de.dass_it.www.vanhelsing.*;
4import de.dass_it.www.vanhelsing.VanHelsingCallbackHandler.*;
5import de.dass_it.www.vanhelsing.VanHelsingStub.*;
6
7public class Client {
8
9 public ResourceInfo[] getListResources(ListResourcesType lrt){
10 VanHelsingStub stub;
11 try {
12
13 stub = getStub();
14
15 VanHelsingStub.ListResources req = new VanHelsingStub.ListResources();
16 req.setListResources(lrt);
17
18 VanHelsingStub.ListResourcesResponse res = stub.listResources(req);
19 return (res.getListResourcesResponse()).getResource();
20
21 } catch (Exception e){
22 System.err.println("getListResources: " + e.toString());
23 }
24 return new ResourceInfo[0];
25 }
26
27 public SimpleResource getSimpleResource(GetResourceType grt){
28 VanHelsingStub stub;
29 try {
30 stub = getStub();
31
32 VanHelsingStub.GetSimpleResource req = new VanHelsingStub.GetSimpleResource();
33 req.setGetSimpleResource(grt);
34
35 VanHelsingStub.GetSimpleResourceResponse res = stub.getSimpleResource(req);
36
37 SimpleResource sr = new SimpleResource();
38 sr.setResourceInfo(res.getResInfo());
39 sr.setResourceAttributeType(res.getResAttribute());
40 return sr;
41
42
43 } catch(Exception e){
44 System.err.println("getSR:" + grt.getResId() + ":" + e.toString());
45 }
46 return new SimpleResource(new ResourceInfo(), new ResourceAttributeType[0]);
47 }
48
49 private VanHelsingStub getStub() throws Exception {
50 String url = new String("http://localhost:8080/");
51 VanHelsingStub stub = new VanHelsingStub(url);
52 stub._getServiceClient().getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
53 return stub;
54 }
55
56 public static void main(String args[]){
57 Client c = new Client();
58 ListResourcesType lrt = new ListResourcesType();
59 lrt.setDirector("bacula-dir");
60 lrt.setResourceType("JobDefs");
61
62 ResourceInfo[] rinfo = c.getListResources(lrt);
63
64 System.err.println("!!!rinfo!!!");
65 for (int i = 0; i < rinfo.length && rinfo.length > 0; i++){
66 System.err.println(rinfo[i].getDirector());
67 System.err.println(rinfo[i].getResId());
68 System.err.println(rinfo[i].getResName());
69 System.err.println(rinfo[i].getResType());
70 }
71
72 GetResourceType grt = new GetResourceType();
73 grt.setDirector("bacula-dir");
74 grt.setResId(117);
75
76 SimpleResource sr = new SimpleResource();
77 sr = c.getSimpleResource(grt);
78
79 System.err.println("!!sr!!");
80 System.err.println(sr.getResourceInfo().getDirector());
81 System.err.println(sr.getResourceInfo().getResId());
82 System.err.println(sr.getResourceInfo().getResName());
83 System.err.println(sr.getResourceInfo().getResType());
84
85 for (int i = 0; i < sr.getResourceAttributeType().length; i++){
86 System.err.print("\nKey: ");
87 System.err.print((sr.getResourceAttributeType())[i].getKey());
88 System.err.print("\nValue: ");
89 System.err.print((sr.getResourceAttributeType())[i].getValue());
90 }
91
92 }
93
94}
Note: See TracBrowser for help on using the repository browser.