#992 - Remove URI restriction in HAL-FORMS implementation.

Prior to this commit the HAL-FORMS implementation verified the URIs of the affordances to match the self link of the representation model. This prevents the implementation of the HAL-FORMS metadata lookup protocol as defined in the HAL-FORMS specification [0].

We removed the verification to allow alternate URIs to be used for the afforances.

[0] https://rwcbook.github.io/hal-forms/#_suggested_process_flow_for_hal_forms_documents
This commit is contained in:
Oliver Drotbohm
2019-06-27 14:33:12 +02:00
parent 628148a169
commit 440e1852cc
2 changed files with 0 additions and 229 deletions

View File

@@ -280,7 +280,6 @@ class HalFormsSerializers {
.map(it -> it.getAffordanceModel(MediaTypes.HAL_FORMS_JSON)) //
.map(HalFormsAffordanceModel.class::cast) //
.filter(it -> !it.hasHttpMethod(HttpMethod.GET)) //
.peek(it -> validate(resource, it)) //
.forEach(it -> {
Class<?> type = it.getInputType().resolve(Object.class);
@@ -388,21 +387,4 @@ class HalFormsSerializers {
return new String[] { qualifiedCode, localCode, globalCode };
}
}
/**
* Verify that the resource's self link and the affordance's URI have the same relative path.
*
* @param resource
* @param model
*/
private static void validate(RepresentationModel<?> resource, HalFormsAffordanceModel model) {
String affordanceUri = model.getURI();
String selfLinkUri = resource.getRequiredLink(IanaLinkRelations.SELF.value()).expand().getHref();
if (!affordanceUri.equals(selfLinkUri)) {
throw new IllegalStateException("Affordance's URI " + affordanceUri + " doesn't match self link " + selfLinkUri
+ " as expected in HAL-FORMS");
}
}
}