Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Resolve PlatformPlugin-URIs to file URIs in a test setup
Resolve PlatformPlugin-URIs to file URIs in a test setup [message #1070762] Thu, 18 July 2013 15:51 Go to next message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 140
Registered: July 2009
Senior Member
Hi,
I'm running some tests using models which come from a normal Eclipse
runtime setup. This means, these models refer to other models with
PlatformPlugin-URIs all starting with 'platform:/plugin/pluginID'. I
cannot change these URIs in the models. What I want is to resolve those
URIs to normal file URIs, starting with 'file:/myworkspace/pluginID', in
my test setup. So what I did before running the test is the following:

File root = // determine the directory of the workspace where all
plugins are located;
File[] subDirs = root.listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.exists() && pathname.isDirectory() &&
!pathname.isHidden() && pathname.canRead() &&
!pathname.getName().startsWith(".");
}
});
Map<URI, URI> uriMap = URIConverter.URI_MAP;
for (File subDir : subDirs) {
String realPath = subDir.getAbsolutePath();
URI realUri = URI.createFileURI(realPath);
String pluginName = realUri.lastSegment();
URI pluginURI = URI.createPlatformPluginURI(pluginName, true);
uriMap.put(pluginURI, realUri);
}

My hope was that every request to a resource with a URI starting with
'platform:/plugin/pluginID' then is resolved to
'file:/myworkspace/pluginID'. But that's not the case. Am I doing
something wrong?

best regards,
Gilbert
Re: Resolve PlatformPlugin-URIs to file URIs in a test setup [message #1070794 is a reply to message #1070762] Thu, 18 July 2013 17:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Jan,

Comments below.

On 18/07/2013 5:51 PM, Jan Reimann wrote:
> Hi,
> I'm running some tests using models which come from a normal Eclipse
> runtime setup. This means, these models refer to other models with
> PlatformPlugin-URIs all starting with 'platform:/plugin/pluginID'. I
> cannot change these URIs in the models. What I want is to resolve those
> URIs to normal file URIs, starting with 'file:/myworkspace/pluginID', in
> my test setup. So what I did before running the test is the following:
>
> File root = // determine the directory of the workspace where all
> plugins are located;
> File[] subDirs = root.listFiles(new FileFilter() {
> public boolean accept(File pathname) {
> return pathname.exists() && pathname.isDirectory() &&
> !pathname.isHidden() && pathname.canRead() &&
> !pathname.getName().startsWith(".");
> }
> });
> Map<URI, URI> uriMap = URIConverter.URI_MAP;
> for (File subDir : subDirs) {
> String realPath = subDir.getAbsolutePath();
> URI realUri = URI.createFileURI(realPath);
> String pluginName = realUri.lastSegment();
> URI pluginURI = URI.createPlatformPluginURI(pluginName, true);
> uriMap.put(pluginURI, realUri);
> }
>
> My hope was that every request to a resource with a URI starting with
> 'platform:/plugin/pluginID' then is resolved to
> 'file:/myworkspace/pluginID'. But that's not the case. Am I doing
> something wrong?
Keep in mind that to map entire trees that both the source and target
URIs must end with a "/". I.e., they must be folder mappings, so that
all URI's with the prefix of the "key" URI are mapped to replace that
prefix with the "value" URI. Note that you can use archive: URIs to
refer to things within jars...
>
> best regards,
> Gilbert


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Resolve PlatformPlugin-URIs to file URIs in a test setup [message #1073153 is a reply to message #1070794] Wed, 24 July 2013 08:19 Go to previous messageGo to next message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 140
Registered: July 2009
Senior Member
Hi Ed,

Ed Merks wrote:
> Keep in mind that to map entire trees that both the source and target
> URIs must end with a "/". I.e., they must be folder mappings, so that
> all URI's with the prefix of the "key" URI are mapped to replace that
> prefix with the "value" URI. Note that you can use archive: URIs to
> refer to things within jars...

Yes, thx!

Do you have a hint for my main problem? As explained, my idea with
URIConverter.URI_MAP doesn't work. How can I map platform URIs to file URIs?

best regards,
Jan
Re: Resolve PlatformPlugin-URIs to file URIs in a test setup [message #1073165 is a reply to message #1073153] Wed, 24 July 2013 08:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Jan,

It's not working because your mappings aren't folder mappings.
Alternatively you can use
org.eclipse.emf.ecore.plugin.EcorePlugin.getPlatformResourceMap() to
describe the file location of each project name.


On 24/07/2013 10:19 AM, Jan Reimann wrote:
> Hi Ed,
>
> Ed Merks wrote:
>> Keep in mind that to map entire trees that both the source and target
>> URIs must end with a "/". I.e., they must be folder mappings, so that
>> all URI's with the prefix of the "key" URI are mapped to replace that
>> prefix with the "value" URI. Note that you can use archive: URIs to
>> refer to things within jars...
> Yes, thx!
>
> Do you have a hint for my main problem? As explained, my idea with
> URIConverter.URI_MAP doesn't work. How can I map platform URIs to file URIs?
>
> best regards,
> Jan


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Resolve PlatformPlugin-URIs to file URIs in a test setup [message #1073197 is a reply to message #1073165] Wed, 24 July 2013 09:51 Go to previous message
Jan Reimann is currently offline Jan ReimannFriend
Messages: 140
Registered: July 2009
Senior Member
Thanks Ed, I thought I did it the way you suggested but I didn't. I
overlooked the missing "/" at the end of the URIs. Now it works.

best regards,
Jan

Ed Merks wrote:
> Jan,
>
> It's not working because your mappings aren't folder mappings.
> Alternatively you can use
> org.eclipse.emf.ecore.plugin.EcorePlugin.getPlatformResourceMap() to
> describe the file location of each project name.
>
>
> On 24/07/2013 10:19 AM, Jan Reimann wrote:
>> Hi Ed,
>>
>> Ed Merks wrote:
>>> Keep in mind that to map entire trees that both the source and target
>>> URIs must end with a "/". I.e., they must be folder mappings, so that
>>> all URI's with the prefix of the "key" URI are mapped to replace that
>>> prefix with the "value" URI. Note that you can use archive: URIs to
>>> refer to things within jars...
>> Yes, thx!
>>
>> Do you have a hint for my main problem? As explained, my idea with
>> URIConverter.URI_MAP doesn't work. How can I map platform URIs to file
>> URIs?
>>
>> best regards,
>> Jan
>
Previous Topic:Modeling implicits (how to?)
Next Topic:Why is EMF called EMF?
Goto Forum:
  


Current Time: Thu Mar 28 08:31:35 GMT 2024

Powered by FUDForum. Page generated in 0.05378 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top