Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 341615

Summary: [Metamodel Management] Conversion of files outside of Eclipse workspace is not possible due to problems with MetaModelDescriptorRegistry
Product: [Automotive] Sphinx Reporter: Stephan Krusche <stephan.krusche>
Component: CoreAssignee: Stephan Eberle <stephaneberle9>
Status: CLOSED FIXED QA Contact:
Severity: major    
Priority: P3 CC: phoser7
Version: 0.7.0   
Target Milestone: 0.7.0   
Hardware: All   
OS: All   
Whiteboard:

Description Stephan Krusche CLA 2011-04-01 09:11:12 EDT
Build Identifier: 

The method method "public IMetaModelDescriptor getDescriptor(final Resource resource)" in line 517 of the class org.eclipse.sphinx.emf.metamodel.MetaModelDescriptorRegistry is not able to handle files or resources that are not in the Eclipse Workspace.

The solution of the problem might be not so difficult. After the try to "retrieve the descriptor for the underlaying IFile" there should be tried to retrieve the descriptor of the underlaying java.io.File when IFile is null.

Reproducible: Always

Steps to Reproduce:
1. Extend Artop with a wizard, that tries to deserialize arxml files that were not in the workspace
2. Use an arxml file that is not of the current version (e.g. 2.1.2 instead of 2.1.5)
3. The file should be converted before loading, but it is not, because the MetaModelDescriptorRegistry could not identify the MetaModelDescriptor of the used resource even if this MetaModelDescriptor is registered.
Comment 1 Stephan Eberle CLA 2011-04-04 07:15:02 EDT
(In reply to comment #0)
> The method method "public IMetaModelDescriptor getDescriptor(final Resource
> resource)" in line 517 of the class
> org.eclipse.sphinx.emf.metamodel.MetaModelDescriptorRegistry is not able to
> handle files or resources that are not in the Eclipse Workspace.

This is a valid issue and there should not be such limitation.

> The solution of the problem might be not so difficult. After the try to
> "retrieve the descriptor for the underlaying IFile" there should be tried to
> retrieve the descriptor of the underlaying java.io.File when IFile is null.

Obtaining the java.io.File of resource is for sure not difficult - but it doesn't help ;) What we ultimately need is the resource's content type which is defined within the Eclipse environment (via contribution to the ''org.eclipse.core.contenttype.contentTypes'' extension point). From the id of this content type we can then conclude the matching IMetaModelDescriptor.

Fortunately we already have the necessary API in place for that. So, I could simply use as a more general replacement for the IFile based IMetaModelDescriptor retrieval. I've also added a new test ''org.eclipse.sphinx.tests.emf.metamodel.MetaModelDescriptorRegistryOutsideWorkspaceTest'' proving that this works well for file resources outside the workspace and even for platform:/plugin resources that are loaded directly from one of the application's plug-ins.
Comment 2 Stephan Eberle CLA 2011-04-04 07:37:34 EDT
I've finally added back the IFile based metamodel descriptor retrieval because for resources that are located inside the workspace it is faster as content type id based metamodel descriptor retrieval.
Comment 3 Stephan Eberle CLA 2011-04-08 20:16:38 EDT
Switched from using content type id to model namespace for retrieving IMetaModelDescriptor of unloaded resources outside the workspace because this works also for standalone applications.
Comment 4 Stephan Krusche CLA 2011-04-11 03:41:55 EDT
thank you! it works perfectly now!
Comment 5 Balazs Grill CLA 2021-07-14 02:15:13 EDT
Mass-closing Resolved tickets