/*
 * Copyright 2016 EPAM Systems
 * 
 * 
 * This file is part of EPAM Report Portal.
 * https://github.com/epam/ReportPortal
 * 
 * Report Portal is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Report Portal 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Report Portal.  If not, see <http://www.gnu.org/licenses/>.
 */ 

package com.epam.ta.reportportal.ws.model.settings;

import java.io.Serializable;

import javax.validation.constraints.NotNull;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Configurable email setting for project object
 * 
 * @author Andrei_Ramanchuk
 */
@JsonInclude(Include.NON_NULL)
public class ServerEmailConfig implements Serializable {
	/**
	 * Generated SVUID
	 */
	private static final long serialVersionUID = 2573744596368345366L;

	@NotNull
	@JsonProperty(value = "host")
	private String host;

	@JsonProperty(value = "port")
	private int port = 25;

	@JsonProperty(value = "protocol")
	private String protocol = "smtp";

	@JsonProperty(value = "authEnabled")
	private Boolean authEnabled = false;

	@JsonProperty(value = "username")
	private String username;

	@JsonProperty(value = "password")
	private String password;

	@JsonProperty(value = "debug")
	@JsonIgnore
	private boolean debug;

	public ServerEmailConfig() {
	}

	public ServerEmailConfig(final String host, final int port, final String protocol, final boolean isAuth, final String username,
			final String password, final boolean debug) {
		this.host = host;
		this.port = port;
		this.protocol = protocol.toLowerCase();
		this.authEnabled = isAuth;
		this.username = username;
		this.password = password;
		this.debug = debug;
	}

	/* Setters and getters */
	public void setHost(String host) {
		this.host = host;
	}

	public String getHost() {
		return host;
	}

	public void setPort(int port) {
		this.port = port;
	}

	public int getPort() {
		return port;
	}

	public void setProtocol(String protocol) {
		this.protocol = protocol.toLowerCase();
	}

	public String getProtocol() {
		return protocol;
	}

	public void setAuthEnabled(boolean enable) {
		this.authEnabled = enable;
	}

	public Boolean getAuthEnabled() {
		return authEnabled;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getUsername() {
		return username;
	}

	public void setPassword(String pass) {
		this.password = pass;
	}

	public String getPassword() {
		return password;
	}

	public void setDebug(boolean debug) {
		this.debug = debug;
	}

	public boolean getDebug() {
		return debug;
	}

	@Override
	public String toString() {
		return "ServerEmailConfig [host=" + host + ", port=" + port + ", protocol=" + protocol + ", authEnabled=" + authEnabled
				+ ", username=" + username + ", debug=" + debug + "]";
	}
}
@@ -1670,24 +1670,82 @@
 d = false;%0A%0A
+%09@JsonProperty%0A%09private Boolean startTlsEnabled = false;%0A%0A
 %09@JsonProper
@@ -1986,22 +1986,16 @@
 lConfig(
-final 
 String h
@@ -1998,22 +1998,16 @@
 ng host,
- final
  int por
@@ -2008,22 +2008,16 @@
 nt port,
- final
  String 
@@ -2030,36 +2030,57 @@
 ol, 
-final boolean isAuth, final 
+Boolean authEnabled, Boolean startTlsEnabled,%0A%09%09%09
 Stri
@@ -2095,17 +2095,8 @@
 ame,
-%0A%09%09%09final
  Str
@@ -2108,22 +2108,16 @@
 assword,
- final
  boolean
@@ -2192,30 +2192,50 @@
 protocol
-.toLowerCase()
+;%0A%09%09this.authEnabled = authEnabled
 ;%0A%09%09this
@@ -2227,36 +2227,40 @@
 Enabled;%0A%09%09this.
-auth
+startTls
 Enabled = isAuth
@@ -2257,14 +2257,23 @@
 d = 
-isAuth
+startTlsEnabled
 ;%0A%09%09
@@ -2733,148 +2733,8 @@
 %09%7D%0A%0A
-%09public void setAuthEnabled(boolean enable) %7B%0A%09%09this.authEnabled = enable;%0A%09%7D%0A%0A%09public Boolean getAuthEnabled() %7B%0A%09%09return authEnabled;%0A%09%7D%0A%0A
 %09pub
@@ -2977,24 +2977,287 @@
 ssword;%0A%09%7D%0A%0A
+%09public void setAuthEnabled(Boolean authEnabled) %7B%0A%09%09this.authEnabled = authEnabled;%0A%09%7D%0A%0A%09public Boolean getStartTlsEnabled() %7B%0A%09%09return startTlsEnabled;%0A%09%7D%0A%0A%09public void setStartTlsEnabled(Boolean startTlsEnabled) %7B%0A%09%09this.startTlsEnabled = startTlsEnabled;%0A%09%7D%0A%0A
 %09public void
@@ -3582,8 +3582,9 @@
 %5D%22;%0A%09%7D%0A%7D
+%0A

update email server config. Add possibility to configure starttls