View | Details | Raw Unified | Return to bug 175922 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/ui/editor/BugzillaTaskEditor.java (-2 / +83 lines)
Lines 21-26 Link Here
21
import org.eclipse.jface.layout.GridDataFactory;
21
import org.eclipse.jface.layout.GridDataFactory;
22
import org.eclipse.jface.viewers.ILabelProvider;
22
import org.eclipse.jface.viewers.ILabelProvider;
23
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
23
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
24
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCustomField;
24
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaReportElement;
25
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaReportElement;
25
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
26
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
26
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_OPERATION;
27
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_OPERATION;
Lines 36-41 Link Here
36
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor;
37
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor;
37
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
38
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
38
import org.eclipse.swt.SWT;
39
import org.eclipse.swt.SWT;
40
import org.eclipse.swt.custom.CCombo;
39
import org.eclipse.swt.events.ModifyEvent;
41
import org.eclipse.swt.events.ModifyEvent;
40
import org.eclipse.swt.events.ModifyListener;
42
import org.eclipse.swt.events.ModifyListener;
41
import org.eclipse.swt.events.SelectionAdapter;
43
import org.eclipse.swt.events.SelectionAdapter;
Lines 73-78 Link Here
73
75
74
	private static final String LABEL_TIME_TRACKING = "Bugzilla Time Tracking";
76
	private static final String LABEL_TIME_TRACKING = "Bugzilla Time Tracking";
75
77
78
	private static final String LABEL_CUSTOM_FIELD = "Custom Fields";
79
76
	protected Text keywordsText;
80
	protected Text keywordsText;
77
81
78
	protected Text estimateText;
82
	protected Text estimateText;
Lines 200-205 Link Here
200
		if (taskData.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()) != null)
204
		if (taskData.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()) != null)
201
			addBugzillaTimeTracker(getManagedForm().getToolkit(), composite);
205
			addBugzillaTimeTracker(getManagedForm().getToolkit(), composite);
202
206
207
		try {
208
			List<BugzillaCustomField> customFields = BugzillaCorePlugin.getRepositoryConfiguration(this.repository,
209
					false).getCustomFields();
210
			if (!customFields.isEmpty()) {
211
				Section cfSection = toolkit.createSection(composite, ExpandableComposite.SHORT_TITLE_BAR);
212
				cfSection.setText(LABEL_CUSTOM_FIELD);
213
				GridLayout gl = new GridLayout();
214
				GridData gd = new GridData(SWT.FILL, SWT.NONE, false, false);
215
				gd.horizontalSpan = 4;
216
				cfSection.setLayout(gl);
217
				cfSection.setLayoutData(gd);
218
219
				Composite cfComposite = toolkit.createComposite(cfSection);
220
				gl = new GridLayout(4, false);
221
				cfComposite.setLayout(gl);
222
				gd = new GridData();
223
				gd.horizontalSpan = 5;
224
				cfComposite.setLayoutData(gd);
225
				for (BugzillaCustomField bugzillaCustomField : customFields) {
226
					List<String> optionList = bugzillaCustomField.getOptions();
227
					attribute = this.taskData.getAttribute(bugzillaCustomField.getName());
228
					if (attribute == null) {
229
						RepositoryTaskAttribute newattribute = new RepositoryTaskAttribute(
230
								bugzillaCustomField.getName(), bugzillaCustomField.getDescription(), false);
231
						newattribute.setReadOnly(false);
232
						this.taskData.addAttribute(bugzillaCustomField.getName(), newattribute);
233
					}
234
					final RepositoryTaskAttribute cfattribute = this.taskData.getAttribute(bugzillaCustomField.getName());
235
					Label label = createLabel(cfComposite, cfattribute);
236
					GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(label);
237
					if (optionList != null && !optionList.isEmpty()) {
238
						GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
239
						data.horizontalSpan = 1;
240
						final CCombo attributeCombo = new CCombo(cfComposite, SWT.FLAT | SWT.READ_ONLY);
241
						toolkit.adapt(attributeCombo, true, true);
242
						attributeCombo.setFont(TEXT_FONT);
243
						attributeCombo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
244
						if (hasChanged(cfattribute)) {
245
							attributeCombo.setBackground(getColorIncoming());
246
						}
247
						attributeCombo.setLayoutData(data);
248
249
						for (String val : optionList) {
250
							if (val != null) {
251
								attributeCombo.add(val);
252
							}
253
						}
254
						String value = cfattribute.getValue();
255
						if (value == null) {
256
							value = "";
257
						}
258
						if (attributeCombo.indexOf(value) != -1) {
259
							attributeCombo.select(attributeCombo.indexOf(value));
260
						}
261
						attributeCombo.clearSelection();
262
						attributeCombo.addSelectionListener(new SelectionAdapter() {
263
							@Override
264
							public void widgetSelected(SelectionEvent event) {
265
								if (attributeCombo.getSelectionIndex() > -1) {
266
									String sel = attributeCombo.getItem(attributeCombo.getSelectionIndex());
267
									cfattribute.setValue(sel);
268
									attributeChanged(cfattribute);
269
									attributeCombo.clearSelection();
270
								}
271
							}
272
						});
273
					} else {
274
						Text cfField = createTextField(cfComposite, cfattribute, SWT.FLAT);
275
						GridDataFactory.fillDefaults().hint(135, SWT.DEFAULT).applyTo(cfField);
276
					}
277
				}
278
				toolkit.paintBordersFor(cfComposite);
279
				cfSection.setClient(cfComposite);
280
			}
281
		} catch (CoreException e) {
282
			e.printStackTrace();
283
		}
