Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 136219 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylar/internal/bugzilla/core/BugzillaRepositoryUtil.java (-87 / +67 lines)
Lines 26-32 Link Here
26
import java.security.KeyManagementException;
26
import java.security.KeyManagementException;
27
import java.security.NoSuchAlgorithmException;
27
import java.security.NoSuchAlgorithmException;
28
import java.util.ArrayList;
28
import java.util.ArrayList;
29
import java.util.Arrays;
30
import java.util.HashMap;
29
import java.util.HashMap;
31
import java.util.List;
30
import java.util.List;
32
31
Lines 44-50 Link Here
44
import org.apache.commons.httpclient.params.HttpMethodParams;
43
import org.apache.commons.httpclient.params.HttpMethodParams;
45
import org.eclipse.core.runtime.IProgressMonitor;
44
import org.eclipse.core.runtime.IProgressMonitor;
46
import org.eclipse.core.runtime.IStatus;
45
import org.eclipse.core.runtime.IStatus;
47
import org.eclipse.core.runtime.NullProgressMonitor;
48
import org.eclipse.core.runtime.Status;
46
import org.eclipse.core.runtime.Status;
49
import org.eclipse.jface.dialogs.MessageDialog;
47
import org.eclipse.jface.dialogs.MessageDialog;
50
import org.eclipse.jface.preference.IPreferenceStore;
48
import org.eclipse.jface.preference.IPreferenceStore;
Lines 55-61 Link Here
55
import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser;
53
import org.eclipse.mylar.internal.bugzilla.core.internal.BugParser;
56
import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser;
54
import org.eclipse.mylar.internal.bugzilla.core.internal.NewBugParser;
57
import org.eclipse.mylar.internal.bugzilla.core.internal.OfflineReportsFile;
55
import org.eclipse.mylar.internal.bugzilla.core.internal.OfflineReportsFile;
58
import org.eclipse.mylar.internal.bugzilla.core.search.BugzillaQueryPageParser;
56
import org.eclipse.mylar.internal.bugzilla.core.internal.ProductConfiguration;
57
import org.eclipse.mylar.internal.bugzilla.core.internal.ServerConfigurationFactory;
59
import org.eclipse.mylar.internal.core.util.MylarStatusHandler;
58
import org.eclipse.mylar.internal.core.util.MylarStatusHandler;
60
import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
59
import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
61
import org.eclipse.mylar.provisional.tasklist.TaskRepository;
60
import org.eclipse.mylar.provisional.tasklist.TaskRepository;
Lines 211-264 Link Here
211
	 *             LoginException Exception
210
	 *             LoginException Exception
212
	 */
211
	 */
213
	public static List<String> getProductList(TaskRepository repository) throws IOException, LoginException, Exception {
212
	public static List<String> getProductList(TaskRepository repository) throws IOException, LoginException, Exception {
214
		// BufferedReader in = null;
213
215
		// try {
214
		return BugzillaPlugin.getDefault().getProductConfiguration(repository.getUrl()).getProducts();
216
		// repository =
215
217
		// MylarTaskListPlugin.getRepositoryManager().getRepository(
216
//		BugzillaQueryPageParser parser = new BugzillaQueryPageParser(repository, new NullProgressMonitor());
218
		// BugzillaPlugin.REPOSITORY_KIND, repositoryUrl);
217
//		if (!parser.wasSuccessful()) {
219
		// String urlText = "";
218
//			throw new RuntimeException("Couldn't get products");
220
		// if (repository.hasCredentials()) {
219
//		} else {
221
		// urlText += POST_ARGS_LOGIN_FIRST
220
//			return Arrays.asList(parser.getProductValues());
222
		// + URLEncoder.encode(repository.getUserName(),
221
//		}
223
		// BugzillaPlugin.ENCODING_UTF_8)
222
224
		// + POST_ARGS_PASSWORD
225
		// + URLEncoder.encode(repository.getPassword(),
226
		// BugzillaPlugin.ENCODING_UTF_8);
227
		// }
228
		//
229
		// URL url = new URL(repository.getUrl() + "/enter_bug.cgi" + urlText);
230
		//
231
		// URLConnection cntx =
232
		// BugzillaPlugin.getDefault().getUrlConnection(url);
233
		// if (cntx != null) {
234
		// InputStream input = cntx.getInputStream();
235
		// if (input != null) {
236
		// in = new BufferedReader(new InputStreamReader(input));
237
		//
238
		//					
239
		//					
240
		// return new ProductParser(in).getProducts(repository);
241
		// }
242
		// }
243
244
		BugzillaQueryPageParser parser = new BugzillaQueryPageParser(repository, new NullProgressMonitor());
245
		if (!parser.wasSuccessful()) {
246
			throw new RuntimeException("Couldn't get products");
247
		} else {
248
			return Arrays.asList(parser.getProductValues());
249
		}
250
251
		// return null;
252
		// } finally {
253
		// try {
254
		// if (in != null)
255
		// in.close();
256
		// } catch (IOException e) {
257
		// BugzillaPlugin.log(new Status(IStatus.ERROR,
258
		// IBugzillaConstants.PLUGIN_ID, IStatus.ERROR,
259
		// "Problem closing the stream", e));
260
		// }
261
		// }
262
	}
223
	}
