Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 359669

Summary: CDO cannot handle resources with indexed fragments
Product: [Modeling] EMF Reporter: Martin Fluegge <martin.fluegge>
Component: cdo.coreAssignee: Martin Fluegge <martin.fluegge>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3 Flags: stepper: review+
Version: 4.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Test v1
none
Patch v1
none
Patch v2 (incl. test)
none
Test v3
none
Patch v2
none
Patch v3 (combined)
none
Patch v4 none

Description Martin Fluegge CLA 2011-10-02 17:33:27 EDT
The following URL is valid and should deliver the first object in the resource:

cdo://repo1/default1317589160531.acore_graphiti#/0

Likewise should do a call as the following

resource.getEObject("/0");

Actually COD fails on this and delivers null.
Comment 1 Martin Fluegge CLA 2011-10-02 17:35:12 EDT
Created attachment 204429 [details]
Test v1

I attached a test to reproduce the issue.
Comment 2 Martin Fluegge CLA 2011-10-02 17:44:24 EDT
Created attachment 204430 [details]
Patch v1

And here comes the patch...
Comment 3 Eike Stepper CLA 2011-10-05 04:19:57 EDT
According to http://learning.infocollections.com/ebook%202/Computer/Programming/Java/Eclipse.Modeling.Framework/0131425420_ch13lev1sec2.html the URI fragment can be much more complex than the one you're using in the single test case. Will attach a more complex test in a minute...
Comment 4 Eike Stepper CLA 2011-10-05 04:20:23 EDT
Created attachment 204571 [details]
Patch v2 (incl. test)
Comment 5 Martin Fluegge CLA 2011-10-09 06:25:39 EDT
Created attachment 204829 [details]
Test v3

I had some hard time finding the fix, because you had a nice typo in your test. 

it must be 

resource.getEObject("//@categories.0/@products.2");

and not 

resource.getEObject("//@categories.0/@product.2");

The missing 's' made it impossible to finde the correct feature ;)

Attached the corrected version.
Comment 6 Martin Fluegge CLA 2011-10-09 06:26:30 EDT
Created attachment 204830 [details]
Patch v2

Here comes a fixe whcih basically bases on the ResourceImpl implementation.
Comment 7 Eike Stepper CLA 2011-10-09 06:47:46 EDT
(In reply to comment #5)
> I had some hard time finding the fix, because you had a nice typo in your test. 
> it must be 
> 
> resource.getEObject("//@categories.0/@products.2");
> 
> and not 
> 
> resource.getEObject("//@categories.0/@product.2");
> 
> The missing 's' made it impossible to finde the correct feature ;)
> Attached the corrected version.

Oops ;-(
Comment 8 Martin Fluegge CLA 2011-10-09 07:45:20 EDT
Created attachment 204832 [details]
Patch v3 (combined)

Sorry, the last patch contained to much. Applied a combined patch in the correct version.
Comment 9 Eike Stepper CLA 2011-10-10 02:16:20 EDT
Created attachment 204852 [details]
Patch v4

I've removed the comment where you're asking if we should return "this" from getEObject() if uriFragment==null. I think that unnecessarily creates an incompatibility with EMF.
Comment 10 Eike Stepper CLA 2011-10-10 02:18:01 EDT
Please backport to 4.0 via bug 360380.
Comment 11 Martin Fluegge CLA 2011-10-10 13:08:52 EDT
Committed revision 9470
Comment 12 Eike Stepper CLA 2012-09-21 07:16:01 EDT
Closing.