| Summary: | ModelManager#getNewModelForRead/Edit always throws ResourceAlreadyExists exception | ||
|---|---|---|---|
| Product: | [WebTools] WTP Source Editing | Reporter: | Hirotaka Matsumoto <jljlmatu> |
| Component: | wst.sse | Assignee: | David Williams <david_williams> |
| Status: | CLOSED FIXED | QA Contact: | |
| Severity: | critical | ||
| Priority: | P1 | CC: | sisikawa |
| Version: | 0.7.1 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Hirotaka Matsumoto
This was a conceptual error on my part in implementation. We'll investigate fixing in 071 stream. I could not reproduce. I tried our testNonExistentJSP JUnit test and it seemed to work as exected. So ... eihter there is more to the scenerio we'll need to know ... or .. this porblem is related to something else not seen in this simple tests? If you can provide a JUnit test similar to testNonExisentJSP, but which show's the problem, that would be very helpful for us. I've a JUnit test case for this, but it depends on our
proprietary code, I can't put this as is, but the net code is that
given that you have a project named "Project" but you don't have
a file of "/Project/WebContent/a.jsp", if you call model manager api
like :
IModelManager modelManager = StructuredModelManager.getModelManager();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile input = root.getFile(new Path("Project/WebContent/a.jsp"));
IStructuredModel model = modelManager.getNewModelForEdit(input,false);
it throws ResourceAlreadyExists exception.
Thanks, It was the 'false' part of getNewModelForEdit(input,false); that I didn't have. I can reproduce the problem now. I will investigate after I get some sleep :) Thanks, I've fixed the etNewModelForEdit(input,false) method so I think it works as expected now. I will commit to HEAD now, if it would do you some good being in 0.7.1 stream, I believe we safely could. As I fixed this method, though, I realized we do not do much in there, that you could not do yourself -- indicating this maybe should not be an API method at all? We do, however, set the 'new' state of the model, meaning it is a model without an underlying resource. Can you investigate some how tightly that is required from your current code. Feel free to explain to me in an email (or we can set up phone call if easier). *** Bug 107316 has been marked as a duplicate of this bug. *** *** Bug 107420 has been marked as a duplicate of this bug. *** (In reply to comment #5) > without an underlying resource. Can you investigate some how tightly that is > required from your current code. Feel free to explain to me in an email (or we > can set up phone call if easier). I think the following is a key and not a confidential one, and we should share this kind of information, so I'll put it here :) We are mainly three usages for new model. a) File > New In eclipse, File > New asks us to create an actual file. I would think it's ok for the development language ( i.e. C++, java, ...) But it may not good for non development language ( i.e. html. jsp, ...) Actually, other tool such as .NET, word, power point, ...don't ask us to create an actual html/jspfile when we start File > New. In our editor, we use this new model for creating a freme document from the existing file ( we call it 'split frame' ) and when saving such documents, we ask a filename and save it with that filename. So our first usage is for frame. I see this is out-of Eclipse-Way and probably it could be told that this isn't better Eclipse-Editor-Behaviour. We may change our current Frame behaviour, but again, this is huge design chagne for our editor. b) Save As Our editors have the functionality for link fixups when the document is going to be saved so that the saved files can be safely deployed. ( No broken links are there. ) To do this, what we are doing for SaveAs is : - Create a new model - Copy the content(text) from the old model to new model - Process link fixup for the new model so that the linked resources are copied and the links are fixed up. - Save that new model - Note: During this process, we can cancel SaveAs so that the content of the original model isn't modified. ( because we are using new model for fixup. ) This is our second usage. c) Thumbnail Our editor(actually some wizards) has a functionality for the preview of the file and we are using new model for this thumbnail view. This is our third usage. I've confirmed that this was fixed. . |