| Summary: | [ModelSet - Read only] Papyrus rewrites referenced models during save | ||
|---|---|---|---|
| Product: | [Modeling] Papyrus | Reporter: | Ansgar Radermacher <ansgar.radermacher> |
| Component: | Core | Assignee: | Camille Letavernier <cletavernier> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | critical | ||
| Priority: | P3 | CC: | cedric.dumoulin, emilien.perico, faure.tristan, papyrus-bugs, Patrick.Tessier, sebastien.gerard, yann.tanguy |
| Version: | 1.0.0 | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
| Bug Depends on: | |||
| Bug Blocks: | 379160 | ||
|
Description
Ansgar Radermacher
Can you attach a corrupted file example ? Well, the referenced model was basically empty. I suspected that the unload mechanism causes the problem, but I cannot confirm it: when unloaded, the modification date of the referenced file does not change during save (referenced models are unloaded, if they change - the lazy load mechanism ensures that the updated contents becomes available, if required). However, I could reproduce that the referenced model file is actually re-written: manually inserted spaces in the referenced model file vanish after the save is executing in the importing model. Effectively, there is a simpler test: if you open the importing model and change the imported model, the changes are actually stored in the imported model. I don't know, if someone added this as "a feature" (since it was not always the case) - it is however a very bad idea as it might interfere with changes made by an editor that opens the imported model directly. The error has been introduced by fix of bug 317430 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=317430). I guess the basic motivation of 317430 was to let users work on a set of small models and enabling them to make changes to all of these) instead of using a single large one. However, users are typically not aware that imports are saved and might make inconsistent updates if the imported models are referenced by more than one model. Another (minor) side-effect: If the referenced model is currently open, the user gets a pop-up that his resource has been modified. If at all, additional models should not be saved by default, i.e. there could be a configuration property for it that is "off" by default. >> I propose to deactivate the save of additional models completely as long as there is no property that let the user control it. The save is done in method saveModel of class AdditionalResourcesModel (in org.eclipse.papyrus.resource.additional). The additional checks do not prevent a save in case of one model importing a model from the workspace. public void saveModel() throws IOException { for(Resource r : modelSet.getResources()) { if(modelSet.isAdditionalResource(r.getURI())) { EditingDomain editingDomain = modelSet.getTransactionalEditingDomain(); if(!r.getContents().isEmpty() && editingDomain != null && !editingDomain.isReadOnly(r) && (r.getURI().isPlatform() || r.getURI().isFile())) { r.save(Collections.EMPTY_MAP); } } } } I guess I know how models could be emptied: the ResourceUpdateService assumes that imported models are read-only (see comments in ResourceUpdateService.java within diagram.common). Therefore, I considered it safe to unload imported models once they change. They will be reloaded on-demand if referenced. However, during the save of the importing model, the unloaded imported model (thus empty) was saved as well. This is prevented since some time (20/12/2010) by a modification in class AdditionalResourceModel which now saves additional models only, if their contents is not empty. When I reported the error, I had apparently still an unpatched version of the AdditionalResourceModel class in my workspace. Thus, it is currently probably not possible to erase existing model, but still easy to create inconsistencies (accidental modification of imported models, loose modifications that are made in the editor importing a model vs. modifications made in an editor opening it directly). Models imported are saved to make possible the creation of controlled packages. If you disable this mechanism you shall guarantee that it is still possible to control/uncontrol packages Maybe I was ignorant concerning "controlled packages": I haven't heart about it before. Are there any documents available how the support of collaborative work on models is supposed to work? There is a specification document in this section, the document talks about collaborative work and package control sorry with the link svn+ssh://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.papyrus/trunk/doc/DevelopperDocuments/Specifications Checked-in trivial change into 0.7.x branch: only modified additional resources are written change the status of the bug to "accept" Still valid in 0.10. I won't fix it now because there's a conflict when CDO is installed (Which might lead to even worse/unexpected behaviors). I'll fix that properly for SR1 This is a very annoying bug. When you have multiple models open that reference each other and then make a modification of the model and saves it you get lots of confusing pop-up windows asking to save (or not) the referenced models. One example is when having a hyperlink to a diagram in a different model. Users/architects have asked: "Are we going to get all these pop-ups for every model we modify?" Since the new Read-only framework is available, referenced models are not saved anymore (Unless they've explicitly been made writable by the user) I close this task |