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

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaLanguageSettings.java (+2 lines)
Lines 38-43 Link Here
38
38
39
	public static final String COMMAND_CHANGES_SUBMITTED = "changes_submitted";
39
	public static final String COMMAND_CHANGES_SUBMITTED = "changes_submitted";
40
40
41
	public static final String COMMAND_ERROR_CONFIRM_MATCH = "error_confirm_match";
42
41
	private Map<String, List<String>> languageAttributes = new LinkedHashMap<String, List<String>>();
43
	private Map<String, List<String>> languageAttributes = new LinkedHashMap<String, List<String>>();
42
44
43
	public BugzillaLanguageSettings(String languageName) {
45
	public BugzillaLanguageSettings(String languageName) {
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaTaskDataHandler.java (+28 lines)
Lines 22-27 Link Here
22
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_RESOLUTION_3_0;
22
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants.BUGZILLA_RESOLUTION_3_0;
23
import org.eclipse.mylyn.monitor.core.StatusHandler;
23
import org.eclipse.mylyn.monitor.core.StatusHandler;
24
import org.eclipse.mylyn.tasks.core.AbstractAttributeFactory;
24
import org.eclipse.mylyn.tasks.core.AbstractAttributeFactory;
25
import org.eclipse.mylyn.tasks.core.AbstractPostTaskDataResult;
25
import org.eclipse.mylyn.tasks.core.AbstractTask;
26
import org.eclipse.mylyn.tasks.core.AbstractTask;
26
import org.eclipse.mylyn.tasks.core.AbstractTaskDataHandler;
27
import org.eclipse.mylyn.tasks.core.AbstractTaskDataHandler;
27
import org.eclipse.mylyn.tasks.core.RepositoryOperation;
28
import org.eclipse.mylyn.tasks.core.RepositoryOperation;
Lines 359-362 Link Here
359
		return true;
360
		return true;
360
	}
361
	}
361
362
363
	@Override
364
	public boolean usePostTaskDataNewAPI() {
365
		return true;
366
	}
367
	
368
	public void postTaskData(TaskRepository repository, RepositoryTaskData taskData, IProgressMonitor monitor, AbstractPostTaskDataResult abstractPostTaskDataResult)
369
	throws CoreException {
370
try {
371
	BugzillaClient client = connector.getClientManager().getClient(repository);
372
	try {
373
		client.postTaskData(taskData, abstractPostTaskDataResult);
374
	} catch (CoreException e) {
375
		// TODO: Move retry handling into client
376
		if (e.getStatus().getCode() == RepositoryStatus.ERROR_REPOSITORY_LOGIN) {
377
			client.postTaskData(taskData, abstractPostTaskDataResult);
378
		} else {
379
			throw e;
380
		}
381
382
	}
383
384
} catch (IOException e) {
385
	throw new CoreException(new BugzillaStatus(IStatus.ERROR, BugzillaCorePlugin.PLUGIN_ID,
386
			RepositoryStatus.ERROR_IO, repository.getUrl(), e));
387
}
388
}
389
362
}
390
}
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaRepositoryConnector.java (+1 lines)
Lines 90-95 Link Here
90
		enSetting.addLanguageAttribute("bad_login", "error");
90
		enSetting.addLanguageAttribute("bad_login", "error");
91
		enSetting.addLanguageAttribute("processed", "processed");
91
		enSetting.addLanguageAttribute("processed", "processed");
92
		enSetting.addLanguageAttribute("changes_submitted", "Changes submitted");
92
		enSetting.addLanguageAttribute("changes_submitted", "Changes submitted");
93
		enSetting.addLanguageAttribute("error_confirm_match", "confirm match");
93
		languages.add(enSetting);
94
		languages.add(enSetting);
94
	}
95
	}
