Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[43] Only call getPackageForURI on URI-like paths #45

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
*/
public class GsonEObjectDeserializer implements JsonDeserializer<List<EObject>> {

private static final char SCHEME_SEPARATOR = ':';

/**
* The JsonHelper.
*/
Expand Down Expand Up @@ -540,15 +542,13 @@ private void deserializeSingleNonContainmentEReference(EReference eReference, Js
this.helper.setValue(eObject, eReference, object);
}
} else {
String resourceURIPath = id.substring(0, index); // The URI of the resource where I can find
// the EObject
EPackage ePackage = this.getPackageForURI(resourceURIPath); // return an EPackage only if the
// URI represent an EPackage
Resource packageResource = null;
String resourceURIPath = id.substring(0, index);
EObject object = null;
if (ePackage != null) {
packageResource = ePackage.eResource();
object = packageResource.getEObject(fragmentEMF);
if (resourceURIPath.indexOf(SCHEME_SEPARATOR) != -1) {
EPackage ePackage = this.getPackageForURI(resourceURIPath);
if (ePackage != null) {
object = ePackage.eResource().getEObject(fragmentEMF);
}
} else {
object = this.createProxyEObject(id, qualifiedType, eReference);
}
Comment on lines +547 to 554
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the new logic is wrong. It assumes only resources from the package registry have full URI paths (with scheme, separator, etc.). This will not be the case in e.g. SysON where standard libraries, which are plain models, have URIs of the form kermllibrary://<uuid>. With the new code, such a URI would be lookup up in the package registry (because is has a :), which will fail, and we'll stop there. We should fall back to the this.createProxyEObject() in this case as in a non-URI-like path.

Expand Down Expand Up @@ -605,7 +605,7 @@ private EObject createProxyEObject(String id, String qualifiedType, EReference e
/**
* Resolves a type from a qualified name (e.g. "flow:System") into the corresponding EClass (or null) using the
* resource set's package registry.
*
*
* @param qualifiedType
* the qualified name of the type to resolve.
* @return the corresponding EClass, or null.
Expand Down Expand Up @@ -701,12 +701,12 @@ private void deserializeMultipleNonContainmentEReference(EReference eReference,
}
} else {
String resourceURIPath = id.substring(0, index);
EPackage ePackage = this.getPackageForURI(resourceURIPath);
Resource packageResource = null;
EObject object = null;
if (ePackage != null) {
packageResource = ePackage.eResource();
object = packageResource.getEObject(fragmentEMF);
if (resourceURIPath.indexOf(SCHEME_SEPARATOR) != -1) {
EPackage ePackage = this.getPackageForURI(resourceURIPath);
if (ePackage != null) {
object = ePackage.eResource().getEObject(fragmentEMF);
}
} else {
object = this.createProxyEObject(id, qualifiedType, eReference);
}
Expand Down
Loading