|
Lines 62-68
Link Here
|
| 62 |
import org.eclipse.swt.widgets.Display; |
62 |
import org.eclipse.swt.widgets.Display; |
| 63 |
import org.eclipse.ui.PlatformUI; |
63 |
import org.eclipse.ui.PlatformUI; |
| 64 |
|
64 |
|
| 65 |
|
|
|
| 66 |
/** |
65 |
/** |
| 67 |
* @author Mik Kersten (some rewriting) |
66 |
* @author Mik Kersten (some rewriting) |
| 68 |
* @author Rob Elves (attachments) |
67 |
* @author Rob Elves (attachments) |
|
Lines 99-105
Link Here
|
| 99 |
|
98 |
|
| 100 |
public static final char PREF_DELIM_REPOSITORY = ':'; |
99 |
public static final char PREF_DELIM_REPOSITORY = ':'; |
| 101 |
|
100 |
|
| 102 |
public static final String POST_ARGS_SHOW_BUG = "/show_bug.cgi?id="; |
101 |
public static final String POST_ARGS_SHOW_BUG = "/show_bug.cgi?id=";//ctype=xml& |
| 103 |
|
102 |
|
| 104 |
public static final String POST_ARGS_ATTACHMENT_DOWNLOAD = "/attachment.cgi?id="; |
103 |
public static final String POST_ARGS_ATTACHMENT_DOWNLOAD = "/attachment.cgi?id="; |
| 105 |
|
104 |
|
|
Lines 142-152
Link Here
|
| 142 |
if (input != null) { |
141 |
if (input != null) { |
| 143 |
in = new BufferedReader(new InputStreamReader(input)); |
142 |
in = new BufferedReader(new InputStreamReader(input)); |
| 144 |
|
143 |
|
| 145 |
// get the actual bug fron the server and return it |
144 |
// BugReportFactory reportFactory = |
| 146 |
BugReport bug = BugParser.parseBug(in, id, repository.getUrl(), !repository.getVersion().equals( |
145 |
// BugReportFactory.getInstance(); |
| 147 |
BugzillaServerVersion.SERVER_216.toString()), repository.getUserName(), repository |
146 |
// BugReport bugReport = reportFactory.readReport(in, id, |
|
|
147 |
// repository, connection.getContentType()); |
| 148 |
// get the actual bug from the server and return it |
| 149 |
BugReport bugReport = BugParser.parseBug(in, id, repository.getUrl(), !repository.getVersion() |
| 150 |
.equals(BugzillaServerVersion.SERVER_216.toString()), repository.getUserName(), repository |
| 148 |
.getPassword(), connection.getContentType()); |
151 |
.getPassword(), connection.getContentType()); |
| 149 |
return bug; |
152 |
return bugReport; |
| 150 |
} |
153 |
} |
| 151 |
} |
154 |
} |
| 152 |
// TODO handle the error |
155 |
// TODO handle the error |
|
Lines 213-224
Link Here
|
| 213 |
|
216 |
|
| 214 |
return BugzillaPlugin.getDefault().getProductConfiguration(repository.getUrl()).getProducts(); |
217 |
return BugzillaPlugin.getDefault().getProductConfiguration(repository.getUrl()).getProducts(); |
| 215 |
|
218 |
|
| 216 |
// BugzillaQueryPageParser parser = new BugzillaQueryPageParser(repository, new NullProgressMonitor()); |
219 |
// BugzillaQueryPageParser parser = new |
| 217 |
// if (!parser.wasSuccessful()) { |
220 |
// BugzillaQueryPageParser(repository, new NullProgressMonitor()); |
| 218 |
// throw new RuntimeException("Couldn't get products"); |
221 |
// if (!parser.wasSuccessful()) { |
| 219 |
// } else { |
222 |
// throw new RuntimeException("Couldn't get products"); |
| 220 |
// return Arrays.asList(parser.getProductValues()); |
223 |
// } else { |
| 221 |
// } |
224 |
// return Arrays.asList(parser.getProductValues()); |
|
|
225 |
// } |
| 222 |
|
226 |
|
| 223 |
} |
227 |
} |
| 224 |
|
228 |
|
|
Lines 303-363
Link Here
|
| 303 |
|
307 |
|
| 304 |
HashMap<String, Attribute> attributes = new HashMap<String, Attribute>(); |
308 |
HashMap<String, Attribute> attributes = new HashMap<String, Attribute>(); |
| 305 |
|
309 |
|
| 306 |
// ATTRIBUTE: Severity |
|
|
| 307 |
Attribute a = new Attribute("Severity"); |
310 |
Attribute a = new Attribute("Severity"); |
| 308 |
a.setParameterName("bug_severity"); |
311 |
a.setParameterName("bug_severity"); |
| 309 |
// get optionValues from ProductConfiguration |
|
|
| 310 |
List<String> optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getSeverities(); |
312 |
List<String> optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getSeverities(); |
| 311 |
// add option values from ProductConfiguration to Attribute optionValues |
313 |
for (String option : optionValues) { |
| 312 |
for (String option: optionValues) { |
|
|
| 313 |
a.addOptionValue(option, option); |
314 |
a.addOptionValue(option, option); |
| 314 |
} |
315 |
} |
| 315 |
// add Attribute to model |
|
|
| 316 |
attributes.put("severites", a); |
316 |
attributes.put("severites", a); |
| 317 |
|
317 |
|
| 318 |
// ATTRIBUTE: OS |
|
|
| 319 |
a = new Attribute("OS"); |
318 |
a = new Attribute("OS"); |
| 320 |
a.setParameterName("op_sys"); |
319 |
a.setParameterName("op_sys"); |
| 321 |
optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getOSs(); |
320 |
optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getOSs(); |
| 322 |
for (String option: optionValues) { |
321 |
for (String option : optionValues) { |
| 323 |
a.addOptionValue(option, option); |
322 |
a.addOptionValue(option, option); |
| 324 |
} |
323 |
} |
| 325 |
attributes.put("OSs", a); |
324 |
attributes.put("OSs", a); |
| 326 |
|
325 |
|
| 327 |
// ATTRIBUTE: Platform |
|
|
| 328 |
a = new Attribute("Platform"); |
326 |
a = new Attribute("Platform"); |
| 329 |
a.setParameterName("rep_platform"); |
327 |
a.setParameterName("rep_platform"); |
| 330 |
optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPlatforms(); |
328 |
optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPlatforms(); |
| 331 |
for (String option: optionValues) { |
329 |
for (String option : optionValues) { |
| 332 |
a.addOptionValue(option, option); |
330 |
a.addOptionValue(option, option); |
| 333 |
} |
331 |
} |
| 334 |
attributes.put("platforms", a); |
332 |
attributes.put("platforms", a); |
| 335 |
|
333 |
|
| 336 |
// ATTRIBUTE: Version |
|
|
| 337 |
a = new Attribute("Version"); |
334 |
a = new Attribute("Version"); |
| 338 |
a.setParameterName("version"); |
335 |
a.setParameterName("version"); |
| 339 |
optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getVersions(model.getProduct()); |
336 |
optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getVersions(model.getProduct()); |
| 340 |
for (String option: optionValues) { |
337 |
for (String option : optionValues) { |
| 341 |
a.addOptionValue(option, option); |
338 |
a.addOptionValue(option, option); |
| 342 |
} |
339 |
} |
| 343 |
attributes.put("versions", a); |
340 |
attributes.put("versions", a); |
| 344 |
|
341 |
|
| 345 |
// ATTRIBUTE: Component |
342 |
|
| 346 |
a = new Attribute("Component"); |
343 |
a = new Attribute("Component"); |
| 347 |
a.setParameterName("component"); |
344 |
a.setParameterName("component"); |
| 348 |
optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getComponents(model.getProduct()); |
345 |
optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getComponents(model.getProduct()); |
| 349 |
for (String option: optionValues) { |
346 |
for (String option : optionValues) { |
| 350 |
a.addOptionValue(option, option); |
347 |
a.addOptionValue(option, option); |
| 351 |
} |
348 |
} |
| 352 |
attributes.put("components", a); |
349 |
attributes.put("components", a); |
| 353 |
|
350 |
|
| 354 |
// ATTRIBUTE: Priority |
351 |
|
| 355 |
a = new Attribute("Priority"); |
352 |
a = new Attribute("Priority"); |
| 356 |
a.setParameterName("bug_severity"); |
353 |
a.setParameterName("priority"); |
| 357 |
optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPriorities(); |
354 |
optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getPriorities(); |
| 358 |
for (String option: optionValues) { |
355 |
for (String option : optionValues) { |
| 359 |
a.addOptionValue(option, option); |
356 |
a.addOptionValue(option, option); |
| 360 |
} |
357 |
} |
|
|
358 |
attributes.put("priorities", a); |
| 359 |
|
| 360 |
|
| 361 |
a = new Attribute("Product"); |
| 362 |
a.setParameterName("product"); |
| 363 |
optionValues = BugzillaPlugin.getDefault().getProductConfiguration(serverUrl).getProducts(); |
| 364 |
for (String option : optionValues) { |
| 365 |
a.addOptionValue(option, option); |
| 366 |
} |
| 367 |
attributes.put("products", a); |
| 361 |
|
368 |
|
| 362 |
// set NBM Attributes (after all Attributes have been created, and added |
369 |
// set NBM Attributes (after all Attributes have been created, and added |
| 363 |
// to attributes map) |
370 |
// to attributes map) |
|
Lines 387-399
Link Here
|
| 387 |
} |
394 |
} |
| 388 |
|
395 |
|
| 389 |
static String queryOptionsToString(List<String> array) { |
396 |
static String queryOptionsToString(List<String> array) { |
| 390 |
|
397 |
|
| 391 |
StringBuffer buffer = new StringBuffer(); |
398 |
StringBuffer buffer = new StringBuffer(); |
| 392 |
for (String string : array) { |
399 |
for (String string : array) { |
| 393 |
buffer.append(string); |
400 |
buffer.append(string); |
| 394 |
buffer.append("!"); |
401 |
buffer.append("!"); |
| 395 |
} |
402 |
} |
| 396 |
|
403 |
|
| 397 |
return buffer.toString(); |
404 |
return buffer.toString(); |
| 398 |
} |
405 |
} |
| 399 |
|
406 |
|
|
Lines 437-448
Link Here
|
| 437 |
IOException { |
444 |
IOException { |
| 438 |
|
445 |
|
| 439 |
String repositoryUrl = repository.getUrl(); |
446 |
String repositoryUrl = repository.getUrl(); |
| 440 |
// BugzillaQueryPageParser parser = new BugzillaQueryPageParser(repository, monitor); |
447 |
// BugzillaQueryPageParser parser = new |
| 441 |
// if (!parser.wasSuccessful()) |
448 |
// BugzillaQueryPageParser(repository, monitor); |
| 442 |
// return; |
449 |
// if (!parser.wasSuccessful()) |
| 443 |
|
450 |
// return; |
| 444 |
RepositoryConfiguration config = ServerConfigurationFactory.getInstance().getConfiguration( |
451 |
|
| 445 |
repositoryUrl); |
452 |
RepositoryConfiguration config = ServerConfigurationFactory.getInstance().getConfiguration(repositoryUrl); |
| 446 |
|
453 |
|
| 447 |
// get the preferences store so that we can change the data in it |
454 |
// get the preferences store so that we can change the data in it |
| 448 |
IPreferenceStore prefs = BugzillaPlugin.getDefault().getPreferenceStore(); |
455 |
IPreferenceStore prefs = BugzillaPlugin.getDefault().getPreferenceStore(); |
|
Lines 479-485
Link Here
|
| 479 |
queryOptionsToString(config.getProducts())); |
486 |
queryOptionsToString(config.getProducts())); |
| 480 |
monitor.worked(1); |
487 |
monitor.worked(1); |
| 481 |
|
488 |
|
| 482 |
|
|
|
| 483 |
prefs.setValue(IBugzillaConstants.VALUES_COMPONENT + PREF_DELIM_REPOSITORY + repositoryUrl, |
489 |
prefs.setValue(IBugzillaConstants.VALUES_COMPONENT + PREF_DELIM_REPOSITORY + repositoryUrl, |
| 484 |
queryOptionsToString(config.getComponents())); |
490 |
queryOptionsToString(config.getComponents())); |
| 485 |
monitor.worked(1); |
491 |
monitor.worked(1); |
|
Lines 487-513
Link Here
|
| 487 |
prefs.setValue(IBugzillaConstants.VALUES_VERSION + PREF_DELIM_REPOSITORY + repositoryUrl, |
493 |
prefs.setValue(IBugzillaConstants.VALUES_VERSION + PREF_DELIM_REPOSITORY + repositoryUrl, |
| 488 |
queryOptionsToString(config.getVersions())); |
494 |
queryOptionsToString(config.getVersions())); |
| 489 |
monitor.worked(1); |
495 |
monitor.worked(1); |
| 490 |
|
496 |
|
| 491 |
prefs.setValue(IBugzillaConstants.VALUES_TARGET + PREF_DELIM_REPOSITORY + repositoryUrl, |
497 |
prefs.setValue(IBugzillaConstants.VALUES_TARGET + PREF_DELIM_REPOSITORY + repositoryUrl, |
| 492 |
queryOptionsToString(config.getTargetMilestones())); |
498 |
queryOptionsToString(config.getTargetMilestones())); |
| 493 |
monitor.worked(1); |
499 |
monitor.worked(1); |
| 494 |
|
500 |
|
| 495 |
for (String product: config.getProducts()) { |
501 |
for (String product : config.getProducts()) { |
| 496 |
prefs.setValue(IBugzillaConstants.VALUES_COMPONENT + PREF_DELIM_REPOSITORY + repositoryUrl+PREF_DELIM_REPOSITORY+product, |
502 |
prefs.setValue(IBugzillaConstants.VALUES_COMPONENT + PREF_DELIM_REPOSITORY + repositoryUrl |
| 497 |
queryOptionsToString(config.getComponents(product))); |
503 |
+ PREF_DELIM_REPOSITORY + product, queryOptionsToString(config.getComponents(product))); |
| 498 |
monitor.worked(1); |
504 |
monitor.worked(1); |
| 499 |
|
505 |
|
| 500 |
prefs.setValue(IBugzillaConstants.VALUES_VERSION + PREF_DELIM_REPOSITORY + repositoryUrl+PREF_DELIM_REPOSITORY+product, |
506 |
prefs.setValue(IBugzillaConstants.VALUES_VERSION + PREF_DELIM_REPOSITORY + repositoryUrl |
| 501 |
queryOptionsToString(config.getVersions(product))); |
507 |
+ PREF_DELIM_REPOSITORY + product, queryOptionsToString(config.getVersions(product))); |
| 502 |
monitor.worked(1); |
508 |
monitor.worked(1); |
| 503 |
|
509 |
|
| 504 |
prefs.setValue(IBugzillaConstants.VALUES_TARGET + PREF_DELIM_REPOSITORY + repositoryUrl+PREF_DELIM_REPOSITORY+product, |
510 |
prefs.setValue(IBugzillaConstants.VALUES_TARGET + PREF_DELIM_REPOSITORY + repositoryUrl |
| 505 |
queryOptionsToString(config.getTargetMilestones(product))); |
511 |
+ PREF_DELIM_REPOSITORY + product, queryOptionsToString(config.getTargetMilestones(product))); |
| 506 |
monitor.worked(1); |
512 |
monitor.worked(1); |
| 507 |
} |
513 |
} |
| 508 |
|
|
|
| 509 |
|
514 |
|
| 510 |
|
|
|
| 511 |
} |
515 |
} |
| 512 |
|
516 |
|
| 513 |
public static boolean downloadAttachment(TaskRepository repository, int id, File destinationFile, boolean overwrite) |
517 |
public static boolean downloadAttachment(TaskRepository repository, int id, File destinationFile, boolean overwrite) |
|
Lines 613-619
Link Here
|
| 613 |
} |
617 |
} |
| 614 |
|
618 |
|
| 615 |
postMethod.setRequestEntity(new MultipartRequestEntity(parts.toArray(new Part[1]), postMethod.getParams())); |
619 |
postMethod.setRequestEntity(new MultipartRequestEntity(parts.toArray(new Part[1]), postMethod.getParams())); |
| 616 |
|
620 |
|
| 617 |
client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); |
621 |
client.getHttpConnectionManager().getParams().setConnectionTimeout(5000); |
| 618 |
int status = client.executeMethod(postMethod); |
622 |
int status = client.executeMethod(postMethod); |
| 619 |
if (status == HttpStatus.SC_OK) { |
623 |
if (status == HttpStatus.SC_OK) { |