Skip to content

Commit

Permalink
Resolve most deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfurey committed Dec 20, 2024
1 parent f94477f commit 3897427
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 23 deletions.
4 changes: 2 additions & 2 deletions app/controllers/ReadOnlyApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ReadOnlyApi(
val xmlTags = tags.get.sortBy(_.id).map(_.asExportedXml(sections))

Ok(<tags>
{xmlTags.seq.map { x => x }}
{xmlTags.map { x => x }}
</tags>)
}

Expand All @@ -48,7 +48,7 @@ class ReadOnlyApi(


Ok(<sections>
{xmlSections.seq.map { x => x }}
{xmlSections.map { x => x }}
</sections>)
}

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Support.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import services.{AWS, Config, FetchError, ImageMetadataService, InvalidImage}

import scala.concurrent.{ExecutionContext, Future}
import scala.util.control.NonFatal
import collection.JavaConverters._
import scala.jdk.CollectionConverters._

class Support(
val wsClient: WSClient,
Expand Down
2 changes: 1 addition & 1 deletion app/model/command/RemoveEditionFromSectionCommand.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ case class RemoveEditionFromSectionCommand(sectionId: Long, editionName: String)

val pageId = try { PathManager.removePathForId(editionInfo.pageId) } catch { case p: PathRemoveFailed => PathNotFound}

val updatedEditions = section.editions.filterKeys(_.toUpperCase != editionName.toUpperCase).toMap
val updatedEditions = section.editions.view.filterKeys(_.toUpperCase != editionName.toUpperCase).toMap

val updatedSection = section.copy(
editions = updatedEditions,
Expand Down
2 changes: 1 addition & 1 deletion app/repositories/ContentAPI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object ContentAPI extends Logging {

def countOccurencesOfTagInContents(contentIds: List[String], apiTagId: String)(implicit ec: ExecutionContext): Int = {
if (contentIds.nonEmpty) {
val builder = StringBuilder.newBuilder
val builder = new StringBuilder()
var pageSize = 0

var total = 0
Expand Down
58 changes: 41 additions & 17 deletions app/services/AWS.scala
Original file line number Diff line number Diff line change
@@ -1,36 +1,54 @@
package services

import java.nio.ByteBuffer

import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider
import com.amazonaws.auth.profile.ProfileCredentialsProvider
import com.amazonaws.regions.{Region, Regions}
import com.amazonaws.services.cloudwatch.AmazonCloudWatchAsyncClient
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient
import com.amazonaws.services.cloudwatch.AmazonCloudWatchAsyncClientBuilder
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder
import com.amazonaws.services.dynamodbv2.document.DynamoDB
import com.amazonaws.services.ec2.AmazonEC2Client
import com.amazonaws.services.ec2.AmazonEC2ClientBuilder
import com.amazonaws.services.ec2.model.{DescribeTagsRequest, Filter}
import com.amazonaws.services.kinesis.AmazonKinesisClient
import com.amazonaws.services.s3.AmazonS3Client
import com.amazonaws.services.sqs.AmazonSQSClient
import com.amazonaws.services.kinesis.AmazonKinesisClientBuilder
import com.amazonaws.services.s3.{AmazonS3Client, AmazonS3ClientBuilder}
import com.amazonaws.services.sqs.AmazonSQSClientBuilder
import com.amazonaws.util.EC2MetadataUtils
import com.twitter.scrooge.ThriftStruct
import play.api.Logging
import services.AWS.region

import scala.jdk.CollectionConverters._

object AWS {

lazy val region = Region getRegion Regions.EU_WEST_1

lazy val EC2Client = region.createClient(classOf[AmazonEC2Client], null, null)
lazy val CloudWatch = region.createClient(classOf[AmazonCloudWatchAsyncClient], null, null)
lazy val Kinesis = region.createClient(classOf[AmazonKinesisClient], null, null)
lazy val S3Client = region.createClient(classOf[AmazonS3Client], null, null)

private lazy val frontendCredentialsProvider = Config().frontendBucketWriteRole.map(new STSAssumeRoleSessionCredentialsProvider(_, "tagManager"))

lazy val frontendStaticFilesS3Client = region.createClient(classOf[AmazonS3Client], frontendCredentialsProvider.getOrElse(new ProfileCredentialsProvider("frontend")), null)
lazy val EC2Client = AmazonEC2ClientBuilder
.standard()
.withRegion(region.getName)
.build()
lazy val CloudWatch = AmazonCloudWatchAsyncClientBuilder
.standard()
.withRegion(region.getName)
.build()
lazy val Kinesis = AmazonKinesisClientBuilder
.standard()
.withRegion(region.getName)
.build()
lazy val S3Client = AmazonS3ClientBuilder
.standard()
.withRegion(region.getName)
.build()

private lazy val frontendCredentialsProvider = Config().frontendBucketWriteRole.map(
new STSAssumeRoleSessionCredentialsProvider.Builder(_, "tagManager").build()
)

lazy val frontendStaticFilesS3Client = AmazonS3ClientBuilder
.standard()
.withCredentials(frontendCredentialsProvider.getOrElse(new ProfileCredentialsProvider("frontend")))
.withRegion(region.getName)
.build()
}

trait AwsInstanceTags {
Expand All @@ -51,7 +69,10 @@ trait AwsInstanceTags {
}

object Dynamo {
lazy val client = AWS.region.createClient(classOf[AmazonDynamoDBClient], null, null)
lazy val client = AmazonDynamoDBClientBuilder
.standard()
.withRegion(AWS.region.getName)
.build()
lazy val dynamoDb = new DynamoDB(client)

lazy val tagTable = dynamoDb.getTable(Config().tagsTableName)
Expand All @@ -72,7 +93,10 @@ object Dynamo {
}

object SQS {
lazy val SQSClient = AWS.region.createClient(classOf[AmazonSQSClient], null, null)
lazy val SQSClient = AmazonSQSClientBuilder
.standard()
.withRegion(region.getName)
.build()

lazy val jobQueue = new SQSQueue(Config().jobQueueName)
}
Expand Down
2 changes: 1 addition & 1 deletion app/services/SQSQueue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.util.concurrent.atomic.AtomicBoolean

import com.amazonaws.services.sqs.model._
import play.api.Logging
import collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.annotation.tailrec
import scala.util.control.NonFatal

Expand Down

0 comments on commit 3897427

Please sign in to comment.