Class ValidatorsRestController

  • All Implemented Interfaces:
    ValidatorsRestOpenApi

    @RestController
    @RequestMapping("/v2.1.1/configuration-validators/")
    public class ValidatorsRestController
    extends Object
    implements ValidatorsRestOpenApi
    The definition of the Validator Rest Controller.
    Author:
    Mauricio Ruiz Beltrán <mauricio.ruiz@kuwaiba.org>
    • Constructor Detail

      • ValidatorsRestController

        public ValidatorsRestController()
    • Method Detail

      • createValidatorDefinition

        @RequestMapping(method=POST,
                        value="createValidatorDefinition/{name}/{description}/{className}/{script}/{enabled}/{userName}/{sessionId}",
                        produces="application/json")
        public long createValidatorDefinition​(@PathVariable("name")
                                              String name,
                                              @PathVariable("description")
                                              String description,
                                              @PathVariable("className")
                                              String className,
                                              @PathVariable("script")
                                              String script,
                                              @PathVariable("enabled")
                                              boolean enabled,
                                              @PathVariable("userName")
                                              String userName,
                                              @PathVariable("sessionId")
                                              String sessionId)
        Creates a validator definition.
        Specified by:
        createValidatorDefinition in interface ValidatorsRestOpenApi
        Parameters:
        name - The name of the validator. It's recommended to use camel case notation (for example thisIsAName). This field is mandatory
        description - The optional description of the validator.
        className - The class or super class of the classes whose instances will be checked against this validator.
        script - The groovy script containing the logic of the validator , that is, the.
        enabled - If this validador should be applied or not.
        userName - The session token user name.
        sessionId - The session token id.
        Returns:
        The id of the newly created validator definition.
      • updateValidatorDefinition

        @RequestMapping(method=PUT,
                        value="updateValidatorDefinition/{id}/{name}/{description}/{className}/{script}/{enabled}/{userName}/{sessionId}",
                        produces="application/json")
        public void updateValidatorDefinition​(@PathVariable("id")
                                              long id,
                                              @PathVariable("name")
                                              String name,
                                              @PathVariable("description")
                                              String description,
                                              @PathVariable("className")
                                              String className,
                                              @PathVariable("script")
                                              String script,
                                              @PathVariable("enabled")
                                              boolean enabled,
                                              @PathVariable("userName")
                                              String userName,
                                              @PathVariable("sessionId")
                                              String sessionId)
        Updates the properties of a validator. The null values will be ignored.
        Specified by:
        updateValidatorDefinition in interface ValidatorsRestOpenApi
        Parameters:
        id - The id of teh validator definition to be updated.
        name - The new name, if any, null otherwise.
        description - The new description, if any, null otherwise.
        className - The new class to be associated to this validator, if any, null otherwise.
        script - The new script, if any, null otherwise.
        enabled - If the validator should be enabled or not, if any, null otherwise.
        userName - The session token user name.
        sessionId - The session token id.
      • getValidatorDefinitionsForClass

        @RequestMapping(method=GET,
                        value="getValidatorDefinitionsForClass/{className}/{sessionId}",
                        produces="application/json")
        public List<ValidatorDefinition> getValidatorDefinitionsForClass​(@PathVariable("className")
                                                                         String className,
                                                                         @PathVariable("sessionId")
                                                                         String sessionId)
        Retrieves all the validator definitions in the system.
        Specified by:
        getValidatorDefinitionsForClass in interface ValidatorsRestOpenApi
        Parameters:
        className - The class to retrieve the validator definitions from.
        sessionId - The session token id.
        Returns:
        The list of validator definitions.
      • getAllValidatorDefinitions

        @RequestMapping(method=GET,
                        value="getAllValidatorDefinitions/{sessionId}",
                        produces="application/json")
        public List<ValidatorDefinition> getAllValidatorDefinitions​(@PathVariable("sessionId")
                                                                    String sessionId)
        Gets all validator definitions, no matter what class they are related to.
        Specified by:
        getAllValidatorDefinitions in interface ValidatorsRestOpenApi
        Parameters:
        sessionId - The session token id.
        Returns:
        The list of validators.
      • runValidationsForObject

        @RequestMapping(method=POST,
                        value="runValidationsForObject/{className}/{id}/{sessionId}",
                        produces="application/json")
        public List<Validator> runValidationsForObject​(@PathVariable("className")
                                                       String className,
                                                       @PathVariable("id")
                                                       long id,
                                                       @PathVariable("sessionId")
                                                       String sessionId)
        Runs the existing validations for the class associated to the given object. Validators set to enabled = false will be ignored.
        Specified by:
        runValidationsForObject in interface ValidatorsRestOpenApi
        Parameters:
        className - The class of the object.
        id - The id of the object.
        sessionId - The session token id.
        Returns:
        The list of validators associated to the object and its class.
      • deleteValidatorDefinition

        @RequestMapping(method=DELETE,
                        value="deleteValidatorDefinition/{id}/{userName}/{sessionId}",
                        produces="application/json")
        public void deleteValidatorDefinition​(@PathVariable("id")
                                              long id,
                                              @PathVariable("userName")
                                              String userName,
                                              @PathVariable("sessionId")
                                              String sessionId)
        Deletes a validator definition.
        Specified by:
        deleteValidatorDefinition in interface ValidatorsRestOpenApi
        Parameters:
        id - The id of the validator to be deleted.
        userName - The session token user name.
        sessionId - The session token id.