当前位置: 首页>>代码示例>>Java>>正文


Java FormValidation类代码示例

本文整理汇总了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());
    }
}
 
开发者ID:FluffyFairyGames,项目名称:jenkins-telegram-plugin,代码行数:27,代码来源:TelegramNotifier.java

示例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();
}
 
开发者ID:jenkinsci,项目名称:gitea-plugin,代码行数:23,代码来源:PersonalAccessTokenImpl.java

示例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>");
    }
}
 
开发者ID:IBM,项目名称:ibm-cloud-devops,代码行数:21,代码来源:PublishSQ.java

示例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>");
	}
}
 
开发者ID:IBM,项目名称:ibm-cloud-devops,代码行数:21,代码来源:PublishDeploy.java

示例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();
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:18,代码来源:SQSTrigger.java

示例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");
    }
}
 
开发者ID:BBVA,项目名称:mirrorgate-jenkins-builds-collector,代码行数:17,代码来源:MirrorGatePublisher.java

示例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();
}
 
开发者ID:BBVA,项目名称:mirrorgate-jenkins-builds-collector,代码行数:22,代码来源:MirrorGatePublisher.java

示例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();
}
 
开发者ID:Compuware-Corp,项目名称:CPWR-CodeCoverage,代码行数:19,代码来源:CodeCoverageBuilder.java

示例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();
}
 
开发者ID:jenkinsci,项目名称:sap-hcp-deployer-plugin,代码行数:17,代码来源:HcpDeploymentBuilder.java

示例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");
    }

}
 
开发者ID:pason-systems,项目名称:jenkins-artifactory-polling-plugin,代码行数:26,代码来源:ArtifactoryRepository.java

示例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");
    }
}
 
开发者ID:pason-systems,项目名称:jenkins-artifactory-polling-plugin,代码行数:24,代码来源:ArtifactoryRepository.java

示例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());
	}
}
 
开发者ID:baloise,项目名称:rocket-chat-notifier,代码行数:24,代码来源:RocketChatNotifier.java

示例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.");
}
 
开发者ID:awslabs,项目名称:aws-codebuild-jenkins-plugin,代码行数:19,代码来源:CodeBuildCredentials.java

示例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();
}
 
开发者ID:agovindaraju,项目名称:vmware-vrealize-orchestrator,代码行数:18,代码来源:OrchestratorBuilder.java

示例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


注:本文中的hudson.util.FormValidation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。