Skip to main content
summaryrefslogtreecommitdiffstats
blob: ed2a2be95cc7d772091f344a2d2e7f064e7a3a97 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
/*******************************************************************************
 * Copyright (c) 2004, 2010 Tasktop Technologies and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Tasktop Technologies - initial API and implementation
 *******************************************************************************/

package org.eclipse.mylyn.internal.bugzilla.core;

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

/**
 * Quick config rdf parser.
 * 
 * <pre>
 * config.cgi?ctype=rdf
 * </pre>
 * 
 * Populates a <link>RepositoryConfiguration</link> data structure.
 * 
 * @author Rob Elves
 */
public class SaxConfigurationContentHandler extends DefaultHandler {

	private static final String ELEMENT_RESOLUTION = "resolution"; //$NON-NLS-1$

	private static final String ELEMENT_STATUS_OPEN = "status_open"; //$NON-NLS-1$

	private static final String ELEMENT_STATUS_CLOSED = "status_closed"; //$NON-NLS-1$

	private static final String ELEMENT_TARGET_MILESTONE = "target_milestone"; //$NON-NLS-1$

	private static final String ELEMENT_TARGET_MILESTONES = "target_milestones"; //$NON-NLS-1$

	private static final String ELEMENT_INSTALL_VERSION = "install_version"; //$NON-NLS-1$

	private static final String ELEMENT_DB_ENCODING = "db_encoding"; //$NON-NLS-1$

	private static final String ATTRIBUTE_RDF_ABOUT = "rdf:about"; //$NON-NLS-1$

	private static final String ATTRIBUTE_RESOURCE = "resource"; //$NON-NLS-1$

	private static final String ELEMENT_VERSION = "version"; //$NON-NLS-1$

	private static final String ELEMENT_VERSIONS = "versions"; //$NON-NLS-1$

	private static final String ELEMENT_COMPONENT = "component"; //$NON-NLS-1$

	private static final String ELEMENT_COMPONENTS = "components"; //$NON-NLS-1$

	private static final String ELEMENT_NAME = "name"; //$NON-NLS-1$

	private static final String ELEMENT_PRODUCTS = "products"; //$NON-NLS-1$

	private static final String ELEMENT_DESCRIPTION = "description"; //$NON-NLS-1$

	private static final String ELEMENT_FIELDS = "fields"; //$NON-NLS-1$

	private static final String ELEMENT_FIELD = "field"; //$NON-NLS-1$

	private static final String ELEMENT_FLAG_TYPES = "flag_types"; //$NON-NLS-1$

	private static final String ELEMENT_FLAG_TYPE = "flag_type"; //$NON-NLS-1$

	private static final String ELEMENT_SEVERITY = "severity"; //$NON-NLS-1$

	private static final String ELEMENT_PRIORITY = "priority"; //$NON-NLS-1$

	private static final String ELEMENT_KEYWORD = "keyword"; //$NON-NLS-1$

	private static final String ELEMENT_OP_SYS = "op_sys"; //$NON-NLS-1$

	private static final String ELEMENT_PLATFORM = "platform"; //$NON-NLS-1$

	private static final String ELEMENT_LI = "li"; //$NON-NLS-1$

	private static final String ELEMENT_STATUS = "status"; //$NON-NLS-1$

	private static final String ELEMENT_TYPE = "type"; //$NON-NLS-1$

	private static final String ELEMENT_ENTER_BUG = "enter_bug"; //$NON-NLS-1$

	private static final String ELEMENT_REQUESTABLE = "requestable"; //$NON-NLS-1$

	private static final String ELEMENT_SPECIFICALLY_REQUESTABLE = "specifically_requestable"; //$NON-NLS-1$

	private static final String ELEMENT_ID = "id"; //$NON-NLS-1$

	private static final String ELEMENT_MULTIPLICABLE = "multiplicable"; //$NON-NLS-1$

	private static final String ELEMENT_ALLOWS_UNCONFIRMED = "allows_unconfirmed"; //$NON-NLS-1$

	private static final int EXPECTING_ROOT = 0;

	private static final int IN_INSTALL_VERSION = 1 << 1;

