public FormValidation doCheckName(@QueryParameter String value ) { String name = Util.fixEmptyAndTrim(value); if(name==null) return FormValidation.error(Messages.NodeDescriptor_CheckName_Mandatory()); try { Jenkins.checkGoodName(name); } catch (Failure f) { return FormValidation.error(f.getMessage()); } return FormValidation.ok(); }
/** * Makes sure that the given name is good as an agent name. */ public FormValidation doCheckName(@QueryParameter String value) throws IOException, ServletException { Jenkins.getInstance().checkPermission(Computer.CREATE); if(Util.fixEmpty(value)==null) return FormValidation.ok(); try { checkName(value); return FormValidation.ok(); } catch (Failure e) { return FormValidation.error(e.getMessage()); } }
/** * 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; } }
/** * Called by {@link #doConfirmRename} and {@code rename.jelly} to validate renames. * @return {@link FormValidation#ok} if this item can be renamed as specified, otherwise * {@link FormValidation#error} with a message explaining the problem. */ @Restricted(NoExternalUse.class) public @Nonnull FormValidation doCheckNewName(@QueryParameter String newName) { // TODO: Create an Item.RENAME permission to use here, see JENKINS-18649. if (!hasPermission(Item.CONFIGURE)) { if (parent instanceof AccessControlled) { ((AccessControlled)parent).checkPermission(Item.CREATE); } checkPermission(Item.DELETE); } newName = newName == null ? null : newName.trim(); try { Jenkins.checkGoodName(newName); assert newName != null; // Would have thrown Failure if (newName.equals(name)) { return FormValidation.warning(Messages.AbstractItem_NewNameUnchanged()); } Jenkins.get().getProjectNamingStrategy().checkName(newName); checkIfNameIsUsed(newName); checkRename(newName); } catch (Failure e) { return FormValidation.error(e.getMessage()); } return FormValidation.ok(); }
/** * Makes sure that the given name is good as a job name. * For use from {@code newJob}. */ @Restricted(DoNotUse.class) // called from newJob view public FormValidation doCheckJobName(@QueryParameter String value) { // this method can be used to check if a file exists anywhere in the file system, // so it should be protected. getOwner().checkPermission(Item.CREATE); if (Util.fixEmpty(value) == null) { return FormValidation.ok(); } try { Jenkins.checkGoodName(value); value = value.trim(); // why trim *after* checkGoodName? not sure, but ItemGroupMixIn.createTopLevelItem does the same Jenkins.getInstance().getProjectNamingStrategy().checkName(value); } catch (Failure e) { return FormValidation.error(e.getMessage()); } if (getOwner().getItemGroup().getItem(value) != null) { return FormValidation.error(Messages.Hudson_JobAlreadyExists(value)); } // looks good return FormValidation.ok(); }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { req.setAttribute("message",getMessage()); if(pre) req.setAttribute("pre",true); if (node instanceof AbstractItem) // Maintain ancestors rsp.forward(Jenkins.getInstance(), ((AbstractItem)node).getUrl() + "error", req); else rsp.forward(node instanceof AbstractModelObject ? node : Jenkins.getInstance() ,"error", req); } }
public static boolean isGoodName(String name, PrintStream stderr) { try { Hudson.checkGoodJobName(name); } catch (Failure e) { stderr.println(e.getMessage()); return false; } return true; } }
private FormValidation validGoodName(String variance) { if (StringUtils.isBlank(variance)) { return FormValidation.ok(); } try { Jenkins.checkGoodName(variance); return FormValidation.ok(); } catch (Failure e) { return FormValidation.error(e.getMessage()); } } }
public FormValidation doCheckName(@QueryParameter String value ) { String name = Util.fixEmptyAndTrim(value); if(name==null) return FormValidation.error(Messages.NodeDescriptor_CheckName_Mandatory()); try { Jenkins.checkGoodName(name); } catch (Failure f) { return FormValidation.error(f.getMessage()); } return FormValidation.ok(); }
public FormValidation doCheckName(@QueryParameter String value ) { String name = Util.fixEmptyAndTrim(value); if(name==null) return FormValidation.error(Messages.NodeDescripter_CheckName_Mandatory()); try { Hudson.checkGoodName(name); } catch (Failure f) { return FormValidation.error(f.getMessage()); } return FormValidation.ok(); }
public FormValidation doCheckName(@QueryParameter String value ) { String name = Util.fixEmptyAndTrim(value); if(name==null) return FormValidation.error(Messages.NodeDescripter_CheckName_Mandatory()); try { Hudson.checkGoodName(name); } catch (Failure f) { return FormValidation.error(f.getMessage()); } return FormValidation.ok(); }
public FormValidation doCheckName(@QueryParameter String value ) { String name = Util.fixEmptyAndTrim(value); if(name==null) return FormValidation.error(Messages.NodeDescripter_CheckName_Mandatory()); try { Hudson.checkGoodName(name); } catch (Failure f) { return FormValidation.error(f.getMessage()); } return FormValidation.ok(); }
public FormValidation doCheckName(@QueryParameter String value) { String name = Util.fixEmptyAndTrim(value); if (name == null) { return FormValidation.error(Messages.NodeDescripter_CheckName_Mandatory()); } try { Hudson.checkGoodName(name); } catch (Failure f) { return FormValidation.error(f.getMessage()); } return FormValidation.ok(); }
@Restricted(DoNotUse.class) @RequirePOST public FormValidation doCheckName(@QueryParameter String value) { try { Jenkins.checkGoodName(value); return FormValidation.ok(); } catch (Failure ex) { return FormValidation.error(ex.getMessage()); } }
public Team createTeam(String teamName, String description, String customFolder) throws IOException, TeamAlreadyExistsException { try { Hudson.checkGoodTeamName(teamName); if (teamName.trim().length() > Hudson.TEAM_NAME_LIMIT) { throw new Failure("Team name cannot exceed " + Hudson.TEAM_NAME_LIMIT + " characters."); } } catch (Failure ex) { throw new IOException(ex.getMessage()); } return internalCreateTeam(teamName, description, customFolder); }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { req.setAttribute("message",getMessage()); if(pre) req.setAttribute("pre",true); if (node instanceof AbstractItem) // Maintain ancestors rsp.forward(Hudson.getInstance(), ((AbstractItem)node).getUrl() + "error", req); else rsp.forward(node instanceof AbstractModelObject ? node : Hudson.getInstance() ,"error", req); } }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { req.setAttribute("message",getMessage()); if(pre) req.setAttribute("pre",true); if (node instanceof AbstractItem) // Maintain ancestors rsp.forward(Hudson.getInstance(), ((AbstractItem)node).getUrl() + "error", req); else rsp.forward(node instanceof AbstractModelObject ? node : Hudson.getInstance() ,"error", req); } }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { req.setAttribute("message",getMessage()); if(pre) req.setAttribute("pre",true); if (node instanceof AbstractItem) // Maintain ancestors rsp.forward(Hudson.getInstance(), ((AbstractItem)node).getUrl() + "error", req); else rsp.forward(node instanceof AbstractModelObject ? node : Hudson.getInstance() ,"error", req); } }
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { req.setAttribute("message",getMessage()); if(pre) req.setAttribute("pre",true); if (node instanceof AbstractItem) // Maintain ancestors rsp.forward(Jenkins.getInstance(), ((AbstractItem)node).getUrl() + "error", req); else rsp.forward(node instanceof AbstractModelObject ? node : Jenkins.getInstance() ,"error", req); } }