fix for #659
This commit is contained in:
parent
bae1ee69ba
commit
11aa1c5a9e
|
@ -305,11 +305,16 @@ public class IdDt extends UriDt implements /*IPrimitiveDatatype<String>, */IIdTy
|
|||
b.append(myResourceType);
|
||||
}
|
||||
|
||||
if (b.length() > 0) {
|
||||
if (b.length() > 0 && isNotBlank(myUnqualifiedId)) {
|
||||
b.append('/');
|
||||
}
|
||||
|
||||
if (isNotBlank(myUnqualifiedId)) {
|
||||
b.append(myUnqualifiedId);
|
||||
} else if (isNotBlank(myUnqualifiedVersionId)) {
|
||||
b.append('/');
|
||||
}
|
||||
|
||||
b.append(myUnqualifiedId);
|
||||
if (isNotBlank(myUnqualifiedVersionId)) {
|
||||
b.append('/');
|
||||
b.append(Constants.PARAM_HISTORY);
|
||||
|
@ -527,7 +532,21 @@ public class IdDt extends UriDt implements /*IPrimitiveDatatype<String>, */IIdTy
|
|||
if (typeIndex == -1) {
|
||||
myResourceType = theValue.substring(0, idIndex);
|
||||
} else {
|
||||
myResourceType = theValue.substring(typeIndex + 1, idIndex);
|
||||
if (typeIndex > 0 && '/' == theValue.charAt(typeIndex - 1)) {
|
||||
typeIndex = theValue.indexOf('/', typeIndex + 1);
|
||||
}
|
||||
if (typeIndex >= idIndex) {
|
||||
// e.g. http://example.org/foo
|
||||
// 'foo' was the id but we're making that the resource type. Nullify the id part because we don't have an id.
|
||||
// Also set null value to the super.setValue() and enable myHaveComponentParts so it forces getValue() to properly
|
||||
// recreate the url
|
||||
myResourceType = myUnqualifiedId;
|
||||
myUnqualifiedId = null;
|
||||
super.setValue(null);
|
||||
myHaveComponentParts = true;
|
||||
} else {
|
||||
myResourceType = theValue.substring(typeIndex + 1, idIndex);
|
||||
}
|
||||
|
||||
if (typeIndex > 4) {
|
||||
myBaseUrl = theValue.substring(0, typeIndex);
|
||||
|
|
|
@ -197,7 +197,15 @@ public class ResourceLink implements Serializable {
|
|||
public void setTargetResourceUrl(IIdType theTargetResourceUrl) {
|
||||
Validate.isTrue(theTargetResourceUrl.hasBaseUrl());
|
||||
Validate.isTrue(theTargetResourceUrl.hasResourceType());
|
||||
Validate.isTrue(theTargetResourceUrl.hasIdPart());
|
||||
|
||||
if (theTargetResourceUrl.hasIdPart()) {
|
||||
// do nothing
|
||||
} else {
|
||||
// Must have set an url like http://example.org/something
|
||||
// We treat 'something' as the resource type because of fix for #659. Prior to #659 fix, 'something' was
|
||||
// treated as the id and 'example.org' was treated as the resource type
|
||||
// TODO: log a warning?
|
||||
}
|
||||
|
||||
myTargetResourceType = theTargetResourceUrl.getResourceType();
|
||||
myTargetResourceUrl = theTargetResourceUrl.getValue();
|
||||
|
|
|
@ -358,11 +358,16 @@ public final class IdType extends UriType implements IPrimitiveType<String>, IId
|
|||
b.append(myResourceType);
|
||||
}
|
||||
|
||||
if (b.length() > 0) {
|
||||
if (b.length() > 0 && isNotBlank(myUnqualifiedId)) {
|
||||
b.append('/');
|
||||
}
|
||||
|
||||
if (isNotBlank(myUnqualifiedId)) {
|
||||
b.append(myUnqualifiedId);
|
||||
} else if (isNotBlank(myUnqualifiedVersionId)) {
|
||||
b.append('/');
|
||||
}
|
||||
|
||||
b.append(myUnqualifiedId);
|
||||
if (isNotBlank(myUnqualifiedVersionId)) {
|
||||
b.append('/');
|
||||
b.append("_history");
|
||||
|
@ -554,7 +559,21 @@ public final class IdType extends UriType implements IPrimitiveType<String>, IId
|
|||
if (typeIndex == -1) {
|
||||
myResourceType = theValue.substring(0, idIndex);
|
||||
} else {
|
||||
myResourceType = theValue.substring(typeIndex + 1, idIndex);
|
||||
if (typeIndex > 0 && '/' == theValue.charAt(typeIndex - 1)) {
|
||||
typeIndex = theValue.indexOf('/', typeIndex + 1);
|
||||
}
|
||||
if (typeIndex >= idIndex) {
|
||||
// e.g. http://example.org/foo
|
||||
// 'foo' was the id but we're making that the resource type. Nullify the id part because we don't have an id.
|
||||
// Also set null value to the super.setValue() and enable myHaveComponentParts so it forces getValue() to properly
|
||||
// recreate the url
|
||||
myResourceType = myUnqualifiedId;
|
||||
myUnqualifiedId = null;
|
||||
super.setValue(null);
|
||||
myHaveComponentParts = true;
|
||||
} else {
|
||||
myResourceType = theValue.substring(typeIndex + 1, idIndex);
|
||||
}
|
||||
|
||||
if (typeIndex > 4) {
|
||||
myBaseUrl = theValue.substring(0, typeIndex);
|
||||
|
|
|
@ -357,11 +357,16 @@ public final class IdType extends UriType implements IPrimitiveType<String>, IId
|
|||
b.append(myResourceType);
|
||||
}
|
||||
|
||||
if (b.length() > 0) {
|
||||
if (b.length() > 0 && isNotBlank(myUnqualifiedId)) {
|
||||
b.append('/');
|
||||
}
|
||||
|
||||
if (isNotBlank(myUnqualifiedId)) {
|
||||
b.append(myUnqualifiedId);
|
||||
} else if (isNotBlank(myUnqualifiedVersionId)) {
|
||||
b.append('/');
|
||||
}
|
||||
|
||||
b.append(myUnqualifiedId);
|
||||
if (isNotBlank(myUnqualifiedVersionId)) {
|
||||
b.append('/');
|
||||
b.append("_history");
|
||||
|
@ -553,7 +558,21 @@ public final class IdType extends UriType implements IPrimitiveType<String>, IId
|
|||
if (typeIndex == -1) {
|
||||
myResourceType = theValue.substring(0, idIndex);
|
||||
} else {
|
||||
myResourceType = theValue.substring(typeIndex + 1, idIndex);
|
||||
if (typeIndex > 0 && '/' == theValue.charAt(typeIndex - 1)) {
|
||||
typeIndex = theValue.indexOf('/', typeIndex + 1);
|
||||
}
|
||||
if (typeIndex >= idIndex) {
|
||||
// e.g. http://example.org/foo
|
||||
// 'foo' was the id but we're making that the resource type. Nullify the id part because we don't have an id.
|
||||
// Also set null value to the super.setValue() and enable myHaveComponentParts so it forces getValue() to properly
|
||||
// recreate the url
|
||||
myResourceType = myUnqualifiedId;
|
||||
myUnqualifiedId = null;
|
||||
super.setValue(null);
|
||||
myHaveComponentParts = true;
|
||||
} else {
|
||||
myResourceType = theValue.substring(typeIndex + 1, idIndex);
|
||||
}
|
||||
|
||||
if (typeIndex > 4) {
|
||||
myBaseUrl = theValue.substring(0, typeIndex);
|
||||
|
|
|
@ -384,11 +384,16 @@ public final class IdType extends UriType implements IPrimitiveType<String>, IId
|
|||
b.append(myResourceType);
|
||||
}
|
||||
|
||||
if (b.length() > 0) {
|
||||
if (b.length() > 0 && isNotBlank(myUnqualifiedId)) {
|
||||
b.append('/');
|
||||
}
|
||||
|
||||
if (isNotBlank(myUnqualifiedId)) {
|
||||
b.append(myUnqualifiedId);
|
||||
} else if (isNotBlank(myUnqualifiedVersionId)) {
|
||||
b.append('/');
|
||||
}
|
||||
|
||||
b.append(myUnqualifiedId);
|
||||
if (isNotBlank(myUnqualifiedVersionId)) {
|
||||
b.append('/');
|
||||
b.append("_history");
|
||||
|
@ -571,7 +576,21 @@ public final class IdType extends UriType implements IPrimitiveType<String>, IId
|
|||
if (typeIndex == -1) {
|
||||
myResourceType = theValue.substring(0, idIndex);
|
||||
} else {
|
||||
myResourceType = theValue.substring(typeIndex + 1, idIndex);
|
||||
if (typeIndex > 0 && '/' == theValue.charAt(typeIndex - 1)) {
|
||||
typeIndex = theValue.indexOf('/', typeIndex + 1);
|
||||
}
|
||||
if (typeIndex >= idIndex) {
|
||||
// e.g. http://example.org/foo
|
||||
// 'foo' was the id but we're making that the resource type. Nullify the id part because we don't have an id.
|
||||
// Also set null value to the super.setValue() and enable myHaveComponentParts so it forces getValue() to properly
|
||||
// recreate the url
|
||||
myResourceType = myUnqualifiedId;
|
||||
myUnqualifiedId = null;
|
||||
super.setValue(null);
|
||||
myHaveComponentParts = true;
|
||||
} else {
|
||||
myResourceType = theValue.substring(typeIndex + 1, idIndex);
|
||||
}
|
||||
|
||||
if (typeIndex > 4) {
|
||||
myBaseUrl = theValue.substring(0, typeIndex);
|
||||
|
|
Loading…
Reference in New Issue