	private static final int IN_STATUS = 1 << 2;

	private static final int IN_PLATFORM = 1 << 3;

	private static final int IN_OP_SYS = 1 << 4;

	private static final int IN_PRIORITY = 1 << 5;

	private static final int IN_SEVERITY = 1 << 6;

	private static final int IN_PRODUCTS = 1 << 7;

	private static final int IN_COMPONENTS = 1 << 8;

	private static final int IN_VERSIONS = 1 << 9;

	private static final int IN_LI = 1 << 10;

	private static final int IN_LI_LI = 1 << 11;

	private static final int IN_NAME = 1 << 12;

	private static final int IN_COMPONENT = 1 << 13;

	private static final int IN_VERSION = 1 << 14;

	private static final int IN_TARGET_MILESTONES = 1 << 15;

	private static final int IN_TARGET_MILESTONE = 1 << 16;

	private static final int IN_STATUS_OPEN = 1 << 17;

	private static final int IN_RESOLUTION = 1 << 18;

	private static final int IN_KEYWORD = 1 << 19;

	private static final int IN_STATUS_CLOSED = 1 << 20;

	private static final int IN_FIELDS = 1 << 21;

	private static final int IN_FIELD = 1 << 22;

	private static final int IN_CUSTOM_OPTION = 1 << 23;

	private static final int IN_FLAG_TYPES = 1 << 24;

	private static final int IN_FLAG_TYPE = 1 << 25;

	private static final int IN_DB_ENCODING = 1 << 26;

	private int state = EXPECTING_ROOT;

	private String currentProduct = ""; //$NON-NLS-1$

	private String currentName = ""; //$NON-NLS-1$

	private String currentDescription = ""; //$NON-NLS-1$

	private String currentType;

	private String currentRequestable;

	private String currentSpecifically_requestable;

	private String currentMultiplicable;

	private int currentId;

	private String currentEnterBug = ""; //$NON-NLS-1$

	private StringBuffer characters = new StringBuffer();

	private String about;

	private final RepositoryConfiguration configuration;

	private final Map<String, List<String>> components = new HashMap<String, List<String>>();

	private final Map<String, List<String>> versions = new HashMap<String, List<String>>();

	private final Map<String, List<String>> milestones = new HashMap<String, List<String>>();

	private final Map<String, String> componentNames = new HashMap<String, String>();

	private final Map<String, String> versionNames = new HashMap<String, String>();

	private final Map<String, String> milestoneNames = new HashMap<String, String>();

	private final Map<String, List<String>> customOption = new HashMap<String, List<String>>();

	private final Map<String, Map<String, List<String>>> flagsInComponent = new HashMap<String, Map<String, List<String>>>();

	private final Map<String, Integer> flagIds = new HashMap<String, Integer>();

	private String currentComponent = ""; //$NON-NLS-1$

	private String currentCustomOptionName = ""; //$NON-NLS-1$

	public SaxConfigurationContentHandler() {
		configuration = new RepositoryConfiguration();
	}

	public RepositoryConfiguration getConfiguration() {
		return configuration;
	}

	@Override
	public void characters(char[] ch, int start, int length) throws SAXException {
		characters.append(ch, start, length);
	}