203
	}
284
	}
204
285
205
	private boolean hasCustomAttributeChanges() {
286
	private boolean hasCustomAttributeChanges() {
Lines 692-700 Link Here
692
			if (haveRealName) {
773
			if (haveRealName) {
693
				textField.setText(textField.getText() + " <"
774
				textField.setText(textField.getText() + " <"
694
						+ taskData.getAttributeValue(BugzillaReportElement.QA_CONTACT.getKeyString()) + ">");
775
						+ taskData.getAttributeValue(BugzillaReportElement.QA_CONTACT.getKeyString()) + ">");
695
			}			
776
			}
696
		}
777
		}
697
		
778
698
		super.addSelfToCC(composite);
779
		super.addSelfToCC(composite);
699
780
700
	}
781
	}
(-)src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java (-1 / +1 lines)
Lines 238-244 Link Here
238
238
239
	protected static final String CONTEXT_MENU_ID = "#MylynRepositoryEditor";
239
	protected static final String CONTEXT_MENU_ID = "#MylynRepositoryEditor";
240
240
241
	private FormToolkit toolkit;
241
	protected FormToolkit toolkit;
242
242
243
	private ScrolledForm form;
243
	private ScrolledForm form;
244
244
(-)src/org/eclipse/mylyn/internal/bugzilla/core/RepositoryConfiguration.java (-1 / +14 lines)
Lines 22-28 Link Here
22
 */
22
 */
23
public class RepositoryConfiguration implements Serializable {
23
public class RepositoryConfiguration implements Serializable {
24
24
25
	private static final long serialVersionUID = -3623617786905114255L;
25
	private static final long serialVersionUID = -482656956042521023L;
26
26
27
	private static final String VERSION_UNKNOWN = "unknown";
27
	private static final String VERSION_UNKNOWN = "unknown";
28
28
Lines 54-59 Link Here
54
54
55
	private List<String> milestones = new ArrayList<String>();
55
	private List<String> milestones = new ArrayList<String>();
56
56
57
	private List<BugzillaCustomField> customFields = new ArrayList<BugzillaCustomField>();
58
57
	private String version = VERSION_UNKNOWN;
59
	private String version = VERSION_UNKNOWN;
58
60
59
	public RepositoryConfiguration() {
61
	public RepositoryConfiguration() {
Lines 379-382 Link Here
379
		}
381
		}
380
	}
382
	}
381
383
384
	/**
385
	 * Adds a field to the configuration.
386
	 */
387
	public void addCustomField(BugzillaCustomField newField) {
388
		customFields.add(newField);
389
	}
390
391
	public List<BugzillaCustomField> getCustomFields() {
392
		return customFields;
393
	}
394
382
}
395
}
(-)src/org/eclipse/mylyn/internal/bugzilla/core/SaxMultiBugReportContentHandler.java (-2 / +25 lines)
Lines 9-14 Link Here
9
package org.eclipse.mylyn.internal.bugzilla.core;
9
package org.eclipse.mylyn.internal.bugzilla.core;
10
10
11
import java.util.HashMap;
11
import java.util.HashMap;
12
import java.util.List;
12
import java.util.Locale;
13
import java.util.Locale;
13
import java.util.Map;
14
import java.util.Map;
14
15
Lines 51-61 Link Here
51
52
52
	private AbstractAttributeFactory attributeFactory;
53
	private AbstractAttributeFactory attributeFactory;
53
54
55
	private List<BugzillaCustomField> customFields;
56
54
	//private int retrieved = 1;
