Package hudson.plugins.collabnet.util
Class CNFormFieldValidator
- java.lang.Object
-
- hudson.plugins.collabnet.util.CNFormFieldValidator
-
public abstract class CNFormFieldValidator extends Object
-
-
Constructor Summary
Constructors Constructor Description CNFormFieldValidator()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FormValidation
assignCheck(CollabNetApp cna, String project, String assign)
Class for checking if a user can be assigned a tracker artifact.static void
checkInterpretedString(String str)
Utility function to check that a str contains only valid environmental variables to interpret.static FormValidation
checkSoapUrl(String collabNetUrl)
Check that a URL has the expected SOAP service.static FormValidation
checkUrl(String url)
Returns form validation that represents the validity of the URL.static FormValidation
documentPathCheck(CollabNetApp app, String project, String path)
Class to check that the path to a document exists.static org.apache.http.impl.client.CloseableHttpClient
getHttpClient()
static FormValidation
groupListCheck(String groupStr, String userStr)
Check that a comma-separated list of groups exists.static FormValidation
hostUrlCheck(String hostUrl)
Class for checking if a Host URL is correct.static FormValidation
interpretedCheck(String str, String name, boolean isRequired)
Class for checking an unrequired value that may include interpreted strings (i.e.static FormValidation
loginCheck(CollabNetApp app, String password)
Class for checking that a login to CollabNet is valid.static FormValidation
numberCheck(String number, boolean allowPositive, boolean allowZero, boolean allowNegative)
Perform checking of numberstatic FormValidation
packageCheck(CollabNetApp cna, String project, String rpackage)
Class to check that a package exists.static FormValidation
projectCheck(CollabNetApp app, String project)
Checks if a project name is valid, by using the given connection.static FormValidation
regexCheck(String regex)
Class to check for validity of a regex expression.static FormValidation
releaseCheck(CollabNetApp cna, String project, String rpackage, String release, boolean required)
Class to check that a release exists.static FormValidation
repoCheck(org.kohsuke.stapler.StaplerRequest request)
Class to check that a repo exists.static FormValidation
requiredCheck(String value, String name)
Class for checking that a required value is set.static FormValidation
requiredInterpretedCheck(String str, String name)
Class for checking an interpreted string which is required.static FormValidation
soapUrlCheck(String collabNetUrl)
Class for checking if a URL is correct and corresponds to a CollabNet server.static FormValidation
trackerCheck(CollabNetApp cna, String project, String tracker)
Class to check that a tracker exists.static FormValidation
unrequiredInterpretedCheck(String str, String name)
Class for checking an interpreted string which is unrequired.static FormValidation
userListCheck(String userStr)
Check that a comma-separated list of users exists.
-
-
-
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.
-
getHttpClient
public static org.apache.http.impl.client.CloseableHttpClient getHttpClient() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException
-
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
-
unrequiredInterpretedCheck
public static FormValidation unrequiredInterpretedCheck(String str, String name) throws FormValidation
Class for checking an interpreted string which is unrequired.- Throws:
FormValidation
-
requiredInterpretedCheck
public static FormValidation requiredInterpretedCheck(String str, String name) throws FormValidation
Class for checking an interpreted string which is required.- 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.
-
projectCheck
public static FormValidation projectCheck(CollabNetApp app, String project) throws IOException
Checks if a project name is valid, by using the given connection.- Throws:
IOException
-
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
-
packageCheck
public static FormValidation packageCheck(CollabNetApp cna, String project, String rpackage) throws IOException
Class to check that a package exists. Expects a StaplerRequest with a url, username, password, project, and package.- Throws:
IOException
-
releaseCheck
public static FormValidation releaseCheck(CollabNetApp cna, String project, String rpackage, String release, boolean required) throws IOException
Class to check that a release exists. Expects a StaplerRequest with a url, username, password, project, package (optional), and release.- 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
-
trackerCheck
public static FormValidation trackerCheck(CollabNetApp cna, String project, String tracker) throws IOException
Class to check that a tracker exists. Expects a StaplerRequest with a url, username, password, project, and tracker.- 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 numberallowPositive
- true to allow positiveallowZero
- true to allow zeroallowNegative
- true to allow negative- Returns:
- validation
-
-