Search in sources :

Example 1 with DefaultMyViewsTabBar

use of hudson.views.DefaultMyViewsTabBar in project hudson-2.x by hudson.

the class Hudson method doConfigSubmit.

//
//
// actions
//
//
/**
     * 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();
        // 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) {
            // go to the top page
            rsp.sendRedirect(req.getContextPath() + '/');
        } else {
            // back to config
            rsp.sendRedirect("configure");
        }
    } finally {
        bc.commit();
    }
}
Also used : DefaultMyViewsTabBar(hudson.views.DefaultMyViewsTabBar) MyViewsTabBar(hudson.views.MyViewsTabBar) BulkChange(hudson.BulkChange) DefaultViewsTabBar(hudson.views.DefaultViewsTabBar) DefaultMyViewsTabBar(hudson.views.DefaultMyViewsTabBar) ViewsTabBar(hudson.views.ViewsTabBar) MyViewsTabBar(hudson.views.MyViewsTabBar) DefaultMyViewsTabBar(hudson.views.DefaultMyViewsTabBar) FormException(hudson.model.Descriptor.FormException) TcpSlaveAgentListener(hudson.TcpSlaveAgentListener) JSONObject(net.sf.json.JSONObject) RawHtmlMarkupFormatter(hudson.markup.RawHtmlMarkupFormatter) MarkupFormatter(hudson.markup.MarkupFormatter) DefaultViewsTabBar(hudson.views.DefaultViewsTabBar)

Aggregations

BulkChange (hudson.BulkChange)1 TcpSlaveAgentListener (hudson.TcpSlaveAgentListener)1 MarkupFormatter (hudson.markup.MarkupFormatter)1 RawHtmlMarkupFormatter (hudson.markup.RawHtmlMarkupFormatter)1 FormException (hudson.model.Descriptor.FormException)1 DefaultMyViewsTabBar (hudson.views.DefaultMyViewsTabBar)1 DefaultViewsTabBar (hudson.views.DefaultViewsTabBar)1 MyViewsTabBar (hudson.views.MyViewsTabBar)1 ViewsTabBar (hudson.views.ViewsTabBar)1 JSONObject (net.sf.json.JSONObject)1