Add support for : in string identifier

This commit is contained in:
Andrea Bollini
2020-06-18 12:56:44 +02:00
parent f44b28a8f5
commit d38dfdb31f
2 changed files with 6 additions and 5 deletions

View File

@@ -149,7 +149,7 @@ public class RestResourceController implements InitializingBean {
* @return single DSpaceResource * @return single DSpaceResource
*/ */
@RequestMapping(method = RequestMethod.GET, value = REGEX_REQUESTMAPPING_IDENTIFIER_AS_DIGIT) @RequestMapping(method = RequestMethod.GET, value = REGEX_REQUESTMAPPING_IDENTIFIER_AS_DIGIT)
public DSpaceResource<RestAddressableModel> findOne(@PathVariable String apiCategory, @PathVariable String model, public HALResource<RestAddressableModel> findOne(@PathVariable String apiCategory, @PathVariable String model,
@PathVariable Integer id) { @PathVariable Integer id) {
return findOneInternal(apiCategory, model, id); return findOneInternal(apiCategory, model, id);
} }
@@ -180,7 +180,7 @@ public class RestResourceController implements InitializingBean {
* @return single DSpaceResource * @return single DSpaceResource
*/ */
@RequestMapping(method = RequestMethod.GET, value = REGEX_REQUESTMAPPING_IDENTIFIER_AS_STRING_VERSION_STRONG) @RequestMapping(method = RequestMethod.GET, value = REGEX_REQUESTMAPPING_IDENTIFIER_AS_STRING_VERSION_STRONG)
public DSpaceResource<RestAddressableModel> findOne(@PathVariable String apiCategory, @PathVariable String model, public HALResource<RestAddressableModel> findOne(@PathVariable String apiCategory, @PathVariable String model,
@PathVariable String id) { @PathVariable String id) {
return findOneInternal(apiCategory, model, id); return findOneInternal(apiCategory, model, id);
} }
@@ -200,7 +200,7 @@ public class RestResourceController implements InitializingBean {
* @return single DSpaceResource * @return single DSpaceResource
*/ */
@RequestMapping(method = RequestMethod.GET, value = REGEX_REQUESTMAPPING_IDENTIFIER_AS_UUID) @RequestMapping(method = RequestMethod.GET, value = REGEX_REQUESTMAPPING_IDENTIFIER_AS_UUID)
public DSpaceResource<RestAddressableModel> findOne(@PathVariable String apiCategory, @PathVariable String model, public HALResource<RestAddressableModel> findOne(@PathVariable String apiCategory, @PathVariable String model,
@PathVariable UUID uuid) { @PathVariable UUID uuid) {
return findOneInternal(apiCategory, model, uuid); return findOneInternal(apiCategory, model, uuid);
} }
@@ -213,7 +213,7 @@ public class RestResourceController implements InitializingBean {
* @param id Identifier from request * @param id Identifier from request
* @return single DSpaceResource * @return single DSpaceResource
*/ */
private <ID extends Serializable> DSpaceResource<RestAddressableModel> findOneInternal(String apiCategory, private <ID extends Serializable> HALResource<RestAddressableModel> findOneInternal(String apiCategory,
String model, ID id) { String model, ID id) {
DSpaceRestRepository<RestAddressableModel, ID> repository = utils.getResourceRepository(apiCategory, model); DSpaceRestRepository<RestAddressableModel, ID> repository = utils.getResourceRepository(apiCategory, model);
Optional<RestAddressableModel> modelObject = Optional.empty(); Optional<RestAddressableModel> modelObject = Optional.empty();

View File

@@ -28,7 +28,8 @@ public class RegexUtils {
* identifier (digits or uuid) * identifier (digits or uuid)
*/ */
public static final String REGEX_REQUESTMAPPING_IDENTIFIER_AS_STRING_VERSION_STRONG = "/{id:^(?!^\\d+$)" + public static final String REGEX_REQUESTMAPPING_IDENTIFIER_AS_STRING_VERSION_STRONG = "/{id:^(?!^\\d+$)" +
"(?!^[0-9a-fxA-FX]{8}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{12}$)[\\w+\\-\\.]+$+}"; "(?!^[0-9a-fxA-FX]{8}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{4}-[0-9a-fxA-FX]{12}$)"
+ "[\\w+\\-\\.:]+$+}";
/** /**
* Regular expression in the request mapping to accept number as identifier * Regular expression in the request mapping to accept number as identifier