Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2009-09-02 23:30:41 +0000
committersminto2009-09-02 23:30:41 +0000
commit68974693c26399117d480ef0977de966ae02cf49 (patch)
tree494df8868e7da5099aca99aa77b5e6624707d14b /org.eclipse.mylyn.tasks.core
parent2fc474589d61d10150a9f3b5b0a425f868bddada (diff)
downloadorg.eclipse.mylyn.tasks-68974693c26399117d480ef0977de966ae02cf49.tar.gz
org.eclipse.mylyn.tasks-68974693c26399117d480ef0977de966ae02cf49.tar.xz
org.eclipse.mylyn.tasks-68974693c26399117d480ef0977de966ae02cf49.zip
ASSIGNED - bug 207623: [api] add support for deleting a task from repository
https://bugs.eclipse.org/bugs/show_bug.cgi?id=207623
Diffstat (limited to 'org.eclipse.mylyn.tasks.core')
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/DeleteTasksJob.java87
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SubmitJob.java15
-rw-r--r--org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/TaskJob.java13
3 files changed, 100 insertions, 15 deletions
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/DeleteTasksJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/DeleteTasksJob.java
new file mode 100644
index 000000000..d9981f038
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/internal/tasks/core/sync/DeleteTasksJob.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.core.sync;
+
+import java.util.Collection;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.IRepositoryManager;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.sync.TaskJob;
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Shawn Minto
+ */
+public class DeleteTasksJob extends TaskJob {
+ private final Collection<ITask> tasksToDelete;
+
+ private MultiStatus status;
+
+ private final IRepositoryManager repositoryManager;
+
+ public DeleteTasksJob(String name, Collection<ITask> tasksToDelete, IRepositoryManager repositoryManager) {
+ super(name);
+ Assert.isNotNull(tasksToDelete);
+ Assert.isNotNull(repositoryManager);
+ this.repositoryManager = repositoryManager;
+ this.tasksToDelete = tasksToDelete;
+ }
+
+ @Override
+ public IStatus getStatus() {
+ return status;
+ }
+
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ status = new MultiStatus(ITasksCoreConstants.ID_PLUGIN, IStatus.OK,
+ "Problems occurred while deleting repository tasks", null); //$NON-NLS-1$
+ for (ITask task : tasksToDelete) {
+ // delete the task on the server using the repository connector
+ AbstractRepositoryConnector repositoryConnector = repositoryManager.getRepositoryConnector(task.getConnectorKind());
+ TaskRepository repository = repositoryManager.getRepository(task.getConnectorKind(),
+ task.getRepositoryUrl());
+ if (repositoryConnector.canDeleteTask(repository, task)) {
+ try {
+ repositoryConnector.deleteTask(repository, task, monitor);
+ } catch (OperationCanceledException e) {
+ return Status.CANCEL_STATUS;
+ } catch (Exception e) {
+ String taskId = task.getTaskKey();
+ if (taskId == null) {
+ taskId = task.getTaskId();
+ }
+ status.add(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, NLS.bind(
+ "Problems occurred while deleting {0} from {1}.", taskId, task.getRepositoryUrl()), e)); //$NON-NLS-1$
+ } catch (LinkageError e) {
+ String taskId = task.getTaskKey();
+ if (taskId == null) {
+ taskId = task.getTaskId();
+ }
+ status.add(new Status(IStatus.ERROR, ITasksCoreConstants.ID_PLUGIN, NLS.bind(
+ "Internal Error occurred while deleting {0} from {1}.", taskId, task.getRepositoryUrl()), e)); //$NON-NLS-1$
+ }
+
+ }
+ }
+ return Status.OK_STATUS;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SubmitJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SubmitJob.java
index 1c2a33749..594c9cd4f 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SubmitJob.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/SubmitJob.java
@@ -21,8 +21,6 @@ import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
-import org.eclipse.mylyn.commons.core.DelegatingProgressMonitor;
-import org.eclipse.mylyn.commons.core.IDelegatingProgressMonitor;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.net.Policy;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
@@ -39,16 +37,10 @@ public abstract class SubmitJob extends TaskJob {
private final List<SubmitJobListener> submitJobListeners = Collections.synchronizedList(new ArrayList<SubmitJobListener>());
/**
- * @since 3.2
- */
- protected final IDelegatingProgressMonitor monitor;
-
- /**
* @since 3.0
*/
public SubmitJob(String name) {
super(name);
- this.monitor = new DelegatingProgressMonitor();
}
/**
@@ -132,11 +124,4 @@ public abstract class SubmitJob extends TaskJob {
*/
public abstract RepositoryResponse getResponse();
- /**
- * @since 3.2
- */
- public IDelegatingProgressMonitor getMonitor() {
- return monitor;
- }
-
}
diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/TaskJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/TaskJob.java
index c292bc4ea..d93681651 100644
--- a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/TaskJob.java
+++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/core/sync/TaskJob.java
@@ -13,6 +13,8 @@ package org.eclipse.mylyn.tasks.core.sync;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.mylyn.commons.core.DelegatingProgressMonitor;
+import org.eclipse.mylyn.commons.core.IDelegatingProgressMonitor;
/**
* @author Steffen Pingel
@@ -20,12 +22,17 @@ import org.eclipse.core.runtime.jobs.Job;
* @noextend This class is not intended to be subclassed by clients.
*/
public abstract class TaskJob extends Job {
+ /**
+ * @since 3.3
+ */
+ protected final IDelegatingProgressMonitor monitor;
/**
* @since 3.0
*/
public TaskJob(String name) {
super(name);
+ this.monitor = new DelegatingProgressMonitor();
}
/**
@@ -33,4 +40,10 @@ public abstract class TaskJob extends Job {
*/
public abstract IStatus getStatus();
+ /**
+ * @since 3.3
+ */
+ public IDelegatingProgressMonitor getMonitor() {
+ return monitor;
+ }
}

Back to the top