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

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

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Set;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.monitor.core.StatusHandler;
import org.eclipse.mylyn.tasks.core.AbstractAttachmentHandler;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
import org.eclipse.mylyn.tasks.core.AbstractTask;
import org.eclipse.mylyn.tasks.core.AbstractTaskDataHandler;
import org.eclipse.mylyn.tasks.core.ITaskCollector;
import org.eclipse.mylyn.tasks.core.ITaskFactory;
import org.eclipse.mylyn.tasks.core.QueryHitCollector;
import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
import org.eclipse.mylyn.tasks.core.TaskComment;
import org.eclipse.mylyn.tasks.core.TaskList;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.AbstractTask.PriorityLevel;

/**
 * @author Mik Kersten
 * @author Rob Elves
 */
public class BugzillaRepositoryConnector extends AbstractRepositoryConnector {

	private static final String BUG_ID = "&bug_id=";

	private static final String CHANGED_BUGS_CGI_ENDDATE = "&chfieldto=Now";

	private static final String CHANGED_BUGS_CGI_QUERY = "/buglist.cgi?query_format=advanced&chfieldfrom=";

	private static final String CLIENT_LABEL = "Bugzilla (supports uncustomized 2.18-3.0)";

	private static final String COMMENT_FORMAT = "yyyy-MM-dd HH:mm";

	private static final String DEADLINE_FORMAT = "yyyy-MM-dd";

	private BugzillaAttachmentHandler attachmentHandler;

	private BugzillaTaskDataHandler taskDataHandler;

	private BugzillaClientManager clientManager;

	@Override
	public void init(TaskList taskList) {
		super.init(taskList);
		this.taskDataHandler = new BugzillaTaskDataHandler(this);
		this.attachmentHandler = new BugzillaAttachmentHandler(this);
		BugzillaCorePlugin.setConnector(this);
	}

	@Override
	public String getLabel() {
		return CLIENT_LABEL;
	}

	@Override
	public AbstractAttachmentHandler getAttachmentHandler() {
		return attachmentHandler;
	}

	@Override
	public AbstractTaskDataHandler getTaskDataHandler() {
		return taskDataHandler;
	}

	@Override
	public String getConnectorKind() {
		return BugzillaCorePlugin.REPOSITORY_KIND;
	}

	public AbstractTask createTask(String repositoryUrl, String id, String summary) {
		BugzillaTask task = new BugzillaTask(repositoryUrl, id, summary);
		task.setCreationDate(new Date());
		return task;
	}

	public void updateTaskFromTaskData(TaskRepository repository, AbstractTask repositoryTask,
			RepositoryTaskData taskData) {
		BugzillaTask bugzillaTask = (BugzillaTask) repositoryTask;
		if (taskData != null) {

////			// subtasks
//			repositoryTask.dropSubTasks();
//			Set<String> subTaskIds = taskDataHandler.getSubTaskIds(taskData);
//			if (subTaskIds != null && !subTaskIds.isEmpty()) {
//				for (String subId : subTaskIds) {
//					ITask subTask = taskList.getTask(repository.getUrl(), subId);
////					if (subTask == null && retrieveSubTasks) {
////						if (!subId.trim().equals(taskData.getId()) && !subId.equals("")) {
////							try {
////								subTask = createTaskFromExistingId(repository, subId, false, new NullProgressMonitor());
////							} catch (CoreException e) {
////								// ignore
////							}
////						}
////					}
//					if (subTask != null) {
//						bugzillaTask.addSubTask(subTask);
//					}
//				}
//			}

			// Summary
			String summary = taskData.getSummary();
			bugzillaTask.setSummary(summary);

			// Owner
			String owner = taskData.getAssignedTo();
			if (owner != null && !owner.equals("")) {
				bugzillaTask.setOwner(owner);
			}

			// Completed
			boolean isComplete = false;
			// TODO: use repository configuration to determine what -completed-
			// states are
			if (taskData.getStatus() != null) {
				isComplete = taskData.getStatus().equals(IBugzillaConstants.VALUE_STATUS_RESOLVED)
						|| taskData.getStatus().equals(IBugzillaConstants.VALUE_STATUS_CLOSED)
						|| taskData.getStatus().equals(IBugzillaConstants.VALUE_STATUS_VERIFIED);
			}
			bugzillaTask.setCompleted(isComplete);

			// Completion Date
			if (isComplete) {
				Date completionDate = null;
				try {

					List<TaskComment> taskComments = taskData.getComments();
					if (taskComments != null && !taskComments.isEmpty()) {
						// TODO: fix not to be based on comment
						completionDate = new SimpleDateFormat(COMMENT_FORMAT).parse(taskComments.get(
								taskComments.size() - 1).getCreated());

					}

				} catch (Exception e) {

				}

				if (bugzillaTask.getCompletionDate() != null && completionDate != null) {
					// if changed:
					// TODO: get taskListManger.setDueDate(ITask task, Date
					// dueDate)
				}
				bugzillaTask.setCompletionDate(completionDate);

			}

			// Priority
			String priority = PriorityLevel.getDefault().toString();
			if (taskData.getAttribute(RepositoryTaskAttribute.PRIORITY) != null) {
				priority = taskData.getAttribute(RepositoryTaskAttribute.PRIORITY).getValue();
			}
			bugzillaTask.setPriority(priority);

			// Task Web Url
			String url = getTaskUrl(repository.getUrl(), taskData.getId());
			if (url != null) {
				bugzillaTask.setUrl(url);
			}

			// Bugzilla Specific Attributes

			// Product
			if (taskData.getProduct() != null) {
				bugzillaTask.setProduct(taskData.getProduct());
			}

			// Severity
			String severity = taskData.getAttributeValue(BugzillaReportElement.BUG_SEVERITY.getKeyString());
			if (severity != null && !severity.equals("")) {
				bugzillaTask.setSeverity(severity);
			}

			// Due Date
			if (taskData.getAttribute(BugzillaReportElement.ESTIMATED_TIME.getKeyString()) != null) {
				Date dueDate = null;
				// HACK: if estimated_time field exists, time tracking is
				// enabled
				try {
					String dueStr = taskData.getAttributeValue(BugzillaReportElement.DEADLINE.getKeyString());
					if (dueStr != null) {
						dueDate = new SimpleDateFormat(DEADLINE_FORMAT).parse(dueStr);
					}
				} catch (Exception e) {
					// ignore
				}
				bugzillaTask.setDueDate(dueDate);
			}

		}
	}

