Package hudson

Examples of hudson.BulkChange


//
    /**
     * Accepts submission from the configuration page.
     */
    public synchronized void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
        BulkChange bc = new BulkChange(this);
        try {
            checkPermission(ADMINISTER);

            JSONObject json = req.getSubmittedForm();

            // keep using 'useSecurity' field as the main configuration setting
            // until we get the new security implementation working
            // useSecurity = null;
            if (json.has("use_security")) {
                useSecurity = true;
                JSONObject security = json.getJSONObject("use_security");
                setSecurityRealm(SecurityRealm.all().newInstanceFromRadioList(security, "realm"));
                setAuthorizationStrategy(AuthorizationStrategy.all().newInstanceFromRadioList(security, "authorization"));

                if (security.has("markupFormatter")) {
                    markupFormatter = req.bindJSON(MarkupFormatter.class, security.getJSONObject("markupFormatter"));
                } else {
                    markupFormatter = null;
                }
            } else {
                useSecurity = null;
                setSecurityRealm(SecurityRealm.NO_AUTHENTICATION);
                authorizationStrategy = AuthorizationStrategy.UNSECURED;
                markupFormatter = null;
            }

            if (json.has("csrf")) {
                JSONObject csrf = json.getJSONObject("csrf");
                setCrumbIssuer(CrumbIssuer.all().newInstanceFromRadioList(csrf, "issuer"));
            } else {
                setCrumbIssuer(null);
            }

            if (json.has("viewsTabBar")) {
                viewsTabBar = req.bindJSON(ViewsTabBar.class, json.getJSONObject("viewsTabBar"));
            } else {
                viewsTabBar = new DefaultViewsTabBar();
            }

            if (json.has("myViewsTabBar")) {
                myViewsTabBar = req.bindJSON(MyViewsTabBar.class, json.getJSONObject("myViewsTabBar"));
            } else {
                myViewsTabBar = new DefaultMyViewsTabBar();
            }

            primaryView = json.has("primaryView") ? json.getString("primaryView") : getViews().iterator().next().getViewName();

            noUsageStatistics = json.has("usageStatisticsCollected") ? null : true;

            {
                String v = req.getParameter("slaveAgentPortType");
                if (!isUseSecurity() || v == null || v.equals("random")) {
                    slaveAgentPort = 0;
                } else if (v.equals("disable")) {
                    slaveAgentPort = -1;
                } else {
                    try {
                        slaveAgentPort = Integer.parseInt(req.getParameter("slaveAgentPort"));
                    } catch (NumberFormatException e) {
                        throw new FormException(Messages.Hudson_BadPortNumber(req.getParameter("slaveAgentPort")), "slaveAgentPort");
                    }
                }

                // relaunch the agent
                if (tcpSlaveAgentListener == null) {
                    if (slaveAgentPort != -1) {
                        tcpSlaveAgentListener = new TcpSlaveAgentListener(slaveAgentPort);
                    }
                } else {
                    if (tcpSlaveAgentListener.configuredPort != slaveAgentPort) {
                        tcpSlaveAgentListener.shutdown();
                        tcpSlaveAgentListener = null;
                        if (slaveAgentPort != -1) {
                            tcpSlaveAgentListener = new TcpSlaveAgentListener(slaveAgentPort);
                        }
                    }
                }
            }

            numExecutors = json.getInt("numExecutors");
            if (req.hasParameter("master.mode")) {
                mode = Mode.valueOf(req.getParameter("master.mode"));
            } else {
                mode = Mode.NORMAL;
            }

            label = json.optString("labelString", "");

            quietPeriod = json.getInt("quiet_period");

            scmCheckoutRetryCount = json.getInt("retry_count");

            systemMessage = Util.nullify(req.getParameter("system_message"));

            jdks.clear();
            jdks.addAll(req.bindJSONToList(JDK.class, json.get("jdks")));

            boolean result = true;
            for (Descriptor<?> d : Functions.getSortedDescriptorsForGlobalConfig()) {
                result &= configureDescriptor(req, json, d);
            }

            for (JSONObject o : StructuredForm.toList(json, "plugin")) {
                pluginManager.getPlugin(o.getString("name")).getPlugin().configure(req, o);
            }

            clouds.rebuildHetero(req, json, Cloud.all(), "cloud");

            JSONObject np = json.getJSONObject("globalNodeProperties");
            if (np != null) {
                globalNodeProperties.rebuild(req, np, NodeProperty.for_(this));
            }

            version = VERSION;

            save();
            updateComputerList();
            if (result) {
                rsp.sendRedirect(req.getContextPath() + '/')// go to the top page
            } else {
                rsp.sendRedirect("configure"); // back to config
            }
        } finally {
            bc.commit();
        }
    }
View Full Code Here


     * Accepts submission from the configuration page.
     */
    public synchronized void doConfigExecutorsSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
        checkPermission(ADMINISTER);

        BulkChange bc = new BulkChange(this);
        try {
            JSONObject json = req.getSubmittedForm();

            setNumExecutors(Integer.parseInt(req.getParameter("numExecutors")));
            if (req.hasParameter("master.mode")) {
                mode = Mode.valueOf(req.getParameter("master.mode"));
            } else {
                mode = Mode.NORMAL;
            }

            setNodes(req.bindJSONToList(Slave.class, json.get("slaves")));
        } finally {
            bc.commit();
        }

        rsp.sendRedirect(req.getContextPath() + '/')// go to the top page
    }
View Full Code Here

        return project.getEstimatedDuration();
    }

    public HttpResponse doConfigSubmit( StaplerRequest req ) throws IOException, ServletException, FormException {
        checkPermission(UPDATE);
        BulkChange bc = new BulkChange(this);
        try {
            JSONObject json = req.getSubmittedForm();
            submit(json);
            bc.commit();
        } finally {
            bc.abort();
        }
        return HttpResponses.redirectToDot();
    }
View Full Code Here

TOP

Related Classes of hudson.BulkChange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.