本文整理汇总了Java中hudson.util.FormValidation.error方法的典型用法代码示例。如果您正苦于以下问题:Java FormValidation.error方法的具体用法?Java FormValidation.error怎么用?Java FormValidation.error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hudson.util.FormValidation
的用法示例。
在下文中一共展示了FormValidation.error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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>");
}
}
示例3: 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();
}
示例4: 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");
}
}
示例5: 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();
}
示例6: doCheckBaseRevision
import hudson.util.FormValidation; //导入方法依赖的package包/类
public FormValidation doCheckBaseRevision(@QueryParameter boolean analyzeBranchDiff,
@QueryParameter String baseRevision) throws IOException, ServletException {
if (analyzeBranchDiff && (baseRevision == null || baseRevision.isEmpty())) {
return FormValidation.error("Base revision cannot be empty.");
} else {
return FormValidation.ok();
}
}
示例7: doCheckRiskThreshold
import hudson.util.FormValidation; //导入方法依赖的package包/类
public FormValidation doCheckRiskThreshold(@QueryParameter int riskThreshold, @QueryParameter boolean markBuildAsUnstable) {
if (markBuildAsUnstable && (riskThreshold < 1 || riskThreshold > 10)) {
return FormValidation.error("Risk threshold must be a number between 1 and 10. The value %d is invalid.", riskThreshold);
} else {
return FormValidation.ok();
}
}
示例8: doCheckCredentialsId
import hudson.util.FormValidation; //导入方法依赖的package包/类
public FormValidation doCheckCredentialsId(@QueryParameter String credentialsId) {
if (credentialsId == null || credentialsId.isEmpty()) {
return FormValidation.error("CodeScene API credentials must be set.");
} else {
return FormValidation.ok();
}
}
示例9: doCheckDeltaAnalysisUrl
import hudson.util.FormValidation; //导入方法依赖的package包/类
public FormValidation doCheckDeltaAnalysisUrl(@QueryParameter String deltaAnalysisUrl) {
if (deltaAnalysisUrl == null || deltaAnalysisUrl.isEmpty()) {
return FormValidation.error("CodeScene delta analysis URL cannot be blank.");
} else {
try {
new URL(deltaAnalysisUrl);
return FormValidation.ok();
} catch (MalformedURLException e) {
return FormValidation.error("Invalid URL");
}
}
}
示例10: checkFieldNotEmpty
import hudson.util.FormValidation; //导入方法依赖的package包/类
private FormValidation checkFieldNotEmpty(String value, String field) {
value = StringUtils.strip(value);
if (value == null || value.equals("")) {
return FormValidation.error(field + " is required.");
}
return FormValidation.ok();
}
示例11: doCheckConnectionId
import hudson.util.FormValidation; //导入方法依赖的package包/类
/**
* Validator for the 'Host connection' field.
*
* @param connectionId
* unique identifier for the host connection passed from the config.jelly "connectionId" field
*
* @return validation message
*/
public FormValidation doCheckConnectionId(@QueryParameter String connectionId)
{
String tempValue = StringUtils.trimToEmpty(connectionId);
if (tempValue.isEmpty())
{
return FormValidation.error(Messages.checkHostConnectionError());
}
return FormValidation.ok();
}
示例12: doCheckCredentialsId
import hudson.util.FormValidation; //导入方法依赖的package包/类
/**
* Validation for checkout credentials.
*
* @param context the context.
* @param serverUrl the server url.
* @param value the current selection.
* @return the validation results
*/
@Restricted(NoExternalUse.class)
@SuppressWarnings("unused") // stapler form binding
public FormValidation doCheckCredentialsId(@CheckForNull @AncestorInPath Item context,
@QueryParameter String serverUrl,
@QueryParameter String value) {
if (context == null
? !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)
: !context.hasPermission(Item.EXTENDED_READ)) {
return FormValidation.ok();
}
if (StringUtils.isBlank(value)) {
// use agent key
return FormValidation.ok();
}
if (CredentialsMatchers.firstOrNull(CredentialsProvider
.lookupCredentials(SSHUserPrivateKey.class, context, context instanceof Queue.Task
? Tasks.getDefaultAuthenticationOf((Queue.Task) context)
: ACL.SYSTEM, URIRequirementBuilder.fromUri(serverUrl).build()),
CredentialsMatchers.withId(value)) != null) {
return FormValidation.ok();
}
if (CredentialsMatchers.firstOrNull(CredentialsProvider
.lookupCredentials(StandardUsernameCredentials.class, context, context instanceof Queue.Task
? Tasks.getDefaultAuthenticationOf((Queue.Task) context)
: ACL.SYSTEM, URIRequirementBuilder.fromUri(serverUrl).build()),
CredentialsMatchers.withId(value)) != null) {
return FormValidation.error(Messages.SSHCheckoutTrait_incompatibleCredentials());
}
return FormValidation.warning(Messages.SSHCheckoutTrait_missingCredentials());
}
示例13: doCheckCredentialsId
import hudson.util.FormValidation; //导入方法依赖的package包/类
public FormValidation doCheckCredentialsId(@AncestorInPath SCMSourceOwner context,
@QueryParameter String serverUrl,
@QueryParameter String value)
throws IOException, InterruptedException{
if (context == null) {
if (!Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER)) {
return FormValidation.ok();
}
} else {
if (!context.hasPermission(Item.EXTENDED_READ)
&& !context.hasPermission(CredentialsProvider.USE_ITEM)) {
return FormValidation.ok();
}
}
GiteaServer server = GiteaServers.get().findServer(serverUrl);
if (server == null) {
return FormValidation.ok();
}
if (StringUtils.isBlank(value)) {
return FormValidation.ok();
}
if (CredentialsProvider.listCredentials(
StandardCredentials.class,
context,
context instanceof Queue.Task ?
Tasks.getDefaultAuthenticationOf((Queue.Task) context)
: ACL.SYSTEM,
URIRequirementBuilder.fromUri(serverUrl).build(),
CredentialsMatchers.allOf(
CredentialsMatchers.withId(value),
AuthenticationTokens.matcher(GiteaAuth.class)
)).isEmpty()) {
return FormValidation.error(Messages.GiteaSCMSource_selectedCredentialsMissing());
}
return FormValidation.ok();
}
示例14: doCheckUrl
import hudson.util.FormValidation; //导入方法依赖的package包/类
public FormValidation doCheckUrl(@QueryParameter final String url) {
if (StringUtils.isBlank(url)) {
return FormValidation.warning(Messages.warningBlankUrl());
}
return com.ribose.jenkins.plugin.awscodecommittrigger.utils.StringUtils.isCodeCommitRepo(url)
? FormValidation.ok()
: FormValidation.error(Messages.errorCodeCommitUrlInvalid());
}
示例15: doCheckName
import hudson.util.FormValidation; //导入方法依赖的package包/类
public FormValidation doCheckName(@QueryParameter String name) {
if (name.isEmpty()) {
return FormValidation.error("Please insert a name for the instance.");
}
return FormValidation.ok();
}