263
224
264
	/**
225
	/**
Lines 346-355 Link Here
346
		Attribute a = new Attribute("Severity");
307
		Attribute a = new Attribute("Severity");
347
		a.setParameterName("bug_severity");
308
		a.setParameterName("bug_severity");
348
		// get optionValues from ProductConfiguration
309
		// get optionValues from ProductConfiguration
349
		String[] optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getSeverities();
310
		List<String> optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getSeverities();
350
		// add option values from ProductConfiguration to Attribute optionValues
311
		// add option values from ProductConfiguration to Attribute optionValues
351
		for (int i = 0; i < optionValues.length; i++) {
312
		for (String option: optionValues) {
352
			a.addOptionValue(optionValues[i], optionValues[i]);
313
			a.addOptionValue(option, option);
353
		}
314
		}
354
		// add Attribute to model
315
		// add Attribute to model
355
		attributes.put("severites", a);
316
		attributes.put("severites", a);
Lines 358-365 Link Here
358
		a = new Attribute("OS");
319
		a = new Attribute("OS");
359
		a.setParameterName("op_sys");
320
		a.setParameterName("op_sys");
360
		optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getOSs();
321
		optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getOSs();
361
		for (int i = 0; i < optionValues.length; i++) {
322
		for (String option: optionValues) {
362
			a.addOptionValue(optionValues[i], optionValues[i]);
323
			a.addOptionValue(option, option);
363
		}
324
		}
364
		attributes.put("OSs", a);
325
		attributes.put("OSs", a);
365
326
Lines 367-374 Link Here
367
		a = new Attribute("Platform");
328
		a = new Attribute("Platform");
368
		a.setParameterName("rep_platform");
329
		a.setParameterName("rep_platform");
369
		optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPlatforms();
330
		optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPlatforms();
370
		for (int i = 0; i < optionValues.length; i++) {
331
		for (String option: optionValues) {
371
			a.addOptionValue(optionValues[i], optionValues[i]);
332
			a.addOptionValue(option, option);
372
		}
333
		}
373
		attributes.put("platforms", a);
334
		attributes.put("platforms", a);
374
335
Lines 376-383 Link Here
376
		a = new Attribute("Version");
337
		a = new Attribute("Version");
377
		a.setParameterName("version");
338
		a.setParameterName("version");
378
		optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getVersions(model.getProduct());
339
		optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getVersions(model.getProduct());
379
		for (int i = 0; i < optionValues.length; i++) {
340
		for (String option: optionValues) {
380
			a.addOptionValue(optionValues[i], optionValues[i]);
341
			a.addOptionValue(option, option);
381
		}
342
		}
382
		attributes.put("versions", a);
343
		attributes.put("versions", a);
383
344
Lines 385-392 Link Here
385
		a = new Attribute("Component");
346
		a = new Attribute("Component");
386
		a.setParameterName("component");
347
		a.setParameterName("component");
387
		optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getComponents(model.getProduct());
348
		optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getComponents(model.getProduct());
388
		for (int i = 0; i < optionValues.length; i++) {
349
		for (String option: optionValues) {
389
			a.addOptionValue(optionValues[i], optionValues[i]);
350
			a.addOptionValue(option, option);
390
		}
351
		}
391
		attributes.put("components", a);
352
		attributes.put("components", a);
392
353
Lines 394-401 Link Here
394
		a = new Attribute("Priority");
355
		a = new Attribute("Priority");
395
		a.setParameterName("bug_severity");
356
		a.setParameterName("bug_severity");
396
		optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPriorities();
357
		optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPriorities();
397
		for (int i = 0; i < optionValues.length; i++) {
358
		for (String option: optionValues) {
398
			a.addOptionValue(optionValues[i], optionValues[i]);
359
			a.addOptionValue(option, option);
399
		}
360
		}
400
361
401
		// set NBM Attributes (after all Attributes have been created, and added
362
		// set NBM Attributes (after all Attributes have been created, and added
Lines 425-440 Link Here
425
		return url;
386
		return url;
426
	}
387
	}
427
388
428
	static String queryOptionsToString(String[] array) {
389
	static String queryOptionsToString(List<String> array) {
429
		// make a new string buffer and go through each element in the array
390
		
430
		StringBuffer buffer = new StringBuffer();
391
		StringBuffer buffer = new StringBuffer();
431
		for (int i = 0; i < array.length; i++) {
392
		for (String string : array) {
432
			// append the new value to the end and add a '!' as a delimiter
393
			buffer.append(string);
433
			buffer.append(array[i]);
434
			buffer.append("!");
394
			buffer.append("!");
435
		}
395
		}
436
396
		
437
		// return the buffer converted to a string
438
		return buffer.toString();
397
		return buffer.toString();
439
	}
398
	}
440
399
Lines 478-533 Link Here
478
			IOException {
437
			IOException {
479
438
480
		String repositoryUrl = repository.getUrl();
439
		String repositoryUrl = repository.getUrl();
481
		BugzillaQueryPageParser parser = new BugzillaQueryPageParser(repository, monitor);
440
//		BugzillaQueryPageParser parser = new BugzillaQueryPageParser(repository, monitor);
482
		if (!parser.wasSuccessful())
441
//		if (!parser.wasSuccessful())
483
			return;
442
//			return;
443
		
444
		ProductConfiguration config = ServerConfigurationFactory.getInstance().getConfiguration(
445
				repositoryUrl);
484
446
485
		// get the preferences store so that we can change the data in it
447
		// get the preferences store so that we can change the data in it
486
		IPreferenceStore prefs = BugzillaPlugin.getDefault().getPreferenceStore();
448
		IPreferenceStore prefs = BugzillaPlugin.getDefault().getPreferenceStore();
487
449
488
		prefs.setValue(IBugzillaConstants.VALUES_STATUS + PREF_DELIM_REPOSITORY + repositoryUrl,
450
		prefs.setValue(IBugzillaConstants.VALUES_STATUS + PREF_DELIM_REPOSITORY + repositoryUrl,
489
				queryOptionsToString(parser.getStatusValues()));
451
				queryOptionsToString(config.getStatusValues()));
490
		monitor.worked(1);
452
		monitor.worked(1);
491
453
492
		prefs.setValue(IBugzillaConstants.VALUSE_STATUS_PRESELECTED + PREF_DELIM_REPOSITORY + repositoryUrl,
454
		prefs.setValue(IBugzillaConstants.VALUSE_STATUS_PRESELECTED + PREF_DELIM_REPOSITORY + repositoryUrl,
493
				queryOptionsToString(parser.getPreselectedStatusValues()));
455
				queryOptionsToString(config.getOpenStatusValues()));
494
		monitor.worked(1);
456
		monitor.worked(1);
495
457
496
		prefs.setValue(IBugzillaConstants.VALUES_RESOLUTION + PREF_DELIM_REPOSITORY + repositoryUrl,
458
		prefs.setValue(IBugzillaConstants.VALUES_RESOLUTION + PREF_DELIM_REPOSITORY + repositoryUrl,
497
				queryOptionsToString(parser.getResolutionValues()));
459
				queryOptionsToString(config.getResolutions()));
498
		monitor.worked(1);
460
		monitor.worked(1);
499
461
500
		prefs.setValue(IBugzillaConstants.VALUES_SEVERITY + PREF_DELIM_REPOSITORY + repositoryUrl,
462
		prefs.setValue(IBugzillaConstants.VALUES_SEVERITY + PREF_DELIM_REPOSITORY + repositoryUrl,
501
				queryOptionsToString(parser.getSeverityValues()));
463
				queryOptionsToString(config.getSeverities()));
502
		monitor.worked(1);
464
		monitor.worked(1);
503
465
504
		prefs.setValue(IBugzillaConstants.VALUES_PRIORITY + PREF_DELIM_REPOSITORY + repositoryUrl,
466
		prefs.setValue(IBugzillaConstants.VALUES_PRIORITY + PREF_DELIM_REPOSITORY + repositoryUrl,
505
				queryOptionsToString(parser.getPriorityValues()));
467
				queryOptionsToString(config.getPriorities()));
506
		monitor.worked(1);
468
		monitor.worked(1);
507
469
508
		prefs.setValue(IBugzillaConstants.VALUES_HARDWARE + PREF_DELIM_REPOSITORY + repositoryUrl,
470
		prefs.setValue(IBugzillaConstants.VALUES_HARDWARE + PREF_DELIM_REPOSITORY + repositoryUrl,
509
				queryOptionsToString(parser.getHardwareValues()));
471
				queryOptionsToString(config.getPlatforms()));
510
		monitor.worked(1);
472
		monitor.worked(1);
511
473
512
		prefs.setValue(IBugzillaConstants.VALUES_OS + PREF_DELIM_REPOSITORY + repositoryUrl,
474
		prefs.setValue(IBugzillaConstants.VALUES_OS + PREF_DELIM_REPOSITORY + repositoryUrl,
513
				queryOptionsToString(parser.getOSValues()));
475
				queryOptionsToString(config.getOSs()));
514
		monitor.worked(1);
476
		monitor.worked(1);
515
477
516
		prefs.setValue(IBugzillaConstants.VALUES_PRODUCT + PREF_DELIM_REPOSITORY + repositoryUrl,
478
		prefs.setValue(IBugzillaConstants.VALUES_PRODUCT + PREF_DELIM_REPOSITORY + repositoryUrl,
517
				queryOptionsToString(parser.getProductValues()));
479
				queryOptionsToString(config.getProducts()));
518
		monitor.worked(1);
480
		monitor.worked(1);
519
481
520
		prefs.setValue(IBugzillaConstants.VALUES_COMPONENT + PREF_DELIM_REPOSITORY + repositoryUrl,
482
		
521
				queryOptionsToString(parser.getComponentValues()));
483
		prefs.setValue(IBugzillaConstants.VALUES_COMPONENT + PREF_DELIM_REPOSITORY + repositoryUrl+PREF_DELIM_REPOSITORY,
484
				queryOptionsToString(config.getComponents()));
522
		monitor.worked(1);
485
		monitor.worked(1);
523
486
524
		prefs.setValue(IBugzillaConstants.VALUES_VERSION + PREF_DELIM_REPOSITORY + repositoryUrl,
487
		prefs.setValue(IBugzillaConstants.VALUES_VERSION + PREF_DELIM_REPOSITORY + repositoryUrl,
525
				queryOptionsToString(parser.getVersionValues()));
488
				queryOptionsToString(config.getVersions()));
526
		monitor.worked(1);
489
		monitor.worked(1);
527
490
		
528
		prefs.setValue(IBugzillaConstants.VALUES_TARGET + PREF_DELIM_REPOSITORY + repositoryUrl,
491
		prefs.setValue(IBugzillaConstants.VALUES_TARGET + PREF_DELIM_REPOSITORY + repositoryUrl,
529
				queryOptionsToString(parser.getTargetValues()));
492
				queryOptionsToString(config.getTargetMilestones()));
530
		monitor.worked(1);
493
		monitor.worked(1);
494
		
495
		for (String product: config.getProducts()) {
496
			prefs.setValue(IBugzillaConstants.VALUES_COMPONENT + PREF_DELIM_REPOSITORY + repositoryUrl+PREF_DELIM_REPOSITORY+product,
497
					queryOptionsToString(config.getComponents(product)));
498
			monitor.worked(1);
499
500
			prefs.setValue(IBugzillaConstants.VALUES_VERSION + PREF_DELIM_REPOSITORY + repositoryUrl,
501
					queryOptionsToString(config.getVersions(product)));
502
			monitor.worked(1);
503
			
504
			prefs.setValue(IBugzillaConstants.VALUES_TARGET + PREF_DELIM_REPOSITORY + repositoryUrl,
505
					queryOptionsToString(config.getTargetMilestones(product)));
506
			monitor.worked(1);
507
		}
508
		
509
510
		
531
	}
511
	}
532
512
533
	public static boolean downloadAttachment(TaskRepository repository, int id, File destinationFile, boolean overwrite)
513
	public static boolean downloadAttachment(TaskRepository repository, int id, File destinationFile, boolean overwrite)
(-)src/org/eclipse/mylar/internal/bugzilla/core/BugzillaPlugin.java (-41 / +54 lines)
Lines 40-46 Link Here
40
import org.eclipse.mylar.internal.bugzilla.core.internal.FavoritesFile;
40
import org.eclipse.mylar.internal.bugzilla.core.internal.FavoritesFile;
41
import org.eclipse.mylar.internal.bugzilla.core.internal.OfflineReportsFile;
41
import org.eclipse.mylar.internal.bugzilla.core.internal.OfflineReportsFile;
42
import org.eclipse.mylar.internal.bugzilla.core.internal.ProductConfiguration;
42
import org.eclipse.mylar.internal.bugzilla.core.internal.ProductConfiguration;
43
import org.eclipse.mylar.internal.bugzilla.core.internal.ProductConfigurationFactory;
43
import org.eclipse.mylar.internal.bugzilla.core.internal.ServerConfigurationFactory;
44
import org.eclipse.mylar.internal.bugzilla.core.search.IBugzillaResultEditorMatchAdapter;
44
import org.eclipse.mylar.internal.bugzilla.core.search.IBugzillaResultEditorMatchAdapter;
45
import org.eclipse.mylar.internal.core.util.MylarStatusHandler;
45
import org.eclipse.mylar.internal.core.util.MylarStatusHandler;
46
import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
46
import org.eclipse.mylar.provisional.tasklist.MylarTaskListPlugin;
Lines 105-111 Link Here
105
		}
105
		}
106
		Authenticator.setDefault(authenticator);
106
		Authenticator.setDefault(authenticator);
107
107
108
		setDefaultQueryOptions();
108
		// Removed since not repository specific
109
		//setDefaultQueryOptions();
109
110
110
		readFavoritesFile();
111
		readFavoritesFile();
111
		readOfflineReportsFile();
112
		readOfflineReportsFile();
Lines 217-222 Link Here
217
	}
218
	}
218
219
219
	public ProductConfiguration getProductConfiguration(String serverUrl) {
220
	public ProductConfiguration getProductConfiguration(String serverUrl) {
221
		if(! productConfigurations.containsKey(serverUrl))  {
222
			try {
223
				productConfigurations.put(serverUrl, ServerConfigurationFactory.getInstance().getConfiguration(
224
						serverUrl));
225
			} catch (IOException e) {
226
				MessageDialog
227
				.openInformation(
228
						null,
229
						"Retrieval of Bugzilla Configuration", "Bugzilla configuration retrieval failed.");
230
			}
231
		}
232
		
220
		return productConfigurations.get(serverUrl);
233
		return productConfigurations.get(serverUrl);
221
	}
234
	}
222
235
Lines 290-301 Link Here
290
		IPath configFile = getProductConfigurationCachePath(serverUrl);
303
		IPath configFile = getProductConfigurationCachePath(serverUrl);
291
304
292
		try {
305
		try {
293
			productConfigurations.put(serverUrl, ProductConfigurationFactory.getInstance().readConfiguration(
306
			productConfigurations.put(serverUrl, ServerConfigurationFactory.getInstance().readConfiguration(
294
					configFile.toFile()));
307
					configFile.toFile()));
295
		} catch (IOException ex) {
308
		} catch (IOException ex) {
296
			try {
309
			try {
297
				log(ex);
310
				log(ex);
298
				productConfigurations.put(serverUrl, ProductConfigurationFactory.getInstance().getConfiguration(
311
				productConfigurations.put(serverUrl, ServerConfigurationFactory.getInstance().getConfiguration(
299
						serverUrl));
312
						serverUrl));
300
			} catch (IOException e) {
313
			} catch (IOException e) {
301
				log(e);
314
				log(e);
Lines 420-461 Link Here
420
		return getPreferenceStore().getInt(IBugzillaConstants.MAX_RESULTS);
433
		return getPreferenceStore().getInt(IBugzillaConstants.MAX_RESULTS);
421
	}
434
	}
422
435
423
	private void setDefaultQueryOptions() {
436
//	private void setDefaultQueryOptions() {
424
		// get the preferences store for the bugzilla preferences
437
//		// get the preferences store for the bugzilla preferences
425
		IPreferenceStore prefs = getPreferenceStore();
438
//		IPreferenceStore prefs = getPreferenceStore();
426
439
//
427
		prefs.setDefault(IBugzillaConstants.VALUES_STATUS, BugzillaRepositoryUtil
440
//		prefs.setDefault(IBugzillaConstants.VALUES_STATUS, BugzillaRepositoryUtil
428
				.queryOptionsToString(IBugzillaConstants.DEFAULT_STATUS_VALUES));
441
//				.queryOptionsToString(IBugzillaConstants.DEFAULT_STATUS_VALUES));
429
442
//
430
		prefs.setDefault(IBugzillaConstants.VALUSE_STATUS_PRESELECTED, BugzillaRepositoryUtil
443
//		prefs.setDefault(IBugzillaConstants.VALUSE_STATUS_PRESELECTED, BugzillaRepositoryUtil
431
				.queryOptionsToString(IBugzillaConstants.DEFAULT_PRESELECTED_STATUS_VALUES));
444
//				.queryOptionsToString(IBugzillaConstants.DEFAULT_PRESELECTED_STATUS_VALUES));
432
445
//
433
		prefs.setDefault(IBugzillaConstants.VALUES_RESOLUTION, BugzillaRepositoryUtil
446
//		prefs.setDefault(IBugzillaConstants.VALUES_RESOLUTION, BugzillaRepositoryUtil
434
				.queryOptionsToString(IBugzillaConstants.DEFAULT_RESOLUTION_VALUES));
447
//				.queryOptionsToString(IBugzillaConstants.DEFAULT_RESOLUTION_VALUES));
435
448
//
436
		prefs.setDefault(IBugzillaConstants.VALUES_SEVERITY, BugzillaRepositoryUtil
449
//		prefs.setDefault(IBugzillaConstants.VALUES_SEVERITY, BugzillaRepositoryUtil
437
				.queryOptionsToString(IBugzillaConstants.DEFAULT_SEVERITY_VALUES));
450
//				.queryOptionsToString(IBugzillaConstants.DEFAULT_SEVERITY_VALUES));
438
451
//
439
		prefs.setDefault(IBugzillaConstants.VALUES_PRIORITY, BugzillaRepositoryUtil
452
//		prefs.setDefault(IBugzillaConstants.VALUES_PRIORITY, BugzillaRepositoryUtil
440
				.queryOptionsToString(IBugzillaConstants.DEFAULT_PRIORITY_VALUES));
453
//				.queryOptionsToString(IBugzillaConstants.DEFAULT_PRIORITY_VALUES));
441
454
//
442
		prefs.setDefault(IBugzillaConstants.VALUES_HARDWARE, BugzillaRepositoryUtil
455
//		prefs.setDefault(IBugzillaConstants.VALUES_HARDWARE, BugzillaRepositoryUtil
443
				.queryOptionsToString(IBugzillaConstants.DEFAULT_HARDWARE_VALUES));
456
//				.queryOptionsToString(IBugzillaConstants.DEFAULT_HARDWARE_VALUES));
444
457
//
445
		prefs.setDefault(IBugzillaConstants.VALUES_OS, BugzillaRepositoryUtil
458
//		prefs.setDefault(IBugzillaConstants.VALUES_OS, BugzillaRepositoryUtil
446
				.queryOptionsToString(IBugzillaConstants.DEFAULT_OS_VALUES));
459
//				.queryOptionsToString(IBugzillaConstants.DEFAULT_OS_VALUES));
447
460
//
448
		prefs.setDefault(IBugzillaConstants.VALUES_PRODUCT, BugzillaRepositoryUtil
461
//		prefs.setDefault(IBugzillaConstants.VALUES_PRODUCT, BugzillaRepositoryUtil
449
				.queryOptionsToString(IBugzillaConstants.DEFAULT_PRODUCT_VALUES));
462
//				.queryOptionsToString(IBugzillaConstants.DEFAULT_PRODUCT_VALUES));
450
463
//
451
		prefs.setDefault(IBugzillaConstants.VALUES_COMPONENT, BugzillaRepositoryUtil
464
//		prefs.setDefault(IBugzillaConstants.VALUES_COMPONENT, BugzillaRepositoryUtil
452
				.queryOptionsToString(IBugzillaConstants.DEFAULT_COMPONENT_VALUES));
465
//				.queryOptionsToString(IBugzillaConstants.DEFAULT_COMPONENT_VALUES));
453
466
//
454
		prefs.setDefault(IBugzillaConstants.VALUES_VERSION, BugzillaRepositoryUtil
467
//		prefs.setDefault(IBugzillaConstants.VALUES_VERSION, BugzillaRepositoryUtil
455
				.queryOptionsToString(IBugzillaConstants.DEFAULT_VERSION_VALUES));
468
//				.queryOptionsToString(IBugzillaConstants.DEFAULT_VERSION_VALUES));
456
469
//
457
		prefs.setDefault(IBugzillaConstants.VALUES_TARGET, BugzillaRepositoryUtil
470
//		prefs.setDefault(IBugzillaConstants.VALUES_TARGET, BugzillaRepositoryUtil
458
				.queryOptionsToString(IBugzillaConstants.DEFAULT_TARGET_VALUES));
471
//				.queryOptionsToString(IBugzillaConstants.DEFAULT_TARGET_VALUES));
459
	}
472
//	}
460
	
473
	
461
}
474
}
(-)src/org/eclipse/mylar/internal/bugzilla/core/internal/ProductConfigurationFactory.java (-196 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 University Of British Columbia and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     University Of British Columbia - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.bugzilla.core.internal;
13
14
import java.io.BufferedReader;
15
import java.io.File;
16
import java.io.FileInputStream;
17
import java.io.FileOutputStream;
18
import java.io.IOException;
19
import java.io.InputStreamReader;
20
import java.io.ObjectInputStream;
21
import java.io.ObjectOutputStream;
22
import java.net.URL;
23
import java.net.URLConnection;
24
import java.util.ArrayList;
25
26
import org.eclipse.mylar.internal.bugzilla.core.BugzillaPlugin;
27
28
/**
29
 * A factory for creating ProductConfiguration objects that encapsulate valid
30
 * combinations of products, components, and versions.
31
 */
