Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Mylyn » Download and upload attachments via API (Bugzilla)
Download and upload attachments via API (Bugzilla) [message #65299] Sat, 14 February 2009 20:31 Go to next message
Alexander Karnstedt is currently offline Alexander KarnstedtFriend
Messages: 68
Registered: July 2009
Member
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 #65320 is a reply to message #65299] Sun, 15 February 2009 14:32 Go to previous messageGo to next message
Frank Becker is currently offline Frank BeckerFriend
Messages: 64
Registered: July 2009
Member
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 #65361 is a reply to message #65320] Sun, 15 February 2009 17:54 Go to previous messageGo to next message
Alexander Karnstedt is currently offline Alexander KarnstedtFriend
Messages: 68
Registered: July 2009
Member
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 #65422 is a reply to message #65361] Sun, 15 February 2009 22:41 Go to previous message
Alexander Karnstedt is currently offline Alexander KarnstedtFriend
Messages: 68
Registered: July 2009
Member
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 14:32 Go to previous message
Frank Becker is currently offline Frank BeckerFriend
Messages: 64
Registered: July 2009
Member
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 17:54 Go to previous message
Alexander Karnstedt is currently offline Alexander KarnstedtFriend
Messages: 68
Registered: July 2009
Member
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 22:41 Go to previous message
Alexander Karnstedt is currently offline Alexander KarnstedtFriend
Messages: 68
Registered: July 2009
Member
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
>>>
>>>
>>>
>>>
>>
Previous Topic:"Bugzilla – Suspicious Action" error encountered after Bugzilla 3.2.2 upgrade
Next Topic:CoreException from BugzillaClient#parseHtmlError
Goto Forum:
  


Current Time: Sun Dec 21 21:44:48 GMT 2014

Powered by FUDForum. Page generated in 0.01924 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software