1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.jetspeed.serializer.objects;
19
20 import org.apache.commons.lang.StringEscapeUtils;
21
22 import javolution.xml.XMLFormat;
23 import javolution.xml.stream.XMLStreamException;
24
25 public class JSSeedData extends JSSnapshot
26 {
27
28 public static final int softwareVersion = 1;
29
30 public static final int softwareSubVersion = 0;
31
32 private String encryption;
33
34 private JSMimeTypes mimeTypes;
35
36 private JSMediaTypes mediaTypes;
37
38 private JSClients clients;
39
40 private JSCapabilities capabilities;
41
42 private JSRoles roles;
43
44 private JSGroups groups;
45
46 private JSUsers users;
47
48 private JSPermissions permissions;
49
50 private JSProfilingRules rules;
51
52 private String defaultRule;
53
54 /***
55 * check the software version and subvversion against the saved
56 * version...and verify whether it is compatible...
57 *
58 * @return the current software can process this file
59 */
60 public boolean checkVersion()
61 {
62 return true;
63 }
64
65 /***
66 * @return Returns the softwareSubVersion.
67 */
68 public int getSoftwareSubVersion()
69 {
70 return softwareSubVersion;
71 }
72
73 /***
74 * @return Returns the softwareVersion.
75 */
76 public int getSoftwareVersion()
77 {
78 return softwareVersion;
79 }
80
81
82 public JSSeedData()
83 {
84 super();
85 System.out.println("JSSeedData Class created");
86 }
87
88 public JSSeedData(String name)
89 {
90 super();
91
92 mimeTypes = new JSMimeTypes();
93 mediaTypes = new JSMediaTypes();
94 clients = new JSClients();
95 capabilities = new JSCapabilities();
96 roles = new JSRoles();
97 groups = new JSGroups();
98 users = new JSUsers();
99 permissions = new JSPermissions();
100 rules = new JSProfilingRules();
101 }
102
103
104 /****************************************************************************
105 * SERIALIZER
106 */
107 protected static final XMLFormat XML = new XMLFormat(JSSeedData.class)
108 {
109
110 public void write(Object o, OutputElement xml)
111 throws XMLStreamException
112 {
113
114 try
115 {
116
117 JSSnapshot.XML.write(o,xml);
118
119 JSSeedData g = (JSSeedData) o;
120
121 xml.add(g.getDefaultRule(), "default_rule", String.class);
122
123 xml.add(g.encryption,"encryption",String.class);
124
125 /*** implicitly named (through binding) fields here */
126
127 xml.add(g.getMimeTypes());
128 xml.add(g.getMediaTypes());
129 xml.add(g.getCapabilities());
130 xml.add(g.getClients());
131
132 xml.add(g.getRoles());
133 xml.add(g.getGroups());
134 xml.add(g.getUsers());
135
136 xml.add(g.getPermissions());
137 xml.add(g.getRules());
138
139 } catch (Exception e)
140 {
141 e.printStackTrace();
142 }
143 }
144
145 public void read(InputElement xml, Object o)
146 {
147 try
148 {
149 JSSnapshot.XML.read(xml, o);
150 JSSeedData g = (JSSeedData) o;
151 Object o1 = xml.get("default_rule",String.class);
152 if (o1 instanceof String) g.defaultRule = StringEscapeUtils.unescapeHtml((String) o1);
153 o1 = xml.get("encryption",String.class);
154 if (o1 instanceof String) g.encryption = StringEscapeUtils.unescapeHtml((String) o1);
155
156 while (xml.hasNext())
157 {
158 o1 = xml.getNext();
159
160 if (o1 instanceof JSMimeTypes)
161 g.mimeTypes = (JSMimeTypes) o1;
162 else if (o1 instanceof JSMediaTypes)
163 g.mediaTypes = (JSMediaTypes) o1;
164 else if (o1 instanceof JSClients)
165 g.clients = (JSClients) o1;
166 else if (o1 instanceof JSCapabilities)
167 g.capabilities = (JSCapabilities) o1;
168 else if (o1 instanceof JSRoles)
169 g.roles = (JSRoles) o1;
170 else if (o1 instanceof JSGroups)
171 g.groups = (JSGroups) o1;
172 else if (o1 instanceof JSUsers)
173 g.users = (JSUsers) o1;
174 else if (o1 instanceof JSPermissions)
175 g.permissions = (JSPermissions) o1;
176 else if (o1 instanceof JSProfilingRules)
177 g.rules = (JSProfilingRules) o1;
178 }
179 } catch (Exception e)
180 {
181 e.printStackTrace();
182 }
183 }
184 };
185
186
187 /***
188 * @return Returns the groups.
189 */
190 public JSGroups getGroups()
191 {
192 return groups;
193 }
194
195 /***
196 * @param groups
197 * The groups to set.
198 */
199 public void setGroups(JSGroups groups)
200 {
201 this.groups = groups;
202 }
203
204 /***
205 * @return Returns the roles.
206 */
207 public JSRoles getRoles()
208 {
209 return roles;
210 }
211
212 /***
213 * @param roles
214 * The roles to set.
215 */
216 public void setRoles(JSRoles roles)
217 {
218 this.roles = roles;
219 }
220
221 /***
222 * @return Returns the roles.
223 */
224 public JSUsers getUsers()
225 {
226 return users;
227 }
228
229 /***
230 * @return Returns the encryption.
231 */
232 public String getEncryption()
233 {
234 return encryption;
235 }
236
237 /***
238 * @param encryption
239 * The encryption to set.
240 */
241 public void setEncryption(String encryption)
242 {
243 this.encryption = encryption;
244 }
245
246
247 /***
248 * @return Returns the capabilities.
249 */
250 public JSCapabilities getCapabilities()
251 {
252 return capabilities;
253 }
254
255 /***
256 * @param capabilities
257 * The capabilities to set.
258 */
259 public void setCapabilities(JSCapabilities capabilities)
260 {
261 this.capabilities = capabilities;
262 }
263
264 /***
265 * @return Returns the clients.
266 */
267 public JSClients getClients()
268 {
269 return clients;
270 }
271
272 /***
273 * @param clients
274 * The clients to set.
275 */
276 public void setClients(JSClients clients)
277 {
278 this.clients = clients;
279 }
280
281
282
283 /***
284 * @return Returns the mediaTypes.
285 */
286 public JSMediaTypes getMediaTypes()
287 {
288 return mediaTypes;
289 }
290
291 /***
292 * @param mediaTypes
293 * The mediaTypes to set.
294 */
295 public void setMediaTypes(JSMediaTypes mediaTypes)
296 {
297 this.mediaTypes = mediaTypes;
298 }
299
300 /***
301 * @return Returns the mimeTypes.
302 */
303 public JSMimeTypes getMimeTypes()
304 {
305 return mimeTypes;
306 }
307
308 /***
309 * @param mimeTypes
310 * The mimeTypes to set.
311 */
312 public void setMimeTypes(JSMimeTypes mimeTypes)
313 {
314 this.mimeTypes = mimeTypes;
315 }
316
317
318
319
320 /***
321 * @param users
322 * The users to set.
323 */
324 public void setUsers(JSUsers users)
325 {
326 this.users = users;
327 }
328
329 /***
330 * @return Returns the permissions.
331 */
332 public JSPermissions getPermissions()
333 {
334 return permissions;
335 }
336
337 /***
338 * @param permissions
339 * The permissions to set.
340 */
341 public void setPermissions(JSPermissions permissions)
342 {
343 this.permissions = permissions;
344 }
345
346 /***
347 * @return Returns the rules.
348 */
349 public JSProfilingRules getRules()
350 {
351 return rules;
352 }
353
354 /***
355 * @param rules
356 * The rules to set.
357 */
358 public void setRules(JSProfilingRules rules)
359 {
360 this.rules = rules;
361 }
362
363 /***
364 * @return Returns the defaultRule.
365 */
366 public String getDefaultRule()
367 {
368 return defaultRule;
369 }
370
371 /***
372 * @param defaultRule
373 * The defaultRule to set.
374 */
375 public void setDefaultRule(String defaultRule)
376 {
377 this.defaultRule = defaultRule;
378 }
379
380 }