32
public class ProductConfigurationFactory {
33
	/** Singleton factory instance */
34
	private static ProductConfigurationFactory instance;
35
36
	/**
37
	 * Private constructor to ensure singleton instances.
38
	 */
39
	private ProductConfigurationFactory() {
40
		// no initial setup needed
41
	}
42
43
	/**
44
	 * Returns the factory singletoninstance.
45
	 */
46
	public static synchronized ProductConfigurationFactory getInstance() {
47
		if (instance == null) {
48
			instance = new ProductConfigurationFactory();
49
		}
50
		return instance;
51
	}
52
53
	/**
54
	 * Builds a ProductConfiguration object by parsing the source of the
55
	 * Bugzilla query page.
56
	 */
57
	public ProductConfiguration getConfiguration(String server) throws IOException {
58
		URL serverURL = new URL(server + "/query.cgi");
59
		ProductConfiguration configuration = new ProductConfiguration();
60
		ArrayList<String[]> componentsMatrix = new ArrayList<String[]>();
61
		ArrayList<String[]> versionsMatrix = new ArrayList<String[]>();
62
		URLConnection c = serverURL.openConnection();
63
		BufferedReader in = new BufferedReader(new InputStreamReader(c.getInputStream()));
64
		String line;
65
		while ((line = in.readLine()) != null) {
66
			if (line.startsWith("  cpts[")) {
67
				String[] components = parseComponents(line);
68
				if (components.length > 0)
69
					componentsMatrix.add(components);
70
			} else if (line.startsWith("  vers[")) {
71
				String[] versions = parseComponents(line);
72
				if (versions.length > 0)
73
					versionsMatrix.add(versions);
74
			} else if (line.indexOf("<select name=\"product\"") != -1) {
75
				String[] products = parseProducts(in);
76
				for (int i = 0; i < products.length; i++) {
77
					String product = products[i];
78
					configuration.addProduct(product);
79
					// If components don't jibe with the products, just don't
80
					// make them available.
81
					if (products.length == componentsMatrix.size()) {
82
						configuration.addComponents(product, componentsMatrix.get(i));
83
					}
84
85
					// If versions don't jibe with the products, just don't make
86
					// them available
87
					if (products.length == versionsMatrix.size()) {
88
						configuration.addVersions(product, versionsMatrix.get(i));
89
					}
90
				}
91
			}
92
		}
93
		return configuration;
94
	}
95
96
	/**
97
	 * Returns an array of valid components or versions by parsing the
98
	 * JavaScript array in the Bugzilla query page.
99
	 */
100
	protected String[] parseComponents(String line) {
101
		ArrayList<String> components = new ArrayList<String>();
102
		int start = line.indexOf('\'');
103
		if (start >= 0) {
104
			boolean inName = true;
105
			StringBuffer name = new StringBuffer();
106
			for (int i = start + 1; i < line.length(); i++) {
107
				char ch = line.charAt(i);
108
				if (inName) {
109
					if (ch == '\'') {
110
						components.add(name.toString());
111
						name.setLength(0);
112
						inName = false;
113
					} else
114
						name.append(ch);
115
				} else {
116
					if (ch == '\'') {
117
						inName = true;
118
					}
119
				}
120
			}
121
		}
122
		return components.toArray(new String[0]);
123
	}
124
125
	/**
126
	 * Returns an array of valid product names by parsing the product selection
127
	 * list in the Bugzilla query page.
128
	 */
129
	protected String[] parseProducts(BufferedReader in) throws IOException {
130
		ArrayList<String> products = new ArrayList<String>();
131
		String line;
132
		while ((line = in.readLine()) != null) {
133
			if (line.indexOf("</select>") != -1)
134
				break;
135
			int optionIndex = line.indexOf("<option value=\"");
136
			if (optionIndex != -1) {
137
				boolean inName = false;
138
				StringBuffer name = new StringBuffer();
139
				for (int i = optionIndex; i < line.length(); i++) {
140
					char ch = line.charAt(i);
141
					if (inName) {
142
						if (ch == '<') {
143
							products.add(name.toString());
144
							break;
145
						} else
146
							name.append(ch);
147
					} else {
148
						if (ch == '>') {
149
							inName = true;
150
						}
151
					}
152
				}
153
			}
154
		}
155
		return products.toArray(new String[0]);
156
	}
157
158
	/**
159
	 * Restores a ProductConfiguration from a file.
160
	 */
161
	public ProductConfiguration readConfiguration(File file) throws IOException {
162
		if (!file.exists())
163
			return null;
164
		FileInputStream fin = null;
165
		ProductConfiguration configuration = null;
166
		try {
167
			fin = new FileInputStream(file);
168
			ObjectInputStream in = new ObjectInputStream(fin);
169
			configuration = (ProductConfiguration) in.readObject();
170
		} catch (ClassNotFoundException e) {
171
			BugzillaPlugin.log(e);
172
			IOException ex = new IOException();
173
			ex.initCause(e);
174
			throw ex;
175
		} finally {
176
			if (fin != null)
177
				fin.close();
178
		}
179
		return configuration;
180
	}
181
182
	/**
183
	 * Saves a ProductConfiguration to a file.
184
	 */
185
	public void writeConfiguration(ProductConfiguration configuration, File file) throws IOException {
186
		FileOutputStream fout = null;
187
		try {
188
			fout = new FileOutputStream(file);
189
			ObjectOutputStream out = new ObjectOutputStream(fout);
190
			out.writeObject(configuration);
191
		} finally {
192
			if (fout != null)
193
				fout.close();
194
		}
195
	}
196
}
(-)src/org/eclipse/mylar/internal/bugzilla/core/internal/HtmlTag.java (+15 lines)
Lines 35-40 Link Here
35
35
36
	/** tag's base url */
