Package org.trustdeck.controller
Class DomainRESTController
java.lang.Object
org.trustdeck.controller.DomainRESTController
@RestController
@EnableMethodSecurity
@RequestMapping("/api")
public class DomainRESTController
extends Object
This class encapsulates the requests for domains in a controller for the REST-API.
This REST-API offers full access to the data items.
- Author:
- Armin Müller and Eric Wündisch
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<?> createDomain(DomainDTO domainDTO, String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to create a new domain with a reduced set of attributes.org.springframework.http.ResponseEntity<?> createDomainComplete(DomainDTO domainDTO, String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to create a new domain.org.springframework.http.ResponseEntity<?> deleteDomain(String domainName, Boolean performRecursiveChanges, String responseContentType, jakarta.servlet.http.HttpServletRequest request) This method deletes a domain.org.springframework.http.ResponseEntity<?> getDomain(String domainName, String responseContentType, jakarta.servlet.http.HttpServletRequest request) This method retrieves a domain through its name.org.springframework.http.ResponseEntity<?> getDomainAttribute(String domainName, String attributeName, String responseContentType, jakarta.servlet.http.HttpServletRequest request) This method allows to read only a single attribute of a domain and nothing else.org.springframework.http.ResponseEntity<?> getDomainSubtree(String domainName, String responseContentType, jakarta.servlet.http.HttpServletRequest request) This method returns all domains from the database in a minimal version.org.springframework.http.ResponseEntity<?> listDomainHierarchy(String responseContentType, jakarta.servlet.http.HttpServletRequest request) This method returns all domains from the database in a list of trees with each domains children inlined.org.springframework.http.ResponseEntity<?> updateDomain(String oldDomainName, DomainDTO domainDTO, String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to update a domain with a reduced set of updatable attributes.org.springframework.http.ResponseEntity<?> updateDomainComplete(String oldDomainName, Boolean performRecursiveChanges, DomainDTO domainDTO, String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to update a domain.org.springframework.http.ResponseEntity<?> updateSalt(String domainName, String newSalt, Boolean allowEmpty, String responseContentType, jakarta.servlet.http.HttpServletRequest request) This method updates the salt variable of a domain.
-
Constructor Details
-
DomainRESTController
public DomainRESTController()
-
-
Method Details
-
createDomainComplete
@PostMapping("/domains/complete") @PreAuthorize("hasRole(\'domain-create-complete\')") public org.springframework.http.ResponseEntity<?> createDomainComplete(@RequestBody DomainDTO domainDTO, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to create a new domain. Creates the record inside the domain table.- Parameters:
domainDTO- (required) the domain objectresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 201-CREATED status and the location to the domain inside the response header on success
- a 400-BAD_REQUEST when both, the super-domain name and the super-domain ID were given
- a 404-NOT_FOUND when the provided parent domain could not be found
- a 406-NOT_ACCEPTABLE status when the domain name is violating the URI-validity
- a 422-UNPROCESSABLE_ENTITY when the addition of the domain meta-information failed or when a check digit should be calculated and the provided alphabet length is not an even number
-
createDomain
@PostMapping("/domains") @PreAuthorize("hasRole(\'domain-create\')") public org.springframework.http.ResponseEntity<?> createDomain(@RequestBody DomainDTO domainDTO, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to create a new domain with a reduced set of attributes. Creates the record inside the domain table.- Parameters:
domainDTO- (required) the domain objectresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 200-OK status when the domain was already in the database
- a 201-CREATED status and the location to the domain inside the response header on success
- a 404-NOT_FOUND when the provided parent domain could not be found
- a 406-NOT_ACCEPTABLE status when the domain name is violating the URI-validity
- a 422-UNPROCESSABLE_ENTITY when the addition of the domain failed or when the DTO was invalid
-
deleteDomain
@DeleteMapping("/domains") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'domain-delete\')") public org.springframework.http.ResponseEntity<?> deleteDomain(@RequestParam(name="name",required=true) String domainName, @RequestParam(name="recursive",required=false) Boolean performRecursiveChanges, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) This method deletes a domain. A domain name must be provided.- Parameters:
domainName- (required) the name of the domain that should be deletedperformRecursiveChanges- (optional) specifies whether or not changes should be cascaded to sub-domainsresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 204-NO_CONTENT status when the deletion was successful
- a 404-NOT_FOUND when no domain was found for the given name
- a 500-INTERNAL_SERVER_ERROR status when the domain could not be deleted
-
getDomainAttribute
@GetMapping("/domains/{domainName}/{attribute}") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'domain-read\')") public org.springframework.http.ResponseEntity<?> getDomainAttribute(@PathVariable("domainName") String domainName, @PathVariable("attribute") String attributeName, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) This method allows to read only a single attribute of a domain and nothing else.- Parameters:
domainName- (required) the name of the domainattributeName- (required) the name of the attribute that should be retrieved from the domainresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 200-OK status and the attribute when it was found
- a 403-FORBIDDEN when the rights for accessing the attribute were not found in the token
- a 404-NOT_FOUND when no domain was found for the given name or the when given attribute name wasn't found
-
getDomain
@GetMapping("/domains") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'domain-read\')") public org.springframework.http.ResponseEntity<?> getDomain(@RequestParam(name="name",required=true) String domainName, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) This method retrieves a domain through its name.- Parameters:
domainName- (required) the name of the domain to search forresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 200-OK status and the domain when it was found
- a 404-NOT_FOUND when no domain was found for the given name
-
getDomainSubtree
@GetMapping("/domains/{domainName}/subtree") @PreAuthorize("hasRole(\'domain-read-subtree\')") public org.springframework.http.ResponseEntity<?> getDomainSubtree(@PathVariable("domainName") String domainName, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) This method returns all domains from the database in a minimal version.- Parameters:
domainName- the domain's nameresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 200-OK status and the list of domains when the query was successful
- a 404-NOT_FOUND status, when the given domain could not be found
-
listDomainHierarchy
@GetMapping("/domains/hierarchy") @PreAuthorize("hasRole(\'domain-list-all\')") public org.springframework.http.ResponseEntity<?> listDomainHierarchy(@RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) This method returns all domains from the database in a list of trees with each domains children inlined.- Parameters:
responseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 200-OK status and the list of domain trees when the query was successful
-
updateDomainComplete
@PutMapping("/domains/complete") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #oldDomainName, \'domain-update-complete\')") public org.springframework.http.ResponseEntity<?> updateDomainComplete(@RequestParam(name="name",required=true) String oldDomainName, @RequestParam(name="recursive",required=true) Boolean performRecursiveChanges, @RequestBody DomainDTO domainDTO, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to update a domain.- Parameters:
oldDomainName- (required) the name of the domain that is to be updatedperformRecursiveChanges- (required) specifies whether or not changes should be cascaded to sub-domainsdomainDTO- (required) the domain objectresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 200-OK status when the update was successful
- a 404-NOT_FOUND when the domain that should be updated couldn't be found
- a 406-NOT_ACCEPTABLE status when the new domain name is violating the URI-validity
- a 422-UNPROCESSABLE_ENTITY when updating the domain failed
-
updateDomain
@PutMapping("/domains") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #oldDomainName, \'domain-update\')") public org.springframework.http.ResponseEntity<?> updateDomain(@RequestParam(name="name",required=true) String oldDomainName, @RequestBody DomainDTO domainDTO, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) Method to update a domain with a reduced set of updatable attributes. The attributes newPrefix, algorithm, consecVal, psnLength, and paddingChar are only updatable when the domain is still empty.- Parameters:
oldDomainName- (required) the name of the domain that is to be updateddomainDTO- (required) The domain objectresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 200-OK status when the update was successful
- a 404-NOT_FOUND when the domain that should be updated couldn't be found
- a 422-UNPROCESSABLE_ENTITY when updating the domain failed
-
updateSalt
@PutMapping("/domains/{domainName}/salt") @PreAuthorize("@auth.hasDomainRoleRelationship(#root, #domainName, \'domain-update-salt\')") public org.springframework.http.ResponseEntity<?> updateSalt(@PathVariable("domainName") String domainName, @RequestParam(name="salt",required=true) String newSalt, @RequestParam(name="allowEmpty",required=false,defaultValue="false") Boolean allowEmpty, @RequestHeader(name="accept",required=false) String responseContentType, jakarta.servlet.http.HttpServletRequest request) This method updates the salt variable of a domain.- Parameters:
domainName- (required) the name of the domain for which the salt value should be updatednewSalt- (required) the new salt valueallowEmpty- (optional) determines whether or not the given salt is allowed to be emptyresponseContentType- (optional) the response content typerequest- the request object, injected by Spring Boot- Returns:
- a 200-OK status when the update was successful
- a 400-BAD_REQUEST when the given salt value was empty
- a 404-NOT_FOUND when no domain was found for the given name
- a 422-UNPROCESSABLE_ENTITY when updating the salt value failed
-