source: vanHelsing/trunk/gui/src/de/dass_it/vanhelsing/gui/ValidationParser.java@ 865

Last change on this file since 865 was 865, checked in by tobias, on Apr 20, 2010 at 5:21:42 PM

comments added
all methods of the wsdl file implemented

File size: 5.6 KB
Line 
1package de.dass_it.vanhelsing.gui;
2import java.io.*;
3/**
4 * ValidationParser reads dird_conf.c, filed_conf.c, stored_conf.c and parse.c.
5 * Run ValidationParser from command line with two arguments. The first argument defines the domain, i.e. director, storagedaemon or filedaemon. The second argument should be the path of the c file.
6 * Output is written to standard output and can therefore be appended to the properties file.
7 * The domain of the message resource should be 'director'
8 * @author tgoecke
9 */
10
11
12public class ValidationParser{
13
14 public static void main(String args[]) {
15 try {
16 FileInputStream fs = new FileInputStream(args[1]);
17 DataInputStream ds = new DataInputStream(fs);
18 BufferedReader br = new BufferedReader(new InputStreamReader(ds));
19 String line;
20 String[] lineParts;
21 String name ="FEHLER"; //Resourcename
22 String daemon = args[0];
23
24 String item; //Resourcenitem
25 String type; //Resourcentype
26 String ref; //Referenz auf andere Resourcen
27 String nec; //Kann oder Mussfeld
28 String def; //defaultwert
29
30 String state = "";
31 while ((line = br.readLine()) != null){
32 //Zeile enthält entweder Resourcenname oder Resourcenteildefinition
33 if (line.startsWith("static RES_ITEM")){
34 lineParts = line.split(" ");
35 name = lineParts[2].substring(0, (lineParts[2].length()-2));
36 state = "res";
37 continue;
38 }
39 if (line.startsWith("RES_ITEM")){
40 lineParts = line.split(" ");
41 name = lineParts[1].substring(0, (lineParts[1].length()-2));
42 state = "res";
43 continue;
44
45 }
46 if (line.startsWith("};")){
47 state = "";
48 continue;
49 }
50 if (line.contains("{NULL")){
51 continue;
52 }
53 if (line.split(",").length != 6){
54 continue;
55 }
56 if (state.equals("res")){
57 lineParts = line.split(",");
58 item = lineParts[0].replaceAll(" ", "");
59 item = item.replaceAll("\\{", "");
60 item = item.replaceAll("\"", "");
61 type = lineParts[1].replaceAll(" ", "");
62 type = type.replaceAll("\"", "");
63 ref = lineParts[3];
64 nec = lineParts[4];
65 def = lineParts[5].replaceAll("\\}", "");
66 System.out.println(daemon+"."+getPrettyName(name)+"."+item+"."+"ref" + " = " + getReferenz(ref));
67 System.out.println(daemon+"."+getPrettyName(name)+"."+item+"."+"type" + " = " +getJavaType(type));
68 System.out.println(daemon+"."+getPrettyName(name)+"."+item+"."+"required" + " = " +getJavaReq(nec));
69 System.out.println(daemon+"."+getPrettyName(name)+"."+item+"."+"def" + " = " +def);
70 continue;
71 }
72 }
73 ds.close();
74 } catch (Exception e){
75 e.printStackTrace();
76 }
77 }
78
79 private static String getReferenz(String s){
80 return s;
81 }
82
83 private static String getJavaType(String s){
84 for (conf2type c2t : conf2type.values()){
85 if (c2t.conf.equals(s)){
86 return c2t.type;
87 }
88 }
89 /*if (s.equals("store_bool") || s.equals("store_bit") ){
90 return "boolean";
91 }
92 if (s.equals("store_str") || s.equals("store_name") || s.equals("store_strname")){
93 return "String";
94 }
95 if (s.equals("store_pint32")||s.equals("store_size")){
96 return "int";
97 }
98 if (s.equals("store_dir")){
99 return "Path";
100 }
101 if (s.equals("store_password")){
102 return "Password";
103 }
104 if (s.equals("store_time")){
105 return "Date";
106 }
107 if (s.equals("store_acl")){
108 return "Acl";
109 }
110 if (s.equals("store_res")){
111 return "Resource";
112 }*/
113 //switch(s){
114 //case "store_bool" : s = "boolean"; break;
115 //case "store_pint32" : s = "int"; break;
116 //case "store_str" : s = "String";
117 //case "store_name" : s = "String"; break;
118 //case "store_dir" : s = "Path"; break;
119 //case "store_password" : s = "Password"; break;
120 //case "store_time" : s = "Date"; break;
121 //case "store_bit" : s = "boolean"; break;
122 //case "store_size" : s = "int"; break;
123 //case "store_acl" : s = "Acl"; break;
124 //case "store_strname" : s = "String"; break;
125 //case "store_res" : s = "Resource"; break;
126 //}
127 return s;
128 }
129 private static String getJavaReq(String s){
130 if ( s.contains("ITEM_REQUIRED") ){
131 s = "true";
132 } else {
133 s = "false";
134 }
135 return s;
136 }
137 private static String getPrettyName(String s){
138 for (prettyNames name : prettyNames.values()){
139 if (name.ugly.equals(s)){
140 return name.pretty;
141 }
142 }
143
144 return s;
145 }
146 /**
147 * @author tgoecke
148 */
149 private enum prettyNames{
150 CATALOG ("cat_items", "catalog"),
151 CLIENT ("cli_items", "client"),
152 CONSOLE ("con_items", "console"),
153 COUNTER ("counter_items", "counter"),
154 DIRECTOR ("dir_items", "director"),
155 FILESET ("fs_items", "fileset"),
156 POOL ("pool_items", "pool"),
157 RUNSCRIPT ("runscript_items", "runscript"),
158 SCHEDULE ("sch_items", "schedule"),
159 STORAGE ("store_items", "storage"),
160 AUTOCHANGER ("changer_items", "autochanger"),
161 DEVICE ("dev_items", "device"),
162 JOB("job_items", "job"),
163 MESSAGE("msgs_items","messages");
164
165 private String ugly;
166 private String pretty;
167
168 prettyNames(String ugly, String pretty){
169 this.ugly = ugly;
170 this.pretty = pretty;
171 }
172 }
173 /**
174 * @author tgoecke
175 */
176 private enum conf2type{
177 STOREPOOL ("store_pool", "boolean"),
178 STOREBIT ("store_bit","boolean"),
179 STORE_STR ("store_str","String"),
180 STORE_NAME ("store_name", "String"),
181 STORE_STRNAME ("store_strname", "String"),
182 STORE_PINT32 ("store_pint32", "int"),
183 STORE_SIZE ("store_size", "int"),
184 STORE_DIR ("store_dir", "path"),
185 STORE_PASSWORD ("store_password", "Password"),
186 STORE_TIME ("store_time", "Date"),
187 STORE_ACL ("store_acl", "Acl"),
188 STORE_RES ("store_res", "Resource"),
189 STORE_MSGS ("store_msgs","String");
190
191 private String conf;
192 private String type;
193
194 conf2type(String conf, String type){
195 this.conf = conf;
196 this.type = type;
197 }
198 }
199}
Note: See TracBrowser for help on using the repository browser.