95
96
(-)src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java (+333 lines)
Lines 42-52 Link Here
42
import org.apache.commons.httpclient.methods.multipart.PartBase;
42
import org.apache.commons.httpclient.methods.multipart.PartBase;
43
import org.apache.commons.httpclient.methods.multipart.StringPart;
43
import org.apache.commons.httpclient.methods.multipart.StringPart;
44
import org.apache.commons.httpclient.params.HttpMethodParams;
44
import org.apache.commons.httpclient.params.HttpMethodParams;
45
import org.eclipse.core.runtime.Assert;
45
import org.eclipse.core.runtime.CoreException;
46
import org.eclipse.core.runtime.CoreException;
46
import org.eclipse.core.runtime.IStatus;
47
import org.eclipse.core.runtime.IStatus;
47
import org.eclipse.core.runtime.Status;
48
import org.eclipse.core.runtime.Status;
48
import org.eclipse.mylyn.internal.bugzilla.core.history.BugzillaTaskHistoryParser;
49
import org.eclipse.mylyn.internal.bugzilla.core.history.BugzillaTaskHistoryParser;
49
import org.eclipse.mylyn.internal.bugzilla.core.history.TaskHistory;
50
import org.eclipse.mylyn.internal.bugzilla.core.history.TaskHistory;
51
import org.eclipse.mylyn.tasks.core.AbstractPostTaskDataResult;
50
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
52
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
51
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
53
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
52
import org.eclipse.mylyn.tasks.core.ITaskCollector;
54
import org.eclipse.mylyn.tasks.core.ITaskCollector;
Lines 1341-1344 Link Here
1341
						+ " failed. Please verify connection and authentication information."));
1343
						+ " failed. Please verify connection and authentication information."));
1342
	}
1344
	}
1343
1345
1346
	public void postTaskData(RepositoryTaskData taskData, AbstractPostTaskDataResult abstractPostTaskDataResult) throws IOException, CoreException {
1347
		Assert.isNotNull(abstractPostTaskDataResult);
1348
		NameValuePair[] formData = null;
1349
		String prefix = null;
1350
		String prefix2 = null;
1351
		String postfix = null;
1352
		String postfix2 = null;
1353
1354
		if (taskData == null) {
1355
			return;
1356
		} else if (taskData.isNew()) {
1357
			formData = getPairsForNew(taskData);
1358
			prefix = IBugzillaConstants.FORM_PREFIX_BUG_218;
1359
			prefix2 = IBugzillaConstants.FORM_PREFIX_BUG_220;
1360
			postfix = IBugzillaConstants.FORM_POSTFIX_216;
1361
			postfix2 = IBugzillaConstants.FORM_POSTFIX_218;
1362
		} else {
1363
			formData = getPairsForExisting(taskData);
1364
		}
1365
1366
		GzipPostMethod method = null;
1367
		try {
1368
			if (taskData.isNew()) {
1369
				method = postFormData(POST_BUG_CGI, formData);
1370
			} else {
1371
				method = postFormData(PROCESS_BUG_CGI, formData);
1372
			}
1373
1374
			if (method == null) {
1375
				throw new IOException("Could not post form, client returned null method.");
1376
			}
1377
			BufferedReader in = new BufferedReader(new InputStreamReader(method.getResponseBodyAsUnzippedStream(),
1378
					method.getRequestCharSet()));
1379
			in.mark(40960);
1380
			HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(in, null);
1381
1382
			boolean existingBugPosted = false;
1383
			boolean isTitle = false;
1384
			String title = "";
1385
			boolean isBodyDT = false;
1386
			boolean isBodyCode = false;
1387
			String divIDName = "";
1388
			String dtName = "";
1389
			String codeName = "";
1390
			String bugzillaBody = "";
1391
1392
			for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) {
1393
1394
				if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.TITLE
1395
						&& !((HtmlTag) (token.getValue())).isEndTag()) {
1396
					isTitle = true;
1397
					continue;
1398
				}
1399
1400
				if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.DIV) {
1401
					divIDName = ((HtmlTag) (token.getValue())).getAttribute("id");
1402
				}
1403
1404
				if (divIDName != null && divIDName.equals("bugzilla-body")) {
1405
					bugzillaBody += token.toString();
1406
					if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.DT
1407
							&& ((HtmlTag) (token.getValue())).isEndTag()) {
1408
						isBodyDT = false;
1409
						continue;
1410
					}
