Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Platform URI and special chars in project name
Platform URI and special chars in project name [message #416108] Fri, 18 January 2008 09:17 Go to next message
Sascha Theves is currently offline Sascha ThevesFriend
Messages: 39
Registered: July 2009
Member
Hi all,

we have several problems loading our model files when the project name does
include special characters such as '#' or '%'. Thats because EMF resources
are referenced by URIs. And in the URI implementation such special chars are
used to separate the URI fragment etc... If you have a project with name
'My#Project' that confuses EMF. I think this is a general problem and not
special to our models. Is there a workaround for the problem?

Thanks in advance,

Sascha
Re: Platform URI and special chars in project name [message #416115 is a reply to message #416108] Fri, 18 January 2008 11:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33138
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060305080407010006080608
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Sascha,

You should always use
URI.createPlatformURI(iFile.getFullPath().toString(), *true*) to ensure
that special characters are encoded. For the IFile
"/a#%b/model/a#%b.ecore" it would yield
"platform:/resource/a%23%25b/a%23%25b.ecore", which is of course totally
unreadable so in general you should avoid these characters like a bad
disease. Even a space is bad enough and tends to throw all kinds of
applications for a loop. The basic Ecore things I just tried worked
fine for this scenario, but I still recommend against the practice since
in my experience far too many utilities overlook doing either the
encoding or the decoding either of which is likely to get you into
trouble...


Sascha Theves wrote:
> Hi all,
>
> we have several problems loading our model files when the project name does
> include special characters such as '#' or '%'. Thats because EMF resources
> are referenced by URIs. And in the URI implementation such special chars are
> used to separate the URI fragment etc... If you have a project with name
> 'My#Project' that confuses EMF. I think this is a general problem and not
> special to our models. Is there a workaround for the problem?
>
> Thanks in advance,
>
> Sascha
>
>
>


--------------060305080407010006080608
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Sascha,<br>
<br>
You should always use
URI.createPlatformURI(iFile.getFullPath().toString(), <b>true</b>) to
ensure that special characters are encoded.&nbsp; For the IFile
"/a#%b/model/a#%b.ecore" it would yield&nbsp;
"platform:/resource/a%23%25b/a%23%25b.ecore", which is of course
totally unreadable so in general you should avoid these characters like
a bad disease.&nbsp; Even a space is bad enough and tends to throw all kinds
of applications for a loop.&nbsp; The basic Ecore things I just tried worked
fine for this scenario, but I still recommend against the practice
since in my experience far too many utilities overlook doing either the
encoding or the decoding either of which is likely to get you into
trouble...<br>
<br>
<br>
Sascha Theves wrote:
<blockquote cite="mid:fmpqrh$j5d$1@build.eclipse.org" type="cite">
<pre wrap="">Hi all,

we have several problems loading our model files when the project name does
include special characters such as '#' or '%'. Thats because EMF resources
are referenced by URIs. And in the URI implementation such special chars are
used to separate the URI fragment etc... If you have a project with name
'My#Project' that confuses EMF. I think this is a general problem and not
special to our models. Is there a workaround for the problem?

Thanks in advance,

Sascha


</pre>
</blockquote>
<br>
</body>
</html>

--------------060305080407010006080608--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Platform URI and special chars in project name [message #416128 is a reply to message #416115] Fri, 18 January 2008 14:52 Go to previous messageGo to next message
Sascha Theves is currently offline Sascha ThevesFriend
Messages: 39
Registered: July 2009
Member
This is a multi-part message in MIME format.

------=_NextPart_000_0027_01C859EA.16884DB0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Ed,

you are right, we can encode the URI when creating the instance and then =
loading our models with that URI. But as you said many tools doesn`t =
worry much about encoding/decoding of URIs and that results in several =
exceptions in our application. The problem is we cannot prevent the user =
renaming its project to an invalid name. So in my opinion you cannot =
prevent such exceptions. Am I right? Maybe EMF could encode/decode such =
URIs automatically so clients doesn`t worry about it?

But whatever - thanks for your answer and quick help!!! The support in =
EMF newsgroup is amazing!

Greets

Sascha

------=_NextPart_000_0027_01C859EA.16884DB0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type =
content=3Dtext/html;charset=3DISO-8859-1>
<META content=3D"MSHTML 6.00.6000.16544" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY text=3D#000000 bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi Ed,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>you are right,&nbsp;we can encode the =
URI when=20
creating the instance and then loading our models with that URI. But as =
you said=20
many tools doesn`t worry much about encoding/decoding of URIs =
and&nbsp;that=20
results in several exceptions in our application. The problem is we =
cannot=20
prevent the user renaming its project to an invalid name. So in my =
opinion you=20
cannot prevent such exceptions. Am I right? Maybe EMF could =
encode/decode such=20
URIs automatically so clients doesn`t worry about it?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>But whatever -&nbsp;thanks for your =
answer and=20
quick help!!! The support in EMF newsgroup is amazing!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Greets</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Sascha</FONT></DIV><BR></BODY></HTML>

------=_NextPart_000_0027_01C859EA.16884DB0--
Re: Platform URI and special chars in project name [message #416131 is a reply to message #416128] Fri, 18 January 2008 15:21 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33138
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------010608050304020002050400
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Sasacha,

EMF does all such encoding and decoding automatically. That's why we
deprecated the one argument URI.createPlatformResourceURI to force all
users to consider that they should call the new one with true (we got
complaints when we did this in the existing method). You'll find all
uses both generated and in the framework use the two argument for and
specify true. The toPlatformString will do the decoding and we always
use that too. The problem with encoding is you have to be so careful
not to do it too many times...


Sascha Theves wrote:
> Hi Ed,
>
> you are right, we can encode the URI when creating the instance and
> then loading our models with that URI. But as you said many tools
> doesn`t worry much about encoding/decoding of URIs and that results in
> several exceptions in our application. The problem is we cannot
> prevent the user renaming its project to an invalid name. So in my
> opinion you cannot prevent such exceptions. Am I right? Maybe EMF
> could encode/decode such URIs automatically so clients doesn`t worry
> about it?
>
> But whatever - thanks for your answer and quick help!!! The support in
> EMF newsgroup is amazing!
>
> Greets
>
> Sascha
>


--------------010608050304020002050400
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Sasacha,<br>
<br>
EMF does all such encoding and decoding automatically.&nbsp; That's why we
deprecated the one argument URI.createPlatformResourceURI to force all
users to consider that they should call the new one with true (we got
complaints when we did this in the existing method).&nbsp;&nbsp; You'll find all
uses both generated and in the framework use the two argument for and
specify true.&nbsp; The toPlatformString will do the decoding and we always
use that too.&nbsp; The problem with encoding is you have to be so careful
not to do it too many times...<br>
<br>
<br>
Sascha Theves wrote:
<blockquote cite="mid:fmqeeq$3m6$1@build.eclipse.org" type="cite">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<meta content="MSHTML 6.00.6000.16544" name="GENERATOR">
<style></style>
<div><font face="Arial" size="2">Hi Ed,</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">you are right,&nbsp;we can encode the URI
when creating the instance and then loading our models with that URI.
But as you said many tools doesn`t worry much about encoding/decoding
of URIs and&nbsp;that results in several exceptions in our application. The
problem is we cannot prevent the user renaming its project to an
invalid name. So in my opinion you cannot prevent such exceptions. Am I
right? Maybe EMF could encode/decode such URIs automatically so clients
doesn`t worry about it?</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">But whatever -&nbsp;thanks for your
answer and quick help!!! The support in EMF newsgroup is amazing!</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Greets</font></div>
<div>&nbsp;</div>
<div><font face="Arial" size="2">Sascha</font></div>
<br>
</blockquote>
<br>
</body>
</html>

--------------010608050304020002050400--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Referring to resources located in bundles
Next Topic:The "best way" to handle external resource changes?
Goto Forum:
  


Current Time: Sat Apr 20 08:47:07 GMT 2024

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

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

Back to the top