Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2006-10-12 19:09:41 -0400
committerspingel2006-10-12 19:09:41 -0400
commit8c705db1932ec5be508071c04f69f3dff9919cd4 (patch)
tree5b32731d6be6608dcad8b26052e8effbbab539a6 /org.eclipse.mylyn.trac.core/src
parent21eae7b0bb004eaf529abbd5dbbfc58c07567df3 (diff)
downloadorg.eclipse.mylyn.tasks-8c705db1932ec5be508071c04f69f3dff9919cd4.tar.gz
org.eclipse.mylyn.tasks-8c705db1932ec5be508071c04f69f3dff9919cd4.tar.xz
org.eclipse.mylyn.tasks-8c705db1932ec5be508071c04f69f3dff9919cd4.zip
Progress on: 159345: Error adding existing Trac ticket
https://bugs.eclipse.org/bugs/show_bug.cgi?id=159345
Diffstat (limited to 'org.eclipse.mylyn.trac.core/src')
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracOfflineTaskHandler.java10
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java46
2 files changed, 42 insertions, 14 deletions
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracOfflineTaskHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracOfflineTaskHandler.java
index 9c18d60e3..3310b75c1 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracOfflineTaskHandler.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracOfflineTaskHandler.java
@@ -55,13 +55,17 @@ public class TracOfflineTaskHandler implements IOfflineTaskHandler {
}
public RepositoryTaskData downloadTaskData(final AbstractRepositoryTask task, TaskRepository repository, Proxy proxySettings) throws CoreException {
- if (!connector.hasRichEditor(repository, task)) {
+ int id = Integer.parseInt(AbstractRepositoryTask.getTaskId(task.getHandleIdentifier()));
+ return downloadTaskData(repository, id);
+ }
+
+ public RepositoryTaskData downloadTaskData(TaskRepository repository, int id) throws CoreException {
+ if (!connector.hasRichEditor(repository)) {
// offline mode is only supported for XML-RPC
return null;
}
try {
- int id = Integer.parseInt(AbstractRepositoryTask.getTaskId(task.getHandleIdentifier()));
RepositoryTaskData data = new RepositoryTaskData(attributeFactory, TracCorePlugin.REPOSITORY_KIND,
repository.getUrl(), id + "");
ITracClient client = connector.getClientManager().getRepository(repository);
@@ -72,7 +76,7 @@ public class TracOfflineTaskHandler implements IOfflineTaskHandler {
return data;
} catch (Exception e) {
throw new CoreException(new Status(IStatus.ERROR, TracCorePlugin.PLUGIN_ID, 0, "Ticket download from "
- + task.getRepositoryUrl() + " failed, please see details.", e));
+ + repository.getUrl() + " for task " + id + " failed, please see details.", e));
}
}
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 c6ade79f6..90468a5a5 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
@@ -32,6 +32,7 @@ import org.eclipse.mylar.tasks.core.IAttachmentHandler;
import org.eclipse.mylar.tasks.core.IOfflineTaskHandler;
import org.eclipse.mylar.tasks.core.ITask;
import org.eclipse.mylar.tasks.core.QueryHitCollector;
+import org.eclipse.mylar.tasks.core.RepositoryTaskData;
import org.eclipse.mylar.tasks.core.TaskRepository;
/**
@@ -138,18 +139,41 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
@Override
public ITask createTaskFromExistingKey(TaskRepository repository, String id, Proxy proxySettings) throws CoreException {
+ int bugId = -1;
try {
- ITracClient connection = getClientManager().getRepository(repository);
- TracTicket ticket = connection.getTicket(Integer.parseInt(id));
-
- String handleIdentifier = AbstractRepositoryTask.getHandle(repository.getUrl(), ticket.getId());
- TracTask task = createTask(ticket, handleIdentifier);
- updateTaskDetails(task, ticket, true);
-
- return task;
- } catch (Exception e) {
- throw new CoreException(TracCorePlugin.toStatus(e));
+ bugId = Integer.parseInt(id);
+ } catch (NumberFormatException e) {
+ throw new CoreException(new Status(IStatus.ERROR, TracCorePlugin.PLUGIN_ID, IStatus.OK,
+ "Invalid ticket id: " + id, e));
+ }
+
+ String handle = AbstractRepositoryTask.getHandle(repository.getUrl(), bugId);
+
+ TracTask task;
+ ITask existingTask = taskList.getTask(handle);
+ if (existingTask instanceof TracTask) {
+ task = (TracTask) existingTask;
+ } else {
+ RepositoryTaskData taskData = offlineTaskHandler.downloadTaskData(repository, bugId);
+ if (taskData != null) {
+ task = new TracTask(handle, taskData.getId() + ":" + taskData.getDescription(), true);
+ task.setTaskData(taskData);
+ taskList.addTask(task);
+ } else {
+ // repository does not support XML-RPC, fall back to web access
+ try {
+ ITracClient connection = getClientManager().getRepository(repository);
+ TracTicket ticket = connection.getTicket(Integer.parseInt(id));
+
+ task = new TracTask(handle, getTicketDescription(ticket), true);
+ updateTaskDetails(task, ticket, false);
+ taskList.addTask(task);
+ } catch (Exception e) {
+ throw new CoreException(TracCorePlugin.toStatus(e));
+ }
+ }
}
+ return task;
}
public synchronized TracClientManager getClientManager() {
@@ -205,7 +229,7 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
return Version.XML_RPC.name().equals(repository.getVersion());
}
- public boolean hasRichEditor(TaskRepository repository, AbstractRepositoryTask task) {
+ public boolean hasRichEditor(TaskRepository repository) {
return Version.XML_RPC.name().equals(repository.getVersion());
}

Back to the top