summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Muskalla2012-11-12 15:57:11 (EST)
committerSteffen Pingel2012-11-13 05:48:51 (EST)
commit6d030db9f368c33e3dcc5182bacb9f42b62d97e8 (patch)
treeb0e9282b7bf6202616e874fac20cfbf86e7c86aa
parent107375ddaf942a0500a8e68b60a0dccd88ae975a (diff)
downloadorg.eclipse.mylyn.tasks-6d030db9f368c33e3dcc5182bacb9f42b62d97e8.zip
org.eclipse.mylyn.tasks-6d030db9f368c33e3dcc5182bacb9f42b62d97e8.tar.gz
org.eclipse.mylyn.tasks-6d030db9f368c33e3dcc5182bacb9f42b62d97e8.tar.bz2
Implement deleteTask API for Tracrefs/changes/46/8646/3
For API consumers, it is helpful to have an API to delete exisiting tasks (eg. for cleanup). Given Mylyn already provides the API, this change simply implements this behavior for Trac Change-Id: I262b2910c8ecd8ffcd835c4531c06663c5c0f7e2
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java20
-rw-r--r--org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java15
2 files changed, 35 insertions, 0 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 09b735f..a8c3b3e 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Steffen Pingel - initial API and implementation
+ * Benjamin Muskalla (Tasktop Technologies) - support for deleting tasks
*******************************************************************************/
package org.eclipse.mylyn.internal.trac.core;
@@ -35,6 +36,7 @@ import org.eclipse.mylyn.internal.trac.core.client.AbstractWikiHandler;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.core.client.ITracWikiClient;
+import org.eclipse.mylyn.internal.trac.core.client.TracException;
import org.eclipse.mylyn.internal.trac.core.model.TracComment;
import org.eclipse.mylyn.internal.trac.core.model.TracPriority;
import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
@@ -58,6 +60,7 @@ import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession;
/**
* @author Steffen Pingel
+ * @author Benjamin Muskalla
*/
public class TracRepositoryConnector extends AbstractRepositoryConnector {
@@ -751,4 +754,21 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
throw new CoreException(TracCorePlugin.toStatus(e, repository));
}
}
+
+ @Override
+ public boolean canDeleteTask(TaskRepository repository, ITask task) {
+ return hasRichEditor(repository);
+ }
+
+ @Override
+ public IStatus deleteTask(TaskRepository repository, ITask task, IProgressMonitor monitor) throws CoreException {
+ monitor = Policy.monitorFor(monitor);
+ ITracClient client = getClientManager().getTracClient(repository);
+ try {
+ client.deleteTicket(getTicketId(task.getTaskId()), monitor);
+ } catch (TracException e) {
+ throw new CoreException(TracCorePlugin.toStatus(e, repository));
+ }
+ return Status.OK_STATUS;
+ }
}
diff --git a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java
index bdeaec9..8804f5d 100644
--- a/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java
+++ b/org.eclipse.mylyn.trac.tests/src/org/eclipse/mylyn/trac/tests/core/TracRepositoryConnectorTest.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Steffen Pingel - initial API and implementation
+ * Benjamin Muskalla (Tasktop Technologies) - support for deleting tasks
*******************************************************************************/
package org.eclipse.mylyn.trac.tests.core;
@@ -316,4 +317,18 @@ public class TracRepositoryConnectorTest extends TestCase {
assertEquals(new Date(123 * 1000), task.getCompletionDate());
}
+ public void testDeleteNewTask() throws Exception {
+ ITracClient client = connector.getClientManager().getTracClient(repository);
+ TracTicket ticket = TracTestUtil.createTicket(client, "testDeleteNewTask");
+ String taskId = String.valueOf(ticket.getId());
+ ITask task = TracTestUtil.createTask(repository, taskId);
+ assertTrue(connector.canDeleteTask(repository, task));
+ connector.deleteTask(repository, task, null);
+ try {
+ connector.getTaskData(repository, taskId, null);
+ fail("Task should be gone");
+ } catch (CoreException e) {
+ assertTrue(e.getMessage().contains("does not exist"));
+ }
+ }
}