Closed Phillipus closed 5 years ago
The problem is when two or more users may have different versions of Archi and/or an Archi model with different features such as reported in #95
I'm working on sorting this out. Grafico Importer has to be re-written to handle EMF Resources and Resource Sets differently...
...I'll be back in a couple of days. :-(
I've now come up with a solution. They key is not to call this:
XMLResource resource = (XMLResource)resourceSet.getResource(file, true);
EMF will eventually call resource.load() and if it encounters any problems throw an exception and abandon the resource.
What we need to do is load the resource ourselves and handle exceptions, just as we do in EditorModelManager#loadModel()
So I've written a new Resource loader class that does all of this.
We also get model backwards-compatible checking so if anything needs fixing, such as text alignment defaults, it will do that too.
Fixed for next version
To reproduce this, manually edit a grafico XML file and add an unknown XML attribute. For example, in a text editor edit a ArchimateDiagramModel_xxxxxxx file and add
something=value
:Save the file and in another git tool (SmartGit) commit the change.
Back in Archi load that model and do "Abort Uncommitted changes". This will trigger the GraficoModelImporter to re-load the model from the XML files.
An Exception will be thrown and the model will not load.
The problem is triggered at
GraficoModelImporter#loadModel(File)
If EMF fails to resolve the feature "something" it throws an exception and the load fails. It would be nice if it would simply ignore the missing feature but it doesn't. And there's no way to catch the exception and use a default.
Compare this with EditorModelManager#loadModel() where we load the single XML file in one go into a Resource Set and an unknown feature can be ignored.
I don't know how we can guard against this.