|
Re: problems using OPTION_RESOURCE_HANDLER [message #505297 is a reply to message #505290] |
Tue, 29 December 2009 11:37 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------050608010004070504050008
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Peter,
Comments below.
peter wrote:
> Hi,
>
> Following the cookbook recipe on model migration I have successfully
> added my own ResourceHandler to help catch and migrate model errors.
> http://wiki.eclipse.org/EMF/Recipes#Recipe:_Data_Migration
>
> I had some simple tests that worked on one set of models but more
> recently I tried on another model and I get the following exception(s)
> continuously:
>
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Unresolved
> reference '//@someObject/@anotherObject'. (, 15, 121) ...
This is what happens when an IDREF (intradocument reference) can't be
resolved at the end of loading. Proxies are not created for such
cases. Such a document is internally inconsistent.
>
> I get this error when, and only when, the following option is set:
>
> options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
The above error doesn't have anything to do with unrecognized features
though.
>
> If its false or not set then there are no issues but there is no
> correct error reporting in my Handler ie the postLoad isn't correctly
> called. Note that it fails even if the model is correct; you cannot
> appear to use the above option AND resolve references it seems.
I'm not quite sure what you're saying here. Loading is implemented like
this:
public void doLoad(InputStream inputStream, Map<?, ?> options)
throws IOException
{
XMLLoad xmlLoad = createXMLLoad();
if (options == null)
{
options = Collections.EMPTY_MAP;
}
ResourceHandler handler =
(ResourceHandler)options.get(OPTION_RESOURCE_HANDLER);
if (handler != null)
{
handler.preLoad(this, inputStream, options);
}
xmlLoad.load(this, inputStream, options);
xmlLoad = null;
if (handler != null)
{
handler.postLoad(this, inputStream, options);
}
}
Maybe postLoad should be called even when an exception is thrown using a
finally block, but you seem to be saying the opposite of what I expect.
>
> The only differences between my new test case and the previous is that
> the model I am working on now is a single entity, the previous one was
> a multiple top level entity containing cross references.
You're talking multiple root objects?
> Finally I don't use the ExtendedMetaData option but I have never used
> this or appeared to need it.
>
> thanks for any help or advice on this topic.
Set a breakpoint for the exception being thrown and figure out why the
referenced object isn't being found. It looks like
UnresolvedReferenceException.
>
> cheers,
>
> peter
--------------050608010004070504050008
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Peter,<br>
<br>
Comments below.<br>
<br>
<br>
peter wrote:
<blockquote cite="mid:hhcm74$rc1$1@build.eclipse.org" type="cite">Hi,
<br>
<br>
Following the cookbook recipe on model migration I have successfully
added my own ResourceHandler to help catch and migrate model errors. <br>
<a class="moz-txt-link-freetext" href="http://wiki.eclipse.org/EMF/Recipes#Recipe:_Data_Migration">http://wiki.eclipse.org/EMF/Recipes#Recipe:_Data_Migration</a>
<br>
<br>
I had some simple tests that worked on one set of models but more
recently I tried on another model and I get the following exception(s)
continuously:
<br>
<br>
org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Unresolved
reference '//@someObject/@anotherObject'. (, 15, 121) ...
<br>
</blockquote>
This is what happens when an IDREF (intradocument reference) can't be
resolved at the end of loading. Proxies are not created for such
cases. Such a document is internally inconsistent.<br>
<blockquote cite="mid:hhcm74$rc1$1@build.eclipse.org" type="cite"><br>
I get this error when, and only when, the following option is set:
<br>
<br>
options.put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
<br>
</blockquote>
The above error doesn't have anything to do with unrecognized features
though.<br>
<blockquote cite="mid:hhcm74$rc1$1@build.eclipse.org" type="cite"><br>
If its false or not set then there are no issues but there is no
correct error reporting in my Handler ie the postLoad isn't correctly
called. Note that it fails even if the model is correct; you cannot
appear to use the above option AND resolve references it seems.
<br>
</blockquote>
I'm not quite sure what you're saying here. Loading is implemented
like this:<br>
<blockquote><small> public void doLoad(InputStream inputStream,
Map<?, ?> options) throws IOException</small><br>
<small> {</small><br>
<small> XMLLoad xmlLoad = createXMLLoad();</small><br>
<br>
<small> if (options == null)</small><br>
<small> {</small><br>
<small> options = Collections.EMPTY_MAP;</small><br>
<small> }</small><br>
<br>
<small> ResourceHandler handler =
(ResourceHandler)options.get(OPTION_RESOURCE_HANDLER);</small ><br>
<br>
<small> if (handler != null)</small><br>
<small> {</small><br>
<small> handler.preLoad(this, inputStream, options);</small><br>
<small> }</small><br>
<br>
<small> xmlLoad.load(this, inputStream, options);</small><br>
<small> xmlLoad = null;</small><br>
<br>
<small> if (handler != null)</small><br>
<small> {</small><br>
<small> handler.postLoad(this, inputStream, options);</small><br>
<small> }</small><br>
<small> }</small><br>
</blockquote>
Maybe postLoad should be called even when an exception is thrown using
a finally block, but you seem to be saying the opposite of what I
expect.<br>
<blockquote cite="mid:hhcm74$rc1$1@build.eclipse.org" type="cite"><br>
The only differences between my new test case and the previous is that
the model I am working on now is a single entity, the previous one was
a multiple top level entity containing cross references. <br>
</blockquote>
You're talking multiple root objects?<br>
<blockquote cite="mid:hhcm74$rc1$1@build.eclipse.org" type="cite">Finally
I don't use the ExtendedMetaData option but I have never used this or
appeared to need it.
<br>
<br>
thanks for any help or advice on this topic.
<br>
</blockquote>
Set a breakpoint for the exception being thrown and figure out why the
referenced object isn't being found. It looks like
UnresolvedReferenceException.<br>
<blockquote cite="mid:hhcm74$rc1$1@build.eclipse.org" type="cite"><br>
cheers,
<br>
<br>
peter
<br>
</blockquote>
</body>
</html>
--------------050608010004070504050008--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
|
Re: problems using OPTION_RESOURCE_HANDLER [message #505327 is a reply to message #505325] |
Tue, 29 December 2009 10:40 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Peter,
I'd recommend doing more than looking at it statically. The debugger is
your best friend so best you not ignore him. E.g., set a breakpoint in
the logic after each guard and see why you go in that branch when you
use the option. That's more likely to produce results quickly than
asking me.
peter wrote:
> ok, I need to work an a sample for you as I cannot share the model I
> am using ... I have tried looking at all references to the record
> option but it doesn't seem to have an obvious impact.
>
> Very confused.
>
> thanks,
>
> peter
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03526 seconds