Skip to content

Commit

Permalink
Merge pull request #261 from jhipster/6.10.4
Browse files Browse the repository at this point in the history
upgrade KHipster to support JHipster v6.10.4
  • Loading branch information
sendilkumarn authored Oct 18, 2020
2 parents 57a449b + 51f7e10 commit e91cc3e
Show file tree
Hide file tree
Showing 15 changed files with 191 additions and 113 deletions.
18 changes: 15 additions & 3 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
template: |
## What’s Changed
name: Release Drafter

$CHANGES
on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- main

jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/angular.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ env:
JHI_LIB_REPO: https://github.com/jhipster/jhipster.git
JHI_LIB_BRANCH: release
JHI_GEN_REPO: https://github.com/jhipster/generator-jhipster.git
JHI_GEN_BRANCH: v6.10.1
JHI_GEN_BRANCH: v6.10.4
SPRING_OUTPUT_ANSI_ENABLED: ALWAYS
SPRING_JPA_SHOW_SQL: false
JHI_DISABLE_WEBPACK_LOGS: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/applications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
JHI_LIB_REPO: https://github.com/jhipster/jhipster.git
JHI_LIB_BRANCH: release
JHI_GEN_REPO: https://github.com/jhipster/generator-jhipster.git
JHI_GEN_BRANCH: v6.10.1
JHI_GEN_BRANCH: v6.10.4
SPRING_OUTPUT_ANSI_ENABLED: ALWAYS
SPRING_JPA_SHOW_SQL: false
JHI_DISABLE_WEBPACK_LOGS: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
JHI_LIB_REPO: https://github.com/jhipster/jhipster.git
JHI_LIB_BRANCH: release
JHI_GEN_REPO: https://github.com/jhipster/generator-jhipster.git
JHI_GEN_BRANCH: v6.10.1
JHI_GEN_BRANCH: v6.10.4
SPRING_OUTPUT_ANSI_ENABLED: ALWAYS
SPRING_JPA_SHOW_SQL: false
JHI_DISABLE_WEBPACK_LOGS: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ env:
JHI_LIB_REPO: https://github.com/jhipster/jhipster.git
JHI_LIB_BRANCH: release
JHI_GEN_REPO: https://github.com/jhipster/generator-jhipster.git
JHI_GEN_BRANCH: v6.10.1
JHI_GEN_BRANCH: v6.10.4
SPRING_OUTPUT_ANSI_ENABLED: ALWAYS
SPRING_JPA_SHOW_SQL: false
JHI_DISABLE_WEBPACK_LOGS: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/webflux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ env:
JHI_LIB_REPO: https://github.com/jhipster/jhipster.git
JHI_LIB_BRANCH: release
JHI_GEN_REPO: https://github.com/jhipster/generator-jhipster.git
JHI_GEN_BRANCH: v6.10.1
JHI_GEN_BRANCH: v6.10.4
SPRING_OUTPUT_ANSI_ENABLED: ALWAYS
SPRING_JPA_SHOW_SQL: false
JHI_DISABLE_WEBPACK_LOGS: true
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ Fix / Code / Document and create a pull request 💯
These are some of the guidelines that we would like you to follow if you are a regular contributor to the project
or joined the [JHipster team](https://www.jhipster.tech/team/).

- We recommend not committing directly to master, but always submit changes through PRs.
- We recommend not committing directly to main, but always submit changes through PRs.
- Before merging, try to get at least one review on the PR.
- Add appropriate labels to issues and PRs that you create (if you have permission to do so).
- Follow the project's [policies](https://www.jhipster.tech/policies/#-policies).
- Follow the project's [Code of Conduct](https://github.com/jhipster/generator-jhipster/blob/master/CODE_OF_CONDUCT.md)
- Follow the project's [Code of Conduct](https://github.com/jhipster/generator-jhipster/blob/main/CODE_OF_CONDUCT.md)
and be polite and helpful to users when answering questions/bug reports and when reviewing PRs.
- We work on our free time so we have no obligation nor commitment. Work/life balance is important, so don't
feel tempted to put in all your free time fixing something.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">
<a href="https://khipster.dev">
<img width="320" height="160" src="https://raw.githubusercontent.com/jhipster/jhipster-kotlin/master/logo-khipster.png">
<img width="320" height="160" src="https://raw.githubusercontent.com/jhipster/jhipster-kotlin/main/logo-khipster.png">
</a>
</div>

Expand Down Expand Up @@ -62,7 +62,7 @@ Install the package with `npm install -g generator-jhipster-kotlin`

Found an issue, let us know [here](https://github.com/jhipster/jhipster-kotlin/issues).

Interested in contributing, check out our [contributing guide](https://github.com/jhipster/jhipster-kotlin/blob/master/CONTRIBUTING.md) to get started.
Interested in contributing, check out our [contributing guide](https://github.com/jhipster/jhipster-kotlin/blob/main/CONTRIBUTING.md) to get started.

Any questions [sendilkumarn](https://twitter.com/sendilkumarn)

Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
JHI_LIB_BRANCH: release
# if JHI_GEN_BRANCH value is release, use the release from NPM
JHI_GEN_REPO: https://github.com/jhipster/generator-jhipster.git
JHI_GEN_BRANCH: v6.10.1
JHI_GEN_BRANCH: v6.10.4
# specific config
SPRING_OUTPUT_ANSI_ENABLED: NEVER
SPRING_JPA_SHOW_SQL: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import <%= packageName %>.repository.search.UserSearchRepository
import <%= packageName %>.security.ADMIN
<%_ if (authenticationType !== 'oauth2') { _%>
import <%= packageName %>.service.MailService
import org.springframework.data.domain.Sort
<%_ } _%>
import <%= packageName %>.service.UserService
import <%= packageName %>.service.dto.<%= asDto('User') %>
Expand Down Expand Up @@ -128,6 +129,13 @@ class UserResource(
private val userSearchRepository: UserSearchRepository<% } %>
) {

<%_ if (authenticationType !== 'oauth2') { _%>
companion object {
private val ALLOWED_ORDERED_PROPERTIES = arrayOf("id", "login", "firstName", "lastName", "email", "activated", "langKey")
}
<%_ } _%>


private val log = LoggerFactory.getLogger(javaClass)

@Value("\${jhipster.clientApp.name}")
Expand Down Expand Up @@ -271,6 +279,11 @@ class UserResource(
<%_ if (databaseType === 'sql' || databaseType === 'mongodb' || databaseType === 'neo4j' || databaseType === 'couchbase') { _%>
<%_ if (!reactive) { _%>
fun getAllUsers(pageable: Pageable): ResponseEntity<List<<%= asDto('User') %>>> {
<%_ if (authenticationType !== 'oauth2') { _%>
if (!onlyContainsAllowedProperties(pageable)) {
return ResponseEntity.badRequest().build()
}
<%_ } _%>
val page = userService.getAllManagedUsers(pageable)
val headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page)
return ResponseEntity(page.content, headers, HttpStatus.OK)
Expand All @@ -279,12 +292,23 @@ class UserResource(
fun getAllUsers(
request: ServerHttpRequest,
pageable: Pageable
): Mono<ResponseEntity<Flux<<%= asDto('User') %>>>> =
userService.countManagedUsers()
): Mono<ResponseEntity<Flux<<%= asDto('User') %>>>> {
<%_ if (authenticationType !== 'oauth2') { _%>
if (!onlyContainsAllowedProperties(pageable)) {
return Mono.just(ResponseEntity.badRequest().build())
}
<%_ } _%>

return userService.countManagedUsers()
.map { total -> PageImpl(mutableListOf<<%= asDto('User') %>>(), pageable, total!!) }
.map { page -> PaginationUtil.generatePaginationHttpHeaders(UriComponentsBuilder.fromHttpRequest(request), page) }
.map { headers -> ResponseEntity.ok().headers(headers).body(userService.getAllManagedUsers(pageable)) }
}
<%_ } _%>
<%_ if (authenticationType !== 'oauth2') { _%>
private fun onlyContainsAllowedProperties(pageable: Pageable) =
pageable.sort.map(Sort.Order::getProperty).all { ALLOWED_ORDERED_PROPERTIES.contains(it) }
<%_ } _%>

/**
* Gets a list of all roles.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
-%>
package <%= packageName %>.web.rest.errors

import io.github.jhipster.config.JHipsterConstants
import io.github.jhipster.web.util.HeaderUtil

import org.apache.commons.lang3.StringUtils
import org.springframework.beans.factory.annotation.Value
<%_ if (databaseType !== 'no' && databaseType !== 'cassandra') { _%>
import org.springframework.dao.ConcurrencyFailureException
<%_ } _%>
import org.springframework.dao.DataAccessException
import org.springframework.http.ResponseEntity
import org.springframework.http.converter.HttpMessageConversionException
<%_ if (reactive && databaseType === 'sql') { _%>
import org.springframework.stereotype.Component
<%_ } _%>
Expand All @@ -40,9 +44,12 @@ import org.springframework.web.server.ServerWebExchange
<%_ if (!reactive) { _%>
import org.springframework.web.context.request.NativeWebRequest
<%_ } _%>
import org.springframework.core.env.Environment
import org.zalando.problem.DefaultProblem
import org.zalando.problem.Problem
import org.zalando.problem.ProblemBuilder
import org.zalando.problem.Status
import org.zalando.problem.StatusType
import org.zalando.problem.spring.web<% if (reactive) { %>flux<% } %>.advice.ProblemHandling
import org.zalando.problem.spring.web<% if (reactive) { %>flux<% } %>.advice.security.SecurityAdviceTrait
import org.zalando.problem.violations.ConstraintViolationProblem
Expand All @@ -53,6 +60,7 @@ import reactor.core.publisher.Mono
<%_ if (!reactive) { _%>
import javax.servlet.http.HttpServletRequest
<%_ } _%>
import java.net.URI

private const val FIELD_ERRORS_KEY = "fieldErrors"
private const val MESSAGE_KEY = "message"
Expand All @@ -67,7 +75,7 @@ private const val VIOLATIONS_KEY = "violations"
<%_ if (databaseType === 'sql' && reactive) { _%>
@Component("jhiExceptionTranslator")
<%_ } _%>
class ExceptionTranslator : ProblemHandling, SecurityAdviceTrait {
class ExceptionTranslator(private val env: Environment) : ProblemHandling, SecurityAdviceTrait {
<%_
let returnType;
let requestClass;
Expand Down Expand Up @@ -190,4 +198,30 @@ _%>
return create(ex, problem, request)
}
<%_ } _%>

override fun prepare(throwable: Throwable, status: StatusType, type: URI): ProblemBuilder {
val activeProfiles = env.activeProfiles
var detail = throwable.message
if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
detail = when (throwable) {
is HttpMessageConversionException -> "Unable to convert http message"
is DataAccessException -> "Failure during data access"
else -> {
if (containsPackageName(throwable.message)) {
"Unexpected runtime exception"
} else {
throwable.message
}
}
}
}
return Problem.builder()
.withType(type)
.withTitle(status.reasonPhrase)
.withStatus(status)
.withDetail(detail)
.withCause(throwable.cause.takeIf { isCausalChainsEnabled }?.let { toProblem(it) })
}

private fun containsPackageName(message: String?) = listOf("org.", "java.", "net.", "javax.", "com.", "io.", "de.", "<%= packageName %>").any { it == message }
}
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ class UserResourceIT<% if (databaseType === 'cassandra') { %>: AbstractCassandra
<%_ } _%>
.andExpect(jsonPath("\$.[*].langKey").value(hasItem(DEFAULT_LANGKEY)))
<%_ } else { _%>
val foundUser = webTestClient.get().uri("/api/users?sort=createdDate,DESC")
val foundUser = webTestClient.get().uri("/api/users?sort=id,DESC")
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus().isOk
Expand All @@ -478,6 +478,32 @@ class UserResourceIT<% if (databaseType === 'cassandra') { %>: AbstractCassandra
<%_ } _%>
}

<%_ if (databaseType === 'sql' && authenticationType !== 'oauth2') { _%>
@Test
<%_ if (!reactive) { _%>
@Transactional
<%_ } _%>
<%_ if (!reactive) { _%>
@Throws(Exception::class)
<%_ } _%>
fun getAllUsersSortedByParameters() {
// Initialize the database
userRepository.<% if (reactive) { %>save<% } else { %>saveAndFlush<% } %>(user)<% if (reactive) { %>.block()<% } %>

<%_ if (!reactive) { _%>
restUserMockMvc.perform(get("/api/users?sort=resetKey,desc").accept(MediaType.APPLICATION_JSON)).andExpect(status().isBadRequest)
restUserMockMvc.perform(get("/api/users?sort=password,desc").accept(MediaType.APPLICATION_JSON)).andExpect(status().isBadRequest)
restUserMockMvc.perform(get("/api/users?sort=resetKey,id,desc").accept(MediaType.APPLICATION_JSON)).andExpect(status().isBadRequest)
restUserMockMvc.perform(get("/api/users?sort=id,desc").accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk)
<%_ } else { _%>
webTestClient.get().uri("/api/users?sort=resetKey,DESC").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isBadRequest
webTestClient.get().uri("/api/users?sort=password,DESC").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isBadRequest
webTestClient.get().uri("/api/users?sort=resetKey,id,DESC").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isBadRequest
webTestClient.get().uri("/api/users?sort=id,DESC").accept(MediaType.APPLICATION_JSON).exchange().expectStatus().isOk
<%_ } _%>
}
<%_ } _%>

@Test
<%_ if (databaseType === 'sql' && !reactive) { _%>
@Transactional
Expand Down
Loading

0 comments on commit e91cc3e

Please sign in to comment.