Skip to content

Commit

Permalink
feat: Remove unused controllers + add basic auth for actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Guillaume Naimi committed Dec 16, 2019
1 parent ac29419 commit 7da42db
Show file tree
Hide file tree
Showing 148 changed files with 87 additions and 47,447 deletions.
15 changes: 4 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,15 @@ dependencies {
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${kotlinVersion}")
compile("org.jetbrains.kotlin:kotlin-reflect:${kotlinVersion}")
compile("org.springframework.boot:spring-boot-starter-data-mongodb")
compile("org.springframework.boot:spring-boot-starter-mail")
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile("org.springframework.boot:spring-boot-starter-security")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.security.oauth:spring-security-oauth2")
compile("com.fasterxml.jackson.module:jackson-module-kotlin:${jacksonModuleVersion}")
compile("me.ramswaroop.jbot:jbot:${jbotVersion}")
compile("io.springfox:springfox-swagger2:${swaggerVersion}")
compile("io.springfox:springfox-swagger-ui:${swaggerVersion}")
//Just for the login/logout demo START
compile("org.webjars:angularjs:1.4.3")
compile("org.webjars:jquery:2.1.1")
compile("org.webjars:bootstrap:3.2.0")
compile("org.webjars:webjars-locator")
compile 'com.google.api-client:google-api-client:1.25.0'

testCompile("org.springframework.boot:spring-boot-starter-test")


testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("org.springframework.security:spring-security-test")
testCompile("org.amshove.kluent:kluent:${kluentVersion}")
testCompile("com.nhaarman:mockito-kotlin-kt1.1:${mockitoVersion}")
Expand Down
18 changes: 0 additions & 18 deletions src/main/kotlin/io/saagie/astonparking/AstonParkingApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ import org.springframework.context.annotation.Configuration
import org.springframework.scheduling.annotation.EnableAsync
import org.springframework.scheduling.annotation.EnableScheduling
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
import springfox.documentation.builders.PathSelectors
import springfox.documentation.builders.RequestHandlerSelectors
import springfox.documentation.spi.DocumentationType
import springfox.documentation.spring.web.plugins.Docket
import springfox.documentation.swagger2.annotations.EnableSwagger2
import java.util.concurrent.Executor


Expand All @@ -33,19 +28,6 @@ class AstonParkingApplication {

}

@Configuration
@EnableSwagger2
class SwaggerConfig {
@Bean
fun api(): Docket {
return Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}

fun main(args: Array<String>) {
SpringApplication.run(AstonParkingApplication::class.java, *args)
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

8 changes: 1 addition & 7 deletions src/main/kotlin/io/saagie/astonparking/domain/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,9 @@ data class User(
@JsonIgnore @Id val id: String?,
val username: String,
var email: String? = null,
var image_24: String? = null,
var image_32: String? = null,
var image_48: String? = null,
var image_72: String? = null,
var image_192: String? = null,
var image_512: String? = null,
var creationDate: Date = Date.from(Instant.now()),
var attribution: Int = 0,
var enable: Boolean = false,
var enable: Boolean = true,
var activated: Boolean = false,
var alreadySelected: Boolean = false,
var hasFixedSpot: Boolean = false,
Expand Down
19 changes: 10 additions & 9 deletions src/main/kotlin/io/saagie/astonparking/googleActions/Actions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import com.google.actions.api.ActionRequest
import com.google.actions.api.ActionResponse
import com.google.actions.api.DialogflowApp
import com.google.actions.api.ForIntent
import io.saagie.astonparking.domain.Schedule
import io.saagie.astonparking.domain.ScheduleSpot
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken
import io.saagie.astonparking.service.DrawService
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component
import java.time.LocalDate
import java.time.LocalDateTime



@Component
class Actions(private val drawService: DrawService) : DialogflowApp() {

@ForIntent("today spots")
fun todaySpots(request: ActionRequest): ActionResponse {
LOGGER.info("today spots.")
val responseBuilder = getResponseBuilder(request)
with(drawService.getCurrentSchedules().firstOrNull { it.date == LocalDate.now() }) {
with(drawService.getSchedule(LocalDate.now())) {
if (this == null) {
responseBuilder.add("No spots attributed today.")
} else {
Expand All @@ -32,6 +32,7 @@ class Actions(private val drawService: DrawService) : DialogflowApp() {
).joinToString(" ")
responseBuilder.add(message)
}
responseBuilder.endConversation();
return responseBuilder.build()
}
}
Expand All @@ -40,7 +41,7 @@ class Actions(private val drawService: DrawService) : DialogflowApp() {
fun todayFreeSpots(request: ActionRequest): ActionResponse {
LOGGER.info("today free spots.")
val responseBuilder = getResponseBuilder(request)
with(drawService.getCurrentSchedules().firstOrNull { it.date == LocalDate.now() }) {
with(drawService.getSchedule(LocalDate.now())) {
if (this == null) {
responseBuilder.add("No spots attributed today.")
} else {
Expand All @@ -53,7 +54,7 @@ class Actions(private val drawService: DrawService) : DialogflowApp() {
responseBuilder.add(message)
}
}

responseBuilder.endConversation();
return responseBuilder.build()
}
}
Expand All @@ -63,7 +64,7 @@ class Actions(private val drawService: DrawService) : DialogflowApp() {
LOGGER.info("today spot.")
val responseBuilder = getResponseBuilder(request)
val usernameParam = request.getParameter("username") as String
with(drawService.getCurrentSchedules().firstOrNull { it.date == LocalDate.now() }) {
with(drawService.getSchedule(LocalDate.now())) {
if (this == null) {
responseBuilder.add("No spots attributed today.")
} else {
Expand All @@ -76,10 +77,10 @@ class Actions(private val drawService: DrawService) : DialogflowApp() {
responseBuilder.add(message)
}
}
responseBuilder.endConversation();
return responseBuilder.build()
}
}

companion object {

private val LOGGER = LoggerFactory.getLogger(Actions::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ class ActionsServlet(private val actionsApp: Actions) : HttpServlet() {

}

@Throws(IOException::class)
@GetMapping("/actions")
override fun doGet(request: HttpServletRequest, response: HttpServletResponse) {
response.contentType = "text/plain"
response
.writer
.println(
"ActionsServlet is listening but requires valid POST request to respond with Action response.")
}

private fun writeResponse(res: HttpServletResponse, asJson: String) {
try {
res.writer.write(asJson)
Expand Down
Loading

0 comments on commit 7da42db

Please sign in to comment.