Skip to content

Commit

Permalink
Merge branch 'jhipster_upgrade'
Browse files Browse the repository at this point in the history
  • Loading branch information
frostmarked committed Dec 30, 2020
2 parents 1973683 + acbd6a3 commit 33f1901
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .yo-rc.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"packageFolder": "com/bonlimousin/content",
"entitySuffix": "Entity",
"dtoSuffix": "DTO",
"jhipsterVersion": "6.10.1",
"jhipsterVersion": "6.10.5",
"creationTimestamp": 1593712140033,
"clientPackageManager": "npm",
"jwtSecretKey": "YzAzOGZmNThlNDc4YjUzZDYzNGMxMjkwNjAyMTg2ZTIzZTg1Y2QwMDc2ZjdjNDcwYzI1ZDA1NmNiMDU1YzdmNGY5ZjQ2NzAyNGRjZmM3ZDBjMzJkMTAxNGRlYzdmZGE5MjBhYzBiOTRjYjdiYjFhNTgwMWFiODdmOGEyYzRmYjY=",
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Visit the parent project https://github.com/frostmarked/bonParent for more infor

# bonContentService

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).
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).

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.

Expand Down Expand Up @@ -131,12 +131,12 @@ For more information refer to [Using Docker and Docker-Compose][], this page als
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.

[jhipster homepage and latest documentation]: https://www.jhipster.tech
[jhipster 6.10.1 archive]: https://www.jhipster.tech/documentation-archive/v6.10.1
[doing microservices with jhipster]: https://www.jhipster.tech/documentation-archive/v6.10.1/microservices-architecture/
[using jhipster in development]: https://www.jhipster.tech/documentation-archive/v6.10.1/development/
[service discovery and configuration with the jhipster-registry]: https://www.jhipster.tech/documentation-archive/v6.10.1/microservices-architecture/#jhipster-registry
[using docker and docker-compose]: https://www.jhipster.tech/documentation-archive/v6.10.1/docker-compose
[using jhipster in production]: https://www.jhipster.tech/documentation-archive/v6.10.1/production/
[running tests page]: https://www.jhipster.tech/documentation-archive/v6.10.1/running-tests/
[code quality page]: https://www.jhipster.tech/documentation-archive/v6.10.1/code-quality/
[setting up continuous integration]: https://www.jhipster.tech/documentation-archive/v6.10.1/setting-up-ci/
[jhipster 6.10.5 archive]: https://www.jhipster.tech/documentation-archive/v6.10.5
[doing microservices with jhipster]: https://www.jhipster.tech/documentation-archive/v6.10.5/microservices-architecture/
[using jhipster in development]: https://www.jhipster.tech/documentation-archive/v6.10.5/development/
[service discovery and configuration with the jhipster-registry]: https://www.jhipster.tech/documentation-archive/v6.10.5/microservices-architecture/#jhipster-registry
[using docker and docker-compose]: https://www.jhipster.tech/documentation-archive/v6.10.5/docker-compose
[using jhipster in production]: https://www.jhipster.tech/documentation-archive/v6.10.5/production/
[running tests page]: https://www.jhipster.tech/documentation-archive/v6.10.5/running-tests/
[code quality page]: https://www.jhipster.tech/documentation-archive/v6.10.5/code-quality/
[setting up continuous integration]: https://www.jhipster.tech/documentation-archive/v6.10.5/setting-up-ci/
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
],
"devDependencies": {
"@openapitools/openapi-generator-cli": "1.0.13-4.3.1",
"generator-jhipster": "6.10.1",
"generator-jhipster": "6.10.5",
"husky": "4.2.5",
"lint-staged": "8.2.1",
"prettier": "2.0.5"
"prettier": "2.1.2"
},
"engines": {
"node": ">=12.16.1"
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<profile.tls />

<!-- Dependency versions -->
<jhipster-dependencies.version>3.9.0</jhipster-dependencies.version>
<jhipster-dependencies.version>3.9.1</jhipster-dependencies.version>
<!-- The spring-boot version should match the one managed by
https://mvnrepository.com/artifact/io.github.jhipster/jhipster-dependencies/${jhipster-dependencies.version} -->
<spring-boot.version>2.2.7.RELEASE</spring-boot.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
package com.bonlimousin.content.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;
import org.springframework.dao.ConcurrencyFailureException;
import org.springframework.dao.DataAccessException;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageConversionException;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
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.advice.ProblemHandling;
import org.zalando.problem.spring.web.advice.security.SecurityAdviceTrait;
import org.zalando.problem.violations.ConstraintViolationProblem;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.servlet.http.HttpServletRequest;
import java.net.URI;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

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

private final Environment env;

public ExceptionTranslator(Environment env) {
this.env = env;
}

/**
* Post-process the Problem payload to add the message key for the front-end if needed.
*/
Expand Down Expand Up @@ -104,4 +120,62 @@ public ResponseEntity<Problem> handleConcurrencyFailure(ConcurrencyFailureExcept
.build();
return create(ex, problem, request);
}
}

@Override
public ProblemBuilder prepare(final Throwable throwable, final StatusType status, final URI type) {

Collection<String> activeProfiles = Arrays.asList(env.getActiveProfiles());

if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
if (throwable instanceof HttpMessageConversionException) {
return Problem.builder()
.withType(type)
.withTitle(status.getReasonPhrase())
.withStatus(status)
.withDetail("Unable to convert http message")
.withCause(Optional.ofNullable(throwable.getCause())
.filter(cause -> isCausalChainsEnabled())
.map(this::toProblem)
.orElse(null));
}
if (throwable instanceof DataAccessException) {
return Problem.builder()
.withType(type)
.withTitle(status.getReasonPhrase())
.withStatus(status)
.withDetail("Failure during data access")
.withCause(Optional.ofNullable(throwable.getCause())
.filter(cause -> isCausalChainsEnabled())
.map(this::toProblem)
.orElse(null));
}
if (containsPackageName(throwable.getMessage())) {
return Problem.builder()
.withType(type)
.withTitle(status.getReasonPhrase())
.withStatus(status)
.withDetail("Unexpected runtime exception")
.withCause(Optional.ofNullable(throwable.getCause())
.filter(cause -> isCausalChainsEnabled())
.map(this::toProblem)
.orElse(null));
}
}

return Problem.builder()
.withType(type)
.withTitle(status.getReasonPhrase())
.withStatus(status)
.withDetail(throwable.getMessage())
.withCause(Optional.ofNullable(throwable.getCause())
.filter(cause -> isCausalChainsEnabled())
.map(this::toProblem)
.orElse(null));
}

private boolean containsPackageName(String message) {

// This list is for sure not complete
return StringUtils.containsAny(message, "org.", "java.", "net.", "javax.", "com.", "io.", "de.", "com.bonlimousin.content");
}
}
4 changes: 2 additions & 2 deletions src/test/resources/config/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ eureka:

spring:
profiles:
# Uncomment the following line to enable tests against production database type rather than H2, using Testcontainers
#active: testcontainers
# Uncomment the following line to enable tests against production database type rather than H2, using Testcontainers
#active: testcontainers
application:
name: bonContentService
datasource:
Expand Down

0 comments on commit 33f1901

Please sign in to comment.