Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2007-02-17 13:24:34 -0500
committerspingel2007-02-17 13:24:34 -0500
commit3645f6191dce4abda8f696c4ebd4b419105cc175 (patch)
tree3c3eda02c4a6c8e5e4d6b38d5194d1ee23df4085
parent63a62c7c03547258ec71bfb8d0d5ac72679476dd (diff)
downloadorg.eclipse.mylyn.tasks-3645f6191dce4abda8f696c4ebd4b419105cc175.tar.gz
org.eclipse.mylyn.tasks-3645f6191dce4abda8f696c4ebd4b419105cc175.tar.xz
org.eclipse.mylyn.tasks-3645f6191dce4abda8f696c4ebd4b419105cc175.zip
NEW - bug 174552: Trac does not check if task id is numeric
https://bugs.eclipse.org/bugs/show_bug.cgi?id=174552
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java17
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java3
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java2
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracTaskDataHandlerTest.java (renamed from org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracOfflineTaskHandlerTest.java)14
4 files changed, 24 insertions, 12 deletions
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
index b445f4f11..e27a392e2 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
@@ -208,13 +208,7 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
@Override
public AbstractRepositoryTask createTaskFromExistingKey(TaskRepository repository, String taskId) throws CoreException {
- int taskIdInt = -1;
- try {
- taskIdInt = Integer.parseInt(taskId);
- } catch (NumberFormatException e) {
- throw new CoreException(new Status(IStatus.ERROR, TracCorePlugin.PLUGIN_ID, IStatus.OK,
- "Invalid ticket id: " + taskId, e));
- }
+ int taskIdInt = getTicketId(taskId);
// String handle = AbstractRepositoryTask.getHandle(repository.getUrl(), bugId);
TracTask task;
@@ -244,6 +238,15 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
return task;
}
+ public static int getTicketId(String taskId) throws CoreException {
+ try {
+ return Integer.parseInt(taskId);
+ } catch (NumberFormatException e) {
+ throw new CoreException(new Status(IStatus.ERROR, TracCorePlugin.PLUGIN_ID, IStatus.OK,
+ "Invalid ticket id: " + taskId, e));
+ }
+ }
+
public synchronized TracClientManager getClientManager() {
if (clientManager == null) {
File cacheFile = null;
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
index c74b624e4..fef5c4954 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
@@ -51,8 +51,7 @@ public class TracTaskDataHandler implements ITaskDataHandler {
}
public RepositoryTaskData getTaskData(TaskRepository repository, String taskId) throws CoreException {
- int id = Integer.parseInt(taskId);
- return downloadTaskData(repository, id);
+ return downloadTaskData(repository, TracRepositoryConnector.getTicketId(taskId));
}
public RepositoryTaskData downloadTaskData(TaskRepository repository, int id) throws CoreException {
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java
index 567f288f7..740761ac6 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/AllTracTests.java
@@ -39,7 +39,7 @@ public class AllTracTests {
suite.addTestSuite(TracClientManagerTest.class);
suite.addTestSuite(TracAttachmentHandlerTest.class);
suite.addTestSuite(RepositorySearchQueryTest.class);
- suite.addTestSuite(TracOfflineTaskHandlerTest.class);
+ suite.addTestSuite(TracTaskDataHandlerTest.class);
suite.addTestSuite(TracTaskTest.class);
suite.addTestSuite(TracQueryHitTest.class);
suite.addTestSuite(TracRepositorySettingsPageTest.class);
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracOfflineTaskHandlerTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracTaskDataHandlerTest.java
index 157050b10..783d8f989 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracOfflineTaskHandlerTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracTaskDataHandlerTest.java
@@ -16,6 +16,7 @@ import java.util.Set;
import junit.framework.TestCase;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.mylar.context.tests.support.MylarTestUtils;
import org.eclipse.mylar.context.tests.support.MylarTestUtils.Credentials;
import org.eclipse.mylar.context.tests.support.MylarTestUtils.PrivilegeLevel;
@@ -36,7 +37,7 @@ import org.eclipse.mylar.trac.tests.support.XmlRpcServer.TestData;
/**
* @author Steffen Pingel
*/
-public class TracOfflineTaskHandlerTest extends TestCase {
+public class TracTaskDataHandlerTest extends TestCase {
private TracRepositoryConnector connector;
@@ -46,7 +47,7 @@ public class TracOfflineTaskHandlerTest extends TestCase {
private TestData data;
- public TracOfflineTaskHandlerTest() {
+ public TracTaskDataHandlerTest() {
}
@Override
@@ -128,5 +129,14 @@ public class TracOfflineTaskHandlerTest extends TestCase {
result = connector.getChangedSinceLastSync(repository, tasks);
assertEquals(tasks, result);
}
+
+ public void testNonNumericTaskId() {
+ try {
+ connector.getTaskDataHandler().getTaskData(repository, "abc");
+ fail("Expected CoreException");
+ } catch (CoreException e) {
+ }
+ }
+
}

Back to the top