	@Override
	public boolean updateTaskFromQueryHit(TaskRepository repository, AbstractTask existingTask,
			AbstractTask newTask) {
		// these properties are not provided by Bugzilla queries
		newTask.setCompleted(existingTask.isCompleted());
//		newTask.setCompletionDate(existingTask.getCompletionDate());
		
		boolean changed = super.updateTaskFromQueryHit(repository, existingTask, newTask);
		
		if (existingTask instanceof BugzillaTask && newTask instanceof BugzillaTask) {
			BugzillaTask existingBugzillaTask = (BugzillaTask) existingTask;
			BugzillaTask newBugzillaTask = (BugzillaTask) newTask;
			
			if (hasTaskPropertyChanged(existingBugzillaTask.getSeverity(), newBugzillaTask.getSeverity())) {
				existingBugzillaTask.setSeverity(newBugzillaTask.getSeverity());
				changed = true;
			}
			if (hasTaskPropertyChanged(existingBugzillaTask.getProduct(), newBugzillaTask.getProduct())) {
				existingBugzillaTask.setProduct(newBugzillaTask.getProduct());
				changed = true;
			}
		}
		
		return changed;
	}

	@Override
	public boolean markStaleTasks(TaskRepository repository, Set<AbstractTask> tasks, IProgressMonitor monitor)
			throws CoreException {
		try {
			monitor.beginTask("Checking for changed tasks", IProgressMonitor.UNKNOWN);

			if (repository.getSynchronizationTimeStamp() == null) {
				for (AbstractTask task : tasks) {
					task.setStale(true);
				}
				return true;
			}

			String dateString = repository.getSynchronizationTimeStamp();
			if (dateString == null) {
				dateString = "";
			}

			String urlQueryBase = repository.getUrl() + CHANGED_BUGS_CGI_QUERY
					+ URLEncoder.encode(dateString, repository.getCharacterEncoding()) + CHANGED_BUGS_CGI_ENDDATE;

			String urlQueryString = urlQueryBase + BUG_ID;

			// Need to replace this with query that would return list of tasks since last sync
			// the trouble is that bugzilla only have 1 hour granularity for "changed since" query
			// so, we can't say that no tasks has changed in repository

			Set<AbstractTask> changedTasks = new HashSet<AbstractTask>();
			int queryCounter = -1;
			Iterator<AbstractTask> itr = tasks.iterator();
			while (itr.hasNext()) {
				queryCounter++;
				AbstractTask task = itr.next();
				String newurlQueryString = URLEncoder.encode(task.getTaskId() + ",", repository.getCharacterEncoding());
				if ((urlQueryString.length() + newurlQueryString.length() + IBugzillaConstants.CONTENT_TYPE_RDF.length()) > IBugzillaConstants.MAX_URL_LENGTH) {
					queryForChanged(repository, changedTasks, urlQueryString);
					queryCounter = 0;
					urlQueryString = urlQueryBase + BUG_ID;
				}
				urlQueryString += newurlQueryString;
				if (!itr.hasNext()) {
					queryForChanged(repository, changedTasks, urlQueryString);
				}
			}

			for (AbstractTask task : tasks) {
				if (changedTasks.contains(task)) {
					task.setStale(true);
				}
			}

//			for (AbstractTask task : changedTasks) {
//				task.setStale(true);
//			}

			// FIXME check if new tasks were added
			//return changedTasks.isEmpty();
			return true;
		} catch (UnsupportedEncodingException e) {
			// XXX throw CoreException instead?
			StatusHandler.fail(e, "Repository configured with unsupported encoding: "
					+ repository.getCharacterEncoding() + "\n\n Unable to determine changed tasks.", true);
			return false;
		} finally {
			monitor.done();
		}
	}

