code: private void checkIfNameIsUsed(@Nonnull String newName) throws Failure {
          try {
              Item item = getParent().getItem(newName);
              if (item != null) {
                  throw new Failure(Messages.AbstractItem_NewNameInUse(newName));
              }
              try (ACLContext ctx = ACL.as(ACL.SYSTEM)) {
                  item = getParent().getItem(newName);
                  if (item != null) {
                      if (LOGGER.isLoggable(Level.FINE)) {
                          LOGGER.log(Level.FINE, "Unable to rename the job {0}: name {1} is already in use. " +
                                  "User {2} has no {3} permission for existing job with the same name",
                                  new Object[] {this.getFullName(), newName, ctx.getPreviousContext().getAuthentication().getName(), Item.DISCOVER.name} );
                      }
                      // Don't explicitly mention that there is another item with the same name.
                      throw new Failure(Messages.Jenkins_NotAllowedName(newName));
                  }
              }
          } catch(AccessDeniedException ex) {
              if (LOGGER.isLoggable(Level.FINE)) {
                  LOGGER.log(Level.FINE, "Unable to rename the job {0}: name {1} is already in use. " +
                          "User {2} has {3} permission, but no {4} for existing job with the same name",
                          new Object[] {this.getFullName(), newName, User.current(), Item.DISCOVER.name, Item.READ.name} );
              }
              throw new Failure(Messages.AbstractItem_NewNameInUse(newName));
          }
      }
docs: Check new name for job
  @param newName - New name for job.