57
	//private int retrieved = 1;
55
58
56
	public SaxMultiBugReportContentHandler(AbstractAttributeFactory factory, Map<String, RepositoryTaskData> taskDataMap) {
59
	public SaxMultiBugReportContentHandler(AbstractAttributeFactory factory,
60
			Map<String, RepositoryTaskData> taskDataMap, List<BugzillaCustomField> customFields) {
57
		this.attributeFactory = factory;
61
		this.attributeFactory = factory;
58
		this.taskDataMap = taskDataMap;
62
		this.taskDataMap = taskDataMap;
63
		this.customFields = customFields;
59
	}
64
	}
60
65
61
	public boolean errorOccurred() {
66
	public boolean errorOccurred() {
Lines 83-88 Link Here
83
	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
88
	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
84
		characters = new StringBuffer();
89
		characters = new StringBuffer();
85
		BugzillaReportElement tag = BugzillaReportElement.UNKNOWN;
90
		BugzillaReportElement tag = BugzillaReportElement.UNKNOWN;
91
		if (localName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX))
92
			return;
86
		try {
93
		try {
87
			tag = BugzillaReportElement.valueOf(localName.trim().toUpperCase(Locale.ENGLISH));
94
			tag = BugzillaReportElement.valueOf(localName.trim().toUpperCase(Locale.ENGLISH));
88
		} catch (RuntimeException e) {
95
		} catch (RuntimeException e) {
Lines 158-164 Link Here
158
	public void endElement(String uri, String localName, String qName) throws SAXException {
165
	public void endElement(String uri, String localName, String qName) throws SAXException {
159
166
160
		String parsedText = HtmlStreamTokenizer.unescape(characters.toString());
167
		String parsedText = HtmlStreamTokenizer.unescape(characters.toString());
161
168
		if (localName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) {
169
			RepositoryTaskAttribute attribute = repositoryTaskData.getAttribute(localName);
170
			if (attribute == null) {
171
				String desc = "???";
172
				for (BugzillaCustomField bugzillaCustomField : customFields) {
173
					if (localName.equals(bugzillaCustomField.getName())) {
174
						desc = bugzillaCustomField.getDescription();
175
					}
176
				}
177
				RepositoryTaskAttribute newattribute = new RepositoryTaskAttribute(localName, desc, true);
178
				newattribute.setReadOnly(false);
179
				newattribute.setValue(parsedText);
180
				repositoryTaskData.addAttribute(localName, newattribute);
181
			} else {
182
				attribute.addValue(parsedText);
183
			}
184
		}
162
		BugzillaReportElement tag = BugzillaReportElement.UNKNOWN;
185
		BugzillaReportElement tag = BugzillaReportElement.UNKNOWN;
163
		try {
186
		try {
164
			tag = BugzillaReportElement.valueOf(localName.trim().toUpperCase(Locale.ENGLISH));
187
			tag = BugzillaReportElement.valueOf(localName.trim().toUpperCase(Locale.ENGLISH));
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClientManager.java (-1 / +3 lines)
Lines 12-17 Link Here
12
import java.util.HashMap;
12
import java.util.HashMap;
13
import java.util.Map;
13
import java.util.Map;
14
14
15
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.mylyn.tasks.core.ITaskRepositoryListener;
16
import org.eclipse.mylyn.tasks.core.ITaskRepositoryListener;
16
import org.eclipse.mylyn.tasks.core.TaskRepository;
17
import org.eclipse.mylyn.tasks.core.TaskRepository;
17
18
Lines 26-32 Link Here
26
	public BugzillaClientManager() {
27
	public BugzillaClientManager() {
27
	}
28
	}
28
29
29
	public synchronized BugzillaClient getClient(TaskRepository taskRepository) throws MalformedURLException {
30
	public synchronized BugzillaClient getClient(TaskRepository taskRepository) throws MalformedURLException, CoreException {
30
		BugzillaClient client = clientByUrl.get(taskRepository.getUrl());
31
		BugzillaClient client = clientByUrl.get(taskRepository.getUrl());
31
		if (client == null) {
32
		if (client == null) {
32
33
Lines 42-47 Link Here
42
			client = BugzillaClientFactory.createClient(taskRepository.getUrl(), taskRepository.getUserName(),
43
			client = BugzillaClientFactory.createClient(taskRepository.getUrl(), taskRepository.getUserName(),
43
					taskRepository.getPassword(), htUser, htPass, taskRepository.getProxy(),
44
					taskRepository.getPassword(), htUser, htPass, taskRepository.getProxy(),
44
					taskRepository.getCharacterEncoding(), taskRepository.getProperties(), languageSettings);
45
					taskRepository.getCharacterEncoding(), taskRepository.getProperties(), languageSettings);
46
			client.setRepositoryConfiguration(BugzillaCorePlugin.getRepositoryConfiguration(taskRepository, false));
45
			clientByUrl.put(taskRepository.getUrl(), client);
47
			clientByUrl.put(taskRepository.getUrl(), client);
46
		}
48
		}
47
		return client;
49
		return client;
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java (-7 / +9 lines)
Lines 282-288 Link Here
282
	public boolean markStaleTasks(TaskRepository repository, Set<AbstractTask> tasks, IProgressMonitor monitor)
282
	public boolean markStaleTasks(TaskRepository repository, Set<AbstractTask> tasks, IProgressMonitor monitor)
283
			throws CoreException {
283
			throws CoreException {
284
		try {
284
		try {
285
			
285
286
			monitor.beginTask("Checking for changed tasks", IProgressMonitor.UNKNOWN);
286
			monitor.beginTask("Checking for changed tasks", IProgressMonitor.UNKNOWN);
287
287
288
			if (repository.getSynchronizationTimeStamp() == null) {
288
			if (repository.getSynchronizationTimeStamp() == null) {
Lines 313-328 Link Here
313
				String newurlQueryString = URLEncoder.encode(task.getTaskId() + ",", repository.getCharacterEncoding());
313
				String newurlQueryString = URLEncoder.encode(task.getTaskId() + ",", repository.getCharacterEncoding());
314
				urlQueryString += newurlQueryString;
314
				urlQueryString += newurlQueryString;
315
			}
315
			}
316
			
316
317
			queryForChanged(repository, changedTasks, urlQueryString);
317
			queryForChanged(repository, changedTasks, urlQueryString);
318
			
318
319
			for (AbstractTask task : tasks) {
319
			for (AbstractTask task : tasks) {
320
				if (changedTasks.contains(task)) {
320
				if (changedTasks.contains(task)) {
321
					task.setStale(true);
321
					task.setStale(true);
322
				}
322
				}
323
			}
323
			}
324
324
325
326
			// FIXME check if new tasks were added
325
			// FIXME check if new tasks were added
327
			//return changedTasks.isEmpty();
326
			//return changedTasks.isEmpty();
328
			return true;
327
			return true;
Lines 335-341 Link Here
335
			monitor.done();
334
			monitor.done();
336
		}
335
		}
337
	}
336
	}
338
	
337
339
	private void queryForChanged(final TaskRepository repository, Set<AbstractTask> changedTasks, String urlQueryString)
338
	private void queryForChanged(final TaskRepository repository, Set<AbstractTask> changedTasks, String urlQueryString)
340
			throws UnsupportedEncodingException, CoreException {
339
			throws UnsupportedEncodingException, CoreException {
341
		QueryHitCollector collector = new QueryHitCollector(new ITaskFactory() {
340
		QueryHitCollector collector = new QueryHitCollector(new ITaskFactory() {
Lines 476-483 Link Here
476
			throws CoreException {
475
			throws CoreException {
477
		String product = existingReport.getAttributeValue(BugzillaReportElement.PRODUCT.getKeyString());
476
		String product = existingReport.getAttributeValue(BugzillaReportElement.PRODUCT.getKeyString());
478
		for (RepositoryTaskAttribute attribute : existingReport.getAttributes()) {
477
		for (RepositoryTaskAttribute attribute : existingReport.getAttributes()) {
479
			BugzillaReportElement element = BugzillaReportElement.valueOf(attribute.getId().trim().toUpperCase(
478
			String attribID = attribute.getId();
480
					Locale.ENGLISH));
479
			if (attribID.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) {
480
				continue;
481
			}
482
			BugzillaReportElement element = BugzillaReportElement.valueOf(attribID.trim().toUpperCase(Locale.ENGLISH));
481
			attribute.clearOptions();
483
			attribute.clearOptions();
482
			List<String> optionValues = BugzillaCorePlugin.getRepositoryConfiguration(taskRepository, false)
484
			List<String> optionValues = BugzillaCorePlugin.getRepositoryConfiguration(taskRepository, false)
483
					.getOptionValues(element, product);
485
					.getOptionValues(element, product);
(-)src/org/eclipse/mylyn/internal/bugzilla/core/MultiBugReportFactory.java (-2 / +3 lines)
Lines 10-15 Link Here
10
10
11
import java.io.IOException;
11
import java.io.IOException;
12
import java.io.InputStream;
12
import java.io.InputStream;
13
import java.util.List;
13
import java.util.Locale;
14
import java.util.Locale;
14
import java.util.Map;
15
import java.util.Map;
15
16
Lines 31-40 Link Here
31
32
32
	private static BugzillaAttributeFactory bugzillaAttributeFactory = new BugzillaAttributeFactory();
33
	private static BugzillaAttributeFactory bugzillaAttributeFactory = new BugzillaAttributeFactory();
33
34
34
	public void populateReport(Map<String, RepositoryTaskData> bugMap) throws IOException, CoreException {
35
	public void populateReport(Map<String, RepositoryTaskData> bugMap, List<BugzillaCustomField> customFields) throws IOException, CoreException {
35
36
36
		SaxMultiBugReportContentHandler contentHandler = new SaxMultiBugReportContentHandler(bugzillaAttributeFactory,
37
		SaxMultiBugReportContentHandler contentHandler = new SaxMultiBugReportContentHandler(bugzillaAttributeFactory,
37
				bugMap);
38
				bugMap, customFields);
38
		collectResults(contentHandler, false);
39
		collectResults(contentHandler, false);
39
40
40
		if (contentHandler.errorOccurred()) {
41
		if (contentHandler.errorOccurred()) {
(-)src/org/eclipse/mylyn/internal/bugzilla/core/SaxConfigurationContentHandler.java (+62 lines)
Lines 56-61 Link Here
56
56
57
	private static final String ELEMENT_PRODUCTS = "products";
57
	private static final String ELEMENT_PRODUCTS = "products";
58
58
59
	private static final String ELEMENT_DESCRIPTION = "description";
60
61
	private static final String ELEMENT_FIELDS = "fields";
62
63
	private static final String ELEMENT_FIELD = "field";
64
59
	private static final String ELEMENT_SEVERITY = "severity";
65
	private static final String ELEMENT_SEVERITY = "severity";
60
66
61
	private static final String ELEMENT_PRIORITY = "priority";
67
	private static final String ELEMENT_PRIORITY = "priority";
Lines 112-121 Link Here
112
118
113
	private static final int IN_STATUS_CLOSED = 1 << 20;
119
	private static final int IN_STATUS_CLOSED = 1 << 20;
114
120
121
	private static final int IN_FIELDS = 1 << 21;
122
123
	private static final int IN_FIELD = 1 << 22;
124
125
	private static final int IN_CUSTOM_OPTION = 1 << 22;
126
115
	private int state = EXPECTING_ROOT;
127
	private int state = EXPECTING_ROOT;
116
128
117
	private String currentProduct = "";
129
	private String currentProduct = "";
118
130
131
	private String currentName = "";
132
119
	private StringBuffer characters = new StringBuffer();
133
	private StringBuffer characters = new StringBuffer();
120
134
121
	private String about;
135
	private String about;
Lines 134-139 Link Here
134
148
135
	private Map<String, String> milestoneNames = new HashMap<String, String>();
149
	private Map<String, String> milestoneNames = new HashMap<String, String>();
136
150
151
	private Map<String, List<String>> customOption = new HashMap<String, List<String>>();
152
153
	private String currentCustomOptionName = "";
154
137
	public RepositoryConfiguration getConfiguration() {
155
	public RepositoryConfiguration getConfiguration() {
138
		return configuration;
156
		return configuration;
139
	}
157
	}
Lines 190-195 Link Here
190
			state = state | IN_RESOLUTION;
208
			state = state | IN_RESOLUTION;
191
		} else if (localName.equals(ELEMENT_KEYWORD)) {
209
		} else if (localName.equals(ELEMENT_KEYWORD)) {
192
			state = state | IN_KEYWORD;
210
			state = state | IN_KEYWORD;
211
		} else if (localName.equals(ELEMENT_FIELDS)) {
212
			state = state | IN_FIELDS;
213
		} else if (localName.equals(ELEMENT_FIELD)) {
214
			state = state | IN_FIELD;
215
			parseResource(attributes);
216
		} else if (localName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) {
217
			state = state | IN_CUSTOM_OPTION;
218
			currentCustomOptionName = localName;
193
		}
219
		}
194
	}
220
	}
195
221
Lines 224-229 Link Here
224
				configuration.addPriority(characters.toString());
250
				configuration.addPriority(characters.toString());
225
			} else if (state == (IN_SEVERITY)) {
251
			} else if (state == (IN_SEVERITY)) {
226
				configuration.addSeverity(characters.toString());
252
				configuration.addSeverity(characters.toString());
253
			} else if (state == (IN_CUSTOM_OPTION)) {
254
				// Option for CutstomFields
255
				if (currentCustomOptionName != null) {
256
					if (characters.length() > 0) {
257
						List<String> customOptionList = customOption.get(currentCustomOptionName);
258
						if (customOptionList == null) {
259
							customOptionList = new ArrayList<String>();
260
							customOption.put(currentCustomOptionName, customOptionList);
261
						}
262
						customOptionList.add(characters.toString());
263
					}
264
				}
227
			}
265
			}
228
		} else if (localName.equals(ELEMENT_PLATFORM)) {
266
		} else if (localName.equals(ELEMENT_PLATFORM)) {
229
			state = state & ~IN_PLATFORM;
267
			state = state & ~IN_PLATFORM;
Lines 264-269 Link Here
264
						milestoneNames.put(about, characters.toString());
302
						milestoneNames.put(about, characters.toString());
265
					}
303
					}
266
				}
304
				}
305
			} else if (state == (IN_FIELDS | IN_LI | IN_FIELD)) {
306
				// FIELDS NAME
307
				currentName = characters.toString();
267
			}
308
			}
268
		} else if (localName.equals(ELEMENT_COMPONENTS)) {
309
		} else if (localName.equals(ELEMENT_COMPONENTS)) {
269
			state = state & ~IN_COMPONENTS;
310
			state = state & ~IN_COMPONENTS;
Lines 286-291 Link Here
286
			state = state & ~IN_RESOLUTION;
327
			state = state & ~IN_RESOLUTION;
287
		} else if (localName.equals(ELEMENT_KEYWORD)) {
328
		} else if (localName.equals(ELEMENT_KEYWORD)) {
288
			state = state & ~IN_KEYWORD;
329
			state = state & ~IN_KEYWORD;
330
		} else if (localName.equals(ELEMENT_FIELDS)) {
331
			state = state & ~IN_FIELDS;
332
		} else if (localName.equals(ELEMENT_FIELD)) {
333
			state = state & ~IN_FIELD;
334
		} else if (localName.equals(ELEMENT_DESCRIPTION)) {
335
			if (currentName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) {
336
				BugzillaCustomField newField = new BugzillaCustomField(characters.toString(), currentName);
337
				List<String> customOptionList = customOption.get(currentName);
338
				if (customOptionList != null && !customOptionList.isEmpty())
339
					newField.setOptions(customOptionList);
340
				configuration.addCustomField(newField);
341
			}
342
		} else if (localName.startsWith(BugzillaCustomField.CUSTOM_FIELD_PREFIX)) {
343
			state = state & ~IN_CUSTOM_OPTION;
344
			currentCustomOptionName = "";
289
		}
345
		}
290
	}
346
	}
291
347
Lines 348-353 Link Here
348
			}
404
			}
349
			break;
405
			break;
350
406
407
		case IN_FIELDS | IN_LI | IN_FIELD:
408
			if (attributes != null) {
409
				about = attributes.getValue(ATTRIBUTE_RDF_ABOUT);
410
			}
411
			break;
412
351
		}
413
		}
352
	}
414
	}
353
415
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java (-22 / +31 lines)
Lines 154-159 Link Here
154
	private boolean lastModifiedSupported = true;
154
	private boolean lastModifiedSupported = true;
155
155
156
	private BugzillaLanguageSettings bugzillaLanguageSettings;
156
	private BugzillaLanguageSettings bugzillaLanguageSettings;
157
	
158
	private RepositoryConfiguration repositoryConfiguration;
157
159
158
	public BugzillaClient(URL url, String username, String password, String htAuthUser, String htAuthPass,
160
	public BugzillaClient(URL url, String username, String password, String htAuthUser, String htAuthPass,
159
			String characterEncoding) {
161
			String characterEncoding) {
Lines 427-433 Link Here
427
		}
429
		}
428
	}