	private void queryForChanged(final TaskRepository repository, Set<AbstractTask> changedTasks, String urlQueryString)
			throws UnsupportedEncodingException, CoreException {
		QueryHitCollector collector = new QueryHitCollector(new ITaskFactory() {

			public AbstractTask createTask(RepositoryTaskData taskData, IProgressMonitor monitor) {
				// do not construct actual task objects here as query shouldn't result in new tasks
				return taskList.getTask(taskData.getRepositoryUrl(), taskData.getId());
			}
		});

		BugzillaRepositoryQuery query = new BugzillaRepositoryQuery(repository.getUrl(), urlQueryString, "");

		performQuery(query, repository, new NullProgressMonitor(), collector);
		changedTasks.addAll(collector.getTasks());

//		for (AbstractTask taskHit : collector.getTaskHits()) {
//			// String handle =
//			// AbstractTask.getHandle(repository.getUrl(),
//			// hit.getId());
//			if (taskHit != null && taskHit instanceof AbstractTask) {
//				AbstractTask repositoryTask = (AbstractTask) taskHit;
//				// Hack to avoid re-syncing last task from previous
//				// synchronization
//				// This can be removed once we are getting a query timestamp
//				// from the repository rather than
//				// using the last modified stamp of the last task modified in
//				// the return hits.
//				// (or the changeddate field in the hit rdf becomes consistent,
//				// currently it doesn't return a proper modified date string)
//				// if (repositoryTask.getTaskData() != null
//				// &&
//				// repositoryTask.getTaskData().getLastModified().equals(repository.getSyncTimeStamp()))
//				// {
//				// // String taskId =
//				// //
//				// RepositoryTaskHandleUtil.getTaskId(repositoryTask.getHandleIdentifier());
//				// RepositoryTaskData taskData =
//				// getTaskDataHandler().getTaskData(repository,
//				// repositoryTask.getTaskId());
//				// if (taskData != null &&
//				// taskData.getLastModified().equals(repository.getSyncTimeStamp()))
//				// {
//				// continue;
//				// }
//				// }
//				changedTasks.add(repositoryTask);
//			}
//		}
	}

	@Override
	public boolean canCreateTaskFromKey(TaskRepository repository) {
		return true;
	}

	@Override
	public boolean canCreateNewTask(TaskRepository repository) {
		return true;
	}

	@Override
	public IStatus performQuery(final AbstractRepositoryQuery query, TaskRepository repository,
			IProgressMonitor monitor, ITaskCollector resultCollector) {
		try {
			monitor.beginTask("Running query", IProgressMonitor.UNKNOWN);
			BugzillaClient client = getClientManager().getClient(repository);
			boolean hitsReceived = client.getSearchHits(query, resultCollector);
			if (!hitsReceived) {
				// XXX: HACK in case of ip change bugzilla can return 0 hits
				// due to invalid authorization token, forcing relogin fixes
				client.logout();
				client.getSearchHits(query, resultCollector);
			}

			return Status.OK_STATUS;
		} catch (UnrecognizedReponseException e) {
			return new Status(IStatus.ERROR, BugzillaCorePlugin.PLUGIN_ID, Status.INFO,
					"Unrecognized response from server", e);
		} catch (IOException e) {
			return new Status(IStatus.ERROR, BugzillaCorePlugin.PLUGIN_ID, Status.ERROR,
					"Check repository configuration: " + e.getMessage(), e);
		} catch (CoreException e) {
			return e.getStatus();
		} finally {
			monitor.done();
		}
	}

