Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 204711 - Drop of context onto task not working from context zip file
Summary: Drop of context onto task not working from context zip file
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1   Edit
Assignee: Steffen Pingel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 248364
  Show dependency tree
 
Reported: 2007-09-26 13:43 EDT by Robert Elves CLA
Modified: 2009-01-29 00:34 EST (History)
1 user (show)

See Also:


Attachments
Fixed isValidContextFile() util (4.84 KB, patch)
2007-09-28 02:21 EDT, Jevgeni Holodkov CLA
no flags Details | Diff
mylyn/context/zip (10.23 KB, application/octet-stream)
2007-09-28 02:21 EDT, Jevgeni Holodkov CLA
no flags Details
Fixed NPE and SaxContextReader (6.19 KB, patch)
2007-10-15 03:19 EDT, Jevgeni Holodkov CLA
no flags Details | Diff
Fixed NPE and SaxContextReader, recreated patch (7.93 KB, patch)
2007-11-30 02:06 EST, Jevgeni Holodkov CLA
no flags Details | Diff
Fixed NPE and SaxContextReader, recreated patch, clean (6.32 KB, patch)
2007-11-30 02:08 EST, Jevgeni Holodkov CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Elves CLA 2007-09-26 13:43:47 EDT
Upon drag and drop of a context zip file onto a task in the tasklist a validation is performed on the file to ensure it has a context, this validation now fails since it is looking for a bogus context with handle 'temp', hence the drop of context onto the target task is failing. This raises the additional question of what to do when multiple contexts exist in the file. We should likely present a context preview/selection dialog allowing the user to choose the appropriate context.
Comment 1 Jevgeni Holodkov CLA 2007-09-27 12:48:02 EDT
I can fix it in a number of ways:

Since it is only a context filename that can vary in ZIP file then I can detect, that if filename is not "repositories.xml" or "tasklist.xml", then it is a context file. Not very good solution, I think, it can break again if a new data file is added to the arhive later. Fast enough to do, thought.

The second option is to make readContext() to work the old way(process the very first ZipEntry) if handleIndentifier in SaxContextReader.readContext() is "temp" (or "", or null, or what to choose?).

The third option is to pass to ContextCorePlugin.getContextManager().isValidContextFile(file) also a handle of a target AbstractTask, to make the externalizer use legal handle, not a "temp" one. Nevertheless, matching task's handle and context's file name in zip file can fail. This can occur if the handle was changed (can it happen?) or the context was taken from another task.

Another way would be trying to read all files in the archive and fix SaxContextContentHandler() so it would notify/stop processing, if a xml file's content is not a context description.

Which way should I go?