36
	/** tag's base url */
37
	private URL baseUrl;
37
	private URL baseUrl;
38
	
39
	/** tag is self terminated */
40
	private boolean selfTerminating;
38
41
39
	/**
42
	/**
40
	 * Basic constructor. The tag is uninitialized.
43
	 * Basic constructor. The tag is uninitialized.
Lines 244-249 Link Here
244
				sb.append('"');
247
				sb.append('"');
245
			}
248
			}
246
		}
249
		}
250
		if(selfTerminating) {
251
			sb.append('/');
252
		}
247
		sb.append('>');
253
		sb.append('>');
248
254
249
		return sb.toString();
255
		return sb.toString();
Lines 344-347 Link Here
344
		tags.put(new String("UL"), Tag.UL);
350
		tags.put(new String("UL"), Tag.UL);
345
		tags.put(new String("VAR"), Tag.VAR);
351
		tags.put(new String("VAR"), Tag.VAR);
346
	}
352
	}
353
	
354
	public void setSelfTerminating(boolean terminating) {
355
		this.selfTerminating = terminating;
356
		
357
	}
358
	
359
	public boolean isSelfTerminating() {
360
		return selfTerminating;
361
	}
347
}
362
}
(-)src/org/eclipse/mylar/internal/bugzilla/core/internal/ProductConfiguration.java (-43 / +186 lines)
Lines 11-18 Link Here
11
11
12
package org.eclipse.mylar.internal.bugzilla.core.internal;
12
package org.eclipse.mylar.internal.bugzilla.core.internal;
13
13
14
import java.io.Serializable;
15
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Collections;
16
import java.util.HashMap;
16
import java.util.HashMap;
17
import java.util.List;
17
import java.util.List;
18
import java.util.Map;
18
import java.util.Map;
Lines 20-36 Link Here
20
/**
20
/**
21
 * Class describing the configuration of products and components for a given
21
 * Class describing the configuration of products and components for a given
22
 * Bugzilla installation.
22
 * Bugzilla installation.
23
 * 
24
 * @author Rob Elves
23
 */
25
 */
24
public class ProductConfiguration implements Serializable {
26
public class ProductConfiguration {
25
26
	/** Automatically generated serialVersionUID */
27
	private static final long serialVersionUID = 3257004354337519410L;
28
27
29
	private Map<String, ProductEntry> products = new HashMap<String, ProductEntry>();
28
	private Map<String, ProductEntry> products = new HashMap<String, ProductEntry>();
30
29
30
	private List<String> platforms = new ArrayList<String>();
31
32
	private List<String> operatingSystems = new ArrayList<String>();
33
34
	private List<String> priorities = new ArrayList<String>();
35
36
	private List<String> severities = new ArrayList<String>();
37
	
38
	private List<String> bugStatus = new ArrayList<String>();
39
	
40
	private List<String> openStatusValues = new ArrayList<String>();
41
	
42
	private List<String> resolutionValues = new ArrayList<String>();
43
	
44
	// master lists
45
	
46
	private List<String> versions = new ArrayList<String>();
47
	
48
	private List<String> components = new ArrayList<String>();
49
	
50
	private List<String> milestones = new ArrayList<String>();
51
	
52
	
53
		
54
	private String bugzillaVersion = "unknown";
55
31
	public ProductConfiguration() {
56
	public ProductConfiguration() {
32
		super();
57
		super();
33
	}
58
	}
59
	
60
	public void addStatus(String status) {
61
		bugStatus.add(status);
62
	}
63
	
64
	public List<String> getStatusValues() {
65
		return bugStatus;
66
	}
67
	
68
	public void addResolution(String res) {
69
		resolutionValues.add(res);
70
	}
71
	
72
	public List<String> getResolutions() {
73
		return resolutionValues;
74
	}
34
75
35
	/**
76
	/**
36
	 * Adds a product to the configuration.
77
	 * Adds a product to the configuration.
Lines 45-110 Link Here
45
	/**
86
	/**
46
	 * Returns an array of names of current products.
87
	 * Returns an array of names of current products.
47
	 */
88
	 */
48
	public String[] getProducts() {
89
	public List<String> getProducts() {
49
		return products.keySet().toArray(new String[0]);
90
		return new ArrayList<String>(products.keySet());
50
	}
91
	}
51
92
52
	/**
93
	/**
53
	 * Returns an array of names of component that exist for a given product or
94
	 * Returns an array of names of component that exist for a given product or
54
	 * <code>null</code> if the product does not exist.
95
	 * <code>null</code> if the product does not exist.
55
	 */
96
	 */
56
	public String[] getComponents(String product) {
97
	public List<String> getComponents(String product) {
57
		ProductEntry entry = products.get(product);
98
		ProductEntry entry = products.get(product);
58
		if (entry != null) {
99
		if (entry != null) {
59
			return entry.getComponents();
100
			return entry.getComponents();
60
		} else
101
		} else
61
			return null;
102
			return Collections.emptyList();
62
	}
103
	}
63
104
64
	/**
105
	/**
65
	 * Returns an array of names of versions that exist for a given product or
106
	 * Returns an array of names of versions that exist for a given product or
66
	 * <code>null</code> if the product does not exist.
107
	 * <code>null</code> if the product does not exist.
67
	 */
108
	 */
68
	public String[] getVersions(String product) {
109
	public List<String> getVersions(String product) {
69
		ProductEntry entry = products.get(product);
110
		ProductEntry entry = products.get(product);
70
		if (entry != null) {
111
		if (entry != null) {
71
			return entry.getVersions();
112
			return entry.getVersions();
72
		} else
113
		} else
73
			return null;
114
			return Collections.emptyList();
74
	}
115
	}
75
116
76
	/**
117
	/**
77
	 * Returns an array of names of valid severity values.
118
	 * Returns an array of names of valid severity values.
78
	 */
119
	 */
79
	public String[] getSeverities() {
120
	public List<String> getSeverities() {
80
		return new String[] { "blocker", "critical", "major", "normal", "minor", "trivial", "enhancement" };
121
		return severities;
122
		// return new List<String> { "blocker", "critical", "major", "normal",
123
		// "minor", "trivial", "enhancement" };
81
	}
124
	}
82
125
83
	/**
126
	/**
84
	 * Returns an array of names of valid OS values.
127
	 * Returns an array of names of valid OS values.
85
	 */
128
	 */
86
	public String[] getOSs() {
129
	public List<String> getOSs() {
87
		return new String[] { "All", "Windows XP", "Linux", "other" };
130
		return operatingSystems;
131
		// return new List<String> { "All", "Windows XP", "Linux", "other" };
132
	}
133
134
	public void addOS(String os) {
135
		operatingSystems.add(os);
88
	}
136
	}
89
137
90
	/**
138
	/**
91
	 * Returns an array of names of valid platform values.
139
	 * Returns an array of names of valid platform values.
92
	 */
140
	 */
93
	public String[] getPlatforms() {
141
	public List<String> getPlatforms() {
94
		return new String[] { "All", "Macintosh", "PC" };
142
		return platforms;
143
		// return new List<String> { "All", "Macintosh", "PC" };
95
	}
144
	}
96
145
97
	/**
146
	/**
98
	 * Returns an array of names of valid platform values.
147
	 * Returns an array of names of valid platform values.
99
	 */
148
	 */
100
	public String[] getPriorities() {
149
	public List<String> getPriorities() {
101
		return new String[] { "P1", "P2", "P3", "P4", "P5" };
150
		return priorities;
151
		// return new List<String> { "P1", "P2", "P3", "P4", "P5" };
102
	}
152
	}
103
153
104
	/**
154
	/**
105
	 * Adds a component to the given product.
155
	 * Adds a component to the given product.
106
	 */
156
	 */
107
	public void addComponent(String product, String component) {
157
	public void addComponent(String product, String component) {
158
		if(!components.contains(component)) components.add(component);
108
		ProductEntry entry = products.get(product);
159
		ProductEntry entry = products.get(product);
109
		if (entry == null) {
160
		if (entry == null) {
110
			entry = new ProductEntry(product);
161
			entry = new ProductEntry(product);
Lines 113-168 Link Here
113
		entry.addComponent(component);
164
		entry.addComponent(component);
114
	}
165
	}
115
166
116
	/**
167
//	/**
117
	 * Adds a list of components to the given product.
168
//	 * Adds a list of components to the given product.
118
	 */
169
//	 */
119
	public void addComponents(String product, String[] components) {
170
//	public void addComponents(String product, List<String> components) {
171
//		ProductEntry entry = products.get(product);
172
//		if (entry == null) {
173
//			entry = new ProductEntry(product);
174
//			products.put(product, entry);
175
//		}
176
//		for (String component : components) {
177
//			entry.addComponent(component);
178
//		}
179
//	}
180
//	/**
181
//	 * Adds a list of components to the given product.
182
//	 */
183
//	public void addComponents(String product, List<String> components) {
184
//		ProductEntry entry = products.get(product);
185
//		if (entry == null) {
186
//			entry = new ProductEntry(product);
187
//			products.put(product, entry);
188
//		}
189
//		for (String component : components) {
190
//			entry.addComponent(component);
191
//		}			
192
//	}
193
194
	
195
	public void addVersion(String product, String version) {
196
		if(!versions.contains(version)) versions.add(version);
120
		ProductEntry entry = products.get(product);
197
		ProductEntry entry = products.get(product);
121
		if (entry == null) {
198
		if (entry == null) {
122
			entry = new ProductEntry(product);
199
			entry = new ProductEntry(product);
123
			products.put(product, entry);
200
			products.put(product, entry);
124
		}
201
		}
125
		for (int i = 0; i < components.length; i++) {
202
		entry.addVersion(version);
126
			String component = components[i];
127
			entry.addComponent(component);
128
		}
129
	}
203
	}
204
	
205
//	/**
206
//	 * Adds a list of components to the given product.
207
//	 */
208
//	public void addVersions(String product, List<String> versions) {
209
//		ProductEntry entry = products.get(product);
210
//		if (entry == null) {
211
//			entry = new ProductEntry(product);
212
//			products.put(product, entry);
213
//		}
214
//		for (String version : versions) {
215
//			entry.addVersion(version);
216
//		}
217
//	}
130
218
131
	/**
219
	public void addPlatform(String platform) {
132
	 * Adds a list of components to the given product.
220
		platforms.add(platform);
133
	 */
221
	}
134
	public void addVersions(String product, String[] versions) {
222
223
	public void addPriority(String priority) {
224
		priorities.add(priority);
225
226
	}
227
228
	public void addSeverity(String severity) {
229
		severities.add(severity);
230
		
231
	}
232
233
	public void setInstallVersion(String version) {
234
		bugzillaVersion = version;
235
	}
236
	
237
	public String getInstallVersion() {
238
		return bugzillaVersion;
239
	}
240
	
241
	public void addTargetMilestone(String product, String target) {
242
		if(!milestones.contains(target)) milestones.add(target);
135
		ProductEntry entry = products.get(product);
243
		ProductEntry entry = products.get(product);
136
		if (entry == null) {
244
		if (entry == null) {
137
			entry = new ProductEntry(product);
245
			entry = new ProductEntry(product);
138
			products.put(product, entry);
246
			products.put(product, entry);
139
		}
247
		}
140
		for (int i = 0; i < versions.length; i++) {
248
		
141
			String version = versions[i];
249
		entry.addTargetMilestone(target);
142
			entry.addVersion(version);
250
		
143
		}
251
	}
252
253
	public List<String> getTargetMilestones(String product) {
254
		ProductEntry entry = products.get(product);
255
		if (entry != null) {
256
			return entry.getTargetMilestones();
257
		} else
258
			return Collections.emptyList();
144
	}
259
	}
145
260
146
	/**
261
	/**
147
	 * Container for product information: name, components.
262
	 * Container for product information: name, components.
148
	 */
263
	 */
149
	private static class ProductEntry implements Serializable {
264
	private static class ProductEntry {
150
151
		/** Automatically generated serialVersionUID */
152
		private static final long serialVersionUID = 3977018465733391668L;
153
265
154
		String productName;
266
		String productName;
155
267
156
		List<String> components = new ArrayList<String>();
268
		List<String> components = new ArrayList<String>();
157
269
158
		List<String> versions = new ArrayList<String>();
270
		List<String> versions = new ArrayList<String>();
271
		
272
		List<String> milestones = new ArrayList<String>();
159
273
160
		ProductEntry(String name) {
274
		ProductEntry(String name) {
161
			this.productName = name;
275
			this.productName = name;
162
		}
276
		}
163
277
164
		String[] getComponents() {
278
		List<String> getComponents() {
165
			return components.toArray(new String[0]);
279
			return components;
166
		}
280
		}
167
281
168
		void addComponent(String componentName) {
282
		void addComponent(String componentName) {
Lines 171-178 Link Here
171
			}
285
			}
172
		}
286
		}
173
287
174
		String[] getVersions() {
288
		List<String> getVersions() {
175
			return versions.toArray(new String[0]);
289
			return versions;
176
		}
290
		}
177
291
178
		void addVersion(String name) {
292
		void addVersion(String name) {
Lines 180-184 Link Here
180
				versions.add(name);
294
				versions.add(name);
181
			}
295
			}
182
		}
296
		}
297
		
298
		List<String> getTargetMilestones() {
299
			return milestones;
300
		}
301
		
302
		void addTargetMilestone(String target) {
303
			milestones.add(target);
304
		}
305
	}
