Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 209327

Summary: [api] add additional IO support to import/export of tasks
Product: z_Archived Reporter: Remy Suen <remy.suen>
Component: MylynAssignee: Remy Suen <remy.suen>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P2 CC: caniszczyk, robert.elves, steffen.pingel
Version: devKeywords: helpwanted
Target Milestone: 2.3   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 213743    
Bug Blocks:    
Attachments:
Description Flags
Patch to add two new methods to TaskListWriter that takes an OutputStream.
none
Mylyn task context for this bug.
none
updated patch none

Description Remy Suen CLA 2007-11-09 08:08:52 EST
TaskListWriter currently has the following public methods for the importing and exporting of tasks:
readTasks(File)
readTaskList(TaskList, File, TaskDataManager)
writeTask(AbstractTask, File)
writeTaskList(TaskList, File)

Would it be possible to add methods that takes arbitrary InputStreams and OutputStreams? I want to read/write AbstractTasks as byte[]s so that they could be sent around through the network and would prefer not having to create temporary files all the time. Or is there an alternate method to serialize AbstractTasks that I've missed?
Comment 1 Eugene Kuleshov CLA 2007-11-09 13:11:34 EST
Hmm. I've been complaining that this api should not be File-centric and somehow thought it is fixed already.
Comment 2 Remy Suen CLA 2007-11-09 13:51:32 EST
To put some context into this request, the new API addition would make the implementation of bug 195737 cleaner.
Comment 3 Remy Suen CLA 2007-11-09 18:47:01 EST
It'd be nice if some of the other java.io.File methods like TaskListWriter's readRepositories(File) and InteractionContextManager's loadContext(String, File) and loadContext(String, File, InteractionContextScaling) were changed too. I can file separate bugs for those (since they're not necessarily dealing with "tasks" per se), but I'll see how far this api request flies first.
Comment 4 Mik Kersten CLA 2007-11-09 21:01:08 EST
Yup, a stream-based API would be more flexible.

