docs: public synchronized TopLevelItem createTopLevelItem( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
          acl.checkPermission(Item.CREATE);
  
          TopLevelItem result;
  
          String requestContentType = req.getContentType();
          String mode = req.getParameter("mode");
          if (requestContentType == null
                  && !(mode != null && mode.equals("copy")))
              throw new Failure("No Content-Type header set");
  
          boolean isXmlSubmission = requestContentType != null
              && (requestContentType.startsWith("application/xml")
                      || requestContentType.startsWith("text/xml"));
  
          String name = req.getParameter("name");
          if(name==null)
              throw new Failure("Query parameter 'name' is required");
  
          {// check if the name looks good
              Jenkins.checkGoodName(name);
              name = name.trim();
              if(parent.getItem(name)!=null)
                  throw new Failure(Messages.Hudson_JobAlreadyExists(name));
          }
  
          if(mode!=null && mode.equals("copy")) {
              String from = req.getParameter("from");
  
              // resolve a name to Item
              Item src = Jenkins.getInstance().getItem(from, parent);
              if(src==null) {
                  if(Util.fixEmpty(from)==null)
                      throw new Failure("Specify which job to copy");
                  else
                      throw new Failure("No such job: "+from);
              }
              if (!(src instanceof TopLevelItem))
                  throw new Failure(from+" cannot be copied");
  
              result = copy((TopLevelItem) src,name);
          } else {
              if(isXmlSubmission) {
                  result = createProjectFromXML(name, req.getInputStream());
                  rsp.setStatus(HttpServletResponse.SC_OK);
                  return result;
              } else {
                  if(mode==null)
                      throw new Failure("No mode given");
                  TopLevelItemDescriptor descriptor = Items.all().findByName(mode);
                  if (descriptor == null) {
                      throw new Failure("No item type ‘" + mode + "’ is known");
                  }
                  descriptor.checkApplicableIn(parent);
                  acl.getACL().checkCreatePermission(parent, descriptor);
  
                  // create empty job and redirect to the project config screen
                  result = createProject(descriptor, name, true);
              }
          }
  
          rsp.sendRedirect2(redirectAfterCreateItem(req, result));
          return result;
      }