430
	}
429
431
430
	public RepositoryTaskData getTaskData(int id) throws IOException, CoreException {
432
	public RepositoryTaskData getTaskData(int id) throws IOException,
433
			CoreException {
431
		final String idString = String.valueOf(id);
434
		final String idString = String.valueOf(id);
432
		Set<String> data = new HashSet<String>();
435
		Set<String> data = new HashSet<String>();
433
		data.add(idString);
436
		data.add(idString);
Lines 474-505 Link Here
474
		GzipPostMethod postMethod = null;
477
		GzipPostMethod postMethod = null;
475
478
476
		try {
479
		try {
477
			
480
478
			String queryUrl = query.getUrl();
481
			String queryUrl = query.getUrl();
479
			int start = queryUrl.indexOf('?');
482
			int start = queryUrl.indexOf('?');
480
			
483
481
			List<NameValuePair> pairs = new ArrayList<NameValuePair>();
484
			List<NameValuePair> pairs = new ArrayList<NameValuePair>();
482
			if(start != -1) {
485
			if (start != -1) {
483
				queryUrl = queryUrl.substring(start + 1);
486
				queryUrl = queryUrl.substring(start + 1);
484
				String[] result = queryUrl.split("&");
487
				String[] result = queryUrl.split("&");
485
				if(result.length > 0) {
488
				if (result.length > 0) {
486
					for (String string : result) {
489
					for (String string : result) {
487
						String[] nameValue = string.split("=");
490
						String[] nameValue = string.split("=");
488
						if(nameValue.length == 1) {
491
						if (nameValue.length == 1) {
489
							pairs.add(new NameValuePair(nameValue[0].trim(), ""));
492
							pairs.add(new NameValuePair(nameValue[0].trim(), ""));
490
						} else if(nameValue.length == 2 && nameValue[0] != null && nameValue[1] != null) {
493
						} else if (nameValue.length == 2 && nameValue[0] != null && nameValue[1] != null) {
491
							pairs.add(new NameValuePair(nameValue[0].trim(), URLDecoder.decode(nameValue[1].trim(), characterEncoding)));
494
							pairs.add(new NameValuePair(nameValue[0].trim(), URLDecoder.decode(nameValue[1].trim(),
495
									characterEncoding)));
492
						}
496
						}
493
					}
497
					}
494
				}
498
				}
495
			}
499
			}
496
			
500
497
			NameValuePair ctypePair = new NameValuePair("ctype", "rdf");
501
			NameValuePair ctypePair = new NameValuePair("ctype", "rdf");
498
			// Test that we don't specify content type twice.
502
			// Test that we don't specify content type twice.
499
			if(!pairs.contains(ctypePair)) {
503
			if (!pairs.contains(ctypePair)) {
500
				pairs.add(ctypePair);
504
				pairs.add(ctypePair);
501
			}
505
			}
502
			
506
503
			postMethod = postFormData(IBugzillaConstants.URL_BUGLIST, pairs.toArray(new NameValuePair[pairs.size()]));
507
			postMethod = postFormData(IBugzillaConstants.URL_BUGLIST, pairs.toArray(new NameValuePair[pairs.size()]));
504
			//System.err.println(postMethod.getResponseBodyAsString());
508
			//System.err.println(postMethod.getResponseBodyAsString());
505
			if (postMethod.getResponseHeader("Content-Type") != null) {
509
			if (postMethod.getResponseHeader("Content-Type") != null) {
Lines 513-519 Link Here
513
					}
517
					}
514
				}
518
				}
515
			}
519
			}