306
307
	public List<String> getOpenStatusValues() {
308
		return openStatusValues;
309
	}
310
311
	public void addOpenStatusValue(String value) {
312
		openStatusValues.add(value);
313
	}
314
315
	public List<String> getComponents() {
316
		return components;
317
	}
318
	
319
	public List<String> getTargetMilestones() {
320
		return milestones;
321
	}
322
	
323
	public List<String> getVersions() {
324
		return versions;
183
	}
325
	}
326
	
184
}
327
}
(-)src/org/eclipse/mylar/internal/bugzilla/core/internal/HtmlStreamTokenizer.java (-6 / +19 lines)
Lines 223-234 Link Here
223
			}
223
			}
224
			String attributeName = s.substring(start, i).toLowerCase();
224
			String attributeName = s.substring(start, i).toLowerCase();
225
225
226
			if(attributeName.equals("/")) {
227
				tag.setSelfTerminating(true);
228
				continue;
229
			}
230
			
226
			for (; i < s.length() && Character.isWhitespace(s.charAt(i)); i++) {
231
			for (; i < s.length() && Character.isWhitespace(s.charAt(i)); i++) {
227
				// just move forward
232
				// just move forward
228
			}
233
			}
229
			if (i == s.length() || s.charAt(i) != '=') {
234
			if (i == s.length() || s.charAt(i) != '=') {
230
				// no attribute value
235
				// no attribute value				
231
				tag.setAttribute(attributeName, "");
236
				tag.setAttribute(attributeName, "");				
232
				continue;
237
				continue;
233
			}
238
			}
234
239
Lines 450-465 Link Here
450
			}
455
			}
451
			if (value != null) {
456
			if (value != null) {
452
				if (type == TAG) {
457
				if (type == TAG) {
453
					sb.append('<');
458
					// sb.append('<');
454
				} else if (type == COMMENT) {
459
				} else if (type == COMMENT) {
455
					sb.append("<!");
460
					sb.append("<!--");
456
				}
461
				}
457
				sb.append(value);
462
				sb.append(value);
458
				if (type == TAG) {
463
				if (type == TAG) {
459
					sb.append('>');
464
					// if(value instanceof HtmlTag) {
465
					// HtmlTag htmlTag = (HtmlTag)value;
466
					// if(htmlTag.getTagName().startsWith("?xml")) {
467
					// sb.append("?>");
468
					// }
469
					// } else {
470
					// sb.append('>');
471
460
				} else if (type == COMMENT) {
472
				} else if (type == COMMENT) {
461
					sb.append("-->");
473
					sb.append("-->");
462
				}
474
				}
475
463
			}
476
			}
464
			return sb.toString();
477
			return sb.toString();
465
		}
478
		}
Lines 501-507 Link Here
501
	/*
514
	/*
502
	 * Based on ISO 8879.
515
	 * Based on ISO 8879.
503
	 * 
516
	 * 
504
	 * Portions � International Organization for Standardization 1986 Permission
517
	 * Portions � International Organization for Standardization 1986 Permission
505
	 * to copy in any form is granted for use with conforming SGML systems and
518
	 * to copy in any form is granted for use with conforming SGML systems and
506
	 * applications as defined in ISO 8879, provided this notice is included in
519
	 * applications as defined in ISO 8879, provided this notice is included in
507
	 * all copies.
520
	 * all copies.
(-)src/org/eclipse/mylar/internal/bugzilla/core/internal/ServerConfigurationFactory.java (+116 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 University Of British Columbia and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     University Of British Columbia - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.bugzilla.core.internal;
13
14
import java.io.BufferedReader;
15
import java.io.IOException;
16
import java.io.InputStreamReader;
17
import java.io.StringReader;
18
import java.net.URL;
19
import java.net.URLConnection;
20
21
import org.xml.sax.InputSource;
22
import org.xml.sax.SAXException;
23
import org.xml.sax.XMLReader;
24
import org.xml.sax.helpers.XMLReaderFactory;
25
26
/**
27
 * Reads bugzilla product configuration from config.cgi on server in RDF format.
28
 * 
29
 * @author Rob Elves
30
 */
