https://github.com/entando/web-commons
Utilities for services built on spring boot
https://github.com/entando/web-commons
Last synced: 9 months ago
JSON representation
Utilities for services built on spring boot
- Host: GitHub
- URL: https://github.com/entando/web-commons
- Owner: entando
- License: lgpl-3.0
- Created: 2019-04-08T14:22:28.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-01-21T23:28:38.000Z (over 4 years ago)
- Last Synced: 2025-03-26T21:33:41.602Z (over 1 year ago)
- Language: Java
- Size: 64.5 KB
- Stars: 0
- Watchers: 7
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Entando WEB Commons
[](https://jenkins.entandocloud.com/job/de-web-commons-master/)
Utilities for services built on spring boot
# Installation
Just add the dependency on your `pom.xml` file
```
org.entando
web-commons
1.0.0-SNAPSHOT
```
# Configuration
Add these configurations to your `application.properties` file
### To enable Keycloak security
```
keycloak.enabled=true
keycloak.auth-server-url=${KEYCLOAK_AUTH_URL:http://keycloak.url.here/auth}
keycloak.realm=${KEYCLOAK_REALM:realm-here}
keycloak.resource=${KEYCLOAK_CLIENT_ID:client-id}
keycloak.credentials.secret=${KEYCLOAK_CLIENT_SECRET}
keycloak.ssl-required=external
keycloak.public-client=false
```
### To enable swagger generation and `swagger-ui`
```
swagger.enabled=true
swagger.info.title=${pom.name:Project Title Here}
swagger.info.description=${pom.description:Put the default description here}
swagger.info.version=${pom.version:Dev}
swagger.info.contact.name=
swagger.info.contact.email=
swagger.info.license=
swagger.info.licenseUrl=
swagger.info.termsOfServiceUrl=
swagger.info.basePackage=
```
### Exceptions
This project has some common exceptions to throw on your controllers and services.
There's no need to use ResponseEntity to control HTTP status unless you want to use Headers, etc.
#### NotFoundException
Throw this Exception to return 404.
```
throw new NotFoundException("org.entando.someThingNotFound");
```
#### HttpException
Throw this Exception if you want to return another HTTP status code.
```
throw new HttpException(HttpStatus.BAD_REQUEST, "org.entando.badRequest");
```
#### messages.properties
The message passed as argument to these exceptions are i18n in the `messages.properties` file.
```
org.entando.someThingNotFound=Something couldn't be found
org.entando.badRequest=Request is invalid, something is missing
```
Common codes
```
org.entando.error.validationError=Validation error
org.entando.error.permissionDenied=Permission denied
org.entando.error.unauthorized=Unauthorized
org.entando.error.internalServerError=Internal server error
```