Class CNFormFieldValidator


  • public abstract class CNFormFieldValidator
    extends Object
    • Constructor Detail

      • CNFormFieldValidator

        public CNFormFieldValidator()
    • Method Detail

      • checkInterpretedString

        public static void checkInterpretedString​(String str)
                                           throws FormValidation
        Utility function to check that a str contains only valid environmental variables to interpret.
        Parameters:
        str - the string to test.
        Throws:
        FormValidation - error message, if any variables are missing, null if all are found.
      • checkUrl

        public static FormValidation checkUrl​(String url)
        Returns form validation that represents the validity of the URL.
      • requiredCheck

        public static FormValidation requiredCheck​(String value,
                                                   String name)
        Class for checking that a required value is set. Expects a StaplerRequest with a value set to the value and a name set to the name of what is being set (used for error msg).
      • interpretedCheck

        public static FormValidation interpretedCheck​(String str,
                                                      String name,
                                                      boolean isRequired)
                                               throws FormValidation
        Class for checking an unrequired value that may include interpreted strings (i.e. Jenkins environmental values). Expects a StaplerRequest with value. If it's a required value, expects a value name.
        Throws:
        FormValidation
      • hostUrlCheck

        public static FormValidation hostUrlCheck​(String hostUrl)
        Class for checking if a Host URL is correct. Expects a StaplerRequest with value set to the url.
      • soapUrlCheck

        public static FormValidation soapUrlCheck​(String collabNetUrl)
        Class for checking if a URL is correct and corresponds to a CollabNet server. Expects a StaplerRequest with value set to the url.
      • checkSoapUrl

        public static FormValidation checkSoapUrl​(String collabNetUrl)
        Check that a URL has the expected SOAP service.
        Parameters:
        collabNetUrl - for the CollabNet server
        Returns:
        returns the validation result of the URL.
      • loginCheck

        public static FormValidation loginCheck​(CollabNetApp app,
                                                String password)
        Class for checking that a login to CollabNet is valid. Expects a StaplerRequest with url, username, and password set.
      • documentPathCheck

        public static FormValidation documentPathCheck​(CollabNetApp app,
                                                       String project,
                                                       String path)
                                                throws IOException
        Class to check that the path to a document exists. Warns about any missing folders. Expects a StaplerRequest with url, username, password, project, and path.
        Throws:
        IOException
      • repoCheck

        public static FormValidation repoCheck​(org.kohsuke.stapler.StaplerRequest request)
                                        throws IOException
        Class to check that a repo exists. Expects a StaplerRequest with a url, username, password, and project.
        Throws:
        IOException
      • assignCheck

        public static FormValidation assignCheck​(CollabNetApp cna,
                                                 String project,
                                                 String assign)
                                          throws IOException
        Class for checking if a user can be assigned a tracker artifact. Expects a StaplerRequest with login info (url, username, password), project, and assign (which is the username).
        Throws:
        IOException
      • userListCheck

        public static FormValidation userListCheck​(String userStr)
                                            throws IOException
        Check that a comma-separated list of users exists. The check only works for a logged-in site-admin. Otherwise, give a warning that we cannot check the users' validity.
        Throws:
        IOException
      • groupListCheck

        public static FormValidation groupListCheck​(String groupStr,
                                                    String userStr)
                                             throws IOException
        Check that a comma-separated list of groups exists. The check only works for a logged-in site-admin. Also warns the current user if s/he will be locked out once that user saves the configuration.
        Throws:
        IOException
      • regexCheck

        public static FormValidation regexCheck​(String regex)
        Class to check for validity of a regex expression. Expects a StaplerRequest with value set.
      • numberCheck

        public static FormValidation numberCheck​(String number,
                                                 boolean allowPositive,
                                                 boolean allowZero,
                                                 boolean allowNegative)
        Perform checking of number
        Parameters:
        number - the number
        allowPositive - true to allow positive
        allowZero - true to allow zero
        allowNegative - true to allow negative
        Returns:
        validation