Skip to content

Commit 7c7015f

Browse files
committed
fixed deprecations
1 parent 6a414ee commit 7c7015f

10 files changed

Lines changed: 22 additions & 18 deletions

File tree

app/controllers/AuthController.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class AuthController @Inject()(system: ActorSystem,
6060
}
6161

6262
def logout = Action { _ =>
63-
val prefix = configuration.getString("play.http.context").getOrElse("/")
63+
val prefix = configuration.getOptional[String]("play.http.context").getOrElse("/")
6464
Redirect(s"${prefix}login").withNewSession
6565
}
6666

app/controllers/auth/AuthConfig.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import play.api.Configuration
55
trait AuthConfig {
66

77
def getSetting(setting: String)(implicit config: Configuration) = {
8-
config.getString(setting).getOrElse(throw MissingSettingException(setting))
8+
config.getOptional[String](setting).getOrElse(throw MissingSettingException(setting))
99
}
1010

1111
}

app/controllers/auth/AuthenticationModule.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ trait AuthenticationModule {
1717
@Singleton
1818
class AuthenticationModuleImpl @Inject()(config: Configuration) extends AuthenticationModule {
1919

20-
val service = config.getString("auth.type") match {
20+
val service = config.getOptional[String]("auth.type") match {
2121
case Some("ldap") => Some(new LDAPAuthService(config))
2222
case Some("basic") => Some(new BasicAuthService(config))
2323
case _ => None

app/controllers/auth/basic/BasicAuthService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import play.api.Configuration
66

77
class BasicAuthService @Inject()(globalConfig: Configuration) extends AuthService {
88

9-
private implicit final val config = new BasicAuthConfig(globalConfig.getConfig("auth.settings").get)
9+
private implicit final val config = new BasicAuthConfig(globalConfig.get[Configuration]("auth.settings"))
1010

1111
def auth(username: String, password: String): Option[String] = {
1212
(username, password) match {

app/controllers/auth/ldap/LDAPAuthService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class LDAPAuthService @Inject()(globalConfig: Configuration) extends AuthService
1414

1515
private val log = org.slf4j.LoggerFactory.getLogger(classOf[LDAPAuthService])
1616

17-
private final val config = new LDAPAuthConfig(globalConfig.getConfig("auth.settings").get)
17+
private final val config = new LDAPAuthConfig(globalConfig.get[Configuration]("auth.settings"))
1818

1919
def auth(username: String, password: String): Option[String] = {
2020
val env = new Hashtable[String, String](11)

app/dao/RestHistoryDAO.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import java.util.Date
55
import com.google.inject.{ImplementedBy, Inject}
66
import play.api.Configuration
77
import play.api.db.slick.DatabaseConfigProvider
8-
import slick.driver.JdbcProfile
9-
import slick.driver.SQLiteDriver.api._
8+
import slick.jdbc.JdbcProfile
9+
import slick.jdbc.SQLiteProfile.api._
1010
import slick.lifted.TableQuery
1111

1212
import scala.concurrent.ExecutionContext.Implicits.global
@@ -28,7 +28,7 @@ trait RestHistoryDAO {
2828
class RestHistoryDAOImpl @Inject()(dbConfigProvider: DatabaseConfigProvider,
2929
config: Configuration) extends RestHistoryDAO {
3030

31-
private val max = config.getInt("rest.history.size").getOrElse(50)
31+
private val max = config.getOptional[Int]("rest.history.size").getOrElse(50)
3232

3333
private val dbConfig = dbConfigProvider.get[JdbcProfile]
3434

app/dao/RestRequest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dao
33
import java.security.MessageDigest
44
import java.util.Date
55

6-
import slick.driver.SQLiteDriver.api._
6+
import slick.jdbc.SQLiteProfile.api._
77
import slick.lifted.Tag
88

99
case class HashedRestRequest(path: String, method: String, body: String, username: String, createdAt: Long, md5: String)

app/elastic/HTTPElasticClient.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ class HTTPElasticClient @Inject()(client: WSClient) extends ElasticClient {
322322
val authentication = target.authentication
323323
val url = s"${target.host.replaceAll("/+$", "")}$uri"
324324
val request =
325-
authentication.foldLeft(client.url(url).withMethod(method).withHeaders(headers: _*)) {
325+
authentication.foldLeft(client.url(url).withMethod(method).withHttpHeaders(headers: _*)) {
326326
case (request, auth) =>
327327
request.withAuth(auth.username, auth.password, WSAuthScheme.BASIC)
328328
}

app/models/Hosts.scala

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import javax.inject.Singleton
55
import com.google.inject.{ImplementedBy, Inject}
66
import play.api.Configuration
77

8+
import scala.collection.JavaConverters._
9+
import scala.util.{Failure, Success, Try}
10+
11+
812
@ImplementedBy(classOf[HostsImpl])
913
trait Hosts {
1014

@@ -17,18 +21,18 @@ trait Hosts {
1721
@Singleton
1822
class HostsImpl @Inject()(config: Configuration) extends Hosts {
1923

20-
val hosts: Map[String, ElasticServer] = config.getConfigSeq("hosts") match {
21-
case Some(hostsConf) => hostsConf.map { hostConf =>
22-
val host = hostConf.getString("host").get
23-
val name = hostConf.getString("name").getOrElse(host)
24-
val username = hostConf.getString("auth.username")
25-
val password = hostConf.getString("auth.password")
24+
val hosts: Map[String, ElasticServer] = Try(config.underlying.getConfigList("hosts").asScala.map(Configuration(_))) match {
25+
case Success(hostsConf) => hostsConf.map { hostConf =>
26+
val host = hostConf.getOptional[String]("host").get
27+
val name = hostConf.getOptional[String]("name").getOrElse(host)
28+
val username = hostConf.getOptional[String]("auth.username")
29+
val password = hostConf.getOptional[String]("auth.password")
2630
(username, password) match {
2731
case (Some(username), Some(password)) => (name -> ElasticServer(host, Some(ESAuth(username, password))))
2832
case _ => (name -> ElasticServer(host, None))
2933
}
3034
}.toMap
31-
case _ => Map()
35+
case Failure(_) => Map()
3236
}
3337

3438
def getHostNames() = hosts.keys.toSeq

conf/reference.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Secret key
22
secret = "changeme"
3-
play.crypto.secret = ${secret}
3+
play.http.secret.key = ${secret}
44

55
es {
66
gzip = false

0 commit comments

Comments
 (0)