本文整理了Java中hudson.model.Messages
类的一些代码示例,展示了Messages
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Messages
类的具体详情如下:
包路径:hudson.model.Messages
类名称:Messages
[英]Generated localization support class.
[中]生成本地化支持类。
代码示例来源:origin: jenkinsci/jenkins
/**
* Performs on-the-fly validation of the errorlevel.
*/
@Restricted(DoNotUse.class)
public FormValidation doCheckUnstableReturn(@QueryParameter String value) {
value = Util.fixEmptyAndTrim(value);
if (value == null) {
return FormValidation.ok();
}
long unstableReturn;
try {
unstableReturn = Long.parseLong(value);
} catch (NumberFormatException e) {
return FormValidation.error(hudson.model.Messages.Hudson_NotANumber());
}
if (unstableReturn == 0) {
return FormValidation.warning(hudson.tasks.Messages.BatchFile_invalid_exit_code_zero());
}
if (unstableReturn < Integer.MIN_VALUE || unstableReturn > Integer.MAX_VALUE) {
return FormValidation.error(hudson.tasks.Messages.BatchFile_invalid_exit_code_range(unstableReturn));
}
return FormValidation.ok();
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Used for CLI binding.
*/
@CLIResolver
public static AbstractItem resolveForCLI(
@Argument(required=true,metaVar="NAME",usage="Item name") String name) throws CmdLineException {
// TODO can this (and its pseudo-override in AbstractProject) share code with GenericItemOptionHandler, used for explicit CLICommand’s rather than CLIMethod’s?
AbstractItem item = Jenkins.getInstance().getItemByFullName(name, AbstractItem.class);
if (item==null) {
AbstractItem project = Items.findNearest(AbstractItem.class, name, Jenkins.getInstance());
throw new CmdLineException(null, project == null ? Messages.AbstractItem_NoSuchJobExistsWithoutSuggestion(name)
: Messages.AbstractItem_NoSuchJobExists(name, project.getFullName()));
}
return item;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Get the term used in the UI to represent this kind of {@link AbstractProject}.
* Must start with a capital letter.
*/
@Override
public String getPronoun() {
return AlternativeUiTextProvider.get(PRONOUN, this,Messages.AbstractProject_Pronoun());
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Makes sure that the given string is a positive integer.
*/
public static FormValidation validatePositiveInteger(String value) {
try {
if(Integer.parseInt(value)<=0)
return error(hudson.model.Messages.Hudson_NotAPositiveNumber());
return ok();
} catch (NumberFormatException e) {
return error(hudson.model.Messages.Hudson_NotANumber());
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Makes sure that the given string is a non-negative integer.
*/
public static FormValidation validateNonNegativeInteger(String value) {
try {
if(Integer.parseInt(value)<0)
return error(hudson.model.Messages.Hudson_NotANonNegativeNumber());
return ok();
} catch (NumberFormatException e) {
return error(hudson.model.Messages.Hudson_NotANumber());
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Make sure that the given string is an integer in the range specified by the lower and upper bounds (both inclusive)
*
* @param value the value to check
* @param lower the lower bound (inclusive)
* @param upper the upper bound (inclusive)
*
* @since 2.104
*/
public static FormValidation validateIntegerInRange(String value, int lower, int upper) {
try {
int intValue = Integer.parseInt(value);
if (intValue < lower) {
return error(hudson.model.Messages.Hudson_MustBeAtLeast(lower));
}
if (intValue > upper) {
return error(hudson.model.Messages.Hudson_MustBeAtMost(upper));
}
return ok();
} catch (NumberFormatException e) {
return error(hudson.model.Messages.Hudson_NotANumber());
}
}
代码示例来源:origin: org.jenkins-ci.plugins/nested-view
/**
* Checks if a nested view with the given name exists.
*/
public FormValidation doViewExistsCheck(@QueryParameter String value) {
checkPermission(View.CREATE);
String view = fixEmpty(value);
return (view == null || getView(view) == null) ? FormValidation.ok()
: FormValidation.error(hudson.model.Messages.Hudson_ViewAlreadyExists(view));
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Checks if a top-level view with the given name exists.
* @deprecated 1.512
*/
@Deprecated
public FormValidation doViewExistsCheck(@QueryParameter String value) {
checkPermission(View.CREATE);
String view = fixEmpty(value);
if(view==null) return FormValidation.ok();
if(getView(view)==null)
return FormValidation.ok();
else
return FormValidation.error(Messages.Hudson_ViewAlreadyExists(view));
}
代码示例来源:origin: jenkinsci/jenkins
public FormValidation doFieldCheck(@QueryParameter(fixEmpty=true) String value,
@QueryParameter(fixEmpty=true) String type,
@QueryParameter(fixEmpty=true) String errorText,
@QueryParameter(fixEmpty=true) String warningText) {
if (value == null) {
if (errorText != null)
return FormValidation.error(errorText);
if (warningText != null)
return FormValidation.warning(warningText);
return FormValidation.error("No error or warning text was set for fieldCheck().");
} else if (type.equalsIgnoreCase("number-positive")) {
if (NumberFormat.getInstance().parse(value).floatValue() <= 0)
return FormValidation.error(Messages.Hudson_NotAPositiveNumber());
} else if (type.equalsIgnoreCase("number-negative")) {
if (NumberFormat.getInstance().parse(value).floatValue() >= 0)
return FormValidation.error(Messages.Hudson_NotANegativeNumber());
return FormValidation.error(Messages.Hudson_NotANumber());
代码示例来源:origin: jenkinsci/gerrit-trigger-plugin
public FormValidation doCheckDependencyJobsNames(@AncestorInPath Item project, @QueryParameter String value) {
StringTokenizer tokens = new StringTokenizer(Util.fixNull(value), ",");
Jenkins jenkins = Jenkins.getInstance();
assert jenkins != null;
Item item = jenkins.getItem(projectName, project, Item.class);
if ((item == null) || !(item instanceof Job)) {
Job nearest = Items.findNearest(Job.class,
path = nearest.getRelativeNameFrom(project);
return FormValidation.error(
hudson.model.Messages.AbstractItem_NoSuchJobExists(
projectName,
path));
if (directDependencies == null) {
return FormValidation.ok();
return FormValidation.error(Messages.CannotAddSelfAsDependency());
代码示例来源:origin: jenkinsci/gerrit-trigger-plugin
/**
* Checks that the provided parameter is an integer.
* @param value the value.
* @return {@link FormValidation#validatePositiveInteger(String)}
*/
public FormValidation doIntegerCheck(
@QueryParameter("value")
final String value) {
try {
Integer.parseInt(value);
return FormValidation.ok();
} catch (NumberFormatException e) {
return FormValidation.error(hudson.model.Messages.Hudson_NotANumber());
}
}
代码示例来源:origin: hudson/hudson-2.x
public static View create(StaplerRequest req, StaplerResponse rsp, ViewGroup owner)
throws FormException, IOException, ServletException {
String name = req.getParameter("name");
checkGoodName(name);
if(owner.getView(name)!=null)
throw new FormException(Messages.Hudson_ViewAlreadyExists(name),"name");
String mode = req.getParameter("mode");
if (mode==null || mode.length()==0)
throw new FormException(Messages.View_MissingMode(),"mode");
// create a view
View v = all().findByName(mode).newInstance(req,req.getSubmittedForm());
v.owner = owner;
// redirect to the config screen
rsp.sendRedirect2(req.getContextPath()+'/'+v.getUrl()+v.getPostConstructLandingPage());
return v;
}
}
代码示例来源:origin: jenkinsci/jenkins
public static View create(StaplerRequest req, StaplerResponse rsp, ViewGroup owner)
throws FormException, IOException, ServletException {
String mode = req.getParameter("mode");
String requestContentType = req.getContentType();
if (requestContentType == null
&& !(mode != null && mode.equals("copy")))
|| requestContentType.startsWith("text/xml"));
String name = req.getParameter("name");
Jenkins.checkGoodName(name);
if(owner.getView(name)!=null)
throw new Failure(Messages.Hudson_ViewAlreadyExists(name));
owner.getACL().checkCreatePermission(owner, v.getDescriptor());
v.owner = owner;
rsp.setStatus(HttpServletResponse.SC_OK);
return v;
} else
throw new Failure(Messages.View_MissingMode());
rsp.sendRedirect2(req.getContextPath()+'/'+v.getUrl()+v.getPostConstructLandingPage());
代码示例来源:origin: jenkinsci/jenkins
protected void check() throws IOException, ServletException {
try {
String value = request.getParameter("value");
if(Integer.parseInt(value)<0)
error(hudson.model.Messages.Hudson_NotAPositiveNumber());
else
ok();
} catch (NumberFormatException e) {
error(hudson.model.Messages.Hudson_NotANumber());
}
}
}
代码示例来源:origin: org.hudsonci.plugins/parameterized-trigger
private FormValidation validateNumberField(String value) {
// The field can contain Parameters - eliminate them first. The remaining String should
// be empty or a number.
String valueWithoutVariables = Util.replaceMacro(value, EMPTY_STRING_VARIABLE_RESOLVER);
if (StringUtils.isNotEmpty(valueWithoutVariables) && !isNumber(valueWithoutVariables)) {
return FormValidation.warning(hudson.model.Messages.Hudson_NotANumber());
} else {
return FormValidation.validateRequired(value);
}
}
代码示例来源:origin: org.jenkins-ci.plugins/matrix-project
private FormValidation unsafeChar(char chr) {
return FormValidation.error(hudson.model.Messages.Hudson_UnsafeChar(chr));
}
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
Charset charset = Computer.currentComputer().getDefaultCharset();
this.charset = charset.name();
Util.createSymlink(getParent().getBuildDir(),getId(),String.valueOf(getNumber()),listener);
listener.getLogger().println(Messages.Run_BuildAborted());
LOGGER.log(Level.INFO,toString()+" aborted",e);
} catch( Throwable e ) {
代码示例来源:origin: jenkinsci/jenkins
Computer computer = Computer.currentComputer();
Charset charset = null;
if (computer != null) {
charset = computer.getDefaultCharset();
this.charset = charset.name();
listener.started(getCauses());
Authentication auth = Jenkins.getAuthentication();
if (!auth.equals(ACL.SYSTEM)) {
String id = auth.getName();
listener.getLogger().println(Messages.Run_running_as_(id));
listener.getLogger().println(Messages.Run_BuildAborted());
Executor.currentExecutor().recordCauseOfInterruption(Run.this,listener);
LOGGER.log(Level.INFO, this + " aborted", e);
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
return new Summary(false, Messages.Run_Summary_Stable());
else
return new Summary(false, Messages.Run_Summary_BackToNormal());
RunT since = getPreviousNotFailedBuild();
if(since==null)
return new Summary(false, Messages.Run_Summary_BrokenForALongTime());
if(since==prev)
return new Summary(true, Messages.Run_Summary_BrokenSinceThisBuild());
RunT failedBuild = since.getNextBuild();
return new Summary(false, Messages.Run_Summary_BrokenSince(failedBuild.getDisplayName()));
return new Summary(false, Messages.Run_Summary_Aborted());
if(trP==null) {
if(trN!=null && trN.getFailCount()>0)
return new Summary(false, Messages.Run_Summary_TestFailures(trN.getFailCount()));
else // ???
return new Summary(false, Messages.Run_Summary_Unstable());
return new Summary(true, Messages.Run_Summary_TestsStartedToFail(trN.getFailCount()));
if(trP.getFailCount() < trN.getFailCount())
return new Summary(true, Messages.Run_Summary_MoreTestsFailing(trN.getFailCount()-trP.getFailCount(), trN.getFailCount()));
if(trP.getFailCount() > trN.getFailCount())
return new Summary(false, Messages.Run_Summary_LessTestsFailing(trP.getFailCount()-trN.getFailCount(), trN.getFailCount()));
return new Summary(false, Messages.Run_Summary_TestsStillFailing(trN.getFailCount()));
return new Summary(false, Messages.Run_Summary_Unknown());
代码示例来源:origin: org.eclipse.hudson/hudson-core
/**
* Gets the string that says how long the build took to run.
*/
public String getDurationString() {
if (isBuilding()) {
return Messages.Run_InProgressDuration(
Util.getTimeSpanString(System.currentTimeMillis() - timestamp));
}
return Util.getTimeSpanString(duration);
}
内容来源于网络,如有侵权,请联系作者删除!