1411
					if (token.getType() == Token.TAG
1412
							&& ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.CODE
1413
							&& ((HtmlTag) (token.getValue())).isEndTag()) {
1414
						isBodyCode = false;
1415
						abstractPostTaskDataResult.addResponseData(dtName, codeName);
1416
						continue;
1417
					}
1418
					if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.DT) {
1419
						isBodyDT = true;
1420
						dtName = "";
1421
						codeName = "";
1422
					}
1423
					if (token.getType() == Token.TAG
1424
							&& ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.CODE) {
1425
						isBodyCode = true;
1426
						codeName = "";
1427
					}
1428
1429
					if (token.getType() != Token.TAG) {
1430
						if (isBodyDT)
1431
							dtName += ((StringBuffer) token.getValue()).toString().toLowerCase(Locale.ENGLISH) + " ";
1432
						if (isBodyCode)
1433
							codeName += ((StringBuffer) token.getValue()).toString().toLowerCase(Locale.ENGLISH) + " ";
1434
						continue;
1435
					}
1436
				}
1437
1438
				if (isTitle) {
1439
					// get all of the data in the title tag
1440
					if (token.getType() != Token.TAG) {
1441
						title += ((StringBuffer) token.getValue()).toString().toLowerCase(Locale.ENGLISH) + " ";
1442
						continue;
1443
					} else if (token.getType() == Token.TAG
1444
							&& ((HtmlTag) token.getValue()).getTagType() == HtmlTag.Type.TITLE
1445
							&& ((HtmlTag) token.getValue()).isEndTag()) {
1446
1447
						boolean found = false;
1448
						for (Iterator<String> iterator = bugzillaLanguageSettings.getResponseForCommand(
1449
								BugzillaLanguageSettings.COMMAND_PROCESSED).iterator(); iterator.hasNext() && !found;) {
1450
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
1451
							found = found || title.indexOf(value) != -1;
1452
						}
1453
						if (!taskData.isNew() && found) {
1454
							existingBugPosted = true;
1455
						} else if (taskData.isNew() && prefix != null && prefix2 != null && postfix != null
1456
								&& postfix2 != null) {
1457
							int startIndex = -1;
1458
							int startIndexPrefix = title.toLowerCase(Locale.ENGLISH).indexOf(
1459
									prefix.toLowerCase(Locale.ENGLISH));
1460
							int startIndexPrefix2 = title.toLowerCase(Locale.ENGLISH).indexOf(
1461
									prefix2.toLowerCase(Locale.ENGLISH));
1462
1463
							if (startIndexPrefix != -1 || startIndexPrefix2 != -1) {
1464
								if (startIndexPrefix != -1) {
1465
									startIndex = startIndexPrefix + prefix.length();
1466
								} else {
1467
									startIndex = startIndexPrefix2 + prefix2.length();
1468
								}
1469
								int stopIndex = title.toLowerCase(Locale.ENGLISH).indexOf(
1470
										postfix.toLowerCase(Locale.ENGLISH), startIndex);
1471
								if (stopIndex == -1)
1472
									stopIndex = title.toLowerCase(Locale.ENGLISH).indexOf(
1473
											postfix2.toLowerCase(Locale.ENGLISH), startIndex);
1474
								if (stopIndex > -1) {
1475
									abstractPostTaskDataResult.setNewTaskID((title.substring(startIndex, stopIndex)).trim());
1476
								}
1477
							}
1478
						}
1479
						isTitle = false;
1480
					}
1481
				}
1482
			}
1483
1484
			if ((!taskData.isNew() && existingBugPosted != true) || (taskData.isNew() && abstractPostTaskDataResult.getNewTaskID() == null)) {
1485
				try {
1486
					in.reset();
1487
				} catch (IOException e) {
1488
					// ignore
1489
				}
1490
				parseHtmlError(in, abstractPostTaskDataResult);
1491
			}
1492
1493
			return;