516
			
520
517
			parseHtmlError(new BufferedReader(new InputStreamReader(postMethod.getResponseBodyAsUnzippedStream(),
521
			parseHtmlError(new BufferedReader(new InputStreamReader(postMethod.getResponseBodyAsUnzippedStream(),
518
					characterEncoding)));
522
					characterEncoding)));
519
		} finally {
523
		} finally {
Lines 637-646 Link Here
637
						RepositoryConfigurationFactory configFactory = new RepositoryConfigurationFactory(stream,
641
						RepositoryConfigurationFactory configFactory = new RepositoryConfigurationFactory(stream,
638
								characterEncoding);
642
								characterEncoding);
639
643
640
						RepositoryConfiguration configuration = configFactory.getConfiguration();
644
						repositoryConfiguration = configFactory.getConfiguration();
641
						if (configuration != null) {
645
						if (repositoryConfiguration != null) {
642
							configuration.setRepositoryUrl(repositoryUrl.toString());
646
							repositoryConfiguration.setRepositoryUrl(repositoryUrl.toString());
643
							return configuration;
647
							return repositoryConfiguration;
644
						}
648
						}
645
					}
649
					}
646
				}
650
				}
Lines 1180-1192 Link Here
1180
		return null;
1184
		return null;
1181
	}
