    protected int run() throws Exception {
        Team targetTeam = validateTeam(team, create, stderr);
        Hudson h = Hudson.getInstance();
        TeamManager teamManager = h.getTeamManager();
        if (team != null && targetTeam == null) {
            return -1;
        }
        String qualifiedJobName = targetTeam == null
                ? getNewJobName(name)
                : teamManager.getRawTeamQualifiedJobName(targetTeam, name);
        TopLevelItem item = h.getItem(qualifiedJobName);
        if (item == null && !create) {
            stderr.println("Job '" + qualifiedJobName + "' does not exist and create is set to false");
            return -1;
        } else if (item != null && create) {
            stderr.println("Job '" + qualifiedJobName + "' already exists and create is set to true");
            return -1;
        }
        if (item == null) {
            name = name.trim();
            if (!isGoodName(name, stderr)) {
                return -1;
            }
            h.checkPermission(Item.CREATE);
            h.createProjectFromXML(name, team, stdin);
        } else {
            XmlFile oldConfigXml = null;
            Object oldItem = null;
            try {
                h.checkPermission(Job.CONFIGURE);
                File rootDirOfJob = teamManager.getRootFolderForJob(item.getName());
                oldConfigXml = Items.getConfigFile(rootDirOfJob);
                oldItem = oldConfigXml.read();
                File configXml = oldConfigXml.getFile();
                IOUtils.copy(stdin, configXml);
                h.reloadProjectFromDisk(configXml.getParentFile());
            } catch (IOException e) {
                if (oldConfigXml != null && oldItem != null) {
                    oldConfigXml.write(oldItem);
                }
                throw e;
            }
        }
        return 0;
    }

    protected int run() throws Exception {
        Team targetTeam = validateTeam(team, create, stderr);
        Hudson h = Hudson.getInstance();
        TeamManager teamManager = h.getTeamManager();
        if (team != null && targetTeam == null) {
            return -1;
        }
        String qualifiedJobName = !create ? name :
                (targetTeam == null
                    ? getNewJobName(name)
                    : teamManager.getRawTeamQualifiedJobName(targetTeam, name));
        TopLevelItem item = h.getItem(qualifiedJobName);
        if (item == null && !create) {
            stderr.println("Job '" + qualifiedJobName + "' does not exist and create is set to false");
            return -1;
        } else if (item != null && create) {
            stderr.println("Job '" + qualifiedJobName + "' already exists and create is set to true");
            return -1;
        }
        if (item == null) {
            name = name.trim();
            if (!isGoodName(name, stderr)) {
                return -1;
            }
            h.checkPermission(Item.CREATE);
            h.createProjectFromXML(name, team, stdin);
        } else {
            XmlFile oldConfigXml = null;
            Object oldItem = null;
            try {
                item.checkPermission(Job.CONFIGURE);
                File rootDirOfJob = teamManager.getRootFolderForJob(item.getName());
                oldConfigXml = Items.getConfigFile(rootDirOfJob);
                oldItem = oldConfigXml.read();
                File configXml = oldConfigXml.getFile();
                IOUtils.copy(stdin, configXml);
                h.reloadProjectFromDisk(configXml.getParentFile());
            } catch (IOException e) {
                if (oldConfigXml != null && oldItem != null) {
                    oldConfigXml.write(oldItem);
                }
                throw e;
            }
        }
        return 0;
    }