1494
		} catch (ParseException e) {
1495
			authenticated = false;
1496
			throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
1497
					RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + "."));
1498
		} finally {
1499
			if (method != null) {
1500
				method.releaseConnection();
1501
			}
1502
		}
1503
1504
	}
1505
1506
	/**
1507
	 * Utility method for determining what potential error has occurred from a bugzilla html reponse page
1508
	 */
1509
	public void parseHtmlError(BufferedReader in, AbstractPostTaskDataResult abstractPostTaskDataResult) throws IOException, CoreException {
1510
		Assert.isNotNull(abstractPostTaskDataResult);
1511
		HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(in, null);
1512
		boolean isTitle = false;
1513
		String title = "";
1514
		String body = "";
1515
1516
		try {
1517
			for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) {
1518
				body += token.toString();
1519
				if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.TITLE
1520
						&& !((HtmlTag) (token.getValue())).isEndTag()) {
1521
					isTitle = true;
1522
					continue;
1523
				}
1524
1525
				if (isTitle) {
1526
					// get all of the data in the title tag
1527
					if (token.getType() != Token.TAG) {
1528
						title += ((StringBuffer) token.getValue()).toString().toLowerCase(Locale.ENGLISH) + " ";
1529
						continue;
1530
					} else if (token.getType() == Token.TAG
1531
							&& ((HtmlTag) token.getValue()).getTagType() == HtmlTag.Type.TITLE
1532
							&& ((HtmlTag) token.getValue()).isEndTag()) {
1533
1534
						boolean found = false;
1535
						for (Iterator<String> iterator = bugzillaLanguageSettings.getResponseForCommand(
1536
								BugzillaLanguageSettings.COMMAND_ERROR_LOGIN).iterator(); iterator.hasNext() && !found;) {
1537
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
1538
							found = found || title.indexOf(value) != -1;
1539
						}
1540
						if (found) {
1541
							authenticated = false;
1542
							abstractPostTaskDataResult.setErrorStatus("ERROR_REPOSITORY_LOGIN");
1543
							throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
1544
									RepositoryStatus.ERROR_REPOSITORY_LOGIN, repositoryUrl.toString(), title));
1545
						}
1546
						found = false;
1547
						for (Iterator<String> iterator = bugzillaLanguageSettings.getResponseForCommand(
1548
								BugzillaLanguageSettings.COMMAND_ERROR_COLLISION).iterator(); iterator.hasNext()
1549
								&& !found;) {
1550
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
1551
							found = found || title.indexOf(value) != -1;
1552
						}
1553
						if (found) {
1554
							abstractPostTaskDataResult.setErrorStatus("REPOSITORY_COLLISION");
1555
							throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
1556
									RepositoryStatus.REPOSITORY_COLLISION, repositoryUrl.toString()));
1557
						}
1558
						found = false;
1559
						for (Iterator<String> iterator = bugzillaLanguageSettings.getResponseForCommand(
1560
								BugzillaLanguageSettings.COMMAND_ERROR_COMMENT_REQUIRED).iterator(); iterator.hasNext()
1561
								&& !found;) {
1562
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
1563
							found = found || title.indexOf(value) != -1;
1564
						}
1565
						if (found) {
1566
							abstractPostTaskDataResult.setErrorStatus("REPOSITORY_COMMENT_REQUIRED");
1567
							throw new CoreException(new BugzillaStatus(Status.INFO, BugzillaCorePlugin.PLUGIN_ID,
1568
									RepositoryStatus.REPOSITORY_COMMENT_REQUIRED));
1569
						}
1570
						found = false;
1571
						for (Iterator<String> iterator = bugzillaLanguageSettings.getResponseForCommand(
1572
								BugzillaLanguageSettings.COMMAND_ERROR_LOGGED_OUT).iterator(); iterator.hasNext()
1573
								&& !found;) {
1574
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
1575
							found = found || title.indexOf(value) != -1;
1576
						}
