Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Abort resource loading
Abort resource loading [message #420460] Tue, 01 July 2008 08:42 Go to next message
J. Rietz is currently offline J. RietzFriend
Messages: 40
Registered: July 2009
Member
Hi,

I have a scenario when I want the load of a resource to be programatically
aborted in a nice and controlled way.
The scenario is
1. user try to open the resource
2. during the open/load of the resource a specific test is performed
3. if test evaluates true the resource load should be aborted and error
message displayed to user

Is it possible to perform such abort of resource load in a nice way? And
how in that case?
Had some tries around the ResourceFactoryImpl.createResource(URI uri) and
XMIResourceImpl.load(Map<?,?> options) but don't get it work.


Regards,
Joachim
Re: Abort resource loading [message #420467 is a reply to message #420460] Tue, 01 July 2008 11:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Joachim,

Comments below.

Joachim Rietz wrote:
> Hi,
>
> I have a scenario when I want the load of a resource to be
> programatically aborted in a nice and controlled way.
> The scenario is 1. user try to open the resource
> 2. during the open/load of the resource a specific test is performed
> 3. if test evaluates true the resource load should be aborted and
> error message displayed to user
What exactly do you mean by abort?
>
> Is it possible to perform such abort of resource load in a nice way?
> And how in that case?
How is this different that the case of loading an XML file say has a
missing end element tag?
> Had some tries around the ResourceFactoryImpl.createResource(URI uri)
> and XMIResourceImpl.load(Map<?,?> options) but don't get it work.
Generally throwing an exception should do the trick. It's good to
record the failure reason in the Resource.getErrors(). I'd suggest
playing with the loading behavior for ill-formed XML.
>
>
> Regards,
> Joachim
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Abort resource loading [message #420480 is a reply to message #420467] Tue, 01 July 2008 13:26 Go to previous messageGo to next message
J. Rietz is currently offline J. RietzFriend
Messages: 40
Registered: July 2009
Member
Ed,

Thanks for your quick answer.
I'll explain a bit clearer what I mean by "abort load".
What I actually want to do is that if user tries to open a resource (model
instance) that has an "old" non-existing namespace uri I want to
"override" the default behaviour in order to stop the loading to proceed
and display a specific detailed error message.

BTW
I tried to throw an exception from XMIResourceImpl.load(Map<?,?> options)
but I didn't get my specific error message displayed in the opened editor
view, just an ordinary "org.eclipse.core.runtime.AssertionFailedException:
assertion failed: ".
Probably not throwing exception / recording the failure reason in proper
way...

/Joachim

Ed Merks wrote:

> Joachim,

> Comments below.

> Joachim Rietz wrote:
>> Hi,
>>
>> I have a scenario when I want the load of a resource to be
>> programatically aborted in a nice and controlled way.
>> The scenario is 1. user try to open the resource
>> 2. during the open/load of the resource a specific test is performed
>> 3. if test evaluates true the resource load should be aborted and
>> error message displayed to user
> What exactly do you mean by abort?
>>
>> Is it possible to perform such abort of resource load in a nice way?
>> And how in that case?
> How is this different that the case of loading an XML file say has a
> missing end element tag?
>> Had some tries around the ResourceFactoryImpl.createResource(URI uri)
>> and XMIResourceImpl.load(Map<?,?> options) but don't get it work.
> Generally throwing an exception should do the trick. It's good to
> record the failure reason in the Resource.getErrors(). I'd suggest
> playing with the loading behavior for ill-formed XML.
>>
>>
>> Regards,
>> Joachim
>>
Re: Abort resource loading [message #420486 is a reply to message #420480] Tue, 01 July 2008 14:29 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Joachim,

Comments below.

Joachim Rietz wrote:
> Ed,
>
> Thanks for your quick answer.
> I'll explain a bit clearer what I mean by "abort load".
> What I actually want to do is that if user tries to open a resource
> (model instance) that has an "old" non-existing namespace uri I want
> to "override" the default behaviour in order to stop the loading to
> proceed and display a specific detailed error message.
Perhaps similar to what happens when a namspace URI can't be mapped to a
package...
>
> BTW
> I tried to throw an exception from XMIResourceImpl.load(Map<?,?>
> options) but I didn't get my specific error message displayed in the
> opened editor view, just an ordinary
> "org.eclipse.core.runtime.AssertionFailedException: assertion failed: ".
Have a look at how XMLHandler deals with errors. Specifically try
change the namespace used in a root element to something for which there
is no package. Probably you want' behavior much like this.
>
> Probably not throwing exception / recording the failure reason in
> proper way...
>
> /Joachim
>
> Ed Merks wrote:
>
>> Joachim,
>
>> Comments below.
>
>> Joachim Rietz wrote:
>>> Hi,
>>>
>>> I have a scenario when I want the load of a resource to be
>>> programatically aborted in a nice and controlled way.
>>> The scenario is 1. user try to open the resource
>>> 2. during the open/load of the resource a specific test is performed
>>> 3. if test evaluates true the resource load should be aborted and
>>> error message displayed to user
>> What exactly do you mean by abort?
>>>
>>> Is it possible to perform such abort of resource load in a nice way?
>>> And how in that case?
>> How is this different that the case of loading an XML file say has a
>> missing end element tag?
>>> Had some tries around the ResourceFactoryImpl.createResource(URI
>>> uri) and XMIResourceImpl.load(Map<?,?> options) but don't get it work.
>> Generally throwing an exception should do the trick. It's good to
>> record the failure reason in the Resource.getErrors(). I'd suggest
>> playing with the loading behavior for ill-formed XML.
>>>
>>>
>>> Regards,
>>> Joachim
>>>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:loading of sub model element fails ?
Next Topic:[CDO] New checkout/build instructions
Goto Forum:
  


Current Time: Sat Apr 27 03:58:24 GMT 2024

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

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

Back to the top