Skip to content

Add support for routing by handle #256

@artlowel

Description

@artlowel

In order to support retrieving DSpace objects by handles, we'll add support for any kind of external identifier in one go:

  • Create an IdentifierType enum containing the supported identifiers
    • This is likely temporary, as eventually this list will come from rest as well, but if we need to replace it later, it's good to use an enum now, instead of strings everywhere.
    • only add UUID = 'uuid' and HANDLE = 'handle' for now
  • Create an index that maps identifiers to self links
    • Remove the IndexName enum. Since the available indices will depend on the available identifier we can no longer enumerate them. Instead
      • replace REQUEST by a constant
      • replace OBJECT by a getIdentifierIndexName(idType: IdentifierType): string method, that returns object/id-to-self-link/${idType}
      • remember to update all the places that use the old IndexName values
  • Modify the IndexEffects, to update all ID indices instead of only the UUID index, every time an object is added to the cache
    • Rename it to IdentifierIndexEffects
  • In ObjectCacheService replace hasByUUID and getByUUID by hasByID and getByID methods that take the IdentifierType as an optional parameter, if it isn't specified, use UUID
  • In DataService, do the same for findById()
    • If the identifier is UUID, keep using the current endpoints
    • Otherwise, use the new Rest Endpoint.
    • Take in to account that creating the REST endpoint is a Sprint task as well, so if it doesn't exist yet, you won't be able to test this actual call.
    • But due to the cache, this findBy method will still return objects that have been retrieved in another way and indexed in the id index.
  • Create a DSODataService that does nothing but extend Dataservice<NormalizedDspaceObject, DSpaceObject>
  • modify RequestService.isCachedOrPending() to check by other identifiers as well to determine if something is cached.
    • currently it only checks the objectCache by selfLink, but if the request has a property associated with another configured identifier (e.g. request[IdentifierType.HANDLE]) it should also check hasByID for that IdentifierType.
  • configure identifier based routes, that redirect to the DSOType based route
    • routes should be /id/${idType}/${id}
      • these are under /id to prevent accidental clashes with other routes added by dspace or modules built on top of dspace later
    • Also add /handle/${handle} for backwards compatibility. It should do the same thing as /id/handle/${handle}
    • Use DSODataService.findById() to retrieve the object from the api and then redirect to ${object.type}/${object.id}
    • Because it is already cached it should not be fetched again when that route is loaded.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions