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 314744 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java (-10 / +20 lines)
Lines 71-76 Link Here
71
import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer.Token;
71
import org.eclipse.mylyn.commons.net.HtmlStreamTokenizer.Token;
72
import org.eclipse.mylyn.commons.net.HtmlTag;
72
import org.eclipse.mylyn.commons.net.HtmlTag;
73
import org.eclipse.mylyn.commons.net.Policy;
73
import org.eclipse.mylyn.commons.net.Policy;
74
import org.eclipse.mylyn.commons.net.WebLocation;
74
import org.eclipse.mylyn.commons.net.WebUtil;
75
import org.eclipse.mylyn.commons.net.WebUtil;
75
import org.eclipse.mylyn.internal.bugzilla.core.history.BugzillaTaskHistoryParser;
76
import org.eclipse.mylyn.internal.bugzilla.core.history.BugzillaTaskHistoryParser;
76
import org.eclipse.mylyn.internal.bugzilla.core.history.TaskHistory;
77
import org.eclipse.mylyn.internal.bugzilla.core.history.TaskHistory;
Lines 179-185 Link Here
179
180
180
	private final BugzillaRepositoryConnector connector;
181
	private final BugzillaRepositoryConnector connector;
181
182
182
	private BugzillaXmlRpcClient xmlRpcClient;
183
	private BugzillaXmlRpcClient xmlRpcClient = null;
183
184
184
	public BugzillaClient(AbstractWebLocation location, String characterEncoding, Map<String, String> configParameters,
185
	public BugzillaClient(AbstractWebLocation location, String characterEncoding, Map<String, String> configParameters,
185
			BugzillaLanguageSettings languageSettings, BugzillaRepositoryConnector connector)
186
			BugzillaLanguageSettings languageSettings, BugzillaRepositoryConnector connector)
Lines 219-224 Link Here
219
				WebUtil.releaseConnection(method, monitor);
220
				WebUtil.releaseConnection(method, monitor);
220
			}
221
			}
221
		}
222
		}
223
		CustomTransitionManager validTransitions = new CustomTransitionManager();
224
225
		String transitionsFileName = configParameters.get(IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE);
226
		if (!validTransitions.parse(transitionsFileName)) {
227
			throw new CoreException(new Status(IStatus.WARNING, BugzillaCorePlugin.ID_PLUGIN,
228
					"Invalide Transition File Content")); //$NON-NLS-1$
229
		}
230
222
	}
231
	}
223
232
224
	protected boolean hasAuthenticationCredentials() {
233
	protected boolean hasAuthenticationCredentials() {
Lines 689-706 Link Here
689
								}
698
								}
690
699
691
								if (repositoryConfiguration != null) {
700
								if (repositoryConfiguration != null) {
692
									boolean useXml = Boolean.parseBoolean(configParameters.get(IBugzillaConstants.BUGZILLA_USE_XMLRPC));
701
									boolean useXMLRPC = Boolean.parseBoolean(configParameters.get(IBugzillaConstants.BUGZILLA_USE_XMLRPC));
702
									if (useXMLRPC && xmlRpcClient == null) {
703
										WebLocation webLocation = new WebLocation(this.repositoryUrl + "/xmlrpc.cgi"); //$NON-NLS-1$
704
										xmlRpcClient = new BugzillaXmlRpcClient(webLocation);
705
706
									}
693
									if (!repositoryConfiguration.getProducts().isEmpty()) {
707
									if (!repositoryConfiguration.getProducts().isEmpty()) {
694
										repositoryConfiguration.setRepositoryUrl(repositoryUrl.toString());
708
										repositoryConfiguration.setRepositoryUrl(repositoryUrl.toString());
695
709
									}
696
										repositoryConfiguration.setValidTransitions(monitor,
710
									xmlRpcClient.updateConfiguration(monitor, repositoryConfiguration,
697
												configParameters.get(IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE),
711
											configParameters.get(IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE));
698
												useXml);
712
									if (!repositoryConfiguration.getProducts().isEmpty()) {
699
										return repositoryConfiguration;
713
										return repositoryConfiguration;
700
									} else {
714
									} else {
701
										repositoryConfiguration.setValidTransitions(monitor,
702
												configParameters.get(IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE),
703
												useXml);
704
										if (attempt == 0) {
715
										if (attempt == 0) {
705
											// empty configuration, retry authenticate
716
											// empty configuration, retry authenticate
706
											loggedIn = false;
717
											loggedIn = false;
Lines 711-717 Link Here
711
															"No products found in repository configuration. Ensure credentials are valid.")); //$NON-NLS-1$
722
															"No products found in repository configuration. Ensure credentials are valid.")); //$NON-NLS-1$
712
										}
723
										}
