diff options
author | spingel | 2010-02-03 19:46:07 +0000 |
---|---|---|
committer | spingel | 2010-02-03 19:46:07 +0000 |
commit | fce2363f372bac4d0dac48eecb332708d95f205e (patch) | |
tree | a5c11eb6b55a8bef088474e6005c4696352e25eb /org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal | |
parent | 31022318b9c4468c0f173d7bb4e29e1f11f20b6d (diff) | |
download | org.eclipse.mylyn.tasks-fce2363f372bac4d0dac48eecb332708d95f205e.tar.gz org.eclipse.mylyn.tasks-fce2363f372bac4d0dac48eecb332708d95f205e.tar.xz org.eclipse.mylyn.tasks-fce2363f372bac4d0dac48eecb332708d95f205e.zip |
NEW - bug 216557: [patch] add option to "Replace existing attachment of the same name" when attaching files
https://bugs.eclipse.org/bugs/show_bug.cgi?id=216557
Diffstat (limited to 'org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal')
4 files changed, 8 insertions, 20 deletions
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttachmentHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttachmentHandler.java index f5ea58010..524f41e83 100644 --- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttachmentHandler.java +++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracAttachmentHandler.java @@ -27,6 +27,7 @@ import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentHandler; import org.eclipse.mylyn.tasks.core.data.AbstractTaskAttachmentSource; import org.eclipse.mylyn.tasks.core.data.TaskAttachmentMapper; import org.eclipse.mylyn.tasks.core.data.TaskAttribute; +import org.eclipse.mylyn.tasks.core.data.UnsubmittedTaskAttachment; /** * @author Steffen Pingel @@ -70,28 +71,15 @@ public class TracAttachmentHandler extends AbstractTaskAttachmentHandler { "Attachments are not supported by this repository access type")); //$NON-NLS-1$ } - String filename = source.getName(); - String description = source.getDescription(); - if (attachmentAttribute != null) { - TaskAttachmentMapper mapper = TaskAttachmentMapper.createFrom(attachmentAttribute); - if (mapper.getFileName() != null) { - filename = mapper.getFileName(); - } - if (mapper.getDescription() != null) { - description = mapper.getDescription(); - } - } - if (description == null) { - description = ""; //$NON-NLS-1$ - } - + UnsubmittedTaskAttachment attachment = new UnsubmittedTaskAttachment(source, attachmentAttribute); monitor = Policy.monitorFor(monitor); try { monitor.beginTask(Messages.TracAttachmentHandler_Uploading_attachment, IProgressMonitor.UNKNOWN); try { ITracClient client = connector.getClientManager().getTracClient(repository); int id = Integer.parseInt(task.getTaskId()); - client.putAttachmentData(id, filename, description, source.createInputStream(monitor), monitor); + client.putAttachmentData(id, attachment.getFileName(), attachment.getDescription(), + attachment.createInputStream(monitor), monitor, attachment.getReplaceExisting()); if (comment != null && comment.length() > 0) { TracTicket ticket = new TracTicket(id); client.updateTicket(ticket, comment, monitor); diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/ITracClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/ITracClient.java index b431d146d..9c74aed11 100644 --- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/ITracClient.java +++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/ITracClient.java @@ -188,7 +188,7 @@ public interface ITracClient { InputStream getAttachmentData(int ticketId, String filename, IProgressMonitor monitor) throws TracException; - void putAttachmentData(int ticketId, String name, String description, InputStream source, IProgressMonitor monitor) + void putAttachmentData(int ticketId, String name, String description, InputStream source, IProgressMonitor monitor, boolean replace) throws TracException; void deleteAttachment(int ticketId, String filename, IProgressMonitor monitor) throws TracException; diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java index 5c6628855..0741b068f 100644 --- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java +++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java @@ -743,7 +743,7 @@ public class TracWebClient extends AbstractTracClient { } } - public void putAttachmentData(int id, String name, String description, InputStream in, IProgressMonitor monitor) + public void putAttachmentData(int id, String name, String description, InputStream in, IProgressMonitor monitor, boolean replace) throws TracException { throw new TracException("Unsupported operation"); //$NON-NLS-1$ } diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java index b561ec663..007c784a3 100644 --- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java +++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracXmlRpcClient.java @@ -835,14 +835,14 @@ public class TracXmlRpcClient extends AbstractTracClient implements ITracWikiCli } public void putAttachmentData(int ticketId, String filename, String description, InputStream in, - IProgressMonitor monitor) throws TracException { + IProgressMonitor monitor, boolean replace) throws TracException { byte[] data; try { data = readData(in, new NullProgressMonitor()); } catch (IOException e) { throw new TracException(e); } - call(monitor, "ticket.putAttachment", ticketId, filename, description, data, false); //$NON-NLS-1$ + call(monitor, "ticket.putAttachment", ticketId, filename, description, data, replace); //$NON-NLS-1$ } private byte[] readData(InputStream in, IProgressMonitor monitor) throws IOException { |