Remy: are you interested in contributing this?  If so I can give you pointers on how to proceed on making this stream based.  InteractionContextManager changes are also possible, but will be a bit tricker.  Please file a single new bug report for making InteractionContextManager's I/O stream-based.
Comment 5 Remy Suen CLA 2007-11-09 21:39:15 EST
Created attachment 82592 [details]
Patch to add two new methods to TaskListWriter that takes an OutputStream.

 (In reply to comment #4)
> Remy: are you interested in contributing this?

Yes, I would be.

>  If so I can give you pointers on
> how to proceed on making this stream based.

Not sure if the attachment 

> InteractionContextManager changes
> are also possible, but will be a bit tricker.  Please file a single new bug
> report for making InteractionContextManager's I/O stream-based.

Will do. Do you want a separate bug for TaskListWriter's readRepositories(File) or...?
Comment 6 Remy Suen CLA 2007-11-09 21:41:08 EST
Created attachment 82593 [details]
Mylyn task context for this bug.
Comment 7 Remy Suen CLA 2007-11-09 21:43:12 EST
(In reply to comment #5)
> >  If so I can give you pointers on
> > how to proceed on making this stream based.
> 
> Not sure if the attachment 

I meant to say, I'm not sure if the attached patch suits your needs. If not, let me know. I didn't add @since tags since I'm not sure where Mylyn is headed.
Comment 8 Chris Aniszczyk CLA 2007-11-11 14:22:36 EST
+1
Comment 9 Remy Suen CLA 2007-11-21 17:58:50 EST
Any updates on this? Also, did you guys want me to file a separate bug for TaskListWriter's readRepositories(File) or should that be resolved here or merged with InteractionContextManager's (which I have not yet filed because I am waiting on this confirmation)?
Comment 10 Robert Elves CLA 2007-11-27 00:59:22 EST
Remy, this is looking good.  Would you be interested in extending this patch to address the readRepositories() method along with the others that don't take streams within this class? Then we won't have to revisit this again. We could then address the InteracitonContextManager's methods on a separate report.
Comment 11 Mik Kersten CLA 2007-11-27 12:39:36 EST
Rob, Remy: please make sure that any changes have adequate test coverage.  
Comment 12 Steffen Pingel CLA 2007-12-11 22:23:59 EST
Rob, let's pair on this and review the complete TaskListWriter API for 2.3 to make it stream-based with proper exception handling.
Comment 13 Steffen Pingel CLA 2008-01-20 22:14:50 EST
The review of the task list serialization code indicated that the task list serialization and import/export code probably needs a larger refactoring. The current logic is spread over multiple classes and duplicates quite a bit of code. 

In order to design public API to unify task list externalization, import/export and the requirements for this bug it would be helpful to get a better sense of the underlying use case. As far as I understand bug 195737 the goal is to share task list elements through ECF? Essentially that would be very similar to import/export and require serialization of multiple entities that are associated with a task and handled by different sub-systems in Mylyn: 

 * Task
 * Task Data (for rich editing / offline support)
 * Task Context
 * Task Repository

Instead of extending TaskListWriter Rob and I discussed introducing a new class that serves as a facade to TaskListWriter, TaskRepositoriesExternalizer, TaskDataManger and InteractionContextManager. The class could be made public API and would support import and export of these entities through a single stream. The interface could look similar to this:

class TaskExternalizer {

 void write(AbstractTaskContainer[] items, OutputStream out, IProgressMonitor monitor);
 
 Result read(InputStream in, IProgressMonitor monitor);

}

class Result {

 Status getStatus();

 void commit();
  
}

The Result class would provide facilities for user interaction in case of problems (e.g. when a task is imported that already exists). The implementation would require significant effort though and we won't be able to do this for 2.3. We might be able to get to it for 3.0 but we need to figure out how that fits into other priorities. 

Remy, we can make the changes proposed in your patch for Mylyn 2.3 (Europa spring update) but either way the (internal) API is almost certainly going to change for Mylyn 3.0 (Ganymede). Let me know what you think.
Comment 14 Remy Suen CLA 2008-01-20 22:24:56 EST
(In reply to comment #13)
> As far as I understand bug 195737 the goal is to share
> task list elements through ECF?

That's the basic gist of it. Just sending task list stuff around.

> class Result {
> 
>  Status getStatus();

Return IStatus instead of Status?

>  void commit();

What is this committing exactly? Doing the actual writing onto the OutputStream?

> Remy, we can make the changes proposed in your patch for Mylyn 2.3 (Europa
> spring update) but either way the (internal) API is almost certainly going to
> change for Mylyn 3.0 (Ganymede). Let me know what you think.

Just getting my suggested changes in for 2.3 would be a huge boon. If things are going to change for 3.0, so be it, I don't really have a problem with that. All the Eclipse projects that are a part of Ganymede are meant to work together, so if you guys feel the need to make changes, I'll change the code on our side to adapt accordingly so it all falls into place. :)
Comment 15 Steffen Pingel CLA 2008-01-21 00:32:41 EST
 (In reply to comment #14)
> Return IStatus instead of Status?

Makes sense.

> >  void commit();
> 
> What is this committing exactly? Doing the actual writing onto the OutputStream?

My idea is to make the import a two step process. First read the information from the input stream and create a Result object that holds the parsed data and information about potential conflicts. In case of conflicts some type of dialog is presented to the user to allow for manual resolution of conflicts (e.g. replace existing tasks). In a second step the Result object is "committed" to the task list which adds the actual tasks. 
 
> Just getting my suggested changes in for 2.3 would be a huge boon. If things are
> going to change for 3.0, so be it, I don't really have a problem with that. All
> the Eclipse projects that are a part of Ganymede are meant to work together, so
> if you guys feel the need to make changes, I'll change the code on our side to
> adapt accordingly so it all falls into place. :)

Alright. I think it's great that Ganymede projects integrate beyond being installable into the same instance of Eclipse :). 

Rob, do you have objections to merging the patch for 2.3?
Comment 16 Eugene Kuleshov CLA 2008-01-21 01:31:06 EST
(In reply to comment #15)
> ... In case of conflicts some type of dialog
> is presented to the user to allow for manual resolution of conflicts (e.g.
> replace existing tasks).

It should be possible to make this dialog optional or have some kind of pluggable call back, so IO stuff could work in a headless mode (i.e. when materializing task list for new user).
Comment 17 Robert Elves CLA 2008-02-05 12:45:45 EST
 (In reply to comment #15)
> Rob, do you have objections to merging the patch for 2.3?
No objections here. Lets go ahead with this patch and see if we can make progress on the larger scale externalization refactoring for 3.0.
Comment 18 Steffen Pingel CLA 2008-02-05 22:19:10 EST
Created attachment 88957 [details]
updated patch
Comment 19 Robert Elves CLA 2008-02-06 21:53:10 EST
Patch applied, ip log updated. 
Comment 20 Robert Elves CLA 2008-02-06 21:53:46 EST
Marking resolved. Further improvements to externalization apis tracked on bug#217953.