Class PseudonymRESTController

java.lang.Object
org.trustdeck.controller.PseudonymRESTController

@RestController @EnableMethodSecurity @RequestMapping("/api") public class PseudonymRESTController extends Object
This class represents a REST-API controller encapsulating the requests for pseudonym-records. This REST-API offers full access to the data items.
Author:
Armin Müller and Eric Wündisch
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<?>
    createRecord(String domainName, PseudonymDTO pseudonymDTO, Boolean omitPrefix, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    This method creates a new pseudonymization-record.
    org.springframework.http.ResponseEntity<?>
    createRecordBatch(String domainName, Boolean omitPrefix, List<PseudonymDTO> recordDtoList, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    This method creates new pseudonymization-records in batches.
    org.springframework.http.ResponseEntity<?>
    deleteRecord(String domainName, String identifier, String idType, String psn, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    This method deletes a pseudonym-record.
    org.springframework.http.ResponseEntity<?>
    deleteRecordBatch(String domainName, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    This method deletes all records in the given domain.
    org.springframework.http.ResponseEntity<?>
    getLinkedRecords(String sourceDomain, String targetDomain, String sourceIdentifier, String sourceIdType, String sourcePsn, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    Method to search and link pseudonyms along the pseudonym-chain in the tree.
    org.springframework.http.ResponseEntity<?>
    getRecordBatch(String domainName, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    This method retrieves all pseudonym-records stored in the given domain.
    org.springframework.http.ResponseEntity<?>
    getRecordByIdentifier(String domainName, String identifier, String idType, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    This method retrieves a pseudonym-record through its identifier (id & idType).
    org.springframework.http.ResponseEntity<?>
    getRecordByPseudonym(String domainName, String psn, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    This method retrieves a pseudonym-record through its pseudonym (psn).
    org.springframework.http.ResponseEntity<?>
    updateRecord(String domainName, PseudonymUpdateDTO pseudonymDTO, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    This method updates a pseudonym-record with a reduced set of updatable attributes.
    org.springframework.http.ResponseEntity<?>
    updateRecordBatch(String domainName, List<PseudonymUpdateDTO> pseudonymUpdateList, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    This method updates a list of pseudonym-records in a batch.
    org.springframework.http.ResponseEntity<?>
    updateRecordComplete(String oldDomainName, PseudonymUpdateDTO pseudonymUpdateDTO, Boolean regeneratePseudonym, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    This method updates a pseudonym-record identified by either its id and idType or its psn.
    org.springframework.http.ResponseEntity<?>
    validatePseudonym(String domainName, String psn, String responseContentType, jakarta.servlet.http.HttpServletRequest request)
    This method provides an endpoint to validate pseudonyms.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PseudonymRESTController

      public PseudonymRESTController()
  • Method Details

    • createRecordBatch

      @PostMapping("/domains/{domainName}/pseudonyms/batch") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'record-create-batch\')") public org.springframework.http.ResponseEntity<?> createRecordBatch(@PathVariable("domainName") String domainName, @RequestParam(name="omitPrefix",required=false,defaultValue="false") Boolean omitPrefix, @RequestBody List<PseudonymDTO> recordDtoList, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      This method creates new pseudonymization-records in batches. When an external created pseudonym is given, no new pseudonym is created but the given one is stored.
      Parameters:
      domainName - (required) the name of the domain the pseudonyms should be in
      omitPrefix - (optional) determines whether or not the prefix should be added to the pseudonym
      recordDtoList - (required) the list of necessary information, formatted as a JSON to match the recordDto
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 201-CREATED status and a list of the created pseudonym-objects on success
    • a 404-NOT_FOUND when the domain wasn't found
    • a 422-UNPROCESSABLE_ENTITY when the insertion into the database failed (e.g. due to an expired domain validity period or a batch that exceeds the maximum allowed batch size).
    • a 500-INTERNAL_SERVER_ERROR when the pseudonymization failed
    • a 507-INSUFFICICENT_STORAGE when the domain reached its filling point and we therefore only generated collisions.
    • createRecord

      @PostMapping("/domains/{domainName}/pseudonyms") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'record-create\')") public org.springframework.http.ResponseEntity<?> createRecord(@PathVariable("domainName") String domainName, @RequestBody PseudonymDTO pseudonymDTO, @RequestParam(name="omitPrefix",required=false,defaultValue="false") Boolean omitPrefix, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      This method creates a new pseudonymization-record. When an external created pseudonym is given, no new pseudonym is created but the given one is stored. This method functions as a get-method if the record already exists.
      Parameters:
      domainName - (required) the name of the domain the pseudonym should be in
      pseudonymDTO - (required) the Record object
      omitPrefix - (optional) determines whether or not the prefix should be added to the pseudonym
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status and the pseudonym when the requested insertion would be a duplicate
    • a 201-CREATED status and the created record on success
    • a 404-NOT_FOUND when the domain wasn't found
    • a 422-UNPROCESSABLE_ENTITY when the insertion into the database failed (e.g. due to an expired domain validity period).
    • a 500-INTERNAL_SERVER_ERROR when the pseudonymization failed
    • a 507-INSUFFICICENT_STORAGE when the domain reached its filling point and we therefore only generated collisions.
    • deleteRecordBatch

      @DeleteMapping("/domains/{domainName}/pseudonyms/batch") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'record-delete-batch\')") public org.springframework.http.ResponseEntity<?> deleteRecordBatch(@PathVariable("domainName") String domainName, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      This method deletes all records in the given domain.
      Parameters:
      domainName - (required) the name of the domain the pseudonyms are in
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 204-NO_CONTENT status when the deletion was successful
    • a 206-PARTIAL_CONTENT status and a list of deletion results matching the input list
    • a 404-NOT_FOUND when the given domain wasn't found
    • a 422-UNPROCESSABLE_ENTITY status when the records could not be deleted
    • deleteRecord

      @DeleteMapping("/domains/{domainName}/pseudonyms") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'record-delete\')") public org.springframework.http.ResponseEntity<?> deleteRecord(@PathVariable("domainName") String domainName, @RequestParam(name="id",required=false) String identifier, @RequestParam(name="idType",required=false) String idType, @RequestParam(name="psn",required=false) String psn, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      This method deletes a pseudonym-record. It must be given an identifier and its type or a pseudonym.
      Parameters:
      domainName - (required) the name of the domain the record is in
      identifier - (optional) the identifier to search for
      idType - (optional) the type of the identifier
      psn - (optional) the pseudonym to search for
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 204-NO_CONTENT status when the deletion was successful
    • a 400-BAD_REQUEST when neither an identifier, nor a pseudonym were given
    • a 404-NOT_FOUND when no record was found for the given identifier/pseudonym
    • a 422-UNPROCESSABLE_ENTITY status when the record could not be deleted
    • getLinkedRecords

      @GetMapping(value="/domains/linked-pseudonyms", params={"sourceDomain","targetDomain"}) @PreAuthorize("hasRole(\'record-read\') and hasRole(\'link-pseudonyms\')") public org.springframework.http.ResponseEntity<?> getLinkedRecords(@RequestParam(name="sourceDomain",required=true) String sourceDomain, @RequestParam(name="targetDomain",required=true) String targetDomain, @RequestParam(name="sourceIdentifier",required=false) String sourceIdentifier, @RequestParam(name="sourceIdType",required=false) String sourceIdType, @RequestParam(name="sourcePsn",required=false) String sourcePsn, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      Method to search and link pseudonyms along the pseudonym-chain in the tree.
      Parameters:
      sourceDomain - the starting domain for the search
      targetDomain - the target domain for the search
      sourceIdentifier - (optional) the identifier of the record to start the search from
      sourceIdType - (optional) the idType of the record to start the search from
      sourcePsn - (optional) the pseudonym of the record to start the search from
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status and the list of linked pseudonyms when linkable pseudonyms were found
    • a 403-FORBIDDEN when the requester does not have the rights to access the source and/or target domain
    • a 404-NOT_FOUND when no linkable pseudonyms were found for the given parameters
    • getRecordBatch

      @GetMapping("/domains/{domainName}/pseudonyms/batch") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'record-read-batch\')") public org.springframework.http.ResponseEntity<?> getRecordBatch(@PathVariable("domainName") String domainName, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      This method retrieves all pseudonym-records stored in the given domain.
      Parameters:
      domainName - (required) the name of the domain the pseudonyms are in
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status and the list of records when successful
    • a 404-NOT_FOUND when the given domain wasn't found
    • a 422-UNPROCESSABLE_ENTITY status when the records could not be retrieved
    • getRecordByIdentifier

      @GetMapping(value="/domains/{domainName}/pseudonyms", params={"id","idType"}) @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'record-read\')") public org.springframework.http.ResponseEntity<?> getRecordByIdentifier(@PathVariable("domainName") String domainName, @RequestParam(name="id",required=true) String identifier, @RequestParam(name="idType",required=true) String idType, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      This method retrieves a pseudonym-record through its identifier (id & idType).
      Parameters:
      domainName - (required) the name of the domain the record is in
      identifier - (required) the identifier to search for
      idType - (required) the type of the identifier
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status and the record when it was found
    • a 404-NOT_FOUND when no record was found for the given identifier and idType
    • getRecordByPseudonym

      @GetMapping(value="/domains/{domainName}/pseudonyms", params="psn") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'record-read\')") public org.springframework.http.ResponseEntity<?> getRecordByPseudonym(@PathVariable("domainName") String domainName, @RequestParam(name="psn",required=true) String psn, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      This method retrieves a pseudonym-record through its pseudonym (psn).
      Parameters:
      domainName - (required) the name of the domain the record is in
      psn - (required) the pseudonym to search for
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status and the record when it was found
    • a 404-NOT_FOUND when no record was found for the given pseudonym
    • updateRecordBatch

      @PutMapping("/domains/{domainName}/pseudonyms/batch") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'record-update-batch\')") public org.springframework.http.ResponseEntity<?> updateRecordBatch(@PathVariable("domainName") String domainName, @RequestBody List<PseudonymUpdateDTO> pseudonymUpdateList, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      This method updates a list of pseudonym-records in a batch. Every list entry must contain all necessary information (identifier, idType, pseudonym, validFrom, validFromInherited, validTo, validToInherited).
      Parameters:
      domainName - (required) the name of the domain the pseudonyms are in
      pseudonymUpdateList - (required) the list of necessary information, formatted as a JSON to match the recordDto
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status on success
    • a 404-NOT_FOUND status when the domain couldn't be found
    • a 422-UNPROCESSABLE_ENTITY when the update of the record failed
    • updateRecordComplete

      @PutMapping("/domains/{domainName}/pseudonyms/complete") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #oldDomainName, \'record-update-complete\')") public org.springframework.http.ResponseEntity<?> updateRecordComplete(@PathVariable("domainName") String oldDomainName, @RequestBody PseudonymUpdateDTO pseudonymUpdateDTO, @RequestParam(name="regeneratePseudonym",required=false) Boolean regeneratePseudonym, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      This method updates a pseudonym-record identified by either its id and idType or its psn.
      Parameters:
      oldDomainName - (required) the name of the domain the record should be in
      pseudonymUpdateDTO - (required) the update object containing the identifying and the new data
      regeneratePseudonym - (optional) a flag to keep or regenerate the psn when the identifierItem or the domain changed
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status and the pseudonym of the updated record on success
    • a 400-BAD_REQUEST when neither an identifier, nor a pseudonym were given
    • a 404-NOT_FOUND status when either the domain, the record that should be updated, or the new domain couldn't be found
    • a 422-UNPROCESSABLE_ENTITY when the update of the record failed
    • updateRecord

      @PutMapping("/domains/{domainName}/pseudonyms") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'record-update\')") public org.springframework.http.ResponseEntity<?> updateRecord(@PathVariable("domainName") String domainName, @RequestBody PseudonymUpdateDTO pseudonymDTO, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      This method updates a pseudonym-record with a reduced set of updatable attributes. The record is identified by its id and idType.
      Parameters:
      domainName - (required) the name of the domain the record should be in
      pseudonymDTO - (required) the record object
      responseContentType - (optional) the response content type
      request - the request object, injected by Spring Boot
      Returns:
    • a 200-OK status and the pseudonym on success
    • a 400-BAD_REQUEST when neither an identifier, nor a pseudonym were given
    • a 404-NOT_FOUND status when either the domain or the record that should be updated couldn't be found
    • a 422-UNPROCESSABLE_ENTITY when the update of the record failed
    • validatePseudonym

      @GetMapping("/domains/{domainName}/pseudonyms/validation") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'record-read\')") public org.springframework.http.ResponseEntity<?> validatePseudonym(@PathVariable("domainName") String domainName, @RequestParam(name="psn",required=true) String psn, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request)
      This method provides an endpoint to validate pseudonyms.
      Returns:
    • a 200-OK status and the result of the validity- check for the given pseudonym
    • a 404-NOT_FOUND status when either the domain the pseudonym is on or the record that should be validated couldn't be found
    • a 422-UNPROCESSABLE_ENTITY status if there is no check digit according to the domain