31
public class ServerConfigurationFactory extends AbstractBugzillaConfigurationFactory {
32
33
	private static final String CONFIG_RDF_URL = "/config.cgi?ctype=rdf";
34
35
	private static AbstractBugzillaConfigurationFactory instance;
36
37
	private ServerConfigurationFactory() {
38
		// no initial setup needed
39
	}
40
41
	public static synchronized AbstractBugzillaConfigurationFactory getInstance() {
42
		if (instance == null) {
43
			instance = new ServerConfigurationFactory();
44
		}
45
		return instance;
46
	}
47
48
	// public ProductConfiguration getConfiguration(String server) throws
49
	// IOException {
50
	// URL serverURL = new URL(server + "/config.cgi?ctype=rdf");
51
	// URLConnection c = serverURL.openConnection();
52
	// BufferedReader in = new BufferedReader(new
53
	// InputStreamReader(c.getInputStream()));
54
	// Document document;
55
	// DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
56
	// factory.setValidating(false);
57
	// factory.setNamespaceAware(false);
58
	// try {
59
	// DocumentBuilder builder = factory.newDocumentBuilder();
60
	// document = builder.parse( new InputSource(in) );
61
	//
62
	// } catch (SAXParseException spe) {
63
	// System.err.println("Sax parse exception!");
64
	// } catch (ParserConfigurationException e) {
65
	// e.printStackTrace();
66
	// } catch (SAXException e) {
67
	// e.printStackTrace();
68
	// }
69
	// return null;
70
	//
71
	// }
72
73
	public ProductConfiguration getConfiguration(String server) throws IOException {
74
		URL serverURL = new URL(server + CONFIG_RDF_URL);
75
		URLConnection c = serverURL.openConnection();
76
		BufferedReader in = new BufferedReader(new InputStreamReader(c.getInputStream()));
77
78
		SaxConfigurationContentHandler contentHandler = new SaxConfigurationContentHandler();
79
80
		try {
81
			StringBuffer result = XmlCleaner.clean(in);
82
			StringReader strReader = new StringReader(result.toString());
83
			XMLReader reader = XMLReaderFactory.createXMLReader();
84
			// reader.setErrorHandler(new SaxErrorHandler())
85
			reader.setContentHandler(contentHandler);
86
			reader.parse(new InputSource(strReader));
87
		} catch (SAXException e) {
88
			throw new IOException("Unable to read server configuration.");
89
		}
90
		return contentHandler.getConfiguration();
91
92
	}
93
94
	// class SaxErrorHandler implements ErrorHandler {
95
	//
96
	// public void error(SAXParseException exception) throws SAXException {
97
	// System.err.println("Error:
98
	// "+exception.getLineNumber()+"\n"+exception.getLocalizedMessage());
99
	//			
100
	// }
101
	//
102
	// public void fatalError(SAXParseException exception) throws SAXException {
103
	// System.err.println("Fatal Error:
104
	// "+exception.getLineNumber()+"\n"+exception.getLocalizedMessage());
105
	//			
106
	// }
107
	//
108
	// public void warning(SAXParseException exception) throws SAXException {
109
	// System.err.println("Warning:
110
	// "+exception.getLineNumber()+"\n"+exception.getLocalizedMessage());
111
	//			
112
	// }
113
	//		
114
	// }
115
116
}
(-)src/org/eclipse/mylar/internal/bugzilla/core/internal/SaxConfigurationContentHandler.java (+389 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 University Of British Columbia and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     University Of British Columbia - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.bugzilla.core.internal;
13
14
import java.util.ArrayList;
15
import java.util.HashMap;
16
import java.util.List;
17
import java.util.Map;
18
19
import org.xml.sax.Attributes;
20
import org.xml.sax.SAXException;
21
import org.xml.sax.helpers.DefaultHandler;
22
23
/**
24
 * Quick config rdf parser.
25
 * 
26
 * <pre>
27
 *  config.cgi?ctype=rdf
28
 * </pre>
29
 * 
30
 * Populates a <link>ProductConfiguration</link> data structure.
31
 * 
32
 * @author Rob Elves
33
 */
34
public class SaxConfigurationContentHandler extends DefaultHandler {
35
36
	private static final String ELEMENT_RESOLUTION = "resolution";
37
38
	private static final String ELEMENT_STATUS_OPEN = "status_open";
39
40
	private static final String ELEMENT_TARGET_MILESTONE = "target_milestone";
41
42
	private static final String ELEMENT_TARGET_MILESTONES = "target_milestones";
43
44
	private static final String ELEMENT_INSTALL_VERSION = "install_version";
45
46
	private static final String ATTRIBUTE_RDF_ABOUT = "rdf:about";
47
48
	private static final String ATTRIBUTE_RESOURCE = "resource";
49
50
	private static final String ELEMENT_VERSION = "version";
51
52
	private static final String ELEMENT_VERSIONS = "versions";
53
54
	private static final String ELEMENT_COMPONENT = "component";
55
56
	private static final String ELEMENT_COMPONENTS = "components";
57
58
	private static final String ELEMENT_NAME = "name";
59
60
	private static final String ELEMENT_PRODUCTS = "products";
61
62
	private static final String ELEMENT_SEVERITY = "severity";
63
64
	private static final String ELEMENT_PRIORITY = "priority";
65
66
	private static final String ELEMENT_OP_SYS = "op_sys";
67
68
	private static final String ELEMENT_PLATFORM = "platform";
69
70
	private static final String ELEMENT_LI = "li";
71
72
	private static final String ELEMENT_STATUS = "status";
73
74
	private static final int EXPECTING_ROOT = 0;
75
76
	private static final int IN_INSTALL_VERSION = 1 << 1;
77
78
	private static final int IN_STATUS = 1 << 2;
79
80
	private static final int IN_PLATFORM = 1 << 3;
81
82
	private static final int IN_OP_SYS = 1 << 4;
83
84
	private static final int IN_PRIORITY = 1 << 5;
85
86
	private static final int IN_SEVERITY = 1 << 6;
87
88
	private static final int IN_PRODUCTS = 1 << 7;
89
90
	private static final int IN_COMPONENTS = 1 << 8;
91
92
	private static final int IN_VERSIONS = 1 << 9;
93
94
	private static final int IN_LI = 1 << 10;
95
96
	private static final int IN_LI_LI = 1 << 11;
97
98
	private static final int IN_NAME = 1 << 12;
99
100
	private static final int IN_COMPONENT = 1 << 13;
101
102
	private static final int IN_VERSION = 1 << 14;
103
104
	private static final int IN_TARGET_MILESTONES = 1 << 15;
105
106
	private static final int IN_TARGET_MILESTONE = 1 << 16;
107
108
	private static final int IN_STATUS_OPEN = 1 << 17;
109
	
110
	private static final int IN_RESOLUTION = 1 << 18;
111
112
	private int state = EXPECTING_ROOT;
113
114
	private String currentProduct;
115
116
	private String about;
117
118
	private ProductConfiguration configuration = new ProductConfiguration();
119
120
	private Map<String, List<String>> components = new HashMap<String, List<String>>();
121
122
	private Map<String, List<String>> versions = new HashMap<String, List<String>>();
123
124
	private Map<String, List<String>> milestones = new HashMap<String, List<String>>();
125
126
	private Map<String, String> componentNames = new HashMap<String, String>();
127
128
	private Map<String, String> versionNames = new HashMap<String, String>();
129
130
	private Map<String, String> milestoneNames = new HashMap<String, String>();
131
132
	public ProductConfiguration getConfiguration() {
133
		return configuration;
134
	}
135
136
	@Override
137
	public void characters(char[] ch, int start, int length) throws SAXException {
138
		switch (state) {
139
140
		case IN_PRODUCTS | IN_LI | IN_NAME:
141
			configuration.addProduct(String.copyValueOf(ch, start, length));
142
			currentProduct = String.copyValueOf(ch, start, length);
143
			break;
144
		case IN_COMPONENTS | IN_LI | IN_COMPONENT | IN_NAME:
145
			if (about != null) {
146
				String name = String.copyValueOf(ch, start, length);
147
				componentNames.put(about, name);
148
				// System.err.println("Component: "+about+" ---> "+name);
149
			}
150
			break;
151
		case IN_VERSIONS | IN_LI | IN_VERSION | IN_NAME:
152
			if (about != null) {
153
				String name = String.copyValueOf(ch, start, length);
154
				versionNames.put(about, name);
155
				// System.err.println("Version: "+about+" ---> "+name);
156
			}
157
			break;
158
		case IN_TARGET_MILESTONES | IN_LI | IN_TARGET_MILESTONE | IN_NAME:
159
			if (about != null) {
160
				String name = String.copyValueOf(ch, start, length);
161
				milestoneNames.put(about, name);
162
				// System.err.println("Version: "+about+" ---> "+name);
163
			}
164
			break;
165
		case IN_PLATFORM | IN_LI:
166
			configuration.addPlatform(String.copyValueOf(ch, start, length));
167
			break;
168
		case IN_OP_SYS | IN_LI:
169
			configuration.addOS(String.copyValueOf(ch, start, length));
170
			break;
171
		case IN_PRIORITY | IN_LI:
172
			configuration.addPriority(String.copyValueOf(ch, start, length));
173
			break;
174
		case IN_SEVERITY | IN_LI:
175
			configuration.addSeverity(String.copyValueOf(ch, start, length));
176
			break;
177
		case IN_INSTALL_VERSION:
178
			configuration.setInstallVersion(String.copyValueOf(ch, start, length));
179
			break;
180
		case IN_STATUS | IN_LI:
181
			configuration.addStatus(String.copyValueOf(ch, start, length));
182
			break;
183
		case IN_RESOLUTION | IN_LI:
184
			configuration.addResolution(String.copyValueOf(ch, start, length));
185
			break;
186
		case IN_STATUS_OPEN | IN_LI:
187
			configuration.addOpenStatusValue(String.copyValueOf(ch, start, length));
188
			break;
189
		}
190
	}
191
192
	@Override
193
	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
194
195
		if (localName.equals(ELEMENT_STATUS)) {
196
			state = state | IN_STATUS;
197
		} else if (localName.equals(ELEMENT_LI) && ((state & IN_LI) == IN_LI)) {
198
			state = state | IN_LI_LI;
199
			parseResource(attributes);
200
		} else if (localName.equals(ELEMENT_LI) && ((state & IN_LI) != IN_LI)) {
201
			state = state | IN_LI;
202
		} else if (localName.equals(ELEMENT_PLATFORM)) {
203
			state = state | IN_PLATFORM;
204
		} else if (localName.equals(ELEMENT_OP_SYS)) {
205
			state = state | IN_OP_SYS;
206
		} else if (localName.equals(ELEMENT_PRIORITY)) {
207
			state = state | IN_PRIORITY;
208
		} else if (localName.equals(ELEMENT_SEVERITY)) {
209
			state = state | IN_SEVERITY;
210
		} else if (localName.equals(ELEMENT_PRODUCTS)) {
211
			state = state | IN_PRODUCTS;
212
		} else if (localName.equals(ELEMENT_OP_SYS)) {
213
			state = state | IN_OP_SYS;
214
		} else if (localName.equals(ELEMENT_NAME)) {
215
			state = state | IN_NAME;
216
		} else if (localName.equals(ELEMENT_COMPONENTS)) {
217
			state = state | IN_COMPONENTS;
218
		} else if (localName.equals(ELEMENT_COMPONENT)) {
219
			state = state | IN_COMPONENT;
220
			parseResource(attributes);
221
		} else if (localName.equals(ELEMENT_VERSIONS)) {
222
			state = state | IN_VERSIONS;
223
		} else if (localName.equals(ELEMENT_VERSION)) {
224
			state = state | IN_VERSION;
225
			parseResource(attributes);
226
		} else if (localName.equals(ELEMENT_INSTALL_VERSION)) {
227
			state = state | IN_INSTALL_VERSION;
228
		} else if (localName.equals(ELEMENT_TARGET_MILESTONES)) {
229
			state = state | IN_TARGET_MILESTONES;
230
		} else if (localName.equals(ELEMENT_TARGET_MILESTONE)) {
231
			state = state | IN_TARGET_MILESTONE;
232
			parseResource(attributes);
233
		} else if (localName.equals(ELEMENT_STATUS_OPEN)) {
234
			state = state | IN_STATUS_OPEN;
235
		} else if (localName.equals(ELEMENT_RESOLUTION)) {
236
			state = state | IN_RESOLUTION;
237
		}
238
239
	}
240
241
	private void parseResource(Attributes attributes) {
242
243
		switch (state) {
244
		case IN_PRODUCTS | IN_LI | IN_COMPONENTS | IN_LI_LI:
245
			if (attributes != null) {
246
				String compURI = attributes.getValue(ATTRIBUTE_RESOURCE);
247
				if (compURI != null) {
248
249
					List<String> compURIs = components.get(currentProduct);
250
					if (compURIs == null) {
251
						compURIs = new ArrayList<String>();
252
						components.put(currentProduct, compURIs);
253
					}
254
					compURIs.add(compURI);
255
256
				}
257
			}
258
			break;
259
		case IN_PRODUCTS | IN_LI | IN_VERSIONS | IN_LI_LI:
260
			if (attributes != null) {
261
				String resourceURI = attributes.getValue(ATTRIBUTE_RESOURCE);
262
				if (resourceURI != null) {
263
					List<String> versionUris = versions.get(currentProduct);
264
					if (versionUris == null) {
265
						versionUris = new ArrayList<String>();
266
						versions.put(currentProduct, versionUris);
267
					}
268
					versionUris.add(resourceURI);
269
				}
270
			}
271
			break;
272
		case IN_PRODUCTS | IN_LI | IN_TARGET_MILESTONES | IN_LI_LI:
273
			if (attributes != null) {
274
				String resourceURI = attributes.getValue(ATTRIBUTE_RESOURCE);
275
				if (resourceURI != null) {
276
					List<String> milestoneUris = milestones.get(currentProduct);
277
					if (milestoneUris == null) {
278
						milestoneUris = new ArrayList<String>();
279
						milestones.put(currentProduct, milestoneUris);
280
					}
281
					milestoneUris.add(resourceURI);
282
				}
283
			}
284
			break;
285
		case IN_COMPONENTS | IN_LI | IN_COMPONENT:
286
			if (attributes != null) {
287
				about = attributes.getValue(ATTRIBUTE_RDF_ABOUT);
288
			}
289
			break;
290
		case IN_VERSIONS | IN_LI | IN_VERSION:
291
			if (attributes != null) {
292
				about = attributes.getValue(ATTRIBUTE_RDF_ABOUT);
293
			}
294
			break;
295
296
		case IN_TARGET_MILESTONES | IN_LI | IN_TARGET_MILESTONE:
297
			if (attributes != null) {
298
				about = attributes.getValue(ATTRIBUTE_RDF_ABOUT);
299
			}
300
			break;
301
302
		}
303
	}
304
305
	@Override
306
	public void endElement(String uri, String localName, String qName) throws SAXException {
307
308
		// KEEP: && ((state & IN_LI) == IN_LI)
309
310
		if (localName.equals(ELEMENT_STATUS)) {
311
			state = state & ~IN_STATUS;
312
		} else if (localName.equals(ELEMENT_LI) && ((state & IN_LI_LI) == IN_LI_LI)) {
313
			state = state & ~IN_LI_LI;
314
		} else if (localName.equals(ELEMENT_LI) && ((state & IN_LI_LI) != IN_LI_LI)) {
315
			state = state & ~IN_LI;
316
		} else if (localName.equals(ELEMENT_PLATFORM)) {
317
			state = state & ~IN_PLATFORM;
318
		} else if (localName.equals(ELEMENT_OP_SYS)) {
319
			state = state & ~IN_OP_SYS;
320
		} else if (localName.equals(ELEMENT_PRIORITY)) {
321
			state = state & ~IN_PRIORITY;
322
		} else if (localName.equals(ELEMENT_SEVERITY)) {
323
			state = state & ~IN_SEVERITY;
324
		} else if (localName.equals(ELEMENT_PRODUCTS)) {
325
			state = state & ~IN_PRODUCTS;
326
		} else if (localName.equals(ELEMENT_OP_SYS)) {
327
			state = state & ~IN_OP_SYS;
328
		} else if (localName.equals(ELEMENT_NAME)) {
329
			state = state & ~IN_NAME;
330
		} else if (localName.equals(ELEMENT_COMPONENTS)) {
331
			state = state & ~IN_COMPONENTS;
332
		} else if (localName.equals(ELEMENT_COMPONENT)) {
333
			state = state & ~IN_COMPONENT;
334
		} else if (localName.equals(ELEMENT_VERSION)) {
335
			state = state & ~IN_VERSION;
336
		} else if (localName.equals(ELEMENT_VERSIONS)) {
337
			state = state & ~IN_VERSIONS;
338
		} else if (localName.equals(ELEMENT_INSTALL_VERSION)) {
339
			state = state & ~IN_INSTALL_VERSION;
340
		} else if (localName.equals(ELEMENT_TARGET_MILESTONE)) {
341
			state = state & ~IN_TARGET_MILESTONE;
342
		} else if (localName.equals(ELEMENT_TARGET_MILESTONES)) {
343
			state = state & ~IN_TARGET_MILESTONES;
344
		} else if (localName.equals(ELEMENT_STATUS_OPEN)) {
345
			state = state & ~IN_STATUS_OPEN;
346
		} else if (localName.equals(ELEMENT_RESOLUTION)) {
347
			state = state & ~IN_RESOLUTION;
348
		}
349
350
	}
351
352
	@Override
353
	public void endDocument() throws SAXException {
354
355
		for (String product : components.keySet()) {
356
			List<String> componentURIs = components.get(product);
357
			for (String uri : componentURIs) {
358
				String realName = componentNames.get(uri);
359
				if (realName != null) {
360
					configuration.addComponent(product, realName);
361
				}
362
			}
363
364
		}
365
366
		for (String product : versions.keySet()) {
367
			List<String> versionURIs = versions.get(product);
368
			for (String uri : versionURIs) {
369
				String realName = versionNames.get(uri);
370
				if (realName != null) {
371
					configuration.addVersion(product, realName);
372
				}
373
			}
374
375
		}
376
377
		for (String product : milestones.keySet()) {
378
			List<String> milestoneURIs = milestones.get(product);
379
			for (String uri : milestoneURIs) {
380
				String realName = milestoneNames.get(uri);
381
				if (realName != null) {
382
					configuration.addTargetMilestone(product, realName);
383
				}
384
			}
385
386
		}
387
		super.endDocument();
388
	}
389
}
(-)src/org/eclipse/mylar/internal/bugzilla/core/internal/XmlCleaner.java (+63 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 University Of British Columbia and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     University Of British Columbia - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.internal.bugzilla.core.internal;
13
14
import java.io.IOException;
15
import java.io.Reader;
16
import java.text.ParseException;
17
18
import org.eclipse.mylar.internal.bugzilla.core.internal.HtmlStreamTokenizer.Token;
19
20
/**
21
 * This is in place to escape & characters within the resource and rdf:about
22
 * attributes. Currently the values are not escaped which causes sax parser
23
 * errors. This bug has been filed and can be found here:
24
 * https://bugzilla.mozilla.org/show_bug.cgi?id=264785
25
 * 
26
 * @author Rob Elves
27
 */
28
public class XmlCleaner {
29
30
	public static StringBuffer clean(Reader in) {
31
32
		HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(in, null);
33
		StringBuffer content = new StringBuffer();
34
35
		// Hack since HtmlStreamTokenizer not familiar with xml tag.
36
		content.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
37
		try {
38
			for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) {
39
40
				if (token.getType() == Token.TAG) {
41
					HtmlTag tag = (HtmlTag) token.getValue();
42
					if (tag.getAttribute("resource") != null) {
43
						String resourceID = tag.getAttribute("resource");
44
						tag.setAttribute("resource", resourceID.replace("&", "&amp;"));
45
					}
46
					if (tag.getAttribute("rdf:about") != null) {
47
						String resourceID = tag.getAttribute("rdf:about");
48
						tag.setAttribute("rdf:about", resourceID.replace("&", "&amp;"));
49
					}
50
				}
51
				if (!token.toString().startsWith("<?xml")) {
52
					content.append(token.toString());
53
				}
54
			}
55
		} catch (IOException e) {
56
57
		} catch (ParseException e) {
58
59
		}
60
		return content;
61
	}
62
63
}
(-)src/org/eclipse/mylar/internal/bugzilla/ui/wizard/BugzillaProductPage.java (-4 / +5 lines)
Lines 225-235 Link Here
225
		try {
225
		try {
226
			if (!model.hasParsedAttributes() || !prevProduct.equals(model.getProduct())) {
226
			if (!model.hasParsedAttributes() || !prevProduct.equals(model.getProduct())) {
227
				String serverUrl = repository.getUrl();
227
				String serverUrl = repository.getUrl();
228
				if (model.isConnected()) {
228
//				if (model.isConnected()) {
229
					BugzillaRepositoryUtil.setupNewBugAttributes(serverUrl, model, false);
229
//					BugzillaRepositoryUtil.setupNewBugAttributes(serverUrl, model, false);
230
				} else {
230
//				} else {
231
				
231
					BugzillaRepositoryUtil.setupProdConfigAttributes(serverUrl, model);
232
					BugzillaRepositoryUtil.setupProdConfigAttributes(serverUrl, model);
232
				}
233
//				}
233
				model.setParsedAttributesStatus(true);
234
				model.setParsedAttributesStatus(true);
234
				if (prevProduct == null) {
235
				if (prevProduct == null) {
235
					bugWizard.setAttributePage(new WizardAttributesPage(workbench));
236
					bugWizard.setAttributePage(new WizardAttributesPage(workbench));
(-)tests-manual.html (-1 / +3 lines)
Lines 39-45 Link Here
39
		<li>Select repository with invalid password</li>
39
		<li>Select repository with invalid password</li>
40
		<li>Error Dialog presented on product update or selection of Next: The 
40
		<li>Error Dialog presented on product update or selection of Next: The 
41
		user name or password you entered is not valid...</li>
41
		user name or password you entered is not valid...</li>
42
	</ul></li>
42
	</ul>	
43
	</li>
44
	<li><font color="#FF0000">Make sure submission of comment doesn't remove dependancies</font></li>
43
		<li>Submission of changes to existing bug with invalid repository 
45
		<li>Submission of changes to existing bug with invalid repository 
44
		credentials<ul>
46
		credentials<ul>
45
		<li>Mylar Bugzilla Client Dialog: Bugzilla could not post your bug since your login name or password is incorrect.
47
		<li>Mylar Bugzilla Client Dialog: Bugzilla could not post your bug since your login name or password is incorrect.
(-)src/org/eclipse/mylar/bugzilla/tests/BugzillaProductParserTest.java (-16 / +17 lines)
Lines 78-86 Link Here
78
				IBugzillaConstants.BugzillaServerVersion.SERVER_220.toString());
78
				IBugzillaConstants.BugzillaServerVersion.SERVER_220.toString());
79
79
80
		List<String> productList = BugzillaRepositoryUtil.getProductList(repository);
80
		List<String> productList = BugzillaRepositoryUtil.getProductList(repository);
81
		Iterator<String> itr = productList.iterator();
81
		assertEquals(2, productList.size());
82
		assertTrue(itr.hasNext());
82
		assertTrue(productList.contains("TestProduct"));
83
		assertEquals("TestProduct", "TestProduct", itr.next());
83
		assertTrue(productList.contains("Widget"));	
84
84
85
	}
85
	}
86
86
Lines 90-109 Link Here
90
				IBugzillaConstants.BugzillaServerVersion.SERVER_218.toString());
90
				IBugzillaConstants.BugzillaServerVersion.SERVER_218.toString());
