本文整理匯總了Java中hudson.util.FormValidation類的典型用法代碼示例。如果您正苦於以下問題:Java FormValidation類的具體用法?Java FormValidation怎麽用?Java FormValidation使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FormValidation類屬於hudson.util包,在下文中一共展示了FormValidation類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doTestConnection
import hudson.util.FormValidation; //導入依賴的package包/類
public FormValidation doTestConnection(@QueryParameter("telegramToken") final String authToken,
@QueryParameter("telegramChatId") final String chatId,
@QueryParameter("telegramBuildServerUrl") final String buildServerUrl) throws FormException {
try {
String targetToken = authToken;
if (StringUtils.isEmpty(targetToken)) {
targetToken = this.token;
}
String targetChatId = chatId;
if (StringUtils.isEmpty(targetChatId)) {
targetChatId = this.chatId;
}
String targetBuildServerUrl = buildServerUrl;
if (StringUtils.isEmpty(targetBuildServerUrl)) {
targetBuildServerUrl = this.buildServerUrl;
}
TelegramService testTelegramService = getTelegramService(targetToken, targetChatId);
String message = "Telegram/Jenkins plugin: you're all set on " + targetBuildServerUrl;
boolean success = testTelegramService.publish(message, "good");
return success ? FormValidation.ok("Success") : FormValidation.error("Failure");
} catch (Exception e) {
return FormValidation.error("Client error : " + e.getMessage());
}
}
示例2: doCheckToken
import hudson.util.FormValidation; //導入依賴的package包/類
/**
* Sanity check for a Gitea access token.
*
* @param value the token.
* @return the resulst of the sanity check.
*/
@Restricted(NoExternalUse.class) // stapler
@SuppressWarnings("unused") // stapler
public FormValidation doCheckToken(@QueryParameter String value) {
Secret secret = Secret.fromString(value);
if (secret == null) {
return FormValidation.error(Messages.PersonalAccessTokenImpl_tokenRequired());
}
if (StringUtils.equals(value, secret.getPlainText())) {
if (value.length() != 40) {
return FormValidation.error(Messages.PersonalAccessTokenImpl_tokenWrongLength());
}
} else if (secret.getPlainText().length() != 40) {
return FormValidation.warning(Messages.PersonalAccessTokenImpl_tokenWrongLength());
}
return FormValidation.ok();
}
示例3: doTestConnection
import hudson.util.FormValidation; //導入依賴的package包/類
public FormValidation doTestConnection(@AncestorInPath ItemGroup context,
@QueryParameter("credentialsId") final String credentialsId) {
String targetAPI = chooseTargetAPI(environment);
if (!credentialsId.equals(preCredentials) || Util.isNullOrEmpty(bluemixToken)) {
preCredentials = credentialsId;
try {
String newToken = getBluemixToken(context, credentialsId, targetAPI);
if (Util.isNullOrEmpty(newToken)) {
bluemixToken = newToken;
return FormValidation.warning("<b>Got empty token</b>");
} else {
return FormValidation.okWithMarkup("<b>Connection successful</b>");
}
} catch (Exception e) {
return FormValidation.error("Failed to log in to Bluemix, please check your username/password");
}
} else {
return FormValidation.okWithMarkup("<b>Connection successful</b>");
}
}
示例4: doTestConnection
import hudson.util.FormValidation; //導入依賴的package包/類
public FormValidation doTestConnection(@AncestorInPath ItemGroup context,
@QueryParameter("credentialsId") final String credentialsId) {
String targetAPI = chooseTargetAPI(environment);
if (!credentialsId.equals(preCredentials) || Util.isNullOrEmpty(bluemixToken)) {
preCredentials = credentialsId;
try {
String newToken = getBluemixToken(context, credentialsId, targetAPI);
if (Util.isNullOrEmpty(newToken)) {
bluemixToken = newToken;
return FormValidation.warning("<b>Got empty token</b>");
} else {
return FormValidation.okWithMarkup("<b>Connection successful</b>");
}
} catch (Exception e) {
return FormValidation.error("Failed to log in to Bluemix, please check your username/password");
}
} else {
return FormValidation.okWithMarkup("<b>Connection successful</b>");
}
}
示例5: doCheckQueueUuid
import hudson.util.FormValidation; //導入依賴的package包/類
public FormValidation doCheckQueueUuid(@QueryParameter final String value) {
if (this.getSqsQueues().size() == 0) {
return FormValidation.error(Messages.errorQueueUnavailable());
}
if (StringUtils.isEmpty(value)) {
return FormValidation.ok(Messages.infoQueueDefault());
}
final SQSQueue queue = this.getSqsQueue(value);
if (queue == null) {
return FormValidation.error(Messages.errorQueueUuidUnknown());
}
return FormValidation.ok();
}
示例6: doTestConnection
import hudson.util.FormValidation; //導入依賴的package包/類
public FormValidation doTestConnection(
@QueryParameter("mirrorGateAPIUrl") final String mirrorGateAPIUrl,
@QueryParameter("mirrorgateCredentialsId") final String credentialsId)
throws Descriptor.FormException {
MirrorGateService testMirrorGateService = getMirrorGateService();
if (testMirrorGateService != null) {
MirrorGateResponse response
= testMirrorGateService.testConnection();
return response.getResponseCode() == HttpStatus.SC_OK
? FormValidation.ok("Success")
: FormValidation.error("Failure<"
+ response.getResponseCode() + ">");
} else {
return FormValidation.error("Failure");
}
}
示例7: doCheckMirrorgateCredentialsId
import hudson.util.FormValidation; //導入依賴的package包/類
public FormValidation doCheckMirrorgateCredentialsId(
@AncestorInPath Item item,
@QueryParameter("mirrorgateCredentialsId") String credentialsId) {
if (item == null) {
if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
return FormValidation.ok();
}
} else if (!item.hasPermission(Item.EXTENDED_READ)
&& !item.hasPermission(CredentialsProvider.USE_ITEM)) {
return FormValidation.ok();
}
if (StringUtils.isBlank(credentialsId)) {
return FormValidation.ok();
}
if (credentialsId.startsWith("${") && credentialsId.endsWith("}")) {
return FormValidation.warning(
"Cannot validate expression based credentials");
}
return FormValidation.ok();
}
示例8: doCheckCredentialsId
import hudson.util.FormValidation; //導入依賴的package包/類
/**
* Validator for the 'Login credentials' field.
*
* @param credentialsId
* login credentials passed from the config.jelly "credentialsId" field
*
* @return validation message
*/
public FormValidation doCheckCredentialsId(@QueryParameter String credentialsId)
{
String tempValue = StringUtils.trimToEmpty(credentialsId);
if (tempValue.isEmpty())
{
return FormValidation.error(Messages.checkLoginCredentialsError());
}
return FormValidation.ok();
}
示例9: doValidateInput
import hudson.util.FormValidation; //導入依賴的package包/類
public FormValidation doValidateInput(@QueryParameter("host") final String host, @QueryParameter("account") final String account, @QueryParameter("user") final String user,
@QueryParameter("password") final String password, @QueryParameter("appname") final String appname,
@QueryParameter("packageLocation") final String packageLocation) {
if (host == null || host.equals(""))
return FormValidation.error("hostname is null or empty");
if (account == null || account.equals(""))
return FormValidation.error("accountname is null or empty");
if (user == null || user.equals(""))
return FormValidation.error("username is null or empty");
if (password == null || password.equals(""))
return FormValidation.error("password is null or empty");
if (appname == null || appname.equals(""))
return FormValidation.error("application name is null or empty");
return FormValidation.ok();
}
示例10: doCheckArtifactID
import hudson.util.FormValidation; //導入依賴的package包/類
/**
* Function that does form validation for the artifactID field in the UI
* @param value The value of the field
* @return The form state depending on the value
*/
public FormValidation doCheckArtifactID(@QueryParameter String value, @QueryParameter String groupID, @QueryParameter String repo)
{
if (value != "")
{
if (checkIfArtifactExists(repo, groupID, value))
{
return FormValidation.ok();
}
else
{
return FormValidation.error("Could not find artifact: " + groupID + ":" + value + " in repo " + repo);
}
}
else
{
return FormValidation.error("Artifact ID cannot be empty");
}
}
示例11: doCheckGroupID
import hudson.util.FormValidation; //導入依賴的package包/類
/**
* Function that does form validation for the groupID field in the UI
* @param value The value of the field
* @return The form state depending on the value
*/
public FormValidation doCheckGroupID(@QueryParameter String value, @QueryParameter String artifactID, @QueryParameter String repo)
{
if (value != "")
{
if (checkIfArtifactExists(repo, value, artifactID))
{
return FormValidation.ok();
}
else
{
return FormValidation.error("Could not find artifact: " + value + ":" + artifactID + " in repo " + repo);
}
}
else
{
return FormValidation.error("Group ID cannot be empty");
}
}
示例12: doTestConnection
import hudson.util.FormValidation; //導入依賴的package包/類
public FormValidation doTestConnection(
@QueryParameter("url") final String url,
@QueryParameter("user") final String user,
@QueryParameter("password") final String password,
@QueryParameter("room") final String room
) {
try {
RocketChatClient rcClient = new RocketChatClient(url, user, password);
Set<Room> publicRooms = rcClient.getPublicRooms();
StringBuilder message = new StringBuilder("available rooms are: ");
boolean comma = false;
for (Room r : publicRooms) {
if(r.name.equals(room))
return FormValidation.ok("Server version is "+rcClient.getRocketChatVersion());
if(comma) message.append(", ");
comma = true;
message.append("'"+r.name+"'");
}
return FormValidation.error("available rooms are "+message);
} catch (Exception e) {
return FormValidation.error(e.getMessage());
}
}
示例13: doCheckSecretKey
import hudson.util.FormValidation; //導入依賴的package包/類
public FormValidation doCheckSecretKey(@QueryParameter("proxyHost") final String proxyHost,
@QueryParameter("proxyPort") final String proxyPort,
@QueryParameter("accessKey") final String accessKey,
@QueryParameter("secretKey") final String secretKey) {
try {
AWSCredentials initialCredentials = AWSClientFactory.getBasicCredentialsOrDefaultChain(accessKey, secretKey).getCredentials();
new AWSCodeBuildClient(initialCredentials, getClientConfiguration(proxyHost, proxyPort)).listProjects(new ListProjectsRequest());
} catch (Exception e) {
String errorMessage = e.getMessage();
if(errorMessage.length() >= ERROR_MESSAGE_MAX_LENGTH) {
errorMessage = errorMessage.substring(ERROR_MESSAGE_MAX_LENGTH);
}
return FormValidation.error("Authorization failed: " + errorMessage);
}
return FormValidation.ok("AWS access and secret key authorization successful.");
}
示例14: doCheckTenant
import hudson.util.FormValidation; //導入依賴的package包/類
public FormValidation doCheckTenant(@QueryParameter final boolean ssoEnabled,
@QueryParameter final String tenant) {
if (ssoEnabled) {
String tenantVal = Util.fixEmptyAndTrim(tenant);
if (tenantVal == null) {
return FormValidation.error("Please enter tenant.");
}
if (tenantVal.indexOf('$') >= 0) {
// set by variable, can't validate
return FormValidation.ok();
}
}
return FormValidation.ok();
}
示例15: checkCredentials
import hudson.util.FormValidation; //導入依賴的package包/類
private FormValidation checkCredentials(UsernamePasswordCredentials credentials) {
try {
OAuthConfig config = new OAuthConfig(credentials.getUsername(), credentials.getPassword().getPlainText());
BitbucketApiService apiService = (BitbucketApiService) new BitbucketApi().createService(config);
Verifier verifier = null;
Token token = apiService.getAccessToken(OAuthConstants.EMPTY_TOKEN, verifier);
if (token.isEmpty()) {
return FormValidation.error("Invalid Bitbucket OAuth credentials");
}
} catch (Exception e) {
return FormValidation.error(e.getClass() + e.getMessage());
}
return FormValidation.ok();
}
開發者ID:jenkinsci,項目名稱:bitbucket-build-status-notifier-plugin,代碼行數:18,代碼來源:BitbucketBuildStatusNotifier.java