本文整理了Java中jenkins.model.Jenkins.getView()
方法的一些代码示例,展示了Jenkins.getView()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jenkins.getView()
方法的具体详情如下:
包路径:jenkins.model.Jenkins
类名称:Jenkins
方法名:getView
[英]Gets a view by the specified name. The method iterates through hudson.model.ViewGroups if required.
[中]获取具有指定名称的视图。该方法在hudson中迭代。模型视图组(如果需要)。
代码示例来源:origin: jenkinsci/jenkins
@DataBoundConstructor
public ProxyView(String name) {
super(name);
if (Jenkins.getInstance().getView(name) != null) {
// if this is a valid global view name, let's assume the
// user wants to show it
proxiedViewName = name;
}
}
代码示例来源:origin: jenkinsci/jenkins
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
// for compatibility reasons, the actual value is stored in Jenkins
Jenkins j = Jenkins.get();
if (json.has("primaryView")) {
final String viewName = json.getString("primaryView");
final View newPrimaryView = j.getView(viewName);
if (newPrimaryView == null) {
throw new FormException(Messages.GlobalDefaultViewConfiguration_ViewDoesNotExist(viewName), "primaryView");
}
j.setPrimaryView(newPrimaryView);
} else {
// Fallback if the view is not specified
j.setPrimaryView(j.getViews().iterator().next());
}
return true;
}
}
代码示例来源: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: org.jenkins-ci.main/jenkins-core
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
// for compatibility reasons, the actual value is stored in Jenkins
Jenkins j = Jenkins.getInstance();
if (json.has("primaryView")) {
final String viewName = json.getString("primaryView");
final View newPrimaryView = j.getView(viewName);
if (newPrimaryView == null) {
throw new FormException(Messages.GlobalDefaultViewConfiguration_ViewDoesNotExist(viewName), "primaryView");
}
j.setPrimaryView(newPrimaryView);
} else {
// Fallback if the view is not specified
j.setPrimaryView(j.getViews().iterator().next());
}
return true;
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Fails if a global view with the given name does not exist.
*/
public FormValidation doViewExistsCheck(@QueryParameter String value) {
checkPermission(View.CREATE);
String view = Util.fixEmpty(value);
if(view==null) return FormValidation.ok();
if(Jenkins.getInstance().getView(view)!=null)
return FormValidation.ok();
else
return FormValidation.error(Messages.ProxyView_NoSuchViewExists(value));
}
代码示例来源:origin: jenkinsci/jenkins
@Override
protected void submit(StaplerRequest req) throws IOException, ServletException, FormException {
String proxiedViewName = req.getSubmittedForm().getString("proxiedViewName");
if (Jenkins.getInstance().getView(proxiedViewName) == null) {
throw new FormException("Not an existing global view", "proxiedViewName");
}
this.proxiedViewName = proxiedViewName;
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Checks if a top-level view with the given name exists and
* make sure that the name is good as a view name.
*/
public FormValidation doCheckViewName(@QueryParameter String value) {
checkPermission(View.CREATE);
String name = fixEmpty(value);
if (name == null)
return FormValidation.ok();
// already exists?
if (getView(name) != null)
return FormValidation.error(Messages.Hudson_ViewAlreadyExists(name));
// good view name?
try {
checkGoodName(name);
} catch (Failure e) {
return FormValidation.error(e.getMessage());
}
return FormValidation.ok();
}
代码示例来源:origin: jenkinsci/jenkins
public View getProxiedView() {
if (proxiedViewName == null) {
// just so we avoid errors just after creation
return Jenkins.getInstance().getPrimaryView();
} else {
return Jenkins.getInstance().getView(proxiedViewName);
}
}
代码示例来源:origin: jenkinsci/jenkins
@Override
protected int run() throws Exception {
final Jenkins jenkins = Jenkins.getActiveInstance();
jenkins.checkPermission(View.CREATE);
View newView;
try {
newView = View.createViewFromXML(viewName, stdin);
} catch (Failure ex) {
throw new IllegalArgumentException("Invalid view name: " + ex.getMessage());
}
final String newName = newView.getViewName();
if (jenkins.getView(newName) != null) {
throw new IllegalStateException("View '" + newName + "' already exists");
}
jenkins.addView(newView);
return 0;
}
}
代码示例来源:origin: jenkinsci/jenkins
View view = h.getView(name);
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@DataBoundConstructor
public ProxyView(String name) {
super(name);
if (Jenkins.getInstance().getView(name) != null) {
// if this is a valid global view name, let's assume the
// user wants to show it
proxiedViewName = name;
}
}
代码示例来源:origin: jenkinsci/instant-messaging-plugin
@Override
public View getView(String viewName) {
return Jenkins.getInstance().getView(viewName);
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* 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: org.jenkins-ci.main/jenkins-core
/**
* Fails if a global view with the given name does not exist.
*/
public FormValidation doViewExistsCheck(@QueryParameter String value) {
checkPermission(View.CREATE);
String view = Util.fixEmpty(value);
if(view==null) return FormValidation.ok();
if(Jenkins.getInstance().getView(view)!=null)
return FormValidation.ok();
else
return FormValidation.error(Messages.ProxyView_NoSuchViewExists(value));
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Override
protected void submit(StaplerRequest req) throws IOException, ServletException, FormException {
String proxiedViewName = req.getSubmittedForm().getString("proxiedViewName");
if (Jenkins.getInstance().getView(proxiedViewName) == null) {
throw new FormException("Not an existing global view", "proxiedViewName");
}
this.proxiedViewName = proxiedViewName;
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public View getProxiedView() {
if (proxiedViewName == null) {
// just so we avoid errors just after creation
return Jenkins.getInstance().getPrimaryView();
} else {
return Jenkins.getInstance().getView(proxiedViewName);
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
/**
* Checks if a top-level view with the given name exists and
* make sure that the name is good as a view name.
*/
public FormValidation doCheckViewName(@QueryParameter String value) {
checkPermission(View.CREATE);
String name = fixEmpty(value);
if (name == null)
return FormValidation.ok();
// already exists?
if (getView(name) != null)
return FormValidation.error(Messages.Hudson_ViewAlreadyExists(name));
// good view name?
try {
checkGoodName(name);
} catch (Failure e) {
return FormValidation.error(e.getMessage());
}
return FormValidation.ok();
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
@Override
protected int run() throws Exception {
final Jenkins jenkins = Jenkins.getActiveInstance();
jenkins.checkPermission(View.CREATE);
View newView;
try {
newView = View.createViewFromXML(viewName, stdin);
} catch (Failure ex) {
throw new IllegalArgumentException("Invalid view name: " + ex.getMessage());
}
final String newName = newView.getViewName();
if (jenkins.getView(newName) != null) {
throw new IllegalStateException("View '" + newName + "' already exists");
}
jenkins.addView(newView);
return 0;
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
View view = h.getView(name);
内容来源于网络,如有侵权,请联系作者删除!