	@Override
	public String getRepositoryUrlFromTaskUrl(String url) {
		if (url == null) {
			return null;
		}
		int index = url.indexOf(IBugzillaConstants.URL_GET_SHOW_BUG);
		return index == -1 ? null : url.substring(0, index);
	}

	@Override
	public String getTaskIdFromTaskUrl(String url) {
		if (url == null) {
			return null;
		}
		int index = url.indexOf(IBugzillaConstants.URL_GET_SHOW_BUG);
		return index == -1 ? null : url.substring(index + IBugzillaConstants.URL_GET_SHOW_BUG.length());
	}

	@Override
	public String getTaskUrl(String repositoryUrl, String taskId) {
		try {
			return BugzillaClient.getBugUrlWithoutLogin(repositoryUrl, taskId);
		} catch (Exception ex) {
			StatusHandler.fail(ex, "Error constructing task url for " + repositoryUrl + "  id:" + taskId, false);
		}
		return null;
	}

	@Override
	public void updateTaskFromRepository(TaskRepository repository, AbstractTask repositoryTask,
			IProgressMonitor monitor) {
		// ignore
	}

	@Override
	public String getTaskIdPrefix() {
		return "bug";
	}

	public BugzillaClientManager getClientManager() {
		if (clientManager == null) {
			clientManager = new BugzillaClientManager();
		}
		return clientManager;
	}

	@Override
	public void updateAttributes(TaskRepository repository, IProgressMonitor monitor) throws CoreException {
		if (repository != null) {
			BugzillaCorePlugin.getRepositoryConfiguration(repository, true);
		}
	}

	public void updateAttributeOptions(TaskRepository taskRepository, RepositoryTaskData existingReport)
			throws CoreException {
		String product = existingReport.getAttributeValue(BugzillaReportElement.PRODUCT.getKeyString());
		for (RepositoryTaskAttribute attribute : existingReport.getAttributes()) {
			BugzillaReportElement element = BugzillaReportElement.valueOf(attribute.getId().trim().toUpperCase(
					Locale.ENGLISH));
			attribute.clearOptions();
			List<String> optionValues = BugzillaCorePlugin.getRepositoryConfiguration(taskRepository, false)
					.getOptionValues(element, product);
			if (element != BugzillaReportElement.OP_SYS && element != BugzillaReportElement.BUG_SEVERITY
					&& element != BugzillaReportElement.PRIORITY && element != BugzillaReportElement.BUG_STATUS) {
				Collections.sort(optionValues);
			}
			if (element == BugzillaReportElement.TARGET_MILESTONE && optionValues.isEmpty()) {

				existingReport.removeAttribute(BugzillaReportElement.TARGET_MILESTONE);
				continue;
			}
			attribute.clearOptions();
			for (String option : optionValues) {
				attribute.addOption(option, option);
			}

			// TODO: bug#162428, bug#150680 - something along the lines of...
			// but must think about the case of multiple values selected etc.
			// if(attribute.hasOptions()) {
			// if(!attribute.getOptionValues().containsKey(attribute.getValue()))
			// {
			// // updateAttributes()
			// }
			// }
		}

	}

