Skip to content

Commit 440e185

Browse files
committed
#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
1 parent 628148a commit 440e185

File tree

2 files changed

+0
-229
lines changed

2 files changed

+0
-229
lines changed

src/main/java/org/springframework/hateoas/mediatype/hal/forms/HalFormsSerializers.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,6 @@ private static Map<String, HalFormsTemplate> findTemplates(RepresentationModel<?
280280
.map(it -> it.getAffordanceModel(MediaTypes.HAL_FORMS_JSON)) //
281281
.map(HalFormsAffordanceModel.class::cast) //
282282
.filter(it -> !it.hasHttpMethod(HttpMethod.GET)) //
283-
.peek(it -> validate(resource, it)) //
284283
.forEach(it -> {
285284

286285
Class<?> type = it.getInputType().resolve(Object.class);
@@ -388,21 +387,4 @@ public String[] getCodes() {
388387
return new String[] { qualifiedCode, localCode, globalCode };
389388
}
390389
}
391-
392-
/**
393-
* Verify that the resource's self link and the affordance's URI have the same relative path.
394-
*
395-
* @param resource
396-
* @param model
397-
*/
398-
private static void validate(RepresentationModel<?> resource, HalFormsAffordanceModel model) {
399-
400-
String affordanceUri = model.getURI();
401-
String selfLinkUri = resource.getRequiredLink(IanaLinkRelations.SELF.value()).expand().getHref();
402-
403-
if (!affordanceUri.equals(selfLinkUri)) {
404-
throw new IllegalStateException("Affordance's URI " + affordanceUri + " doesn't match self link " + selfLinkUri
405-
+ " as expected in HAL-FORMS");
406-
}
407-
}
408390
}

src/test/java/org/springframework/hateoas/mediatype/hal/forms/HalFormsValidationIntegrationTest.java

Lines changed: 0 additions & 211 deletions
This file was deleted.

0 commit comments

Comments
 (0)