713
									}
724
									}
714
715
								}
725
								}
716
							}
726
							}
717
						}
727
						}
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java (-1 / +8 lines)
Lines 507-513 Link Here
507
				for (String option : optionValues) {
507
				for (String option : optionValues) {
508
					attributeTargetMilestone.putOption(option, option);
508
					attributeTargetMilestone.putOption(option, option);
509
				}
509
				}
510
				attributeTargetMilestone.setValue(optionValues.get(0));
510
				if (repositoryConfiguration != null && product != null && !product.equals("")) { //$NON-NLS-1$
511
					String defaultMilestone = repositoryConfiguration.getDefaultMilestones(product);
512
					if (defaultMilestone != null) {
513
						attributeTargetMilestone.setValue(defaultMilestone);
514
					}
515
				} else {
516
					attributeTargetMilestone.setValue(optionValues.get(0));
517
				}
511
			}
518
			}
512
		}
519
		}
513
		TaskAttribute attributePlatform = createAttribute(taskData, BugzillaAttribute.REP_PLATFORM);
520
		TaskAttribute attributePlatform = createAttribute(taskData, BugzillaAttribute.REP_PLATFORM);
(-)src/org/eclipse/mylyn/internal/bugzilla/core/CustomTransitionManager.java (-13 lines)
Lines 55-78 Link Here
55
55
56
	private boolean valid = false;
56
	private boolean valid = false;
57
57
58
	private boolean fromFile = false;
59
60
	private String filePath;
58
	private String filePath;
61
59
62
	private String duplicateStatus;
60
	private String duplicateStatus;
63
61
64
	private String startStatus;
62
	private String startStatus;
65
63
66
	private boolean usedXml;
67
68
	public CustomTransitionManager() {
64
	public CustomTransitionManager() {
69
		operationMapByCurrentStatus = new HashMap<String, List<AbstractBugzillaOperation>>();
65
		operationMapByCurrentStatus = new HashMap<String, List<AbstractBugzillaOperation>>();
70
		operationMapByEndStatus = new HashMap<String, List<AbstractBugzillaOperation>>();
66
		operationMapByEndStatus = new HashMap<String, List<AbstractBugzillaOperation>>();
71
		closedStatuses = new ArrayList<String>();
67
		closedStatuses = new ArrayList<String>();
72
		this.valid = false;
68
		this.valid = false;
73
		this.filePath = ""; //$NON-NLS-1$
69
		this.filePath = ""; //$NON-NLS-1$
74
		this.fromFile = false;
75
		this.usedXml = false;
76
		duplicateStatus = DEFAULT_DUPLICATE_STATUS;
70
		duplicateStatus = DEFAULT_DUPLICATE_STATUS;
77
		startStatus = DEFAULT_START_STATUS;
71
		startStatus = DEFAULT_START_STATUS;
78
	}
72
	}
Lines 93-99 Link Here
93
			//Do nothing, already parsed this file
87
			//Do nothing, already parsed this file
94
			return false;
88
			return false;
95
		}
89
		}
96
		fromFile = true;
97
		this.filePath = filePath;
