doPost: function()

in sonar-plugin-server/src/main/resources/buildServerResources/manageSonarServers.js [164:236]


        doPost: function() {
            this.cleanErrors();

            if (!this.doValidate()) {
                return false;
            }

            var parameters = {
                "serverinfo.name": $j(".runnerFormTable input[id='serverinfo.name']").val(),
                "sonar.host.url" : $j(".runnerFormTable input[id='sonar.host.url']").val(),
                "sonar.useTokenLogin": $j(".runnerFormTable input[name='sonar.useTokenLogin']:checked").val(),
                "sonar.login": $j(".runnerFormTable input[id='sonar.login']").val(),
                "sonar.jdbc.url": $j(".runnerFormTable input[id='sonar.jdbc.url']").val(),
                "sonar.jdbc.username": $j(".runnerFormTable input[id='sonar.jdbc.username']").val(),
                "projectId": $j("#serverInfoForm #projectId").val(),
                action: $j("#serverInfoForm #SQSaction").val(),
                "serverinfo.id": $j("#serverInfoForm input[id='serverinfo.id']").val(),
                "publicKey" : $j("#serverInfoForm #publicKey").val()
            };

            var $jdbcPasswordField = $j(".runnerFormTable input[id='sonar.jdbc.password_field']");
            if ($jdbcPasswordField.attr("data-modified") == "modified") {
                parameters["sonar.jdbc.password"] = SonarPlugin.encryptPassword($jdbcPasswordField.val());
            } else {
                parameters["sonar.jdbc.password_preserve"] = "true";
            }

            var $passwordField = $j(".runnerFormTable input[id='sonar.password_field']");
            if ($passwordField.attr("data-modified") == "modified") {
                parameters["sonar.password"] = SonarPlugin.encryptPassword($passwordField.val());
            } else {
                parameters["sonar.password_preserve"] = "true";
            }

            var $tokenField = $j(".runnerFormTable input[id='sonar.token_field']");
            if ($tokenField.attr("data-modified") == "modified") {
                parameters["sonar.token"] = SonarPlugin.encryptPassword($tokenField.val());
            } else {
                parameters["sonar.token_preserve"] = "true";
            }

            var dialog = this;

            BS.ajaxRequest(window['base_uri'] + '/admin/manageSonarServers.html', {
                parameters: parameters,
                onComplete: function(transport) {
                    var shouldClose = true;
                    if (transport != null && transport.responseXML != null) {
                        var response = transport.responseXML.getElementsByTagName("response");
                        if (response != null && response.length > 0) {
                            var responseTag = response[0];
                            var error = responseTag.getAttribute("error");
                            if (error != null) {
                                shouldClose = false;
                                alert(error);
                            }
                            if (responseTag.getAttribute("status") == "OK") {
                                shouldClose = true;
                            } else if (responseTag.firstChild == null) {
                                shouldClose = false;
                                alert("Error: empty response");
                            }
                        }
                    }
                    if (shouldClose) {
                        $("SQservers").refresh();
                        dialog.close();
                    }
                }
            });

            return false;
        }