	/**
	 * Adds bug attributes to new bug model and sets defaults
	 * 
	 * @param proxySettings
	 *            TODO
	 * @param characterEncoding
	 *            TODO
	 * 
	 */
	public static void setupNewBugAttributes(TaskRepository taskRepository, RepositoryTaskData newTaskData)
			throws CoreException {

		String product = newTaskData.getProduct();

		newTaskData.removeAllAttributes();

		RepositoryConfiguration repositoryConfiguration = BugzillaCorePlugin.getRepositoryConfiguration(taskRepository,
				false);

		RepositoryTaskAttribute a = BugzillaClient.makeNewAttribute(BugzillaReportElement.PRODUCT);
		List<String> optionValues = repositoryConfiguration.getProducts();
		Collections.sort(optionValues);
		// for (String option : optionValues) {
		// a.addOptionValue(option, option);
		// }
		a.setValue(product);
		a.setReadOnly(true);

		newTaskData.addAttribute(BugzillaReportElement.PRODUCT.getKeyString(), a);
		// attributes.put(a.getName(), a);

		a = BugzillaClient.makeNewAttribute(BugzillaReportElement.BUG_STATUS);
		optionValues = repositoryConfiguration.getStatusValues();
		for (String option : optionValues) {
			a.addOption(option, option);
		}
		a.setValue(IBugzillaConstants.VALUE_STATUS_NEW);

		newTaskData.addAttribute(BugzillaReportElement.BUG_STATUS.getKeyString(), a);

		a = BugzillaClient.makeNewAttribute(BugzillaReportElement.SHORT_DESC);
		newTaskData.addAttribute(BugzillaReportElement.SHORT_DESC.getKeyString(), a);

		a = BugzillaClient.makeNewAttribute(BugzillaReportElement.VERSION);
		optionValues = repositoryConfiguration.getVersions(newTaskData.getProduct());
		Collections.sort(optionValues);
		for (String option : optionValues) {
			a.addOption(option, option);
		}
		if (optionValues != null && optionValues.size() > 0) {
			a.setValue(optionValues.get(optionValues.size() - 1));
		}

		newTaskData.addAttribute(BugzillaReportElement.VERSION.getKeyString(), a);
		// attributes.put(a.getName(), a);

		a = BugzillaClient.makeNewAttribute(BugzillaReportElement.COMPONENT);
		optionValues = repositoryConfiguration.getComponents(newTaskData.getProduct());
		Collections.sort(optionValues);
		for (String option : optionValues) {
			a.addOption(option, option);
		}
		if (optionValues != null && optionValues.size() > 0) {
			a.setValue(optionValues.get(0));
		}

		newTaskData.addAttribute(BugzillaReportElement.COMPONENT.getKeyString(), a);

		a = BugzillaClient.makeNewAttribute(BugzillaReportElement.REP_PLATFORM);
		optionValues = repositoryConfiguration.getPlatforms();
		Collections.sort(optionValues);
		for (String option : optionValues) {
			a.addOption(option, option);
		}
		if (optionValues != null && optionValues.size() > 0) {
			a.setValue(optionValues.get(0));
		}

		newTaskData.addAttribute(BugzillaReportElement.REP_PLATFORM.getKeyString(), a);
		// attributes.put(a.getName(), a);

		a = BugzillaClient.makeNewAttribute(BugzillaReportElement.OP_SYS);
		optionValues = repositoryConfiguration.getOSs();
		for (String option : optionValues) {
			a.addOption(option, option);
		}
		if (optionValues != null && optionValues.size() > 0) {
			a.setValue(optionValues.get(optionValues.size() - 1));
		}

		newTaskData.addAttribute(BugzillaReportElement.OP_SYS.getKeyString(), a);
		// attributes.put(a.getName(), a);

		a = BugzillaClient.makeNewAttribute(BugzillaReportElement.PRIORITY);
		optionValues = repositoryConfiguration.getPriorities();
		for (String option : optionValues) {
			a.addOption(option, option);
		}
		a.setValue(optionValues.get((optionValues.size() / 2)));

		newTaskData.addAttribute(BugzillaReportElement.PRIORITY.getKeyString(), a);
		// attributes.put(a.getName(), a);

		a = BugzillaClient.makeNewAttribute(BugzillaReportElement.BUG_SEVERITY);
		optionValues = repositoryConfiguration.getSeverities();
		for (String option : optionValues) {
			a.addOption(option, option);
		}
		a.setValue(optionValues.get((optionValues.size() / 2)));

		newTaskData.addAttribute(BugzillaReportElement.BUG_SEVERITY.getKeyString(), a);
		// attributes.put(a.getName(), a);

		// a = new
		// RepositoryTaskAttribute(BugzillaReportElement.TARGET_MILESTONE);
		// optionValues =
		// BugzillaCorePlugin.getDefault().getgetProductConfiguration(serverUrl).getTargetMilestones(
		// newReport.getProduct());
		// for (String option : optionValues) {
		// a.addOptionValue(option, option);
		// }
		// if(optionValues.size() > 0) {
		// // new bug posts will fail if target_milestone element is
		// included
		// // and there are no milestones on the server
		// newReport.addAttribute(BugzillaReportElement.TARGET_MILESTONE, a);
		// }

		a = BugzillaClient.makeNewAttribute(BugzillaReportElement.ASSIGNED_TO);
		a.setValue("");
		a.setReadOnly(false);

		newTaskData.addAttribute(BugzillaReportElement.ASSIGNED_TO.getKeyString(), a);
		// attributes.put(a.getName(), a);

		a = BugzillaClient.makeNewAttribute(BugzillaReportElement.BUG_FILE_LOC);
		a.setValue("http://");
		a.setHidden(false);

		newTaskData.addAttribute(BugzillaReportElement.BUG_FILE_LOC.getKeyString(), a);
		// attributes.put(a.getName(), a);

		// newReport.attributes = attributes;
	}

}

Back to the top