90
		this.filePath = filePath;
98
		setValid(true);
91
		setValid(true);
99
92
Lines 320-329 Link Here
320
	}
313
	}
321
314
322
	public void parse(IProgressMonitor monitor, BugzillaXmlRpcClient xmlClient) {
315
	public void parse(IProgressMonitor monitor, BugzillaXmlRpcClient xmlClient) {
323
//		if (usedXml) {
324
//			//XMLRPC should not change, don't look it up again
325
//			return;
326
//		}
327
		this.filePath = ""; //$NON-NLS-1$
316
		this.filePath = ""; //$NON-NLS-1$
328
		operationMapByCurrentStatus.clear();
317
		operationMapByCurrentStatus.clear();
329
		operationMapByEndStatus.clear();
318
		operationMapByEndStatus.clear();
Lines 366-373 Link Here
366
			}
355
			}
367
356
368
			setValid(true);
357
			setValid(true);
369
			usedXml = true;
370
			fromFile = false;
371
		} catch (XmlRpcException e) {
358
		} catch (XmlRpcException e) {
372
			setValid(false);
359
			setValid(false);
373
		}
360
		}
(-)src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java (-5 / +31 lines)
Lines 22-28 Link Here
22
import java.util.Map;
22
import java.util.Map;
23
23
24
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.core.runtime.IProgressMonitor;
25
import org.eclipse.mylyn.commons.net.WebLocation;
26
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_REPORT_STATUS;
25
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_REPORT_STATUS;
27
import org.eclipse.mylyn.internal.bugzilla.core.service.BugzillaXmlRpcClient;
26
import org.eclipse.mylyn.internal.bugzilla.core.service.BugzillaXmlRpcClient;
28
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
27
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
Lines 271-276 Link Here
271
270
272
		List<String> milestones = new ArrayList<String>();
271
		List<String> milestones = new ArrayList<String>();
273
272
273
		String defaultMilestone = null;
274
274
		ProductEntry(String name) {
275
		ProductEntry(String name) {
275
			this.productName = name;
276
			this.productName = name;
276
		}
277
		}
Lines 302-307 Link Here
302
		void addTargetMilestone(String target) {
303
		void addTargetMilestone(String target) {
303
			milestones.add(target);
304
			milestones.add(target);
304
		}
305
		}
306
307
		public String getDefaultMilestone() {
308
			return defaultMilestone;
309
		}
310
311
		public void setDefaultMilestone(String defaultMilestone) {
312
			this.defaultMilestone = defaultMilestone;
313
		}
305
	}
314
	}
