|
|
|
Re: Abort resource loading [message #420486 is a reply to message #420480] |
Tue, 01 July 2008 14:29 |
Ed Merks 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/
|
|
|
Powered by
FUDForum. Page generated in 0.02832 seconds