	@Override
	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
		characters = new StringBuffer();
		if (localName.equals(ELEMENT_STATUS)) {
			state = state | IN_STATUS;
		} else if (localName.equals(ELEMENT_LI) && ((state & IN_LI) == IN_LI)) {
			state = state | IN_LI_LI;
			parseResource(attributes);
		} else if (localName.equals(ELEMENT_LI) && ((state & IN_LI) != IN_LI)) {
			state = state | IN_LI;
		} else if (localName.equals(ELEMENT_PLATFORM)) {
			state = state | IN_PLATFORM;
		} else if (localName.equals(ELEMENT_OP_SYS)) {
			state = state | IN_OP_SYS;
		} else if (localName.equals(ELEMENT_PRIORITY)) {
			state = state | IN_PRIORITY;
		} else if (localName.equals(ELEMENT_SEVERITY)) {
			state = state | IN_SEVERITY;
		} else if (localName.equals(ELEMENT_PRODUCTS)) {
			state = state | IN_PRODUCTS;
		} else if (localName.equals(ELEMENT_OP_SYS)) {
			state = state | IN_OP_SYS;
		} else if (localName.equals(ELEMENT_NAME)) {
			state = state | IN_NAME;
		} else if (localName.equals(ELEMENT_COMPONENTS)) {
			state = state | IN_COMPONENTS;
		} else if (localName.equals(ELEMENT_COMPONENT)) {
			state = state | IN_COMPONENT;
			parseResource(attributes);
		} else if (localName.equals(ELEMENT_VERSIONS)) {
			state = state | IN_VERSIONS;
		} else if (localName.equals(ELEMENT_VERSION)) {
			state = state | IN_VERSION;
			parseResource(attributes);
		} else if (localName.equals(ELEMENT_INSTALL_VERSION)) {
			state = state | IN_INSTALL_VERSION;
		} else if (localName.equals(ELEMENT_DB_ENCODING)) {
			state = state | IN_DB_ENCODING;
		} else if (localName.equals(ELEMENT_TARGET_MILESTONES)) {
			state = state | IN_TARGET_MILESTONES;
		} else if (localName.equals(ELEMENT_TARGET_MILESTONE)) {
			state = state | IN_TARGET_MILESTONE;
			parseResource(attributes);
		} else if (localName.equals(ELEMENT_STATUS_OPEN)) {
			state = state | IN_STATUS_OPEN;
		} else if (localName.equals(ELEMENT_STATUS_CLOSED)) {
			state = state | IN_STATUS_CLOSED;
		} else if (localName.equals(ELEMENT_RESOLUTION)) {
			state = state | IN_RESOLUTION;
		} else if (localName.equals(ELEMENT_KEYWORD)) {
			state = state | IN_KEYWORD;
		} else if (localName.equals(ELEMENT_FIELDS)) {
			state = state | IN_FIELDS;
		} else if (localName.equals(ELEMENT_FIELD)) {
			state = state | IN_FIELD;
			parseResource(attributes);
			currentName = ""; //$NON-NLS-1$
			currentDescription = ""; //$NON-NLS-1$
			currentType = ""; //$NON-NLS-1$
			currentEnterBug = ""; //$NON-NLS-1$
			currentId = -1;
		} else if (localName.equals(ELEMENT_FLAG_TYPES)) {
			state = state | IN_FLAG_TYPES;
		} else if (localName.equals(ELEMENT_FLAG_TYPE)) {
			state = state | IN_FLAG_TYPE;
			parseResource(attributes);
		} else if (localName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) {
			state = state | IN_CUSTOM_OPTION;
			currentCustomOptionName = localName;
		}
	}

	@Override
	public void endElement(String uri, String localName, String qName) throws SAXException {

		// KEEP: && ((state & IN_LI) == IN_LI)

		if (localName.equals(ELEMENT_STATUS)) {
			state = state & ~IN_STATUS;
		} else if (localName.equals(ELEMENT_LI) && ((state & IN_LI_LI) == IN_LI_LI)) {
			state = state & ~IN_LI_LI;
		} else if (localName.equals(ELEMENT_LI) && ((state & IN_LI_LI) != IN_LI_LI)) {
			state = state & ~IN_LI;
			if (characters.length() == 0) {
				return;
			}
			if (state == (IN_STATUS)) {
				configuration.addStatus(characters.toString());
			} else if (state == (IN_STATUS_OPEN)) {
				configuration.addOpenStatusValue(characters.toString());
			} else if (state == (IN_STATUS_CLOSED)) {
				configuration.addClosedStatusValue(characters.toString());
			} else if (state == (IN_RESOLUTION)) {
				configuration.addResolution(characters.toString());
			} else if (state == (IN_KEYWORD)) {
				configuration.addKeyword(characters.toString());
			} else if (state == (IN_PLATFORM)) {
				configuration.addPlatform(characters.toString());
			} else if (state == (IN_OP_SYS)) {
				configuration.addOS(characters.toString());
			} else if (state == (IN_PRIORITY)) {
				configuration.addPriority(characters.toString());
			} else if (state == (IN_SEVERITY)) {
				configuration.addSeverity(characters.toString());
			} else if (state == (IN_CUSTOM_OPTION)) {
				// Option for CutstomFields
				if (currentCustomOptionName != null) {
					if (characters.length() > 0) {
						List<String> customOptionList = customOption.get(currentCustomOptionName);
						if (customOptionList == null) {
							customOptionList = new ArrayList<String>();
							customOption.put(currentCustomOptionName, customOptionList);
						}
						customOptionList.add(characters.toString());
					}
				}
			}
		} else if (localName.equals(ELEMENT_PLATFORM)) {
			state = state & ~IN_PLATFORM;
		} else if (localName.equals(ELEMENT_OP_SYS)) {
			state = state & ~IN_OP_SYS;
		} else if (localName.equals(ELEMENT_PRIORITY)) {
			state = state & ~IN_PRIORITY;
		} else if (localName.equals(ELEMENT_SEVERITY)) {
			state = state & ~IN_SEVERITY;
		} else if (localName.equals(ELEMENT_PRODUCTS)) {
			state = state & ~IN_PRODUCTS;
		} else if (localName.equals(ELEMENT_OP_SYS)) {
			state = state & ~IN_OP_SYS;
		} else if (localName.equals(ELEMENT_NAME)) {
			state = state & ~IN_NAME;
			if (state == (IN_PRODUCTS | IN_LI)) {
				// PRODUCT NAME
				currentProduct = characters.toString();
				configuration.addProduct(currentProduct);
			} else if (state == (IN_VERSIONS | IN_LI | IN_VERSION)) {
				// VERSION NAME
				if (about != null && !versionNames.containsValue(about)) {
					if (characters.length() > 0) {
						versionNames.put(about, characters.toString());
					}
				}
			} else if (state == (IN_COMPONENTS | IN_LI | IN_COMPONENT)) {
				// COMPONENT NAME
				currentComponent = characters.toString();
				if (about != null && !componentNames.containsValue(about)) {
					if (currentComponent.length() > 0) {
						componentNames.put(about, currentComponent);
					}
				}
			} else if (state == (IN_TARGET_MILESTONES | IN_LI | IN_TARGET_MILESTONE)) {
				// MILESTONE NAME
				if (about != null && !milestoneNames.containsValue(about)) {
					if (characters.length() > 0) {
						milestoneNames.put(about, characters.toString());
					}
				}
			} else if (state == (IN_FIELDS | IN_LI | IN_FIELD) || state == (IN_FLAG_TYPES | IN_LI | IN_FLAG_TYPE)) {
				// FIELDS NAME
				currentName = characters.toString();
			}
		} else if (localName.equals(ELEMENT_COMPONENTS)) {
			state = state & ~IN_COMPONENTS;
		} else if (localName.equals(ELEMENT_COMPONENT)) {
			state = state & ~IN_COMPONENT;
		} else if (localName.equals(ELEMENT_VERSION)) {
			state = state & ~IN_VERSION;
		} else if (localName.equals(ELEMENT_VERSIONS)) {
			state = state & ~IN_VERSIONS;
		} else if (localName.equals(ELEMENT_INSTALL_VERSION)) {
			state = state & ~IN_INSTALL_VERSION;
			configuration.setInstallVersion(characters.toString());
		} else if (localName.equals(ELEMENT_DB_ENCODING)) {
			state = state & ~IN_DB_ENCODING;
			String charsetString = characters.toString().trim();
			if (charsetString.length() > 0) {
				try {
					Charset.forName(charsetString);
					configuration.setEncoding(charsetString);
				} catch (Exception e) {
					StatusHandler.log(new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN,
							"Unrecognized encoding in configuration: " + charsetString)); //$NON-NLS-1$
				}
			}
		} else if (localName.equals(ELEMENT_TARGET_MILESTONE)) {
			state = state & ~IN_TARGET_MILESTONE;
		} else if (localName.equals(ELEMENT_TARGET_MILESTONES)) {
			state = state & ~IN_TARGET_MILESTONES;
		} else if (localName.equals(ELEMENT_STATUS_OPEN)) {
			state = state & ~IN_STATUS_OPEN;
		} else if (localName.equals(ELEMENT_STATUS_CLOSED)) {
			state = state & ~IN_STATUS_CLOSED;
		} else if (localName.equals(ELEMENT_RESOLUTION)) {
			state = state & ~IN_RESOLUTION;
		} else if (localName.equals(ELEMENT_KEYWORD)) {
			state = state & ~IN_KEYWORD;
		} else if (localName.equals(ELEMENT_FIELDS)) {
			state = state & ~IN_FIELDS;
		} else if (localName.equals(ELEMENT_FIELD)) {
			if (currentName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) {
				BugzillaCustomField newField = new BugzillaCustomField(currentDescription, currentName, currentType,
						currentEnterBug);
				List<String> customOptionList = customOption.get(currentName);
				if (customOptionList != null && !customOptionList.isEmpty()) {
					newField.setOptions(customOptionList);
				}
				configuration.addCustomField(newField);
			}
			state = state & ~IN_FIELD;
		} else if (localName.equals(ELEMENT_DESCRIPTION)) {
			currentDescription = characters.toString();
		} else if (localName.equals(ELEMENT_TYPE)) {
			currentType = characters.toString();
		} else if (localName.equals(ELEMENT_ID)) {
			currentId = Integer.parseInt(characters.toString());
		} else if (localName.equals(ELEMENT_ENTER_BUG)) {
			currentEnterBug = characters.toString();
		} else if (localName.equals(ELEMENT_REQUESTABLE)) {
			currentRequestable = characters.toString();
		} else if (localName.equals(ELEMENT_SPECIFICALLY_REQUESTABLE)) {
			currentSpecifically_requestable = characters.toString();
		} else if (localName.equals(ELEMENT_MULTIPLICABLE)) {
			currentMultiplicable = characters.toString();
		} else if (localName.equals(ELEMENT_ALLOWS_UNCONFIRMED)) {
			String value = characters.toString();
			Boolean boolValue = value.equals("0") ? false : true; //$NON-NLS-1$
			configuration.addUnconfirmedAllowed(currentProduct, boolValue);
		} else if (localName.equals(ELEMENT_FLAG_TYPES)) {
			state = state & ~IN_FLAG_TYPES;
		} else if (localName.equals(ELEMENT_FLAG_TYPE)) {
			if (currentId != -1) {
				if (about != null && !flagIds.containsValue(about)) {
					flagIds.put(about, currentId);
				}
				BugzillaFlag newFlag = new BugzillaFlag(currentName, currentDescription, currentType,
						currentRequestable, currentSpecifically_requestable, currentMultiplicable, currentId);
				configuration.addFlag(newFlag);
			}
			state = state & ~IN_FLAG_TYPE;
		} else if (localName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) {
			state = state & ~IN_CUSTOM_OPTION;
			currentCustomOptionName = ""; //$NON-NLS-1$
		}
	}

	private void parseResource(Attributes attributes) {

		switch (state) {
		case IN_PRODUCTS | IN_LI | IN_COMPONENTS | IN_LI_LI:
			if (attributes != null) {
				String compURI = attributes.getValue(ATTRIBUTE_RESOURCE);
				if (compURI != null && currentProduct.length() > 0) {
					List<String> compURIs = components.get(currentProduct);
					if (compURIs == null) {
						compURIs = new ArrayList<String>();
						components.put(currentProduct, compURIs);
					}
					compURIs.add(compURI);
				}
			}
			break;
		case IN_PRODUCTS | IN_LI | IN_VERSIONS | IN_LI_LI:
			if (attributes != null) {
				String resourceURI = attributes.getValue(ATTRIBUTE_RESOURCE);
				if (resourceURI != null && currentProduct.length() > 0) {
					List<String> versionUris = versions.get(currentProduct);
					if (versionUris == null) {
						versionUris = new ArrayList<String>();
						versions.put(currentProduct, versionUris);
					}
					versionUris.add(resourceURI);
				}
			}
			break;
		case IN_PRODUCTS | IN_LI | IN_TARGET_MILESTONES | IN_LI_LI:
			if (attributes != null) {
				String resourceURI = attributes.getValue(ATTRIBUTE_RESOURCE);
				if (resourceURI != null) {
					List<String> milestoneUris = milestones.get(currentProduct);
					if (milestoneUris == null) {
						milestoneUris = new ArrayList<String>();
						milestones.put(currentProduct, milestoneUris);
					}
					milestoneUris.add(resourceURI);
				}
			}
			break;
		case IN_COMPONENTS | IN_LI | IN_COMPONENT | IN_FLAG_TYPES | IN_LI_LI:
			if (attributes != null) {
				String compURI = attributes.getValue(ATTRIBUTE_RESOURCE);
				if (compURI != null && currentComponent.length() > 0 && currentProduct.length() > 0
						&& compURI.length() > 0) {

					Map<String, List<String>> flagComponentList = flagsInComponent.get(currentProduct);
					if (flagComponentList == null) {
						flagComponentList = new HashMap<String, List<String>>();
						flagsInComponent.put(currentProduct, flagComponentList);
					}
					List<String> flagsForComponent = flagComponentList.get(currentComponent);
					if (flagsForComponent == null) {
						flagsForComponent = new ArrayList<String>();
						flagComponentList.put(currentComponent, flagsForComponent);
					}
					flagsForComponent.add(compURI.replace("flags.cgi?id=", "flag.cgi?id=")); //$NON-NLS-1$ //$NON-NLS-2$
				}
			}
			break;
		case IN_COMPONENTS | IN_LI | IN_COMPONENT:
			if (attributes != null) {
				about = attributes.getValue(ATTRIBUTE_RDF_ABOUT);
				int idx = about.indexOf("&product="); //$NON-NLS-1$
				if (idx != -1) {
					currentProduct = about.substring(idx + 9);
				}
			}
			break;
		case IN_VERSIONS | IN_LI | IN_VERSION:
			if (attributes != null) {
				about = attributes.getValue(ATTRIBUTE_RDF_ABOUT);
			}
			break;

		case IN_TARGET_MILESTONES | IN_LI | IN_TARGET_MILESTONE:
			if (attributes != null) {
				about = attributes.getValue(ATTRIBUTE_RDF_ABOUT);
			}
			break;
		case IN_FIELDS | IN_LI | IN_FIELD:
			if (attributes != null) {
				about = attributes.getValue(ATTRIBUTE_RDF_ABOUT);
			}
			break;
		case IN_FLAG_TYPES | IN_LI | IN_FLAG_TYPE:
			if (attributes != null) {
				about = attributes.getValue(ATTRIBUTE_RDF_ABOUT);
			}
			break;

		}
	}

	@Override
	public void endDocument() throws SAXException {

		for (String product : components.keySet()) {
			List<String> componentURIs = components.get(product);
			for (String uri : componentURIs) {
				String realName = componentNames.get(uri);
				if (realName != null) {
					configuration.addComponent(product, realName);
				}
			}
		}

		for (String product : versions.keySet()) {
			List<String> versionURIs = versions.get(product);
			for (String uri : versionURIs) {
				String realName = versionNames.get(uri);
				if (realName != null) {
					configuration.addVersion(product, realName);
				}
			}

		}

		for (String product : milestones.keySet()) {
			List<String> milestoneURIs = milestones.get(product);
			for (String uri : milestoneURIs) {
				String realName = milestoneNames.get(uri);
				if (realName != null) {
					configuration.addTargetMilestone(product, realName);
				}
			}

		}

		for (String flagProduct : flagsInComponent.keySet()) {
			Map<String, List<String>> flagComponentUsage = flagsInComponent.get(flagProduct);
			for (String flagusageList : flagComponentUsage.keySet()) {
				List<String> flagList = flagComponentUsage.get(flagusageList);
				for (String flagAbout : flagList) {
					Integer flagId = flagIds.get(flagAbout);
					BugzillaFlag flag = configuration.getFlagWithId(flagId);
					flag.addUsed(flagProduct, flagusageList);
				}
			}
		}

		super.endDocument();
	}
}

Back to the top