Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2006-12-22 11:09:18 -0500
committermkersten2006-12-22 11:09:18 -0500
commit215e5e8e5591f54449fb54e434036053e059509f (patch)
treea4583020e92705785657f85255358af23c80b1aa
parent1f75ebe0265ef343ab086c429b6f8395ad8bc404 (diff)
downloadorg.eclipse.mylyn.tasks-215e5e8e5591f54449fb54e434036053e059509f.tar.gz
org.eclipse.mylyn.tasks-215e5e8e5591f54449fb54e434036053e059509f.tar.xz
org.eclipse.mylyn.tasks-215e5e8e5591f54449fb54e434036053e059509f.zip
NEW - bug 168776: Changing server in task repository does not update servers in tasks and hits
https://bugs.eclipse.org/bugs/show_bug.cgi?id=168776
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/.AbstractRepositoryTask.java18
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryTask.java18
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java12
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryQueryTest.java6
4 files changed, 53 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/.AbstractRepositoryTask.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/.AbstractRepositoryTask.java
index 75e9a8ad8..8ed0d2d67 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/.AbstractRepositoryTask.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/.AbstractRepositoryTask.java
@@ -190,4 +190,22 @@ public abstract class AbstractRepositoryTask extends Task {
this.status = status;
}
+ /**
+ * Need to update URL since it is derived from handle identifier.
+ */
+ @Override
+ public void setHandleIdentifier(String newHandleIdentifier) {
+ String oldHandleIdentifier = getHandleIdentifier();
+ String url = getUrl();
+ if (oldHandleIdentifier != null && url != null) {
+ String oldRepositoryUrl = AbstractRepositoryTask.getRepositoryUrl(oldHandleIdentifier);
+ String newRepositoryUrl = AbstractRepositoryTask.getRepositoryUrl(newHandleIdentifier);
+
+ if (url.startsWith(oldRepositoryUrl)) {
+ setUrl(newRepositoryUrl + url.substring(oldRepositoryUrl.length()));
+ }
+ }
+ super.setHandleIdentifier(newHandleIdentifier);
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryTask.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryTask.java
index 75e9a8ad8..8ed0d2d67 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryTask.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/AbstractRepositoryTask.java
@@ -190,4 +190,22 @@ public abstract class AbstractRepositoryTask extends Task {
this.status = status;
}
+ /**
+ * Need to update URL since it is derived from handle identifier.
+ */
+ @Override
+ public void setHandleIdentifier(String newHandleIdentifier) {
+ String oldHandleIdentifier = getHandleIdentifier();
+ String url = getUrl();
+ if (oldHandleIdentifier != null && url != null) {
+ String oldRepositoryUrl = AbstractRepositoryTask.getRepositoryUrl(oldHandleIdentifier);
+ String newRepositoryUrl = AbstractRepositoryTask.getRepositoryUrl(newHandleIdentifier);
+
+ if (url.startsWith(oldRepositoryUrl)) {
+ setUrl(newRepositoryUrl + url.substring(oldRepositoryUrl.length()));
+ }
+ }
+ super.setHandleIdentifier(newHandleIdentifier);
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
index 9e2b29e94..8626651e7 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
@@ -161,7 +161,17 @@ public class TaskListManagerTest extends TestCase {
manager.refactorRepositoryUrl("http://a", "http://b");
assertNull(manager.getTaskList().getTask("http://a-123"));
assertNotNull(manager.getTaskList().getTask("http://b-123"));
- }
+ }
+
+ public void testMigrateTaskHandlesWithExplicitSet() {
+ AbstractRepositoryTask task = new MockRepositoryTask("http://a-123");
+ task.setUrl("http://a/task/123");
+ manager.getTaskList().addTask(task);
+ manager.refactorRepositoryUrl("http://a", "http://b");
+ assertNull(manager.getTaskList().getTask("http://a-123"));
+ assertNotNull(manager.getTaskList().getTask("http://b-123"));
+ assertEquals("http://b/task/123", task.getUrl());
+ }
public void testIsActiveToday() {
ITask task = new Task("1", "task-1", true);
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryQueryTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryQueryTest.java
index 9e7a309de..c579ef192 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryQueryTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/TracRepositoryQueryTest.java
@@ -19,8 +19,10 @@ import junit.framework.TestCase;
import org.eclipse.mylar.internal.trac.core.ITracClient;
import org.eclipse.mylar.internal.trac.core.TracCorePlugin;
import org.eclipse.mylar.internal.trac.core.TracRepositoryQuery;
+import org.eclipse.mylar.internal.trac.core.TracTask;
import org.eclipse.mylar.internal.trac.core.model.TracSearch;
import org.eclipse.mylar.internal.trac.core.model.TracSearchFilter;
+import org.eclipse.mylar.tasks.core.AbstractRepositoryTask;
import org.eclipse.mylar.tasks.core.TaskRepository;
import org.eclipse.mylar.tasks.core.TaskRepositoryManager;
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
@@ -41,6 +43,9 @@ public class TracRepositoryQueryTest extends TestCase {
String queryUrl = repository.getUrl() + ITracClient.QUERY_URL + search.toUrl();
TracRepositoryQuery query = new TracRepositoryQuery(repository.getUrl(), queryUrl, "description", TasksUiPlugin.getTaskListManager().getTaskList());
TasksUiPlugin.getTaskListManager().getTaskList().addQuery(query);
+
+ TracTask task = new TracTask(AbstractRepositoryTask.getHandle(Constants.TEST_TRAC_096_URL, 123), "desc", true);
+ TasksUiPlugin.getTaskListManager().getTaskList().addTask(task);
String oldUrl = repository.getUrl();
String newUrl = Constants.TEST_TRAC_010_URL;
@@ -49,6 +54,7 @@ public class TracRepositoryQueryTest extends TestCase {
assertEquals(newUrl, query.getRepositoryUrl());
assertEquals(newUrl + ITracClient.QUERY_URL + search.toUrl(), query.getUrl());
+ assertEquals(newUrl + ITracClient.TICKET_URL + 123, task.getUrl());
}
public void testGetFilterList() {

Back to the top