1577
						if (found) {
1578
							authenticated = false;
1579
							// throw new
1580
							// BugzillaException(IBugzillaConstants.LOGGED_OUT);
1581
							abstractPostTaskDataResult.setErrorStatus("REPOSITORY_LOGGED_OUT");
1582
							throw new CoreException(new BugzillaStatus(Status.INFO, BugzillaCorePlugin.PLUGIN_ID,
1583
									RepositoryStatus.REPOSITORY_LOGGED_OUT,
1584
									"You have been logged out. Please retry operation."));
1585
						}
1586
						found = false;
1587
						for (Iterator<String> iterator = bugzillaLanguageSettings.getResponseForCommand(
1588
								BugzillaLanguageSettings.COMMAND_ERROR_CONFIRM_MATCH).iterator(); iterator.hasNext()
1589
								&& !found;) {
1590
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
1591
							found = found || title.indexOf(value) != -1;
1592
						}
1593
						if (found) {
1594
							abstractPostTaskDataResult.setErrorStatus("COMMAND_ERROR_CONFIRM_MATCH");
1595
								try {
1596
									in.reset();
1597
								} catch (IOException e) {
1598
									// ignore
1599
								}
1600
								parseResultConfirmMatch(in, abstractPostTaskDataResult);
1601
						}
1602
						found = false;
1603
						for (Iterator<String> iterator = bugzillaLanguageSettings.getResponseForCommand(
1604
								BugzillaLanguageSettings.COMMAND_CHANGES_SUBMITTED).iterator(); iterator.hasNext()
1605
								&& !found;) {
1606
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
1607
							found = found || title.indexOf(value) != -1;
1608
						}
1609
						if (found) {
1610
							return;
1611
						}
1612
						isTitle = false;
1613
					}
1614
				}
1615
			}
1616
1617
			abstractPostTaskDataResult.setErrorStatus("A repository error has occurred.");
1618
			throw new CoreException(RepositoryStatus.createHtmlStatus(repositoryUrl.toString(), IStatus.INFO,
1619
					BugzillaCorePlugin.PLUGIN_ID, RepositoryStatus.ERROR_REPOSITORY,
1620
					"A repository error has occurred.", body));
1621
1622
		} catch (ParseException e) {
1623
			authenticated = false;
1624
			abstractPostTaskDataResult.setErrorStatus("ERROR_INTERNAL: Unable to parse response from " + repositoryUrl.toString() + ".");
1625
			throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
1626
					RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + "."));
1627
		} finally {
1628
			in.close();
1629
		}
1630
	}
1631
1632
	public void parseResultConfirmMatch(BufferedReader in, AbstractPostTaskDataResult postResult) throws IOException,
1633
			CoreException {
1634
		HtmlStreamTokenizer tokenizer = new HtmlStreamTokenizer(in, null);
1635
1636
		boolean isSelect = false;
1637
		String select = "";
1638
		String body = "";
1639
		String name = "";
1640
		String value = "";
1641
		try {
1642
			for (Token token = tokenizer.nextToken(); token.getType() != Token.EOF; token = tokenizer.nextToken()) {
1643
				body += token.toString();
1644
				if (token.getType() == Token.TAG && ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.SELECT
1645
						&& !((HtmlTag) (token.getValue())).isEndTag()) {
1646
					isSelect = true;
1647
					select += token.toString().toLowerCase(Locale.ENGLISH);
1648
					name = ((HtmlTag) (token.getValue())).getAttribute("id");
1649
					continue;
1650
				}
1651
1652
				if (isSelect) {
1653
					if (token.getType() == Token.TAG
1654
							&& ((HtmlTag) (token.getValue())).getTagType() == HtmlTag.Type.OPTION
1655
							&& !((HtmlTag) (token.getValue())).isEndTag()) {
1656
						value = ((HtmlTag) (token.getValue())).getAttribute("value");
1657
						postResult.addResponseData(name, value);
1658
					}
1659
					if (token.getType() == Token.TAG
1660
							&& ((HtmlTag) token.getValue()).getTagType() == HtmlTag.Type.SELECT
1661
							&& ((HtmlTag) token.getValue()).isEndTag()) {
1662
						isSelect = false;
1663
					}
1664
				}
1665
			}
1666
			postResult.setErrorStatus("ERROR_CONFIRM_MATCH");
1667
			throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
1668
					RepositoryStatus.ERROR_CONFIRM_MATCH, repositoryUrl.toString(), "confirm match"));
