From db33e62bc43c72ccce89a5d68dc06d0f04b6be8e Mon Sep 17 00:00:00 2001 From: Andrea Bollini Date: Tue, 7 Nov 2017 12:10:56 +0100 Subject: [PATCH] avoid ambigous mapping when the id is digit-only with alphanumeric id --- .../java/org/dspace/app/rest/RestResourceController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dspace-spring-rest/src/main/java/org/dspace/app/rest/RestResourceController.java b/dspace-spring-rest/src/main/java/org/dspace/app/rest/RestResourceController.java index 0f34bf3553..73559688fd 100644 --- a/dspace-spring-rest/src/main/java/org/dspace/app/rest/RestResourceController.java +++ b/dspace-spring-rest/src/main/java/org/dspace/app/rest/RestResourceController.java @@ -107,7 +107,7 @@ public class RestResourceController implements InitializingBean { return findOneInternal(apiCategory, model, id, projection); } - @RequestMapping(method = RequestMethod.GET, value = "/{id:[A-z0-9]+}") + @RequestMapping(method = RequestMethod.GET, value = "/{id:^(?!^\\d+$)[[:alnum:]]+$+}") @SuppressWarnings("unchecked") public DSpaceResource findOne(@PathVariable String apiCategory, @PathVariable String model, @PathVariable String id, @RequestParam(required = false) String projection) { @@ -144,7 +144,7 @@ public class RestResourceController implements InitializingBean { return findRelInternal(request, apiCategory, model, id, rel, page, assembler, projection); } - @RequestMapping(method = RequestMethod.GET, value = "/{id:[A-z0-9]+}/{rel}") + @RequestMapping(method = RequestMethod.GET, value = "/{id:^(?!^\\d+$)[[:alnum:]]+$}/{rel}") public ResourceSupport findRel(HttpServletRequest request, @PathVariable String apiCategory, @PathVariable String model, @PathVariable String id, @PathVariable String rel, Pageable page, PagedResourcesAssembler assembler, @RequestParam(required = false) String projection) { @@ -158,7 +158,7 @@ public class RestResourceController implements InitializingBean { return findRelInternal(request, apiCategory, model, uuid, rel, page, assembler, projection); } - @RequestMapping(method = RequestMethod.GET, value = "/{id:[A-z0-9]+}/{rel}/{relid:[A-z0-9]+}") + @RequestMapping(method = RequestMethod.GET, value = "/{id:^(?!^\\d+$)[[:alnum:]]+$}/{rel}/{relid:[A-z0-9]+}") public ResourceSupport findRel(HttpServletRequest request, @PathVariable String apiCategory, @PathVariable String model, @PathVariable String id, @PathVariable String rel, @PathVariable String relid, Pageable page, PagedResourcesAssembler assembler, @RequestParam(required = false) String projection) {