Skip to content

Commit

Permalink
Correct filtration of to licenses filter. Add capability of logging i…
Browse files Browse the repository at this point in the history
…n google cloud platform.
  • Loading branch information
RuiDTLima committed Jun 4, 2018
1 parent 1cdff90 commit 9840456
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 9 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ dependencies {
compile("org.jetbrains.kotlin:kotlin-reflect")
compile("org.ehcache:ehcache:3.1.3")
compile 'org.jsoup:jsoup:1.11.3'

runtime('org.postgresql:postgresql')
runtime('com.google.cloud:google-cloud-logging-logback:0.46.0-alpha')

testCompile('org.springframework.boot:spring-boot-starter-test')
testCompile('org.springframework.restdocs:spring-restdocs-mockmvc')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,16 @@ data class DependencyLicense(
val pk: DependencyLicensePk,

val source: String
) : Serializable
) : Serializable {
override fun equals(other: Any?): Boolean {
if (other is DependencyLicense){
val dependencyLicense = other as DependencyLicense?
return dependencyLicense!!.pk.license.spdxId.equals(this.pk.license.spdxId)
}
return false
}

override fun hashCode(): Int {
return this.pk.license.spdxId.hashCode() * 17
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ class ReportController(val reportService: ReportService,
val dependencyRepo: DependencyRepository,
val vulnerabilityRepo: VulnerabilityRepository,
val licenseRepo: LicenseRepository) {

/**
* Gets the view for the home page
*/
@GetMapping
fun getHome(model: HashMap<String, Any>) : String{

fun getHome(model: HashMap<String, Any>) : String
{
model["page_title"] = "Home"

val projects = projectRepo.findAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.github.ptosda.projectvalidationmanager.database.entities.*
import com.github.ptosda.projectvalidationmanager.database.repositories.ReportRepository
import org.springframework.stereotype.Service
import java.time.ZonedDateTime
import java.util.stream.Collectors

@Service
class ReportFilterService(private val reportService: ReportService,
Expand Down Expand Up @@ -113,7 +114,8 @@ class ReportFilterService(private val reportService: ReportService,
licenses.addAll(it.license)
}

model["licenses"] = licenses
val newLicenses = licenses.stream().distinct().collect(Collectors.toList())
model["licenses"] = newLicenses
model["view_name"] = "licenses"

return model
Expand Down Expand Up @@ -166,6 +168,4 @@ class ReportFilterService(private val reportService: ReportService,

return model
}


}
4 changes: 2 additions & 2 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
spring:
profiles.active: test
profiles.active: local

---

spring:
profiles: test
profiles: local
jpa:
database: POSTGRESQL
show-sql: true
Expand Down
26 changes: 26 additions & 0 deletions src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<configuration>
<springProfile name="local">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="org.springframework.web" level="INFO"/>
</springProfile>

<springProfile name="deploy">
<include resource="org/springframework/boot/logging/logback/base.xml"/>
<logger name="org.springframework.web" level="INFO"/>

<appender name="CLOUD" class="com.google.cloud.logging.logback.LoggingAppender">
<!-- Optional : filter logs at or above a level -->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
<log>application.log</log> <!-- Optional : default java.log -->
<resourceType>gae_app</resourceType> <!-- Optional : default: auto-detected, fallback: global -->
<enhancer>com.example.logging.logback.enhancers.ExampleEnhancer</enhancer> <!-- Optional -->
<flushLevel>WARN</flushLevel> <!-- Optional : default ERROR -->
</appender>

<root level="info">
<appender-ref ref="CLOUD" />
</root>
</springProfile>
</configuration>

0 comments on commit 9840456

Please sign in to comment.