As to the question of many contexts in one file, as I understand, currently it's not possible: for each task a separate file is created with a single context inside.
Comment 2 Robert Elves CLA 2007-09-27 13:23:51 EDT
Thanks Jevgeni, if you don't have time just pass back to me. I think your second option of just using the first available context is appropriate for now provided null is passed for the handle. Is it feasible (in the future) to put contexts into a context folder within the zip making it easier to get 'just contexts' from the zip (for when we have multiple tasks/contexts in a single zip?
Comment 3 Jevgeni Holodkov CLA 2007-09-28 02:21:31 EDT
Created attachment 79352 [details]
Fixed isValidContextFile() util
Comment 4 Jevgeni Holodkov CLA 2007-09-28 02:21:33 EDT
Created attachment 79353 [details]
mylyn/context/zip
Comment 5 Jevgeni Holodkov CLA 2007-09-28 02:30:58 EDT
(In reply to comment #2)
> Thanks Jevgeni, if you don't have time just pass back to me. I think your
> second option of just using the first available context is appropriate for now
> provided null is passed for the handle. Is it feasible (in the future) to put
> contexts into a context folder within the zip making it easier to get 'just
> contexts' from the zip (for when we have multiple tasks/contexts in a single
> zip?
> 


Right, I was also thinking about this option, it should be quite simple to implement. Nevertheless, I would prefer touching xml files's root element to ensure that the the Mylyn is actually working with a correct context file. Matching by filenames seems to me a bit unsafe, but this can be only my gut feeling :)
Comment 6 Robert Elves CLA 2007-09-28 13:04:59 EDT
 (In reply to comment #5)
> I would prefer touching xml files's root element to
> ensure that the the Mylyn is actually working with a correct context file.

Agreed. Will look at patch as soon as I get the go ahead from Mik.
Comment 7 Mik Kersten CLA 2007-09-28 14:26:51 EDT
Let's hold off until 2.1 is fully out.  Consider scheduling for next Tuesday or Wednesay.
Comment 8 Robert Elves CLA 2007-10-04 21:02:39 EDT
Jevgeni: So this patch doesn't resolve the case of dropping a previously dragged out Task (with context) onto another task. If you try you get:

java.lang.NullPointerException
	at org.eclipse.mylyn.internal.monitor.core.util.XmlStringConverter.convertXmlToString(XmlStringConverter.java:59)
	at org.eclipse.mylyn.internal.context.core.SaxContextContentHandler.createEventFromAttributes(SaxContextContentHandler.java:72)
	at org.eclipse.mylyn.internal.context.core.SaxContextContentHandler.startElement(SaxContextContentHandler.java:62)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:501)
	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:179)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2740)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:645)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:508)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
	at org.eclipse.mylyn.internal.context.core.SaxContextReader.readContext(SaxContextReader.java:76)
	at org.eclipse.mylyn.internal.context.core.InteractionContextExternalizer.readContextFromXML(InteractionContextExternalizer.java:132)
	at org.eclipse.mylyn.internal.context.core.InteractionContextExternalizer.readContextFromXML(InteractionContextExternalizer.java:121)
	at org.eclipse.mylyn.internal.context.core.InteractionContextManager.isValidContextFile(InteractionContextManager.java:1073)
	at org.eclipse.mylyn.internal.tasks.ui.views.TaskListDropAdapter.performDrop(TaskListDropAdapter.java:109)
	at org.eclipse.jface.viewers.ViewerDropAdapter.drop(ViewerDropAdapter.java:239)
	at org.eclipse.swt.dnd.DNDListener.handleEvent(DNDListener.java:90)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
Comment 9 Jevgeni Holodkov CLA 2007-10-15 03:19:34 EDT
Created attachment 80334 [details]
Fixed NPE and SaxContextReader

SaxContextReader now scans all entries in ZipFile and detects the context file by the file's content
Comment 10 Mik Kersten CLA 2007-10-18 19:01:19 EDT
Jevgeni: sorry, this patch went stale, could you please re-create?
Comment 11 Mik Kersten CLA 2007-11-23 14:12:51 EST
Jevgeni: are you able to recreate the patch for this?
Comment 12 Jevgeni Holodkov CLA 2007-11-30 02:06:27 EST
Created attachment 84140 [details]
Fixed NPE and SaxContextReader, recreated patch

Sorry for delay, I've been busy with my studies last month. This patch is the same as the previous one, but with 'scaling' added. Hope, I'm using it correctly.
Comment 13 Jevgeni Holodkov CLA 2007-11-30 02:08:54 EST
Created attachment 84141 [details]
 Fixed NPE and SaxContextReader, recreated patch, clean

Removed commented out code as well
Comment 14 Mik Kersten CLA 2007-12-05 21:39:30 EST
Rob: please review.
Comment 15 Robert Elves CLA 2007-12-12 10:41:40 EST
Had a look Jevgeni.  If the first zip entry is something other than a context, a bogus context is constructed. I think we need to do more work to get a proper context out of the file if it exists. Scheduling for 2.3 since we're so late in the 2.2 cycle.
Comment 16 Robert Elves CLA 2008-01-15 18:53:47 EST
Jevgeni, we're pushing this to 3.0. If you don't have time to investigate for 3.0 just let me know and I can take this one.
Comment 17 Robert Elves CLA 2008-06-14 00:24:52 EDT
Need to defer: http://wiki.eclipse.org/index.php/Mylyn/3.0_Plan#Deferred_Items
Comment 18 Steffen Pingel CLA 2009-01-29 00:34:55 EST
I have disabled dropping of files on the task list. We can revisit re-enabling this functionality for a future release if there is interest in the community.