Class ErrorResolver


  • public class ErrorResolver
    extends java.lang.Object
    Utility class to parse specific UI-Errors types from the UI-Error-Binding.
    There are 3 Error types:
    • ValidationErrors: Indicating that the user input is considered invalid. They have no specific type, just the default type FieldError
    • Conflicts: Indicating that the configuration engine has determined a conflict for one or many cstic(-values). They are of specific type ConflictError
    • Missing Mandatory Fields: Indicating that a cstic has no value assigned, although it is considered mandatory by configuration engine. They are of specific type MandatoryFieldError
    Additionally this class can be used to create UI error messages from the UI errors.
    • Method Detail

      • getConflictErrors

        public static java.util.List<ErrorMessage> getConflictErrors​(org.springframework.validation.BindingResult bindResult)
        Get for each error of type ConflictError an error message.
        Parameters:
        bindResult - all UI errors
        Returns:
        list of error messages
      • getMandatoryFieldErrors

        public static java.util.List<ErrorMessage> getMandatoryFieldErrors​(org.springframework.validation.BindingResult bindResult)
        Get for each error of type MandatoryFieldError an error message.
        Parameters:
        bindResult - all UI errors
        Returns:
        list of error messages
      • getWarnings

        public static java.util.List<ErrorMessage> getWarnings​(org.springframework.validation.BindingResult bindResult)
        Get for each error that is either of type MandatoryFieldError or of type ConflictError an error message.
        Parameters:
        bindResult - all UI errors
        Returns:
        list of error messages
      • getValidationErrors

        public static java.util.List<ErrorMessage> getValidationErrors​(org.springframework.validation.BindingResult bindResult)
        Get for each error that is neither of type MandatoryFieldError nor of type ConflictError an error message. Those errors are the classical validation errors.
        Parameters:
        bindResult - all UI errors
        Returns:
        list of error messages
      • getValidationErrorsForCstic

        public static java.util.List<ErrorMessage> getValidationErrorsForCstic​(org.springframework.validation.BindingResult bindResult,
                                                                               java.lang.String path)
        Get for each error that is neither of type MandatoryFieldError nor of type ConflictError an error message. Those errors are the classical validation errors.
        The Result is filtered for the given cstic path.
        Parameters:
        bindResult - all UI errors
        path - UI path identifying a cstic
        Returns:
        list of error messages
      • hasErrorMessages

        public static boolean hasErrorMessages​(org.springframework.validation.BindingResult bindResult)
        Checks whether the configuration has at lest one classical ValidationError, so an error that is neither of type MandatoryFieldError nor of type ConflictError.
        Parameters:
        bindResult - all UI errors
        Returns:
        true only if at least one validation error exists.
      • getWarningsForCstic

        public static java.util.List<ErrorMessage> getWarningsForCstic​(org.springframework.validation.BindingResult bindResult,
                                                                       java.lang.String path)
        Get for each error that is either of type MandatoryFieldError or of type ConflictError an error message.
        The Result is filtered for the given cstic path.
        Parameters:
        bindResult - all UI errors
        path - UI path identifying a cstic
        Returns:
        list of error messages
      • isWarningMessage

        protected static boolean isWarningMessage​(org.springframework.validation.FieldError objError)
      • isErrorMessage

        protected static boolean isErrorMessage​(org.springframework.validation.FieldError objError)
      • createErrorMessageBasedOnType

        protected static ErrorMessage createErrorMessageBasedOnType​(org.springframework.validation.FieldError objError)
      • createErrorMessageMandatoryFieldType

        protected static ErrorMessage createErrorMessageMandatoryFieldType​(org.springframework.validation.FieldError objError)
      • createErrorMessageForConflictType

        protected static ErrorMessage createErrorMessageForConflictType​(org.springframework.validation.FieldError objError)
      • createErrorMessageForErrorType

        protected static ErrorMessage createErrorMessageForErrorType​(org.springframework.validation.FieldError objError)
      • createErrorMessageForType

        protected static ErrorMessage createErrorMessageForType​(org.springframework.validation.FieldError objError,
                                                                ErrorType type)
      • getErrorMessages

        protected static java.util.List<ErrorMessage> getErrorMessages​(java.util.List<org.springframework.validation.FieldError> errorList,
                                                                       java.util.function.Predicate<org.springframework.validation.FieldError> filter,
                                                                       java.util.function.Function<org.springframework.validation.FieldError,​ErrorMessage> mapper)
      • isMandatoryFieldError

        protected static boolean isMandatoryFieldError​(org.springframework.validation.FieldError error)
      • isConfigError

        protected static boolean isConfigError​(org.springframework.validation.FieldError error)