Skip to content

Commit 33f1901

Browse files
committed
Merge branch 'jhipster_upgrade'
2 parents 1973683 + acbd6a3 commit 33f1901

File tree

6 files changed

+91
-17
lines changed

6 files changed

+91
-17
lines changed

.yo-rc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"packageFolder": "com/bonlimousin/content",
2727
"entitySuffix": "Entity",
2828
"dtoSuffix": "DTO",
29-
"jhipsterVersion": "6.10.1",
29+
"jhipsterVersion": "6.10.5",
3030
"creationTimestamp": 1593712140033,
3131
"clientPackageManager": "npm",
3232
"jwtSecretKey": "YzAzOGZmNThlNDc4YjUzZDYzNGMxMjkwNjAyMTg2ZTIzZTg1Y2QwMDc2ZjdjNDcwYzI1ZDA1NmNiMDU1YzdmNGY5ZjQ2NzAyNGRjZmM3ZDBjMzJkMTAxNGRlYzdmZGE5MjBhYzBiOTRjYjdiYjFhNTgwMWFiODdmOGEyYzRmYjY=",

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Visit the parent project https://github.com/frostmarked/bonParent for more infor
1010

1111
# bonContentService
1212

13-
This application was generated using JHipster 6.10.1, you can find documentation and help at [https://www.jhipster.tech/documentation-archive/v6.10.1](https://www.jhipster.tech/documentation-archive/v6.10.1).
13+
This application was generated using JHipster 6.10.5, you can find documentation and help at [https://www.jhipster.tech/documentation-archive/v6.10.5](https://www.jhipster.tech/documentation-archive/v6.10.5).
1414

1515
This is a "microservice" application intended to be part of a microservice architecture, please refer to the [Doing microservices with JHipster][] page of the documentation for more information.
1616

@@ -131,12 +131,12 @@ For more information refer to [Using Docker and Docker-Compose][], this page als
131131
To configure CI for your project, run the ci-cd sub-generator (`jhipster ci-cd`), this will let you generate configuration files for a number of Continuous Integration systems. Consult the [Setting up Continuous Integration][] page for more information.
132132

133133
[jhipster homepage and latest documentation]: https://www.jhipster.tech
134-
[jhipster 6.10.1 archive]: https://www.jhipster.tech/documentation-archive/v6.10.1
135-
[doing microservices with jhipster]: https://www.jhipster.tech/documentation-archive/v6.10.1/microservices-architecture/
136-
[using jhipster in development]: https://www.jhipster.tech/documentation-archive/v6.10.1/development/
137-
[service discovery and configuration with the jhipster-registry]: https://www.jhipster.tech/documentation-archive/v6.10.1/microservices-architecture/#jhipster-registry
138-
[using docker and docker-compose]: https://www.jhipster.tech/documentation-archive/v6.10.1/docker-compose
139-
[using jhipster in production]: https://www.jhipster.tech/documentation-archive/v6.10.1/production/
140-
[running tests page]: https://www.jhipster.tech/documentation-archive/v6.10.1/running-tests/
141-
[code quality page]: https://www.jhipster.tech/documentation-archive/v6.10.1/code-quality/
142-
[setting up continuous integration]: https://www.jhipster.tech/documentation-archive/v6.10.1/setting-up-ci/
134+
[jhipster 6.10.5 archive]: https://www.jhipster.tech/documentation-archive/v6.10.5
135+
[doing microservices with jhipster]: https://www.jhipster.tech/documentation-archive/v6.10.5/microservices-architecture/
136+
[using jhipster in development]: https://www.jhipster.tech/documentation-archive/v6.10.5/development/
137+
[service discovery and configuration with the jhipster-registry]: https://www.jhipster.tech/documentation-archive/v6.10.5/microservices-architecture/#jhipster-registry
138+
[using docker and docker-compose]: https://www.jhipster.tech/documentation-archive/v6.10.5/docker-compose
139+
[using jhipster in production]: https://www.jhipster.tech/documentation-archive/v6.10.5/production/
140+
[running tests page]: https://www.jhipster.tech/documentation-archive/v6.10.5/running-tests/
141+
[code quality page]: https://www.jhipster.tech/documentation-archive/v6.10.5/code-quality/
142+
[setting up continuous integration]: https://www.jhipster.tech/documentation-archive/v6.10.5/setting-up-ci/

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
],
1010
"devDependencies": {
1111
"@openapitools/openapi-generator-cli": "1.0.13-4.3.1",
12-
"generator-jhipster": "6.10.1",
12+
"generator-jhipster": "6.10.5",
1313
"husky": "4.2.5",
1414
"lint-staged": "8.2.1",
15-
"prettier": "2.0.5"
15+
"prettier": "2.1.2"
1616
},
1717
"engines": {
1818
"node": ">=12.16.1"

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
<profile.tls />
4242

4343
<!-- Dependency versions -->
44-
<jhipster-dependencies.version>3.9.0</jhipster-dependencies.version>
44+
<jhipster-dependencies.version>3.9.1</jhipster-dependencies.version>
4545
<!-- The spring-boot version should match the one managed by
4646
https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster-dependencies.version} -->
4747
<spring-boot.version>2.2.7.RELEASE</spring-boot.version>

src/main/java/com/bonlimousin/content/web/rest/errors/ExceptionTranslator.java

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
11
package com.bonlimousin.content.web.rest.errors;
22

3+
import io.github.jhipster.config.JHipsterConstants;
34
import io.github.jhipster.web.util.HeaderUtil;
45

6+
import org.apache.commons.lang3.StringUtils;
57
import org.springframework.beans.factory.annotation.Value;
68
import org.springframework.dao.ConcurrencyFailureException;
9+
import org.springframework.dao.DataAccessException;
710
import org.springframework.http.ResponseEntity;
11+
import org.springframework.http.converter.HttpMessageConversionException;
812
import org.springframework.validation.BindingResult;
913
import org.springframework.web.bind.MethodArgumentNotValidException;
1014
import org.springframework.web.bind.annotation.ControllerAdvice;
1115
import org.springframework.web.bind.annotation.ExceptionHandler;
1216
import org.springframework.web.context.request.NativeWebRequest;
17+
import org.springframework.core.env.Environment;
1318
import org.zalando.problem.DefaultProblem;
1419
import org.zalando.problem.Problem;
1520
import org.zalando.problem.ProblemBuilder;
1621
import org.zalando.problem.Status;
22+
import org.zalando.problem.StatusType;
1723
import org.zalando.problem.spring.web.advice.ProblemHandling;
1824
import org.zalando.problem.spring.web.advice.security.SecurityAdviceTrait;
1925
import org.zalando.problem.violations.ConstraintViolationProblem;
2026

2127
import javax.annotation.Nonnull;
2228
import javax.annotation.Nullable;
2329
import javax.servlet.http.HttpServletRequest;
30+
import java.net.URI;
31+
import java.util.Arrays;
32+
import java.util.Collection;
2433
import java.util.List;
34+
import java.util.Optional;
2535
import java.util.stream.Collectors;
2636

2737
/**
@@ -39,6 +49,12 @@ public class ExceptionTranslator implements ProblemHandling, SecurityAdviceTrait
3949
@Value("${jhipster.clientApp.name}")
4050
private String applicationName;
4151

52+
private final Environment env;
53+
54+
public ExceptionTranslator(Environment env) {
55+
this.env = env;
56+
}
57+
4258
/**
4359
* Post-process the Problem payload to add the message key for the front-end if needed.
4460
*/
@@ -104,4 +120,62 @@ public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureExcept
104120
.build();
105121
return create(ex, problem, request);
106122
}
107-
}
123+
124+
@Override
125+
public ProblemBuilder prepare(final Throwable throwable, final StatusType status, final URI type) {
126+
127+
Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());
128+
129+
if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
130+
if (throwable instanceof HttpMessageConversionException) {
131+
return Problem.builder()
132+
.withType(type)
133+
.withTitle(status.getReasonPhrase())
134+
.withStatus(status)
135+
.withDetail("Unable to convert http message")
136+
.withCause(Optional.ofNullable(throwable.getCause())
137+
.filter(cause -> isCausalChainsEnabled())
138+
.map(this::toProblem)
139+
.orElse(null));
140+
}
141+
if (throwable instanceof DataAccessException) {
142+
return Problem.builder()
143+
.withType(type)
144+
.withTitle(status.getReasonPhrase())
145+
.withStatus(status)
146+
.withDetail("Failure during data access")
147+
.withCause(Optional.ofNullable(throwable.getCause())
148+
.filter(cause -> isCausalChainsEnabled())
149+
.map(this::toProblem)
150+
.orElse(null));
151+
}
152+
if (containsPackageName(throwable.getMessage())) {
153+
return Problem.builder()
154+
.withType(type)
155+
.withTitle(status.getReasonPhrase())
156+
.withStatus(status)
157+
.withDetail("Unexpected runtime exception")
158+
.withCause(Optional.ofNullable(throwable.getCause())
159+
.filter(cause -> isCausalChainsEnabled())
160+
.map(this::toProblem)
161+
.orElse(null));
162+
}
163+
}
164+
165+
return Problem.builder()
166+
.withType(type)
167+
.withTitle(status.getReasonPhrase())
168+
.withStatus(status)
169+
.withDetail(throwable.getMessage())
170+
.withCause(Optional.ofNullable(throwable.getCause())
171+
.filter(cause -> isCausalChainsEnabled())
172+
.map(this::toProblem)
173+
.orElse(null));
174+
}
175+
176+
private boolean containsPackageName(String message) {
177+
178+
// This list is for sure not complete
179+
return StringUtils.containsAny(message, "org.", "java.", "net.", "javax.", "com.", "io.", "de.", "com.bonlimousin.content");
180+
}
181+
}

src/test/resources/config/application.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ eureka:
2222

2323
spring:
2424
profiles:
25-
# Uncomment the following line to enable tests against production database type rather than H2, using Testcontainers
26-
#active: testcontainers
25+
# Uncomment the following line to enable tests against production database type rather than H2, using Testcontainers
26+
#active: testcontainers
2727
application:
2828
name: bonContentService
2929
datasource:

0 commit comments

Comments
 (0)