306
315
307
	public List<String> getOpenStatusValues() {
316
	public List<String> getOpenStatusValues() {
Lines 346-352 Link Here
346
	 * 
355
	 * 
347
	 * @param fileName
356
	 * @param fileName
348
	 */
357
	 */
349
	public void setValidTransitions(IProgressMonitor monitor, String fileName, boolean useXmlRpc) {
358
	public void setValidTransitions(IProgressMonitor monitor, String fileName, BugzillaXmlRpcClient xmlClient) {
350
		//Custom transitions only possible for newer versions of Bugzilla
359
		//Custom transitions only possible for newer versions of Bugzilla
351
		if (getInstallVersion() != null && getInstallVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_2) < 0) {
360
		if (getInstallVersion() != null && getInstallVersion().compareMajorMinorOnly(BugzillaVersion.BUGZILLA_3_2) < 0) {
352
			return;
361
			return;
Lines 354-365 Link Here
354
		if (validTransitions == null) {
363
		if (validTransitions == null) {
355
			validTransitions = new CustomTransitionManager();
364
			validTransitions = new CustomTransitionManager();
356
		}
365
		}
357
		if (!validTransitions.parse(fileName) && useXmlRpc) {
366
		if (!validTransitions.parse(fileName) && xmlClient != null) {
358
			if (getRepositoryUrl().equals("<unknown>")) { //$NON-NLS-1$
367
			if (getRepositoryUrl().equals("<unknown>")) { //$NON-NLS-1$
359
				return; //This occurs during testing
368
				return; //This occurs during testing
360
			}
369
			}
361
			WebLocation webLocation = new WebLocation(getRepositoryUrl() + "/xmlrpc.cgi"); //$NON-NLS-1$
362
			BugzillaXmlRpcClient xmlClient = new BugzillaXmlRpcClient(webLocation);
363
			validTransitions.parse(monitor, xmlClient);
370
			validTransitions.parse(monitor, xmlClient);
364
		}
371
		}
365
	}
372
	}
Lines 934-937 Link Here
934
	public String getStartStatus() {
941
	public String getStartStatus() {
935
		return (validTransitions == null) ? "NEW" : validTransitions.getStartStatus(); //$NON-NLS-1$
942
		return (validTransitions == null) ? "NEW" : validTransitions.getStartStatus(); //$NON-NLS-1$
936
	}
943
	}
944
945
	public String getDefaultMilestones(String product) {
946
		ProductEntry entry = products.get(product);
947
		if (entry != null) {
948
			return entry.getDefaultMilestone();
949
		} else {
950
			return null;
951
		}
952
	}
953
954
	public void setDefaultMilestone(String product, String defaultMilestone) {
955
		ProductEntry entry = products.get(product);
956
		if (entry == null) {
957
			entry = new ProductEntry(product);
958
			products.put(product, entry);
959
		}
960
		entry.setDefaultMilestone(defaultMilestone);
961
	}
962
937
}
963
}
(-)src/org/eclipse/mylyn/internal/bugzilla/core/service/BugzillaXmlRpcClient.java (-1 / +42 lines)
Lines 16-25 Link Here
16
16
17
import org.apache.commons.httpclient.HttpClient;
17
import org.apache.commons.httpclient.HttpClient;
18
import org.apache.xmlrpc.XmlRpcException;
18
import org.apache.xmlrpc.XmlRpcException;
19
import org.eclipse.core.runtime.CoreException;
19
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.IStatus;
22
import org.eclipse.core.runtime.Status;
20
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
23
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
21
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
24
import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
22
import org.eclipse.mylyn.commons.net.AuthenticationType;
25
import org.eclipse.mylyn.commons.net.AuthenticationType;
26
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
27
import org.eclipse.mylyn.internal.bugzilla.core.RepositoryConfiguration;
23
import org.eclipse.mylyn.internal.commons.xmlrpc.CommonXmlRpcClient;
28
import org.eclipse.mylyn.internal.commons.xmlrpc.CommonXmlRpcClient;
24
29
25
@SuppressWarnings("restriction")
30
@SuppressWarnings("restriction")
Lines 284-290 Link Here
284
		}).execute();
289
		}).execute();
285
	}
290
	}
