|
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) |