Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2007-06-24 20:26:06 +0000
committermkersten2007-06-24 20:26:06 +0000
commitd7abab38b383edd86087f94335fe45c937df4791 (patch)
tree13a3cdd1341ce22aa8a6dfa1948e0b0940b047cf
parentb60fe6fa4175509093bba9be4cbeffb7b847b9f1 (diff)
downloadorg.eclipse.mylyn.tasks-d7abab38b383edd86087f94335fe45c937df4791.tar.gz
org.eclipse.mylyn.tasks-d7abab38b383edd86087f94335fe45c937df4791.tar.xz
org.eclipse.mylyn.tasks-d7abab38b383edd86087f94335fe45c937df4791.zip
REOPENED - bug 149624: [api] AbstractRepositoryTask repositoryUrl and task id should not be derived from handleIdentifier
https://bugs.eclipse.org/bugs/show_bug.cgi?id=149624
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryTaskHandleUtil.java14
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java20
2 files changed, 30 insertions, 4 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryTaskHandleUtil.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryTaskHandleUtil.java
index 7c4132627..119e8deb2 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryTaskHandleUtil.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/RepositoryTaskHandleUtil.java
@@ -19,13 +19,14 @@ public class RepositoryTaskHandleUtil {
public static final String HANDLE_DELIM = "-";
private static final String MISSING_REPOSITORY = "norepository";
-
+
public static String getHandle(String repositoryUrl, String taskId) {
+ if (!isValidTaskId(taskId)) {
+ throw new RuntimeException("invalid handle for task, can not contain: " + HANDLE_DELIM + ", was: " + taskId);
+ }
+
if (repositoryUrl == null) {
return MISSING_REPOSITORY + HANDLE_DELIM + taskId;
- } else if (taskId.contains(HANDLE_DELIM)) {
- throw new RuntimeException("invalid handle for task, can not contain: " + HANDLE_DELIM + ", was: "
- + taskId);
} else {
return repositoryUrl + HANDLE_DELIM + taskId;
}
@@ -49,4 +50,9 @@ public class RepositoryTaskHandleUtil {
return null;
}
+
+ public static boolean isValidTaskId(String taskId) {
+ return !taskId.contains(HANDLE_DELIM);
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java
index 50a649765..b8be7f83a 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/TaskList.java
@@ -467,6 +467,10 @@ public class TaskList {
* @since 2.0
*/
public AbstractTask getTask(String repositoryUrl, String taskId) {
+ if (!RepositoryTaskHandleUtil.isValidTaskId(taskId)) {
+ return null;
+ }
+
String handle = RepositoryTaskHandleUtil.getHandle(repositoryUrl, taskId);
AbstractTask task = getTask(handle);
if (task instanceof AbstractTask) {
@@ -494,6 +498,22 @@ public class TaskList {
return null;
}
+ /**
+ * Searches for a task whose key matches.
+ *
+ * @return first task with a key, null if no matching task is found
+ * @since 2.0
+ */
+ public AbstractTask getTaskByKey(String repositoryUrl, String taskKey) {
+ for (AbstractTask task : tasks.values()) {
+ String currentTaskKey = task.getTaskKey();
+ if (currentTaskKey != null && currentTaskKey.equals(taskKey) && task.getRepositoryUrl().equals(repositoryUrl)) {
+ return task;
+ }
+ }
+ return null;
+ }
+
public AbstractTaskCategory getContainerForHandle(String categoryHandle) {
for (AbstractTaskCategory cat : categories.values()) {
if (cat instanceof AbstractTaskCategory) {

Back to the top