import org.apache.commons.mail.SimpleEmail;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.sonar.api.config.EmailSettings;
import org.sonar.api.database.model.User;
import org.sonar.api.notifications.Notification;
import org.sonar.api.notifications.NotificationChannel;
-import org.sonar.api.platform.EmailSettings;
import org.sonar.api.security.UserFinder;
import org.sonar.api.utils.SonarException;
import org.sonar.plugins.emailnotifications.api.EmailMessage;
email.setHostName(configuration.getSmtpHost());
if (StringUtils.equalsIgnoreCase(configuration.getSecureConnection(), "SSL")) {
email.setSSL(true);
- email.setSslSmtpPort(configuration.getSmtpPort());
+ email.setSslSmtpPort(String.valueOf(configuration.getSmtpPort()));
// this port is not used except in EmailException message, that's why it's set with the same value than SSL port.
// It prevents from getting bad message.
- email.setSmtpPort(Integer.parseInt(configuration.getSmtpPort()));
+ email.setSmtpPort(configuration.getSmtpPort());
} else if (StringUtils.isBlank(configuration.getSecureConnection())) {
- email.setSmtpPort(Integer.parseInt(configuration.getSmtpPort()));
+ email.setSmtpPort(configuration.getSmtpPort());
} else {
throw new SonarException("Unknown type of SMTP secure connection: " + configuration.getSecureConnection());
}
package org.sonar.plugins.emailnotifications.newviolations;
import org.sonar.api.notifications.Notification;
-import org.sonar.api.platform.EmailSettings;
+import org.sonar.api.config.EmailSettings;
import org.sonar.plugins.emailnotifications.api.EmailMessage;
import org.sonar.plugins.emailnotifications.api.EmailTemplate;
package org.sonar.plugins.emailnotifications.reviews;
import org.apache.commons.lang.StringUtils;
+import org.sonar.api.config.EmailSettings;
import org.sonar.api.database.model.User;
import org.sonar.api.notifications.Notification;
-import org.sonar.api.platform.EmailSettings;
import org.sonar.api.security.UserFinder;
import org.sonar.plugins.emailnotifications.api.EmailMessage;
import org.sonar.plugins.emailnotifications.api.EmailTemplate;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
-import org.sonar.api.platform.EmailSettings;
+import org.sonar.api.config.EmailSettings;
import org.sonar.plugins.emailnotifications.api.EmailMessage;
import org.subethamail.wiser.Wiser;
import org.subethamail.wiser.WiserMessage;
private void configure() {
when(configuration.getSmtpHost()).thenReturn("localhost");
- when(configuration.getSmtpPort()).thenReturn(Integer.toString(port));
+ when(configuration.getSmtpPort()).thenReturn(port);
when(configuration.getFrom()).thenReturn("server@nowhere");
when(configuration.getPrefix()).thenReturn("[SONAR]");
when(configuration.getServerBaseURL()).thenReturn("http://nemo.sonarsource.org");
import org.junit.Before;
import org.junit.Test;
+import org.sonar.api.config.EmailSettings;
import org.sonar.api.notifications.Notification;
-import org.sonar.api.platform.EmailSettings;
import org.sonar.plugins.emailnotifications.api.EmailMessage;
import static org.hamcrest.Matchers.is;
import org.junit.Before;
import org.junit.Test;
+import org.sonar.api.config.EmailSettings;
import org.sonar.api.database.model.User;
import org.sonar.api.notifications.Notification;
-import org.sonar.api.platform.EmailSettings;
import org.sonar.api.security.UserFinder;
import org.sonar.plugins.emailnotifications.api.EmailMessage;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.sonar.api.batch.bootstrap.ProjectReactor;
-import org.sonar.api.platform.EmailSettings;
+import org.sonar.api.config.EmailSettings;
import org.sonar.api.utils.HttpDownloader;
import org.sonar.batch.FakeMavenPluginExecutor;
import org.sonar.batch.MavenPluginExecutor;
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.config;
+
+import com.google.common.base.Objects;
+import org.sonar.api.BatchComponent;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.ServerComponent;
+import org.sonar.api.config.Settings;
+
+/**
+ * Ruby uses constants from this class.
+ *
+ * @since 3.2
+ */
+public class EmailSettings implements BatchComponent, ServerComponent {
+ public static final String SMTP_HOST = "email.smtp_host.secured";
+ public static final String SMTP_HOST_DEFAULT = "";
+ public static final String SMTP_PORT = "email.smtp_port.secured";
+ public static final String SMTP_PORT_DEFAULT = "25";
+ public static final String SMTP_SECURE_CONNECTION = "email.smtp_secure_connection.secured";
+ public static final String SMTP_SECURE_CONNECTION_DEFAULT = "";
+ public static final String SMTP_USERNAME = "email.smtp_username.secured";
+ public static final String SMTP_USERNAME_DEFAULT = "";
+ public static final String SMTP_PASSWORD = "email.smtp_password.secured";
+ public static final String SMTP_PASSWORD_DEFAULT = "";
+ public static final String FROM = "email.from";
+ public static final String FROM_DEFAULT = "noreply@nowhere";
+ public static final String PREFIX = "email.prefix";
+ public static final String PREFIX_DEFAULT = "[SONAR]";
+
+ private final Settings settings;
+
+ public EmailSettings(Settings settings) {
+ this.settings = settings;
+ }
+
+ public String getSmtpHost() {
+ return get(SMTP_HOST, SMTP_HOST_DEFAULT);
+ }
+
+ public int getSmtpPort() {
+ return Integer.parseInt(get(SMTP_PORT, SMTP_PORT_DEFAULT));
+ }
+
+ public String getSecureConnection() {
+ return get(SMTP_SECURE_CONNECTION, SMTP_SECURE_CONNECTION_DEFAULT);
+ }
+
+ public String getSmtpUsername() {
+ return get(SMTP_USERNAME, SMTP_USERNAME_DEFAULT);
+ }
+
+ public String getSmtpPassword() {
+ return get(SMTP_PASSWORD, SMTP_PASSWORD_DEFAULT);
+ }
+
+ public String getFrom() {
+ return get(FROM, FROM_DEFAULT);
+ }
+
+ public String getPrefix() {
+ return get(PREFIX, PREFIX_DEFAULT);
+ }
+
+ public String getServerBaseURL() {
+ return get(CoreProperties.SERVER_BASE_URL, CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE);
+ }
+
+ private String get(String key, String defaultValue) {
+ return Objects.firstNonNull(settings.getString(key), defaultValue);
+ }
+}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.platform;
-
-import com.google.common.base.Objects;
-import org.sonar.api.BatchComponent;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.ServerComponent;
-import org.sonar.api.config.Settings;
-
-/**
- * Ruby uses constants from this class.
- *
- * @since 3.2
- */
-public class EmailSettings implements BatchComponent, ServerComponent {
- public static final String SMTP_HOST = "email.smtp_host.secured";
- public static final String SMTP_HOST_DEFAULT = "";
- public static final String SMTP_PORT = "email.smtp_port.secured";
- public static final String SMTP_PORT_DEFAULT = "25";
- public static final String SMTP_SECURE_CONNECTION = "email.smtp_secure_connection.secured";
- public static final String SMTP_SECURE_CONNECTION_DEFAULT = "";
- public static final String SMTP_USERNAME = "email.smtp_username.secured";
- public static final String SMTP_USERNAME_DEFAULT = "";
- public static final String SMTP_PASSWORD = "email.smtp_password.secured";
- public static final String SMTP_PASSWORD_DEFAULT = "";
- public static final String FROM = "email.from";
- public static final String FROM_DEFAULT = "noreply@nowhere";
- public static final String PREFIX = "email.prefix";
- public static final String PREFIX_DEFAULT = "[SONAR]";
-
- private final Settings settings;
-
- public EmailSettings(Settings settings) {
- this.settings = settings;
- }
-
- public String getSmtpHost() {
- return get(SMTP_HOST, SMTP_HOST_DEFAULT);
- }
-
- public String getSmtpPort() {
- return get(SMTP_PORT, SMTP_PORT_DEFAULT);
- }
-
- public String getSecureConnection() {
- return get(SMTP_SECURE_CONNECTION, SMTP_SECURE_CONNECTION_DEFAULT);
- }
-
- public String getSmtpUsername() {
- return get(SMTP_USERNAME, SMTP_USERNAME_DEFAULT);
- }
-
- public String getSmtpPassword() {
- return get(SMTP_PASSWORD, SMTP_PASSWORD_DEFAULT);
- }
-
- public String getFrom() {
- return get(FROM, FROM_DEFAULT);
- }
-
- public String getPrefix() {
- return get(PREFIX, PREFIX_DEFAULT);
- }
-
- public String getServerBaseURL() {
- return get(CoreProperties.SERVER_BASE_URL, CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE);
- }
-
- private String get(String key, String defaultValue) {
- return Objects.firstNonNull(settings.getString(key), defaultValue);
- }
-}
--- /dev/null
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.api.config;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.sonar.api.CoreProperties;
+import org.sonar.api.config.EmailSettings;
+import org.sonar.api.config.Settings;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class EmailSettingsTest {
+ EmailSettings emailSettings;
+
+ @Before
+ public void setUp() {
+ emailSettings = new EmailSettings(new Settings());
+ }
+
+ @Test
+ public void should_return_default_values() {
+ assertThat(emailSettings.getSmtpHost()).isEqualTo("");
+ assertThat(emailSettings.getSmtpPort()).isEqualTo(25);
+ assertThat(emailSettings.getSmtpUsername()).isEmpty();
+ assertThat(emailSettings.getSmtpPassword()).isEmpty();
+ assertThat(emailSettings.getSecureConnection()).isEmpty();
+ assertThat(emailSettings.getFrom()).isEqualTo("noreply@nowhere");
+ assertThat(emailSettings.getPrefix()).isEqualTo("[SONAR]");
+ assertThat(emailSettings.getServerBaseURL()).isEqualTo(CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE);
+ }
+}
+++ /dev/null
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2012 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * Sonar is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.platform;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.config.Settings;
-
-import static org.fest.assertions.Assertions.assertThat;
-
-public class EmailSettingsTest {
- EmailSettings emailSettings;
-
- @Before
- public void setUp() {
- emailSettings = new EmailSettings(new Settings());
- }
-
- @Test
- public void should_return_default_values() {
- assertThat(emailSettings.getSmtpHost()).isEqualTo("");
- assertThat(emailSettings.getSmtpPort()).isEqualTo("25");
- assertThat(emailSettings.getSmtpUsername()).isEmpty();
- assertThat(emailSettings.getSmtpPassword()).isEmpty();
- assertThat(emailSettings.getSecureConnection()).isEmpty();
- assertThat(emailSettings.getFrom()).isEqualTo("noreply@nowhere");
- assertThat(emailSettings.getPrefix()).isEqualTo("[SONAR]");
- assertThat(emailSettings.getServerBaseURL()).isEqualTo(CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE);
- }
-}
*/
package org.sonar.server.platform;
-import org.sonar.api.platform.EmailSettings;
+import org.sonar.api.config.EmailSettings;
import org.apache.commons.configuration.BaseConfiguration;
import org.slf4j.LoggerFactory;
private
def configuration
- java_facade.getComponentByClassname('emailnotifications', 'org.sonar.api.platform.EmailSettings').class
+ java_facade.getComponentByClassname('emailnotifications', 'org.sonar.api.config.EmailSettings').class
end
end