91
91
92
		List<String> productList = BugzillaRepositoryUtil.getProductList(repository);
92
		List<String> productList = BugzillaRepositoryUtil.getProductList(repository);
93
		Iterator<String> itr = productList.iterator();
93
		assertEquals(1, productList.size());
94
		assertTrue(itr.hasNext());
94
		assertTrue(productList.contains("TestProduct"));
95
		assertEquals("TestProduct", "TestProduct", itr.next());
96
	}
97
98
	public void test216Products() throws Exception {
99
95
100
		repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_216_URL,
101
				IBugzillaConstants.BugzillaServerVersion.SERVER_216.toString());
102
103
		List<String> productList = BugzillaRepositoryUtil.getProductList(repository);
104
		Iterator<String> itr = productList.iterator();
105
		assertTrue(itr.hasNext());
106
		assertEquals("TestProduct", "TestProduct", itr.next());
107
	}
96
	}
97
	
98
//  No longer supporting 216
99
//	public void test216Products() throws Exception {
100
//
101
//		repository = new TaskRepository(BugzillaPlugin.REPOSITORY_KIND, IBugzillaConstants.TEST_BUGZILLA_216_URL,
102
//				IBugzillaConstants.BugzillaServerVersion.SERVER_216.toString());
103
//
104
//		List<String> productList = BugzillaRepositoryUtil.getProductList(repository);
105
//		Iterator<String> itr = productList.iterator();
106
//		assertTrue(itr.hasNext());
107
//		assertEquals("TestProduct", "TestProduct", itr.next());
108
//	}
108
109
109
}
110
}
(-)src/org/eclipse/mylar/bugzilla/tests/AllBugzillaTests.java (+1 lines)
Lines 21-26 Link Here
21
	public static Test suite() {
21
	public static Test suite() {
22
		TestSuite suite = new TestSuite("Test for org.eclipse.mylar.bugzilla.tests");
22
		TestSuite suite = new TestSuite("Test for org.eclipse.mylar.bugzilla.tests");
23
		// $JUnit-BEGIN$ 
23
		// $JUnit-BEGIN$ 
24
		suite.addTestSuite(BugzillaConfigurationTest.class);
24
		suite.addTestSuite(BugzillaTaskHyperlinkDetectorTest.class);
25
		suite.addTestSuite(BugzillaTaskHyperlinkDetectorTest.class);
25
		suite.addTestSuite(ReportAttachmentTest.class);
26
		suite.addTestSuite(ReportAttachmentTest.class);
26
		suite.addTestSuite(BugzillaSearchEngineTest.class);
27
		suite.addTestSuite(BugzillaSearchEngineTest.class);
(-)src/org/eclipse/mylar/bugzilla/tests/BugzillaConfigurationTest.java (+125 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 University Of British Columbia and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     University Of British Columbia - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylar.bugzilla.tests;
13
14
import java.io.IOException;
15
16
import org.eclipse.mylar.internal.bugzilla.core.IBugzillaConstants;
17
import org.eclipse.mylar.internal.bugzilla.core.internal.AbstractBugzillaConfigurationFactory;
18
import org.eclipse.mylar.internal.bugzilla.core.internal.ProductConfiguration;
19
import org.eclipse.mylar.internal.bugzilla.core.internal.ServerConfigurationFactory;
20
21
import junit.framework.TestCase;
22
23
public class BugzillaConfigurationTest extends TestCase {
24
25
	protected void setUp() throws Exception {
26
		super.setUp();
27
	}
28
29
	protected void tearDown() throws Exception {
30
		super.tearDown();
31
	}
32
33
	
34
	public void test222RDFProductConfig() throws IOException {
35
		AbstractBugzillaConfigurationFactory factory = ServerConfigurationFactory.getInstance();
36
		ProductConfiguration config = factory.getConfiguration(IBugzillaConstants.TEST_BUGZILLA_222_URL);
37
		assertNotNull(config);
38
		assertEquals("2.22rc1", config.getInstallVersion());
39
		assertEquals(7, config.getStatusValues().size());
40
		assertEquals(8, config.getResolutions().size());
41
		assertEquals(4, config.getPlatforms().size());
42
		assertEquals(5, config.getOSs().size());
43
		assertEquals(5, config.getPriorities().size());
44
		assertEquals(7, config.getSeverities().size());
45
		assertEquals(1, config.getProducts().size());
46
		assertEquals(4, config.getOpenStatusValues().size());
47
		assertEquals(1, config.getComponents("TestProduct").size());
48
		assertEquals(1, config.getVersions("TestProduct").size());
49
		assertEquals(1, config.getTargetMilestones("TestProduct").size());
50
	}
51
	
52
	public void test2201RDFProductConfig() throws IOException {
53
		AbstractBugzillaConfigurationFactory factory = ServerConfigurationFactory.getInstance();
54
		ProductConfiguration config = factory.getConfiguration(IBugzillaConstants.TEST_BUGZILLA_2201_URL);
55
		assertNotNull(config);
56
		assertEquals("2.20.1", config.getInstallVersion());
57
		assertEquals(7, config.getStatusValues().size());
58
		assertEquals(8, config.getResolutions().size());
59
		assertEquals(4, config.getPlatforms().size());
60
		assertEquals(5, config.getOSs().size());
61
		assertEquals(5, config.getPriorities().size());
62
		assertEquals(7, config.getSeverities().size());
63
		assertEquals(1, config.getProducts().size());
64
		assertEquals(4, config.getOpenStatusValues().size());
65
		assertEquals(2, config.getComponents("TestProduct").size());
66
		assertEquals(1, config.getVersions("TestProduct").size());	
67
		//assertEquals(1, config.getTargetMilestones("TestProduct").size());
68
	}
69
	
70
	public void test220RDFProductConfig() throws IOException {
71
		AbstractBugzillaConfigurationFactory factory = ServerConfigurationFactory.getInstance();
72
		ProductConfiguration config = factory.getConfiguration(IBugzillaConstants.TEST_BUGZILLA_220_URL);
73
		assertNotNull(config);
74
		assertEquals("2.20", config.getInstallVersion());
75
		assertEquals(7, config.getStatusValues().size());
76
		assertEquals(8, config.getResolutions().size());
77
		assertEquals(4, config.getPlatforms().size());
78
		assertEquals(5, config.getOSs().size());
79
		assertEquals(5, config.getPriorities().size());
80
		assertEquals(7, config.getSeverities().size());
81
		assertEquals(2, config.getProducts().size());
82
		assertEquals(4, config.getOpenStatusValues().size());
83
		assertEquals(2, config.getComponents("TestProduct").size());
84
		assertEquals(1, config.getVersions("TestProduct").size());
85
		//assertEquals(1, config.getTargetMilestones("TestProduct").size());
86
	}
87
	
88
	public void test218RDFProductConfig() throws IOException {
89
		AbstractBugzillaConfigurationFactory factory = ServerConfigurationFactory.getInstance();
90
		ProductConfiguration config = factory.getConfiguration(IBugzillaConstants.TEST_BUGZILLA_218_URL);
91
		assertNotNull(config);
92
		assertEquals("2.18.5", config.getInstallVersion());
93
		assertEquals(7, config.getStatusValues().size());
94
		assertEquals(8, config.getResolutions().size());
95
		assertEquals(8, config.getPlatforms().size());
96
		assertEquals(37, config.getOSs().size());
97
		assertEquals(5, config.getPriorities().size());
98
		assertEquals(7, config.getSeverities().size());
99
		assertEquals(1, config.getProducts().size());
100
		assertEquals(4, config.getOpenStatusValues().size());
101
		assertEquals(1, config.getComponents("TestProduct").size());
102
		assertEquals(1, config.getVersions("TestProduct").size());
103
		//assertEquals(1, config.getTargetMilestones("TestProduct").size());
104
	}
105
	
106
	public void testEclipseRDFProductConfig() throws IOException {
107
		AbstractBugzillaConfigurationFactory factory = ServerConfigurationFactory.getInstance();
108
		ProductConfiguration config = factory.getConfiguration(IBugzillaConstants.ECLIPSE_BUGZILLA_URL);
109
		assertNotNull(config);
110
		assertEquals("2.20.1", config.getInstallVersion());
111
		assertEquals(7, config.getStatusValues().size());
112
		assertEquals(8, config.getResolutions().size());
113
		assertEquals(6, config.getPlatforms().size());
114
		assertEquals(27, config.getOSs().size());
115
		assertEquals(5, config.getPriorities().size());
116
		assertEquals(7, config.getSeverities().size());
117
		assertEquals(53, config.getProducts().size());
118
		assertEquals(4, config.getOpenStatusValues().size());
119
		assertEquals(10, config.getComponents("Mylar").size());
120
		//assertEquals(10, config.getComponents("Hyades").size());
121
		//assertEquals(1, config.getTargetMilestones("TestProduct").size());
122
	}
123
	
124
	// NOTE: Bugzilla 2.16 doesn't have config.cgi interface
125
}

Return to bug 136219