1669
		} catch (ParseException e) {
1670
			throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
1671
					RepositoryStatus.ERROR_INTERNAL, "Unable to parse response from " + repositoryUrl.toString() + "."));
1672
		} finally {
1673
			in.close();
1674
		}
1675
	}
1676
1344
}
1677
}
(-)src/org/eclipse/mylyn/tasks/core/AbstractTaskDataHandler.java (+20 lines)
Lines 52-57 Link Here
52
			throws CoreException;
52
			throws CoreException;
53
53
54
	/**
54
	/**
55
	 * API-3.0 remove when API change is done
56
	 * 
57
	 * @since 2.3
58
	 */
59
	public boolean usePostTaskDataNewAPI() {
60
		return false;
61
	}
62
63
	/**
64
	 * API-3.0 make abstract if we can switch from postTaskData
65
	 * 
66
	 * AbstractRepositoryTaskEditor submitToRepository use old or new style
67
	 * 
68
	 * @since 2.3
69
	 */
70
	public void postTaskData(TaskRepository repository, RepositoryTaskData taskData, IProgressMonitor monitor,
71
			AbstractPostTaskDataResult abstractPostTaskDataResult) throws CoreException {
72
	}
73
74
	/**
55
	 * @param repositoryUrl
75
	 * @param repositoryUrl
56
	 * @param repositoryKind
76
	 * @param repositoryKind
57
	 * @param taskKind
77
	 * @param taskKind
(-)src/org/eclipse/mylyn/tasks/core/RepositoryStatus.java (+2 lines)
Lines 46-51 Link Here
46
46
47
	public final static int ERROR_INTERNAL = 7;
47
	public final static int ERROR_INTERNAL = 7;
48
48
49
	public final static int ERROR_CONFIRM_MATCH = 13;
50
	
49
	private String htmlMessage;
51
	private String htmlMessage;
50
52
51
	protected String repositoryUrl;
53
	protected String repositoryUrl;
(-)src/org/eclipse/mylyn/tasks/core/AbstractPostTaskDataResult.java (+63 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.tasks.core;
10
11
import java.util.LinkedHashMap;
12
import java.util.LinkedList;
13
import java.util.List;
14
import java.util.Map;
15
16
public class AbstractPostTaskDataResult {
17
18
	private String newTaskID;
19
20
	private String errorStatus;
21
22
	private Map<String, List<String>> responseData = new LinkedHashMap<String, List<String>>();
23
24
	public String getNewTaskID() {
25
		return newTaskID;
26
	}
27
28
	public void setNewTaskID(String newTaskID) {
29
		this.newTaskID = newTaskID;
30
	}
31
32
	public String getErrorStatus() {
33
		return errorStatus;
34
	}
35
36
	public void setErrorStatus(String errorStatus) {
37
		this.errorStatus = errorStatus;
38
	}
39
40
	public Map<String, List<String>> getResponseData() {
41
		return responseData;
42
	}
43
44
	public void setResponseData(Map<String, List<String>> responseData) {
45
		this.responseData = responseData;
46
	}
47
48
	public void addResponseData(String name, String response) {
49
		List<String> responseList = responseData.get(name);
50
		if (responseList == null) {
51
			responseList = new LinkedList<String>();
52
			responseData.put(name.toLowerCase(), responseList);
53
		}
54
		responseList.add(response);
55
	}
56
57
	public void reset() {
58
		newTaskID = null;
59
		errorStatus = null;
60
		responseData.clear();
61
	}
62
63
}
(-)src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java (-1 / +14 lines)
Lines 94-99 Link Here
94
import org.eclipse.mylyn.internal.tasks.ui.views.ResetRepositoryConfigurationAction;
94
import org.eclipse.mylyn.internal.tasks.ui.views.ResetRepositoryConfigurationAction;
95
import org.eclipse.mylyn.monitor.core.DateUtil;
95
import org.eclipse.mylyn.monitor.core.DateUtil;
96
import org.eclipse.mylyn.monitor.core.StatusHandler;
96
import org.eclipse.mylyn.monitor.core.StatusHandler;
97
import org.eclipse.mylyn.tasks.core.AbstractPostTaskDataResult;
97
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
98
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
98
import org.eclipse.mylyn.tasks.core.AbstractTask;
99
import org.eclipse.mylyn.tasks.core.AbstractTask;
99
import org.eclipse.mylyn.tasks.core.AbstractTaskCategory;
100
import org.eclipse.mylyn.tasks.core.AbstractTaskCategory;
Lines 318-323 Link Here
318
319
319
	private TaskComment selectedComment = null;
320
	private TaskComment selectedComment = null;
320
321
322
	private AbstractPostTaskDataResult taskDataResult = new AbstractPostTaskDataResult();
323
	
321
	/**
324
	/**
322
	 * @author Raphael Ackermann (bug 195514)
325
	 * @author Raphael Ackermann (bug 195514)
323
	 */