1185
	}
1182
1186
1183
	public Map<String, RepositoryTaskData> getTaskData(Set<String> taskIds) throws IOException, CoreException {
1187
	public Map<String, RepositoryTaskData> getTaskData(Set<String> taskIds)
1188
			throws IOException, CoreException {
1184
		GzipPostMethod method = null;
1189
		GzipPostMethod method = null;
1185
		HashMap<String, RepositoryTaskData> taskDataMap = new HashMap<String, RepositoryTaskData>();
1190
		HashMap<String, RepositoryTaskData> taskDataMap = new HashMap<String, RepositoryTaskData>();
1186
		while (taskIds.size() > 0) {
1191
		while (taskIds.size() > 0) {
1187
1188
			try {
1192
			try {
1189
1190
				Set<String> idsToRetrieve = new HashSet<String>();
1193
				Set<String> idsToRetrieve = new HashSet<String>();
1191
				Iterator<String> itr = taskIds.iterator();
1194
				Iterator<String> itr = taskIds.iterator();
1192
				for (int x = 0; itr.hasNext() && x < MAX_RETRIEVED_PER_QUERY; x++) {
1195
				for (int x = 0; itr.hasNext() && x < MAX_RETRIEVED_PER_QUERY; x++) {
Lines 1216-1230 Link Here
1216
				if (method == null) {
1219
				if (method == null) {
1217
					throw new IOException("Could not post form, client returned null method.");
1220
					throw new IOException("Could not post form, client returned null method.");
1218
				}
1221
				}
1219
				
1222
1220
				boolean parseable = false;
1223
				boolean parseable = false;
1224
				List<BugzillaCustomField> customFields = repositoryConfiguration.getCustomFields();
1221
				if (method.getResponseHeader("Content-Type") != null) {
1225
				if (method.getResponseHeader("Content-Type") != null) {
1222
					Header responseTypeHeader = method.getResponseHeader("Content-Type");
1226
					Header responseTypeHeader = method.getResponseHeader("Content-Type");
1223
					for (String type : VALID_CONFIG_CONTENT_TYPES) {
1227
					for (String type : VALID_CONFIG_CONTENT_TYPES) {
1224
						if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) {
1228
						if (responseTypeHeader.getValue().toLowerCase(Locale.ENGLISH).contains(type)) {
1225
							MultiBugReportFactory factory = new MultiBugReportFactory(
1229
							MultiBugReportFactory factory = new MultiBugReportFactory(
1226
									method.getResponseBodyAsUnzippedStream(), characterEncoding);
1230
									method.getResponseBodyAsUnzippedStream(), characterEncoding);
1227
							factory.populateReport(taskDataMap);
1231
							factory.populateReport(taskDataMap, customFields);
1228
							taskIds.removeAll(idsToRetrieve);
1232
							taskIds.removeAll(idsToRetrieve);
1229
							parseable = true;
1233
							parseable = true;
1230
							break;
1234
							break;
Lines 1237-1243 Link Here
1237
							characterEncoding)));
1241
							characterEncoding)));
1238
					break;
1242
					break;
1239
				}
1243
				}
1240
				
1244
1241
			} finally {
1245
			} finally {
1242
				if (method != null) {
1246
				if (method != null) {
1243
					method.releaseConnection();
1247
					method.releaseConnection();
Lines 1342-1345 Link Here
1342
						+ " failed. Please verify connection and authentication information."));
1346
						+ " failed. Please verify connection and authentication information."));
1343
	}
1347
	}
1344
1348
1349
1350
	public void setRepositoryConfiguration(RepositoryConfiguration repositoryConfiguration) {
1351
		this.repositoryConfiguration = repositoryConfiguration;
1352
	}
1353
1345
}
1354
}
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaCustomField.java (+57 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project committers 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
9
package org.eclipse.mylyn.internal.bugzilla.core;
10
11
import java.io.Serializable;
12
import java.util.ArrayList;
13
import java.util.List;
14
15
/**
16
 * Class describing a custom Fields for a given Bugzilla installation.
17
 * 
18
 * @author Frank Becker
19
 * @since 2.3
20
 */
21
public class BugzillaCustomField implements Serializable {
22
23
	private static final long serialVersionUID = 5703683576871326128L;
24
25
	public static final String CUSTOM_FIELD_PREFIX = "cf_";
26
27
	private String name;
28
29
	private String description;
30
31
	private List<String> options = new ArrayList<String>();
32
33
	public BugzillaCustomField(String description, String name) {
34
		this.description = description;
35
		this.name = name;
36
	}
37
38
	public String getName() {
39
		return name;
40
	}
41
42
	public String getDescription() {
43
		return description;
44
	}
45
46
	public List<String> getOptions() {
47
		return options;
48
	}
49
50
	public void setOptions(List<String> options) {
51
		this.options = options;
52
	}
53
54
	public void addOption(String option) {
55
		this.options.add(option);
56
	}
57
}

Return to bug 175922