Class HALMConnection.DescriptorImpl
- java.lang.Object
-
- hudson.model.Descriptor<HALMConnection>
-
- com.perforce.halm.jenkins.globalconfig.HALMConnection.DescriptorImpl
-
- Enclosing class:
- HALMConnection
@Extension public static class HALMConnection.DescriptorImpl extends Descriptor<HALMConnection>
Used for validating the HALMConnection's config.jelly
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.model.Descriptor
Descriptor.FormException, Descriptor.PropertyType, Descriptor.Self
-
-
Field Summary
-
Fields inherited from class hudson.model.Descriptor
clazz
-
-
Constructor Summary
Constructors Constructor Description DescriptorImpl()
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FormValidation
compareVersions(int[] minimumVersion, String versionToCheck)
Compares a string based version (ex: "2022.2.0" vs a numeric based minimum version, ex: [2022, 2, 0] to determine if the string based version is equal to, or newer than, the minimum version.FormValidation
doCheckAddress(String halmAPIAddress)
Validates that the address provided by the user is valid.FormValidation
doCheckConnectionName(String connectionName)
Verifies that the connection name is not blank.FormValidation
doCheckCredentialsID(String credentialsID)
Checks that the credentials ID has been set.ListBoxModel
doFillCredentialsIDItems(Item context, String remote)
Fills the 'Credentials' dropdown.ListBoxModel
doFillCredentialTypeValueItems()
Populates the 'credentialType' dropdown with appropriate values.FormValidation
doTestConnection(String connectionUUID, String connectionName, String halmAPIAddress, String credentialTypeValue, String credentialsID, boolean acceptSSLCertificates)
Validates that the provided HALM connection information settings are valid.static String
encodeInputAsValidFilename(String input)
Returns an encoded version of the given string that will be a valid filename.String
getDisplayName()
-
Methods inherited from class hudson.model.Descriptor
addHelpFileRedirect, bindJSON, calcAutoCompleteSettings, calcFillSettings, configure, configure, doHelp, find, find, findByDescribableClassName, findById, getCategory, getCheckMethod, getCheckUrl, getConfigFile, getConfigPage, getCurrentDescriptorByNameUrl, getDescriptorFullUrl, getDescriptorUrl, getGlobalConfigPage, getGlobalPropertyType, getHelpFile, getHelpFile, getHelpFile, getId, getJsonSafeClassName, getKlass, getPlugin, getPossibleViewNames, getPropertyType, getPropertyType, getPropertyTypeOrDie, getRequiredGlobalConfigPagePermission, getT, getViewPage, isInstance, isSubTypeOf, load, newInstance, newInstance, newInstancesFromHeteroList, newInstancesFromHeteroList, save, self, toArray, toList, toMap
-
-
-
-
Method Detail
-
getDisplayName
@NonNull public String getDisplayName()
- Overrides:
getDisplayName
in classDescriptor<HALMConnection>
-
doFillCredentialsIDItems
public ListBoxModel doFillCredentialsIDItems(@AncestorInPath Item context, @QueryParameter String remote)
Fills the 'Credentials' dropdown.- Parameters:
context
- - used to determine if the user can get a list of usersremote
- - the remote server in question- Returns:
- Returns the list of items to put into the Credentials dropdown.
-
doFillCredentialTypeValueItems
public ListBoxModel doFillCredentialTypeValueItems()
Populates the 'credentialType' dropdown with appropriate values.- Returns:
- Credential Type dropdown list values.
-
doCheckAddress
@POST public FormValidation doCheckAddress(@QueryParameter("value") String halmAPIAddress)
Validates that the address provided by the user is valid. This is called when the HALM address field loses focus after text is entered. It is an ajax call defined in the config.jelly which calls this function. The @POST just above the function is recommended in the dev docs for Jenkins. It is not required, but is included for security concerns: https://www.jenkins.io/doc/developer/security/form-validation/- Parameters:
halmAPIAddress
- HALM REST API address- Returns:
- Form validation status.
-
doCheckConnectionName
@POST public FormValidation doCheckConnectionName(@QueryParameter("connectionName") String connectionName)
Verifies that the connection name is not blank.- Parameters:
connectionName
- Connection name to verify- Returns:
- FormValidation.Ok if the connection name is not blank.
-
doCheckCredentialsID
@POST public FormValidation doCheckCredentialsID(@QueryParameter("credentialsID") String credentialsID)
Checks that the credentials ID has been set.- Parameters:
credentialsID
- The selection in the credentials dropdown- Returns:
- Returns Ok if there is something selected, an error otherwise.
-
doTestConnection
@POST public FormValidation doTestConnection(@QueryParameter("connectionUUID") String connectionUUID, @QueryParameter("connectionName") String connectionName, @QueryParameter("halmAPIAddress") String halmAPIAddress, @QueryParameter("credentialTypeValue") String credentialTypeValue, @QueryParameter("credentialsID") String credentialsID, @QueryParameter("acceptSSLCertificates") boolean acceptSSLCertificates)
Validates that the provided HALM connection information settings are valid. This is called when the 'Test Connection' button is pressed. The @POST just above the function is recommended in the dev docs for Jenkins. It is not required, but is included for security concerns: https://www.jenkins.io/doc/developer/security/form-validation/- Parameters:
connectionUUID
- the connection's UUID, if it exists.connectionName
- the connection's name from the fieldhalmAPIAddress
- HALM REST API addresscredentialTypeValue
- Basic vs Auth from the dropdowncredentialsID
- Credential ID from Credentials pluginacceptSSLCertificates
- Should this accept invalid certs?- Returns:
- Form validation status.
-
encodeInputAsValidFilename
public static String encodeInputAsValidFilename(String input) throws UnsupportedEncodingException
Returns an encoded version of the given string that will be a valid filename.- Parameters:
input
- The input string to encode- Returns:
- See description
- Throws:
UnsupportedEncodingException
- File must be UTF-8 encoded
-
compareVersions
public static FormValidation compareVersions(int[] minimumVersion, String versionToCheck)
Compares a string based version (ex: "2022.2.0" vs a numeric based minimum version, ex: [2022, 2, 0] to determine if the string based version is equal to, or newer than, the minimum version.- Parameters:
minimumVersion
- Minimum supported version, as a numeric array: Ex: [2022, 2, 0]versionToCheck
- Current version, as text. Ex: "2022.2.0"- Returns:
- FormValidation.OK on success, a FormValidation error otherwise.
-
-