Class HdlResolverRestController

java.lang.Object
org.dspace.app.rest.hdlresolver.HdlResolverRestController

@RestController @ConditionalOnProperty("handle.remote-resolver.enabled") @RequestMapping(path="/{hdlService:hdlresolver|resolve|listhandles|listprefixes}/") public class HdlResolverRestController extends Object
This controller is public and is useful for handle resolving, whether a target handle identifier will be resolved into the corresponding URL (if found), otherwise will respond a null string.
Author:
Vincenzo Mecca (vins01-4science - vincenzo.mecca at 4science.it)
  • Constructor Details

    • HdlResolverRestController

      public HdlResolverRestController()
  • Method Details

    • handleController

      @GetMapping(value="**", produces="application/json;charset=UTF-8") public ResponseEntity<String> handleController(jakarta.servlet.http.HttpServletRequest request, @PathVariable String hdlService)
    • resolveHandle

      public ResponseEntity<String> resolveHandle(jakarta.servlet.http.HttpServletRequest request, String hdlService)
      REST GET Method used to find and retrieve the URL of a target Handle. It should return only one item, if found, else a null body value.
      Generate an HttpStatus.BAD_REQUEST 400 Error if the handle used in path isn't valid.
      The response type will be (application/json;charset=UTF-8) a string representing an array-like list of handles:
      Example:
      • Request: GET - http://{dspace.url}/hdlresolver/handleIdExample/1
      • Response: 200 - ["http://localhost/handle/hanldeIdExample1"]
      Parameters:
      request - HttpServletRequest
      Returns:
      One element List or null with status 200 - HttpStatus.OK or 400 - HttpStatus.BAD_REQUEST error
    • listPrefixes

      public ResponseEntity<String> listPrefixes(jakarta.servlet.http.HttpServletRequest request)
      REST GET Method used to list all available prefixes for handles. It should return a list of prefixes, at least the default one.
      The response type will be (application/json;charset=UTF-8) a string representing an array-like list of handles:
      Example:
      • Request: GET - http://{dspace.url}/listprefixes
      • Response: 200 - ["123456789","prefix1","prefix2"]
      Parameters:
      request - HttpServletRequest
      Returns:
      List of valid prefixes with status 200 HttpStatus.OK
    • listHandles

      public ResponseEntity<String> listHandles(jakarta.servlet.http.HttpServletRequest request, @PathVariable String prefix)
      REST GET Method used to list all available handles starting with target prefix. It should return a list of handles.
      If the controller is disabled `handle.hide.listhandles = true`, then 400 - HttpStatus.NOT_FOUND is returned.
      If the requested prefix is blank, then 404 - HttpStatus.BAD_REQUEST is returned.
      The response type will be (application/json;charset=UTF-8) a string representing an array-like list of handles:
      Example:
      • Request: GET - http://{dspace.url}/listhandles/prefix
      • Response: 200 - ["prefix/zero","prefix1/one","prefix2/two"]
      Parameters:
      request - HttpServletRequest
      prefix - String representing the prefix that will be searched
      Returns:
      List of valid prefixes with status 200 HttpStatus.OK or status 400 HttpStatus.NOT_FOUND if disabled by properties or status 404 HttpStatus.BAD_REQUEST if blank prefix is requested.
    • mapAsJson

      protected String mapAsJson(String resolvedUrl)
    • mapAsJson

      protected String mapAsJson(List<String> jsonList)