Skip to content

Commit 407964c

Browse files
authored
#752: Fixed compiler warnings in maven (#775)
* #752: Fixed compiler warnings in maven
1 parent 006d271 commit 407964c

File tree

71 files changed

+234
-254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+234
-254
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
<modelVersion>4.0.0</modelVersion>
2020
<version>0.5.15-SNAPSHOT</version>
21-
<groupId>za.co.absa</groupId>
2221

2322
<parent>
2423
<groupId>za.co.absa</groupId>
@@ -439,6 +438,7 @@
439438
<plugin>
440439
<groupId>net.alchim31.maven</groupId>
441440
<artifactId>scala-maven-plugin</artifactId>
441+
<version>${scala-maven-plugin.version}</version>
442442
<executions>
443443
<execution>
444444
<id>scala-compile</id>

src/main/scala/za/co/absa/hyperdrive/trigger/api/rest/WebMvcConfig.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import org.springframework.web.servlet.config.annotation.{ViewControllerRegistry
2121

2222
@Configuration
2323
class WebMvcConfig extends WebMvcConfigurer {
24-
override def addViewControllers(registry: ViewControllerRegistry) {
25-
registry.addViewController("/").setViewName("forward:/index.html");
24+
override def addViewControllers(registry: ViewControllerRegistry): Unit = {
25+
registry.addViewController("/").setViewName("forward:/index.html")
2626
}
2727
}

src/main/scala/za/co/absa/hyperdrive/trigger/api/rest/WebSecurityConfig.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class WebSecurityConfig @Inject() (val beanFactory: BeanFactory, authConfig: Aut
7676
// Disable security for isManager endpoint
7777
web.ignoring.antMatchers("/admin/isManager")
7878

79-
override def configure(http: HttpSecurity) {
79+
override def configure(http: HttpSecurity): Unit = {
8080
http
8181
.csrf()
8282
.ignoringAntMatchers("/login")
@@ -117,18 +117,16 @@ class WebSecurityConfig @Inject() (val beanFactory: BeanFactory, authConfig: Aut
117117
}
118118

119119
override def configure(auth: AuthenticationManagerBuilder): Unit =
120-
this.getAuthentication().configure(auth)
120+
this.getAuthentication.configure(auth)
121121

122-
private def getAuthentication(): HyperdriverAuthentication =
122+
private def getAuthentication: HyperdriverAuthentication =
123123
authMechanism.toLowerCase match {
124-
case "inmemory" => {
124+
case "inmemory" =>
125125
logger.info(s"Using $authMechanism authentication")
126126
beanFactory.getBean(classOf[InMemoryAuthentication])
127-
}
128-
case "ldap" => {
127+
case "ldap" =>
129128
logger.info(s"Using $authMechanism authentication")
130129
beanFactory.getBean(classOf[LdapAuthentication])
131-
}
132130
case _ => throw new IllegalArgumentException("Invalid authentication mechanism - use one of: inmemory, ldap")
133131
}
134132

src/main/scala/za/co/absa/hyperdrive/trigger/api/rest/auth/HyperdriverAuthentication.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ package za.co.absa.hyperdrive.trigger.api.rest.auth
1818
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
1919

2020
trait HyperdriverAuthentication {
21-
def configure(auth: AuthenticationManagerBuilder)
21+
def configure(auth: AuthenticationManagerBuilder): Unit
2222
}

src/main/scala/za/co/absa/hyperdrive/trigger/api/rest/auth/InMemoryAuthentication.scala

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
package za.co.absa.hyperdrive.trigger.api.rest.auth
1717

1818
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
19-
import org.springframework.security.crypto.password.NoOpPasswordEncoder
19+
import org.springframework.security.crypto.factory.PasswordEncoderFactories
20+
import org.springframework.security.crypto.password.PasswordEncoder
2021
import org.springframework.stereotype.Component
2122
import za.co.absa.hyperdrive.trigger.configuration.application.AuthConfig
2223

@@ -31,24 +32,24 @@ class InMemoryAuthentication @Inject() (authConfig: AuthConfig) extends Hyperdri
3132
val adminPassword: String = authConfig.inMemoryAdminPassword
3233
val adminRole: Option[String] = authConfig.adminRole
3334

34-
def validateParams() {
35+
def validateParams(): Unit = {
3536
if (username.isEmpty || password.isEmpty) {
3637
throw new IllegalArgumentException("Both username and password have to configured for inmemory authentication.")
3738
}
3839
}
3940

40-
override def configure(auth: AuthenticationManagerBuilder) {
41+
override def configure(auth: AuthenticationManagerBuilder): Unit = {
42+
val encoder: PasswordEncoder = PasswordEncoderFactories.createDelegatingPasswordEncoder()
43+
4144
this.validateParams()
4245
auth
4346
.inMemoryAuthentication()
44-
.passwordEncoder(NoOpPasswordEncoder.getInstance())
4547
.withUser(username)
46-
.password(password)
48+
.password(encoder.encode(password))
4749
.authorities(ROLE_USER)
4850
.and()
49-
.passwordEncoder(NoOpPasswordEncoder.getInstance())
5051
.withUser(adminUsername)
51-
.password(adminPassword)
52+
.password(encoder.encode(adminPassword))
5253
.authorities(adminRole.getOrElse(ROLE_USER))
5354
}
5455
}

src/main/scala/za/co/absa/hyperdrive/trigger/api/rest/auth/LdapAuthentication.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class LdapAuthentication @Inject() (authConfig: AuthConfig) extends HyperdriverA
3737
(ldapSearchFilter, "auth.ldap.search.filter")
3838
)
3939

40-
private def validateParams() {
40+
private def validateParams(): Unit = {
4141
requiredParameters.foreach {
4242
case param if param._1.isEmpty =>
4343
throw new IllegalArgumentException(s"${param._2} has to be configured in order to use ldap authentication")

src/main/scala/za/co/absa/hyperdrive/trigger/api/rest/auth/LdapGrantedAuthoritiesMapper.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,17 @@ import org.springframework.security.core.authority.{AuthorityUtils, SimpleGrante
2222
import java.util
2323

2424
class LdapGrantedAuthoritiesMapper extends GrantedAuthoritiesMapper {
25-
import scala.collection.JavaConversions._
25+
import scala.collection.JavaConverters._
2626

2727
override def mapAuthorities(
2828
grantedAuthorities: util.Collection[_ <: GrantedAuthority]
2929
): util.Collection[_ <: GrantedAuthority] =
3030
if (grantedAuthorities == null) {
3131
AuthorityUtils.NO_AUTHORITIES
3232
} else {
33-
grantedAuthorities.map(grantedAuthority => new SimpleGrantedAuthority(grantedAuthority.getAuthority)).toList
33+
grantedAuthorities.asScala
34+
.map(grantedAuthority => new SimpleGrantedAuthority(grantedAuthority.getAuthority))
35+
.toList
36+
.asJava
3437
}
3538
}

src/main/scala/za/co/absa/hyperdrive/trigger/api/rest/controllers/NotificationRuleController.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class NotificationRuleController @Inject() (notificationRuleService: Notificatio
3737
notificationRuleService.getNotificationRule(id).toJava.toCompletableFuture
3838

3939
@GetMapping(path = Array("/notificationRules"))
40-
def getNotificationRules(): CompletableFuture[Seq[NotificationRule]] =
40+
def getNotificationRules: CompletableFuture[Seq[NotificationRule]] =
4141
notificationRuleService.getNotificationRules().toJava.toCompletableFuture
4242

4343
@PostMapping(path = Array("/notificationRule"))

src/main/scala/za/co/absa/hyperdrive/trigger/api/rest/controllers/UtilController.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class UtilController {
4040
)
4141
QuartzExpressionDetail(expression = expression, isValid = true, explained = description)
4242
} catch {
43-
case e: CronExpressionParseException if CronExpression.isValidExpression(expression) =>
43+
case _: CronExpressionParseException if CronExpression.isValidExpression(expression) =>
4444
QuartzExpressionDetail(
4545
expression = expression,
4646
isValid = true,

src/main/scala/za/co/absa/hyperdrive/trigger/api/rest/controllers/WorkflowController.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class WorkflowController @Inject() (workflowService: WorkflowService, generalCon
5252
workflowService.getWorkflow(id).toJava.toCompletableFuture
5353

5454
@GetMapping(path = Array("/workflows"))
55-
def getWorkflows(): CompletableFuture[Seq[Workflow]] =
55+
def getWorkflows: CompletableFuture[Seq[Workflow]] =
5656
workflowService.getWorkflows.toJava.toCompletableFuture
5757

5858
@PostMapping(path = Array("/workflows/search"))
@@ -85,15 +85,15 @@ class WorkflowController @Inject() (workflowService: WorkflowService, generalCon
8585
workflowService.updateWorkflowsIsActive(jobIdsWrapper.jobIds, isActiveNewValue).toJava.toCompletableFuture
8686

8787
@GetMapping(path = Array("/workflows/projectNames"))
88-
def getProjectNames(): CompletableFuture[Set[String]] =
88+
def getProjectNames: CompletableFuture[Set[String]] =
8989
workflowService.getProjectNames.toJava.toCompletableFuture
9090

9191
@GetMapping(path = Array("/workflows/projects"))
92-
def getProjects(): CompletableFuture[Seq[Project]] =
92+
def getProjects: CompletableFuture[Seq[Project]] =
9393
workflowService.getProjects.toJava.toCompletableFuture
9494

9595
@GetMapping(path = Array("/workflows/projectsInfo"))
96-
def getProjectsInfo(): CompletableFuture[Seq[ProjectInfo]] =
96+
def getProjectsInfo: CompletableFuture[Seq[ProjectInfo]] =
9797
workflowService.getProjectsInfo().toJava.toCompletableFuture
9898

9999
@PutMapping(path = Array("/workflows/run"))
@@ -144,7 +144,7 @@ class WorkflowController @Inject() (workflowService: WorkflowService, generalCon
144144
ResponseEntity
145145
.ok()
146146
.contentType(MediaType.parseMediaType("application/zip"))
147-
.header(HttpHeaders.CONTENT_DISPOSITION, s"attachment; filename=workflows-${environment}.zip")
147+
.header(HttpHeaders.CONTENT_DISPOSITION, s"attachment; filename=workflows-$environment.zip")
148148
.body(new ByteArrayResource(baos.toByteArray))
149149
}
150150

0 commit comments

Comments
 (0)