@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; } }
@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; } }
/** * 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)); }
@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; } }
/** * 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)); }
@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; }
/** * 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(); }
public View getProxiedView() { if (proxiedViewName == null) { // just so we avoid errors just after creation return Jenkins.getInstance().getPrimaryView(); } else { return Jenkins.getInstance().getView(proxiedViewName); } }
@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; } }
View view = h.getView(name);
@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; } }
@Override public View getView(String viewName) { return Jenkins.getInstance().getView(viewName); } }
/** * 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)); }
/** * 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)); }
@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; }
public View getProxiedView() { if (proxiedViewName == null) { // just so we avoid errors just after creation return Jenkins.getInstance().getPrimaryView(); } else { return Jenkins.getInstance().getView(proxiedViewName); } }
/** * 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(); }
@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; } }
View view = h.getView(name);