286
291
287
	public Object[] getProducts(final IProgressMonitor monitor, final Integer[] ids) throws XmlRpcException {
292
	public Object[] getProducts(final IProgressMonitor monitor, final Object[] ids) throws XmlRpcException {
288
		return (new BugzillaXmlRpcOperation<Object[]>(this) {
293
		return (new BugzillaXmlRpcOperation<Object[]>(this) {
289
			@SuppressWarnings("serial")
294
			@SuppressWarnings("serial")
290
			@Override
295
			@Override
Lines 358-361 Link Here
358
		return result;
363
		return result;
359
	}
364
	}
360
365
366
	public void updateConfiguration(IProgressMonitor monitor, RepositoryConfiguration repositoryConfiguration,
367
			String fileName) throws CoreException {
368
		repositoryConfiguration.setValidTransitions(monitor, fileName, this);
369
		if (!repositoryConfiguration.getProducts().isEmpty()) {
370
			updateProductInfo(monitor, repositoryConfiguration);
371
		}
372
	}
373
374
	public void updateProductInfo(IProgressMonitor monitor, RepositoryConfiguration repositoryConfiguration)
375
			throws CoreException {
376
		try {
377
			Object[] productIDs = getAccessibleProducts(monitor);
378
			Object[] products = getProducts(monitor, productIDs);
379
			for (Object object : products) {
380
				if (object instanceof HashMap<?, ?>) {
381
					String defaultMilestone = null;
382
					String product = (String) ((HashMap<?, ?>) object).get("name"); //$NON-NLS-1$
383
					HashMap<?, ?> values = (HashMap<?, ?>) ((HashMap<?, ?>) object).get("internals"); //$NON-NLS-1$
384
					if (values == null) {
385
						continue;
386
					}
387
					if (values instanceof HashMap<?, ?>) {
388
						defaultMilestone = (String) ((HashMap<?, ?>) values).get("defaultmilestone"); //$NON-NLS-1$
389
					}
390
					if (product != null && !product.equals("") //$NON-NLS-1$
391
							&& defaultMilestone != null && !defaultMilestone.equals("")) { //$NON-NLS-1$
392
						repositoryConfiguration.setDefaultMilestone(product, defaultMilestone);
393
					}
394
				}
395
			}
396
		} catch (XmlRpcException e) {
397
			throw new CoreException(new Status(IStatus.ERROR, BugzillaCorePlugin.ID_PLUGIN,
398
					"Can not get the Default Milestons using XMLRPC")); //$NON-NLS-1$
399
		}
400
401
	}
361
}
402
}
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaRepositorySettingsPage.java (-22 / +1 lines)
Lines 454-481 Link Here
454
		repository.setProperty(IBugzillaConstants.BUGZILLA_LANGUAGE_SETTING, languageSettingCombo.getText());
454
		repository.setProperty(IBugzillaConstants.BUGZILLA_LANGUAGE_SETTING, languageSettingCombo.getText());
455
		repository.setProperty(IBugzillaConstants.BUGZILLA_USE_XMLRPC,
455
		repository.setProperty(IBugzillaConstants.BUGZILLA_USE_XMLRPC,
456
				Boolean.toString(useXMLRPCstatusTransitions.getSelection()));
456
				Boolean.toString(useXMLRPCstatusTransitions.getSelection()));
457
		if (oldDescriptorFile == null || !descriptorFile.getText().equals(oldDescriptorFile)) {
457
		repository.setProperty(IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE, descriptorFile.getText());
458
			repository.setProperty(IBugzillaConstants.BUGZILLA_DESCRIPTOR_FILE, descriptorFile.getText());
459
		}
460
		if (repositoryConfiguration != null) {
461
			try {
462
				final String descriptorFileName = descriptorFile.getText();
463
				final boolean useXMLRPCstatusTransitionsSelection = useXMLRPCstatusTransitions.getSelection();
464
				getWizard().getContainer().run(true, false, new IRunnableWithProgress() {
465
					public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
466
						repositoryConfiguration.setValidTransitions(monitor, descriptorFileName,
467
								useXMLRPCstatusTransitionsSelection);
468
					}
469
				});
470
			} catch (InvocationTargetException e1) {
471
				if (e1.getCause() != null) {
472
					setErrorMessage(e1.getCause().getMessage());
473
				}
474
			} catch (InterruptedException e1) {
475
				// ignore
476
			}
477
		}
478
479
		if (!autodetectPlatformOS.getSelection()) {
458
		if (!autodetectPlatformOS.getSelection()) {
480
			repository.setProperty(IBugzillaConstants.BUGZILLA_DEF_PLATFORM,
459
			repository.setProperty(IBugzillaConstants.BUGZILLA_DEF_PLATFORM,
481
					String.valueOf(defaultPlatformCombo.getItem(defaultPlatformCombo.getSelectionIndex())));
460
					String.valueOf(defaultPlatformCombo.getItem(defaultPlatformCombo.getSelectionIndex())));

Return to bug 314744