Download and upload attachments via API (Bugzilla) [message #65299] |
Sat, 14 February 2009 15:31  |
Eclipse User |
|
|
|
Hi,
I want to create Bugzilla tasks programmatically with Mylyn.
What I don't understand is: How to download attachments from Bugzilla and create
new ones.
What I got so far is (from the Mylyn Example):
TaskRepository repository = new
TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, "http://...");
BugzillaRepositoryConnector connector = new BugzillaRepositoryConnector();
TaskData taskData = connector.getTaskData(repository, "1", null);
TaskMapping taskMapping = connector.getTaskMapping(taskData);
System.out.println("Summary: " + taskMapping.getSummary());
System.out.println("Priority: " + taskMapping.getPriority());
.... and now? I can't see any way from the API how to handle attachments.
Regards
Alex
|
|
|
|
|
Re: Download and upload attachments via API (Bugzilla) [message #65422 is a reply to message #65361] |
Sun, 15 February 2009 17:41  |
Eclipse User |
|
|
|
OK... I see: I don't need an ITask do do these things. I'm able to post
attachments through: BugzillaClient#postAttachment
.... it works. But nevertheless I get a CoreException parseHtmlError, which
obviously is another problem.
Thanks again
Alex
TaskAttribute attrAttachment =
taskData.getAttributeMapper().createTaskAttachment(taskData) ;
TaskAttachmentMapper attachmentMapper =
TaskAttachmentMapper.createFrom(attrAttachment);
attachmentMapper.setDescription("Test attachment " + new Date());
attachmentMapper.setContentType("text/plain");
attachmentMapper.setPatch(false);
attachmentMapper.setComment("attachment test");
attachmentMapper.applyTo(attrAttachment);
TextTaskAttachmentSource attachment = new TextTaskAttachmentSource("attachment
test");
client.postAttachment("1", attachmentMapper.getComment()
, attachmentMapper.getDescription()
, attachment.getContentType(), false
, new AttachmentPartSource(attachment,
"file-"+System.currentTimeMillis()+".txt")
, new NullProgressMonitor());
Alexander Karnstedt schrieb am 15.02.2009 18:54:
> Thanks Frank.
>
> I'm confused about a few things now:
>
> - The Test Plugin heavily uses TasksUiPlugin that assembles all the
> complicated stuff (from TaskDataStore to TaskRepositoryManager). I don't
> want to rely on the UI-Plugins in my application; so do I have to wire
> these things up by myself to work with ITask's?
>
> - All the classes I've seen there are internal classes
>
> - What about: TaskData taskData = connector.getTaskData
> ... is it a dead end? Cause I can't see how to get to ITask and
> TaskDataModel from that point
>
> - Isn't it possible to work with attachments through TaskData?
>
> Regards
> Alex
>
>
> Frank Becker schrieb am 15.02.2009 15:32:
>> Hi Alex,
>>
>> please look in the org.eclipse.mylyn.bugzilla.tests plugin.
>>
>> There is an Test testAttachToExistingReport in File
>> BugzillaRepositoryConnectorTest.
>> Hope this helps.
>>
>> Regards
>> Frank
>>
>> Alexander Karnstedt <alex.karnstedt@gmx.de> wrote:
>>
>>> Hi,
>>>
>>> I want to create Bugzilla tasks programmatically with Mylyn.
>>>
>>> What I don't understand is: How to download attachments from Bugzilla
>>> and
>> create
>>> new ones.
>>>
>>> What I got so far is (from the Mylyn Example):
>>>
>>> TaskRepository repository = new
>>> TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, "http://...");
>>> BugzillaRepositoryConnector connector = new
>>> BugzillaRepositoryConnector();
>>>
>>> TaskData taskData = connector.getTaskData(repository, "1", null);
>>>
>>> TaskMapping taskMapping = connector.getTaskMapping(taskData);
>>> System.out.println("Summary: " + taskMapping.getSummary());
>>> System.out.println("Priority: " + taskMapping.getPriority());
>>>
>>> .... and now? I can't see any way from the API how to handle
>>> attachments.
>>>
>>> Regards
>>> Alex
>>>
>>>
>>>
>>>
>>
|
|
|
Re: Download and upload attachments via API (Bugzilla) [message #596208 is a reply to message #65299] |
Sun, 15 February 2009 09:32  |
Eclipse User |
|
|
|
Hi Alex,
please look in the org.eclipse.mylyn.bugzilla.tests plugin.
There is an Test testAttachToExistingReport in File
BugzillaRepositoryConnectorTest.
Hope this helps.
Regards
Frank
Alexander Karnstedt <alex.karnstedt@gmx.de> wrote:
> Hi,
>
> I want to create Bugzilla tasks programmatically with Mylyn.
>
> What I don't understand is: How to download attachments from Bugzilla and
create
> new ones.
>
> What I got so far is (from the Mylyn Example):
>
> TaskRepository repository = new
> TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, "http://..");
> BugzillaRepositoryConnector connector = new BugzillaRepositoryConnector();
>
> TaskData taskData = connector.getTaskData(repository, "1", null);
>
> TaskMapping taskMapping = connector.getTaskMapping(taskData);
> System.out.println("Summary: " + taskMapping.getSummary());
> System.out.println("Priority: " + taskMapping.getPriority());
>
> .... and now? I can't see any way from the API how to handle attachments.
>
> Regards
> Alex
>
>
>
>
|
|
|
Re: Download and upload attachments via API (Bugzilla) [message #596232 is a reply to message #65320] |
Sun, 15 February 2009 12:54  |
Eclipse User |
|
|
|
Thanks Frank.
I'm confused about a few things now:
- The Test Plugin heavily uses TasksUiPlugin that assembles all the complicated
stuff (from TaskDataStore to TaskRepositoryManager). I don't want to rely on the
UI-Plugins in my application; so do I have to wire these things up by myself to
work with ITask's?
- All the classes I've seen there are internal classes
- What about: TaskData taskData = connector.getTaskData
... is it a dead end? Cause I can't see how to get to ITask and
TaskDataModel from that point
- Isn't it possible to work with attachments through TaskData?
Regards
Alex
Frank Becker schrieb am 15.02.2009 15:32:
> Hi Alex,
>
> please look in the org.eclipse.mylyn.bugzilla.tests plugin.
>
> There is an Test testAttachToExistingReport in File
> BugzillaRepositoryConnectorTest.
> Hope this helps.
>
> Regards
>
> Frank
>
> Alexander Karnstedt <alex.karnstedt@gmx.de> wrote:
>
>> Hi,
>>
>> I want to create Bugzilla tasks programmatically with Mylyn.
>>
>> What I don't understand is: How to download attachments from Bugzilla and
> create
>> new ones.
>>
>> What I got so far is (from the Mylyn Example):
>>
>> TaskRepository repository = new
>> TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, "http://..");
>> BugzillaRepositoryConnector connector = new BugzillaRepositoryConnector();
>>
>> TaskData taskData = connector.getTaskData(repository, "1", null);
>>
>> TaskMapping taskMapping = connector.getTaskMapping(taskData);
>> System.out.println("Summary: " + taskMapping.getSummary());
>> System.out.println("Priority: " + taskMapping.getPriority());
>>
>> .... and now? I can't see any way from the API how to handle attachments.
>>
>> Regards
>> Alex
>>
>>
>>
>>
>
|
|
|
Re: Download and upload attachments via API (Bugzilla) [message #596258 is a reply to message #65361] |
Sun, 15 February 2009 17:41  |
Eclipse User |
|
|
|
OK... I see: I don't need an ITask do do these things. I'm able to post
attachments through: BugzillaClient#postAttachment
.... it works. But nevertheless I get a CoreException parseHtmlError, which
obviously is another problem.
Thanks again
Alex
TaskAttribute attrAttachment =
taskData.getAttributeMapper().createTaskAttachment(taskData) ;
TaskAttachmentMapper attachmentMapper =
TaskAttachmentMapper.createFrom(attrAttachment);
attachmentMapper.setDescription("Test attachment " + new Date());
attachmentMapper.setContentType("text/plain");
attachmentMapper.setPatch(false);
attachmentMapper.setComment("attachment test");
attachmentMapper.applyTo(attrAttachment);
TextTaskAttachmentSource attachment = new TextTaskAttachmentSource("attachment
test");
client.postAttachment("1", attachmentMapper.getComment()
, attachmentMapper.getDescription()
, attachment.getContentType(), false
, new AttachmentPartSource(attachment,
"file-"+System.currentTimeMillis()+".txt")
, new NullProgressMonitor());
Alexander Karnstedt schrieb am 15.02.2009 18:54:
> Thanks Frank.
>
> I'm confused about a few things now:
>
> - The Test Plugin heavily uses TasksUiPlugin that assembles all the
> complicated stuff (from TaskDataStore to TaskRepositoryManager). I don't
> want to rely on the UI-Plugins in my application; so do I have to wire
> these things up by myself to work with ITask's?
>
> - All the classes I've seen there are internal classes
>
> - What about: TaskData taskData = connector.getTaskData
> ... is it a dead end? Cause I can't see how to get to ITask and
> TaskDataModel from that point
>
> - Isn't it possible to work with attachments through TaskData?
>
> Regards
> Alex
>
>
> Frank Becker schrieb am 15.02.2009 15:32:
>> Hi Alex,
>>
>> please look in the org.eclipse.mylyn.bugzilla.tests plugin.
>>
>> There is an Test testAttachToExistingReport in File
>> BugzillaRepositoryConnectorTest.
>> Hope this helps.
>>
>> Regards
>> Frank
>>
>> Alexander Karnstedt <alex.karnstedt@gmx.de> wrote:
>>
>>> Hi,
>>>
>>> I want to create Bugzilla tasks programmatically with Mylyn.
>>>
>>> What I don't understand is: How to download attachments from Bugzilla
>>> and
>> create
>>> new ones.
>>>
>>> What I got so far is (from the Mylyn Example):
>>>
>>> TaskRepository repository = new
>>> TaskRepository(BugzillaCorePlugin.CONNECTOR_KIND, "http://..");
>>> BugzillaRepositoryConnector connector = new
>>> BugzillaRepositoryConnector();
>>>
>>> TaskData taskData = connector.getTaskData(repository, "1", null);
>>>
>>> TaskMapping taskMapping = connector.getTaskMapping(taskData);
>>> System.out.println("Summary: " + taskMapping.getSummary());
>>> System.out.println("Priority: " + taskMapping.getPriority());
>>>
>>> .... and now? I can't see any way from the API how to handle
>>> attachments.
>>>
>>> Regards
>>> Alex
>>>
>>>
>>>
>>>
>>
|
|
|
Powered by
FUDForum. Page generated in 0.03246 seconds