326
	 */
Lines 3315-3324 Link Here
3315
			@Override
3318
			@Override
3316
			protected IStatus run(IProgressMonitor monitor) {
3319
			protected IStatus run(IProgressMonitor monitor) {
3317
				AbstractTask modifiedTask = null;
3320
				AbstractTask modifiedTask = null;
3321
				String taskId;
3318
				try {
3322
				try {
3319
					monitor.beginTask("Submitting task", 3);
3323
					monitor.beginTask("Submitting task", 3);
3320
					String taskId = connector.getTaskDataHandler().postTaskData(repository, taskData,
3324
					if (connector.getTaskDataHandler().usePostTaskDataNewAPI()) {
3325
						taskDataResult.reset();
3326
						connector.getTaskDataHandler().postTaskData(repository, taskData,
3327
								new SubProgressMonitor(monitor, 1), taskDataResult);
3328
						taskId = taskDataResult.getNewTaskID();
3329
					} else {
3330
						taskId = connector.getTaskDataHandler().postTaskData(repository, taskData,
3321
							new SubProgressMonitor(monitor, 1));
3331
							new SubProgressMonitor(monitor, 1));
3332
					}
3322
					final boolean isNew = taskData.isNew();
3333
					final boolean isNew = taskData.isNew();
3323
					if (isNew) {
3334
					if (isNew) {
3324
						if (taskId != null) {
3335
						if (taskId != null) {
Lines 3536-3541 Link Here
3536
							submitToRepository();
3547
							submitToRepository();
3537
							return;
3548
							return;
3538
						}
3549
						}
3550
					} else if (exception.getStatus().getCode() == RepositoryStatus.ERROR_CONFIRM_MATCH) {
3551
						StatusHandler.displayStatus("Confirm Match", exception.getStatus());
3539
					} else {
3552
					} else {
3540
						StatusHandler.displayStatus("Submit failed", exception.getStatus());
3553
						StatusHandler.displayStatus("Submit failed", exception.getStatus());
3541
					}
3554
					}
(-)plugin.xml (+1 lines)
Lines 57-62 Link Here
57
            <languageAttribute command="bad_login" 					response="error"/> 
57
            <languageAttribute command="bad_login" 					response="error"/> 
58
            <languageAttribute command="processed" 					response="processed"/> 
58
            <languageAttribute command="processed" 					response="processed"/> 
59
            <languageAttribute command="changes_submitted" 			response="Changes submitted"/> 
59
            <languageAttribute command="changes_submitted" 			response="Changes submitted"/> 
60
            <languageAttribute command="error_confirm_match"		response="Übereinstimmungen bestätigen"/> 
60
      </language> 
61
      </language> 
61
   </extension>    
62
   </extension>    
62
  
63
  

Return to bug 168204