Community
Participate
Working Groups
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.
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.
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?
Created attachment 79352 [details] Fixed isValidContextFile() util
Created attachment 79353 [details] mylyn/context/zip
(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 :)
(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.
Let's hold off until 2.1 is fully out. Consider scheduling for next Tuesday or Wednesay.
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)
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
Jevgeni: sorry, this patch went stale, could you please re-create?
Jevgeni: are you able to recreate the patch for this?
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.
Created attachment 84141 [details] Fixed NPE and SaxContextReader, recreated patch, clean Removed commented out code as well
Rob: please review.
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.
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.
Need to defer: http://wiki.eclipse.org/index.php/Mylyn/3.0_Plan#Deferred_Items
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.