├── .dockerignore
├── .env
├── .gitattributes
├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── PULL_REQUEST_TEMPLATE.md
├── config.yml
├── stale.yml
└── workflows
│ └── hooks.yml
├── .gitignore
├── .gitlab-ci.yml
├── .gitlab
├── issue_templates
│ ├── bug_report.md
│ └── feature_request.md
└── merge_request_templates
│ └── merge_request_template.md
├── .gitpod.yml
├── .theia
├── launch.json
└── settings.json
├── .travis.yml
├── CONTRIBUTING.md
├── Dockerfile.alpine
├── Dockerfile.develop
├── Dockerfile.gitpod
├── Jenkinsfile
├── LICENSE
├── README.md
├── build.gradle
├── docker-compose.h2.test.yml
├── docker-compose.mariadb.test_.yml
├── docker-compose.mysql.test_.yml
├── docker-compose.postgres.test.yml
├── docker-compose.yml
├── docker-entrypoint.sh
├── docker
├── README.md
├── maven
│ └── settings-docker.xml
└── test
│ ├── Dockerfile
│ └── docker_test.sh
├── docs
├── README.md
└── _config.yml
├── gradlew
├── gradlew.bat
├── hooks
├── README.md
├── build
├── post_push
├── post_test
├── pre_push
├── pre_test
├── push
├── run
└── test
├── jitpack.yml
├── manage.sh
├── mvnw
├── mvnw.cmd
├── pmdruleset.xml
├── pom.xml
└── src
├── integration-test
├── java
│ └── com
│ │ └── monogramm
│ │ ├── ApplicationIT.java
│ │ └── starter
│ │ ├── SmtpServerRule.java
│ │ ├── api
│ │ ├── AbstractControllerFullIT.java
│ │ ├── AbstractControllerIT.java
│ │ ├── AbstractControllerMockIT.java
│ │ ├── media
│ │ │ └── controller
│ │ │ │ ├── MediaControllerFullIT.java
│ │ │ │ └── MediaControllerMockIT.java
│ │ ├── oauth
│ │ │ └── controller
│ │ │ │ ├── OAuthControllerFullIT.java
│ │ │ │ └── OAuthControllerMockIT.java
│ │ ├── parameter
│ │ │ └── controller
│ │ │ │ ├── ParameterControllerFullIT.java
│ │ │ │ └── ParameterControllerMockIT.java
│ │ ├── permission
│ │ │ └── controller
│ │ │ │ ├── PermissionControllerFullIT.java
│ │ │ │ └── PermissionControllerMockIT.java
│ │ ├── role
│ │ │ └── controller
│ │ │ │ ├── RoleControllerFullIT.java
│ │ │ │ └── RoleControllerMockIT.java
│ │ ├── type
│ │ │ └── controller
│ │ │ │ ├── TypeControllerFullIT.java
│ │ │ │ └── TypeControllerMockIT.java
│ │ └── user
│ │ │ └── controller
│ │ │ ├── UserControllerFullIT.java
│ │ │ └── UserControllerMockIT.java
│ │ └── persistence
│ │ ├── AbstractGenericRepositoryIT.java
│ │ ├── media
│ │ └── dao
│ │ │ └── MediaRepositoryIT.java
│ │ ├── parameter
│ │ └── dao
│ │ │ └── ParameterRepositoryIT.java
│ │ ├── permission
│ │ └── dao
│ │ │ └── PermissionRepositoryIT.java
│ │ ├── role
│ │ └── dao
│ │ │ └── RoleRepositoryIT.java
│ │ ├── type
│ │ └── dao
│ │ │ └── TypeRepositoryIT.java
│ │ └── user
│ │ └── dao
│ │ ├── PasswordResetTokenRepositoryIT.java
│ │ ├── UserRepositoryIT.java
│ │ └── VerificationTokenRepositoryIT.java
└── resources
│ ├── application.properties
│ └── log4j2-spring.xml
├── main
├── java
│ └── com
│ │ └── monogramm
│ │ ├── Application.java
│ │ ├── package-info.java
│ │ └── starter
│ │ ├── api
│ │ ├── AbstractGenericController.java
│ │ ├── AbstractMailSendingEvent.java
│ │ ├── AbstractMailSendingListener.java
│ │ ├── RestResponseEntityExceptionHandler.java
│ │ ├── discoverability
│ │ │ ├── event
│ │ │ │ ├── AbstractResourceEvent.java
│ │ │ │ ├── PaginatedResultsRetrievedEvent.java
│ │ │ │ ├── ResourceCreatedEvent.java
│ │ │ │ ├── SingleResourceRetrievedEvent.java
│ │ │ │ └── package-info.java
│ │ │ ├── exception
│ │ │ │ ├── PageNotFoundException.java
│ │ │ │ └── package-info.java
│ │ │ ├── listener
│ │ │ │ ├── PaginatedResultsRetrievedDiscoverabilityListener.java
│ │ │ │ ├── ResourceCreatedDiscoverabilityListener.java
│ │ │ │ ├── SingleResourceRetrievedDiscoverabilityListener.java
│ │ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ └── utils
│ │ │ │ ├── LinkUtils.java
│ │ │ │ └── package-info.java
│ │ ├── media
│ │ │ ├── controller
│ │ │ │ ├── MediaController.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ ├── oauth
│ │ │ ├── controller
│ │ │ │ ├── OAuthController.java
│ │ │ │ ├── RevokeTokenEndpoint.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ ├── package-info.java
│ │ ├── parameter
│ │ │ ├── controller
│ │ │ │ ├── ParameterController.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ ├── permission
│ │ │ ├── controller
│ │ │ │ ├── PermissionController.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ ├── role
│ │ │ ├── controller
│ │ │ │ ├── RoleController.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ ├── type
│ │ │ ├── controller
│ │ │ │ ├── TypeController.java
│ │ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ └── user
│ │ │ ├── controller
│ │ │ ├── UserController.java
│ │ │ └── package-info.java
│ │ │ ├── event
│ │ │ ├── OnPasswordResetEvent.java
│ │ │ ├── OnRegistrationCompleteEvent.java
│ │ │ └── package-info.java
│ │ │ ├── listener
│ │ │ ├── PasswordResetListener.java
│ │ │ ├── RegistrationListener.java
│ │ │ └── package-info.java
│ │ │ └── package-info.java
│ │ ├── config
│ │ ├── OAuth2AuthorizationServerConfig.java
│ │ ├── OAuth2GlobalSecurityConfig.java
│ │ ├── OAuth2ResourceServerConfig.java
│ │ ├── OAuth2WebSecurityConfig.java
│ │ ├── SpringFoxConfig.java
│ │ ├── component
│ │ │ ├── CustomPasswordEncoder.java
│ │ │ ├── CustomServletRequestWrapper.java
│ │ │ ├── CustomTokenEnhancer.java
│ │ │ ├── CustomUserDetails.java
│ │ │ ├── CustomUserDetailsService.java
│ │ │ └── package-info.java
│ │ ├── data
│ │ │ ├── AbstractDataLoader.java
│ │ │ ├── GenericOperation.java
│ │ │ ├── InitialDataLoader.java
│ │ │ └── package-info.java
│ │ ├── filter
│ │ │ ├── JsonToUrlEncodedAuthenticationFilter.java
│ │ │ ├── SimpleCorsFilter.java
│ │ │ └── package-info.java
│ │ ├── i8n
│ │ │ ├── ApplicationMessage.java
│ │ │ └── package-info.java
│ │ ├── package-info.java
│ │ ├── properties
│ │ │ ├── ApplicationProperties.java
│ │ │ ├── ApplicationSecurityProperties.java
│ │ │ ├── DataProperties.java
│ │ │ ├── EmailProperties.java
│ │ │ ├── WelcomeProperties.java
│ │ │ └── package-info.java
│ │ └── security
│ │ │ ├── AuthenticationFacade.java
│ │ │ ├── CustomMethodSecurityExpressionHandler.java
│ │ │ ├── CustomMethodSecurityExpressionRoot.java
│ │ │ ├── CustomPermissionEvaluator.java
│ │ │ ├── IAuthenticationFacade.java
│ │ │ └── package-info.java
│ │ ├── dto
│ │ ├── AbstractGenericDto.java
│ │ ├── AbstractGenericDtoComparator.java
│ │ ├── AbstractParameterDto.java
│ │ ├── AbstractTokenDto.java
│ │ ├── media
│ │ │ ├── MediaDto.java
│ │ │ └── package-info.java
│ │ ├── oauth
│ │ │ ├── OAuthRequest.java
│ │ │ ├── OAuthResponse.java
│ │ │ └── package-info.java
│ │ ├── package-info.java
│ │ ├── parameter
│ │ │ ├── ParameterDto.java
│ │ │ └── package-info.java
│ │ ├── permission
│ │ │ ├── PermissionDto.java
│ │ │ └── package-info.java
│ │ ├── role
│ │ │ ├── RoleDto.java
│ │ │ └── package-info.java
│ │ ├── type
│ │ │ ├── TypeDto.java
│ │ │ └── package-info.java
│ │ └── user
│ │ │ ├── PasswordResetDto.java
│ │ │ ├── PasswordResetTokenDto.java
│ │ │ ├── RegistrationDto.java
│ │ │ ├── UserDto.java
│ │ │ ├── VerificationTokenDto.java
│ │ │ └── package-info.java
│ │ ├── package-info.java
│ │ ├── persistence
│ │ ├── AbstractGenericBridge.java
│ │ ├── AbstractGenericEntity.java
│ │ ├── AbstractGenericService.java
│ │ ├── AbstractParameter.java
│ │ ├── AbstractParameterBridge.java
│ │ ├── AbstractToken.java
│ │ ├── AbstractTokenBridge.java
│ │ ├── EntityNotFoundException.java
│ │ ├── GenericRepository.java
│ │ ├── GenericService.java
│ │ ├── ParameterType.java
│ │ ├── media
│ │ │ ├── dao
│ │ │ │ ├── MediaRepository.java
│ │ │ │ └── package-info.java
│ │ │ ├── entity
│ │ │ │ ├── Media.java
│ │ │ │ └── package-info.java
│ │ │ ├── exception
│ │ │ │ ├── MediaNotFoundException.java
│ │ │ │ ├── MediaStorageException.java
│ │ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ ├── properties
│ │ │ │ ├── FileStorageProperties.java
│ │ │ │ └── package-info.java
│ │ │ └── service
│ │ │ │ ├── MediaBridge.java
│ │ │ │ ├── MediaService.java
│ │ │ │ ├── MediaServiceImpl.java
│ │ │ │ ├── StorageUtils.java
│ │ │ │ └── package-info.java
│ │ ├── oauth
│ │ │ ├── dao
│ │ │ │ └── package-info.java
│ │ │ ├── entity
│ │ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ └── service
│ │ │ │ └── package-info.java
│ │ ├── package-info.java
│ │ ├── parameter
│ │ │ ├── dao
│ │ │ │ ├── ParameterRepository.java
│ │ │ │ └── package-info.java
│ │ │ ├── entity
│ │ │ │ ├── Parameter.java
│ │ │ │ └── package-info.java
│ │ │ ├── exception
│ │ │ │ ├── ParameterNotFoundException.java
│ │ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ └── service
│ │ │ │ ├── ParameterBridge.java
│ │ │ │ ├── ParameterService.java
│ │ │ │ ├── ParameterServiceImpl.java
│ │ │ │ └── package-info.java
│ │ ├── permission
│ │ │ ├── dao
│ │ │ │ ├── PermissionRepository.java
│ │ │ │ └── package-info.java
│ │ │ ├── entity
│ │ │ │ ├── Permission.java
│ │ │ │ └── package-info.java
│ │ │ ├── exception
│ │ │ │ ├── PermissionNotFoundException.java
│ │ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ └── service
│ │ │ │ ├── PermissionBridge.java
│ │ │ │ ├── PermissionService.java
│ │ │ │ ├── PermissionServiceImpl.java
│ │ │ │ └── package-info.java
│ │ ├── role
│ │ │ ├── dao
│ │ │ │ ├── RoleRepository.java
│ │ │ │ └── package-info.java
│ │ │ ├── entity
│ │ │ │ ├── Role.java
│ │ │ │ └── package-info.java
│ │ │ ├── exception
│ │ │ │ ├── RoleNotFoundException.java
│ │ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ └── service
│ │ │ │ ├── RoleBridge.java
│ │ │ │ ├── RoleService.java
│ │ │ │ ├── RoleServiceImpl.java
│ │ │ │ └── package-info.java
│ │ ├── type
│ │ │ ├── dao
│ │ │ │ ├── TypeRepository.java
│ │ │ │ └── package-info.java
│ │ │ ├── entity
│ │ │ │ ├── Type.java
│ │ │ │ └── package-info.java
│ │ │ ├── exception
│ │ │ │ ├── TypeNotFoundException.java
│ │ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ └── service
│ │ │ │ ├── TypeBridge.java
│ │ │ │ ├── TypeService.java
│ │ │ │ ├── TypeServiceImpl.java
│ │ │ │ └── package-info.java
│ │ └── user
│ │ │ ├── dao
│ │ │ ├── PasswordResetTokenRepository.java
│ │ │ ├── UserRepository.java
│ │ │ ├── VerificationTokenRepository.java
│ │ │ └── package-info.java
│ │ │ ├── entity
│ │ │ ├── PasswordResetToken.java
│ │ │ ├── User.java
│ │ │ ├── VerificationToken.java
│ │ │ └── package-info.java
│ │ │ ├── exception
│ │ │ ├── PasswordResetTokenNotFoundException.java
│ │ │ ├── UserNotFoundException.java
│ │ │ ├── VerificationTokenNotFoundException.java
│ │ │ └── package-info.java
│ │ │ ├── package-info.java
│ │ │ └── service
│ │ │ ├── PasswordResetTokenBridge.java
│ │ │ ├── PasswordResetTokenService.java
│ │ │ ├── PasswordResetTokenServiceImpl.java
│ │ │ ├── UserBridge.java
│ │ │ ├── UserService.java
│ │ │ ├── UserServiceImpl.java
│ │ │ ├── VerificationTokenBridge.java
│ │ │ ├── VerificationTokenService.java
│ │ │ ├── VerificationTokenServiceImpl.java
│ │ │ └── package-info.java
│ │ └── utils
│ │ ├── JsonUtils.java
│ │ ├── Jsonable.java
│ │ ├── JwtUtils.java
│ │ ├── ZipUtils.java
│ │ ├── converter
│ │ ├── AnyConverter.java
│ │ ├── BooleanConverter.java
│ │ ├── ColorConverter.java
│ │ ├── DateConverter.java
│ │ ├── DateTimeConverter.java
│ │ ├── DoubleConverter.java
│ │ ├── IntegerConverter.java
│ │ ├── ParameterExporter.java
│ │ ├── ParameterImporter.java
│ │ ├── PathConverter.java
│ │ ├── StringConverter.java
│ │ ├── TimeConverter.java
│ │ ├── UrlConverter.java
│ │ └── package-info.java
│ │ ├── package-info.java
│ │ └── validation
│ │ ├── EmailValidator.java
│ │ ├── PasswordConfirmationDto.java
│ │ ├── PasswordMatches.java
│ │ ├── PasswordMatchesValidator.java
│ │ ├── UuidValidator.java
│ │ ├── ValidEmail.java
│ │ ├── ValidUuid.java
│ │ └── package-info.java
└── resources
│ ├── META-INF
│ └── additional-spring-configuration-metadata.json
│ ├── app-banner.txt
│ ├── application.properties
│ ├── data.sql
│ ├── i18n
│ ├── messages.properties
│ └── messages_fr.properties
│ ├── log4j2-spring.xml
│ ├── schema-h2.sql
│ ├── schema-mariadb.sql
│ ├── schema-mysql.sql
│ └── schema-postgresql.sql
└── test
└── java
└── com
└── monogramm
└── starter
├── api
├── AbstractGenericControllerTest.java
├── AbstractMailSendingEventTest.java
├── discoverability
│ ├── event
│ │ ├── AbstractResourceEventTest.java
│ │ └── PaginatedResultsRetrievedEventTest.java
│ ├── exception
│ │ └── PageNotFoundExceptionTest.java
│ └── listener
│ │ ├── PaginatedResultsRetrievedDiscoverabilityListenerTest.java
│ │ ├── ResourceCreatedDiscoverabilityListenerTest.java
│ │ └── SingleResourceRetrievedDiscoverabilityListenerTest.java
├── media
│ └── controller
│ │ └── MediaControllerTest.java
├── parameter
│ └── controller
│ │ └── ParameterControllerTest.java
├── permission
│ └── controller
│ │ └── PermissionControllerTest.java
├── role
│ └── controller
│ │ └── RoleControllerTest.java
├── type
│ └── controller
│ │ └── TypeControllerTest.java
└── user
│ ├── controller
│ └── UserControllerTest.java
│ ├── event
│ ├── OnPasswordResetEventTest.java
│ └── OnRegistrationCompleteEventTest.java
│ └── listener
│ ├── PasswordResetListenerTest.java
│ └── RegistrationListenerTest.java
├── config
├── component
│ ├── CustomPasswordEncoderTest.java
│ ├── CustomServletRequestWrapperTest.java
│ └── CustomTokenEnhancerTest.java
├── data
│ └── InitialDataLoaderTest.java
├── filter
│ ├── JsonToUrlEncodedAuthenticationFilterTest.java
│ └── SimpleCorsFilterTest.java
└── i8n
│ └── ApplicationMessageTest.java
├── dto
├── AbstractGenericDtoTest.java
├── AbstractParameterDtoTest.java
├── AbstractTokenDtoTest.java
├── media
│ └── MediaDtoTest.java
├── oauth
│ ├── OAuthRequestTest.java
│ └── OAuthResponseTest.java
├── parameter
│ └── ParameterDtoTest.java
├── permission
│ └── PermissionDtoTest.java
├── role
│ └── RoleDtoTest.java
├── type
│ └── TypeDtoTest.java
└── user
│ ├── PasswordResetDtoTest.java
│ ├── PasswordResetTokenDtoTest.java
│ ├── RegistrationDtoTest.java
│ ├── UserDtoTest.java
│ └── VerificationTokenDtoTest.java
├── persistence
├── AbstractGenericBridgeTest.java
├── AbstractGenericEntityBuilderTest.java
├── AbstractGenericEntityTest.java
├── AbstractGenericServiceTest.java
├── AbstractParameterBridgeTest.java
├── AbstractParameterBuilderTest.java
├── AbstractParameterTest.java
├── AbstractTokenBridgeTest.java
├── AbstractTokenBuilderTest.java
├── AbstractTokenTest.java
├── GenericServiceTest.java
├── media
│ ├── entity
│ │ ├── MediaBuilderTest.java
│ │ └── MediaTest.java
│ ├── exception
│ │ ├── MediaNotFoundExceptionTest.java
│ │ └── MediaStorageExceptionTest.java
│ └── service
│ │ ├── MediaBridgeTest.java
│ │ └── MediaServiceImplTest.java
├── parameter
│ ├── entity
│ │ ├── ParameterBuilderTest.java
│ │ └── ParameterTest.java
│ ├── exception
│ │ └── ParameterNotFoundExceptionTest.java
│ └── service
│ │ ├── ParameterBridgeTest.java
│ │ └── ParameterServiceImplTest.java
├── permission
│ ├── entity
│ │ ├── PermissionBuilderTest.java
│ │ └── PermissionTest.java
│ ├── exception
│ │ └── PermissionNotFoundExceptionTest.java
│ └── service
│ │ ├── PermissionBridgeTest.java
│ │ └── PermissionServiceImplTest.java
├── role
│ ├── entity
│ │ ├── RoleBuilderTest.java
│ │ └── RoleTest.java
│ ├── exception
│ │ └── RoleNotFoundExceptionTest.java
│ └── service
│ │ ├── RoleBridgeTest.java
│ │ └── RoleServiceImplTest.java
├── type
│ ├── entity
│ │ ├── TypeBuilderTest.java
│ │ └── TypeTest.java
│ ├── exception
│ │ └── TypeNotFoundExceptionTest.java
│ └── service
│ │ ├── TypeBridgeTest.java
│ │ └── TypeServiceImplTest.java
└── user
│ ├── entity
│ ├── PasswordResetTokenBuilderTest.java
│ ├── PasswordResetTokenTest.java
│ ├── UserBuilderTest.java
│ ├── UserTest.java
│ ├── VerificationTokenBuilderTest.java
│ └── VerificationTokenTest.java
│ ├── exception
│ ├── PasswordResetTokenNotFoundExceptionTest.java
│ ├── UserNotFoundExceptionTest.java
│ └── VerificationTokenNotFoundExceptionTest.java
│ └── service
│ ├── PasswordResetTokenBridgeTest.java
│ ├── PasswordResetTokenServiceImplTest.java
│ ├── UserBridgeTest.java
│ ├── UserServiceImplTest.java
│ ├── VerificationTokenBridgeTest.java
│ └── VerificationTokenServiceImplTest.java
└── utils
├── ZipUtilsTest.java
└── validation
├── EmailValidatorTest.java
├── PasswordConfirmationDtoTest.java
├── PasswordMatchesValidatorTest.java
└── UuidValidatorTest.java
/.dockerignore:
--------------------------------------------------------------------------------
1 | # Ignore SCM and IDE items
2 | .git
3 | .idea
4 | .project
5 | .eclipse
6 | .vscode
7 |
8 | # maven
9 | target/
10 | .mvn
11 |
12 | # gradle
13 | gradle/
14 | .gradle/
15 | bin/
16 |
17 | # eclipse
18 | .project
19 | .classpath
20 | .settings
21 |
22 | #ant specific
23 | dist/
24 | build/
25 |
26 | #netbeans specific
27 | #core
28 | nbproject/*
29 | !nbproject/project.properties
30 | !nbproject/project.xml
31 |
32 | #spring specific
33 | .springBeans
34 |
35 | #project specific
36 | h2
37 | data
38 |
39 | #general swap/backup files
40 | *.so
41 | *.log
42 | *.out
43 | *~
44 | *.swp
45 | *.DS_Store
46 | *.lock
47 |
48 | # Docker files
49 | docker-compose*.yml
50 |
51 | # CI
52 | Jenkinsfile
53 | .travis.yml
54 |
55 | # Custom files
56 | .docker/
57 | .docker-build-date
58 | .docker-build
59 | manage.sh
60 |
--------------------------------------------------------------------------------
/.env:
--------------------------------------------------------------------------------
1 |
2 | ########################################
3 | # App Docker configuration
4 | ########################################
5 |
6 | APP_HOME=.docker/app
7 |
8 | # Application Configuration
9 | APP_TITLE=My App
10 | APP_DOMAIN_NAME=example.com
11 | APP_ADMIN_PASSWORD=youshouldoverwritethiswithsomethingelse
12 | APP_SIGNING_KEYPAIR_PASS=youshouldoverwritethiswithsomethingelse
13 |
14 | # Tomcat Configuration
15 | APP_SERVER_PORT=8080
16 | APP_SERVER_CONTEXT_PATH=api
17 | APP_MAX_FILE_SIZE=20MB
18 | APP_MAX_REQUEST_SIZE=20MB
19 |
20 | # Database configuration
21 | APP_DB_NAME=app
22 | APP_DB_USER=app
23 | APP_DB_PASSWORD=somethingverySecure
24 |
25 | # Mail configuration
26 | APP_SMTP_USER=
27 | APP_SMTP_PASSWD=
28 | APP_MAILER_FROM=test@example.com
29 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Autodetect text files
2 | * text=auto
3 |
4 | # ...Unless the name matches the following
5 | # overriding patterns
6 |
7 | # Definitely text files
8 | *.txt text
9 | *.svg text
10 | *.md text
11 | *.bat text eol=crlf
12 | *.cmd text eol=crlf
13 | *.sh text eol=lf
14 | *.yml text eol=lf
15 | *.xml text eol=lf
16 | Dockerfile text eol=lf
17 | Dockerfile.* text eol=lf
18 | /hooks/* text eol=lf
19 |
20 | *.java text
21 | *.properties text eol=lf
22 | /gradlew text eol=lf
23 | /mvnw text eol=lf
24 |
25 | # Ensure those won't be messed up with
26 | *.jpg binary
27 | *.jpeg binary
28 | *.png binary
29 | *.data binary
30 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | name: Bug report
4 | about: Create a report to help us improve
5 | title: ''
6 | labels: bug
7 | assignees:
8 |
9 | ---
10 |
11 | **Describe the bug**
12 | A clear and concise description of what the bug is.
13 |
14 | **To Reproduce**
15 | Steps to reproduce the behavior:
16 | 1. Go to '...'
17 | 2. Click on '....'
18 | 3. Scroll down to '....'
19 | 4. See error
20 |
21 | **Expected behavior**
22 | A clear and concise description of what you expected to happen.
23 |
24 | **Screenshots**
25 | If applicable, add screenshots to help explain your problem.
26 |
27 | **Desktop (please complete the following information):**
28 |
29 | - OS: (e.g. iOS)
30 | - Browser (e.g. chrome, safari)
31 | - Version (e.g. 22)
32 |
33 | **Smartphone (please complete the following information):**
34 |
35 | - Device: (e.g. iPhone6)
36 | - OS: (e.g. iOS8.1)
37 | - Browser (e.g. stock browser, safari)
38 | - Version (e.g. 22)
39 |
40 | **Additional context**
41 | Add any other context about the problem here.
42 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 |
3 | name: Feature request
4 | about: Suggest an idea for this project
5 | title: ''
6 | labels: enhancement
7 | assignees:
8 |
9 | ---
10 |
11 | **Is your feature request related to a problem? Please describe.**
12 | A clear and concise description of what the problem is. Ex. I'm always frustrated when (...)
13 |
14 | **Describe the solution you'd like**
15 | A clear and concise description of what you want to happen.
16 |
17 | **Describe alternatives you've considered**
18 | A clear and concise description of any alternative solutions or features you've considered.
19 |
20 | **Additional context**
21 | Add any other context or screenshots about the feature request here.
22 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
18 |
19 | > Please provide enough information so that others can review your pull request:
20 |
21 |
22 |
23 | > Explain the **details** for making this change. What existing problem does the pull request solve?
24 |
25 |
26 |
27 | > Screenshots/GIFs
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.github/config.yml:
--------------------------------------------------------------------------------
1 | # Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome
2 |
3 | # Comment to be posted to on first time issues
4 | newIssueWelcomeComment: >
5 | Thanks for opening your first issue here! Be sure to follow the issue template!
6 |
7 | # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
8 |
9 | # Comment to be posted to on PRs from first time contributors in your repository
10 | newPRWelcomeComment: >
11 | Thanks for opening this pull request! Please check out our contributing guidelines.
12 |
13 | # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge
14 |
15 | # Comment to be posted to on pull requests merged by a first time user
16 | firstPRMergeComment: >
17 | :tada: Congrats on merging your first pull request! We here at behaviorbot are proud of you!
18 |
19 | # It is recommend to include as many gifs and emojis as possible
20 |
21 | # Configuration for request-info - https://github.com/behaviorbot/request-info
22 |
23 | # *Required* Comment to reply with
24 | requestInfoReplyComment: >
25 | We would appreciate it if you could provide us with more info about this issue/pr!
26 |
27 | # *OPTIONAL* default titles to check against for lack of descriptiveness
28 | # MUST BE ALL LOWERCASE
29 | requestInfoDefaultTitles:
30 | - update readme.md
31 | - updates
32 |
33 |
34 | # *OPTIONAL* Label to be added to Issues and Pull Requests with insufficient information given
35 | requestInfoLabelToAdd: needs-more-info
36 |
--------------------------------------------------------------------------------
/.github/stale.yml:
--------------------------------------------------------------------------------
1 | # Configuration for probot-stale - https://github.com/probot/stale
2 |
3 | # Number of days of inactivity before an issue becomes stale
4 | daysUntilStale: 60
5 | # Number of days of inactivity before a stale issue is closed
6 | daysUntilClose: 30
7 |
8 | # Issues with these labels will never be considered stale
9 | exemptLabels:
10 | - pinned
11 | - security
12 |
13 | # Label to use when marking an issue as stale
14 | staleLabel: wontfix
15 |
16 | # Comment to post when marking an issue as stale. Set to `false` to disable
17 | markComment: >
18 | This issue has been automatically marked as stale because it has not had
19 | recent activity. It will be closed if no further activity occurs. Thank you
20 | for your contributions.
21 |
22 | # Comment to post when closing a stale issue. Set to `false` to disable
23 | closeComment: false
24 |
--------------------------------------------------------------------------------
/.github/workflows/hooks.yml:
--------------------------------------------------------------------------------
1 |
2 | name: Docker Image CI
3 |
4 | on:
5 | pull_request:
6 | push:
7 | branches:
8 | - main
9 | - master
10 | - develop
11 |
12 | jobs:
13 | build:
14 | runs-on: ubuntu-latest
15 | strategy:
16 | matrix:
17 | variant: ['alpine']
18 |
19 | steps:
20 | - name: Check Out Repo
21 | uses: actions/checkout@v2
22 |
23 | - name: Execute CI build hooks
24 | id: docker_build
25 | run: |
26 | # Export variables to tag against GitHub Container Registry
27 | #export DOCKER_REGISTRY=ghcr.io
28 | #export DOCKER_REPO=${{ github.repository }}
29 | ./hooks/run build ${{ matrix.variant }}
30 |
31 | - name: Display docker images
32 | run: docker images
33 |
34 | - name: Execute CI test hooks
35 | id: docker_test
36 | run: |
37 | ./hooks/run test ${{ matrix.variant }}
38 |
39 | #- name: Codacy Coverage Reporter
40 | # uses: codacy/codacy-coverage-reporter-action@0.2.0
41 | # with:
42 | # project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
43 | # coverage-reports: ./coverage/coverage-phpunit-cobertura.xml
44 |
45 | #- name: Execute CI push hooks
46 | # id: docker_push
47 | # run: |
48 | # # Export variables to login and push to GitHub Container Registry
49 | # #export DOCKER_REGISTRY=ghcr.io
50 | # #export DOCKER_LOGIN=${{ github.repository_owner }}
51 | # #export DOCKER_PASSWORD=${{ secrets.GITHUB_REGISTRY_TOKEN }}
52 | # ./hooks/run push ${{ matrix.variant }}
53 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | **/.vscode
2 | target/*
3 | target
4 |
5 |
6 | # Mobile Tools for Java (J2ME)
7 | .mtj.tmp/
8 |
9 | # Package Files #
10 | *.jar
11 | *.war
12 | *.ear
13 |
14 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
15 | hs_err_pid*
16 |
17 | # Intellij Files
18 | *.iml
19 | /lib
20 |
21 | # maven
22 | target/
23 | .mvn
24 |
25 | # gradle
26 | gradle/
27 | .gradle/
28 | bin/
29 |
30 | # eclipse
31 | .project
32 | .classpath
33 | .settings
34 | .checkstyle
35 |
36 | #ant specific
37 | dist/
38 | build/
39 |
40 | #netbeans specific
41 | #core
42 | nbproject/*
43 | !nbproject/project.properties
44 | !nbproject/project.xml
45 |
46 | #java specific
47 | *.class
48 |
49 | #general swap/backup files
50 | *.so
51 | *.log
52 | *.out
53 | *~
54 | *.swp
55 | *.DS_Store
56 | *.lock
57 |
58 | #spring specific
59 | .springBeans
60 |
61 | #project specific
62 | .docker/
63 | data
64 | logs
65 |
--------------------------------------------------------------------------------
/.gitlab/issue_templates/bug_report.md:
--------------------------------------------------------------------------------
1 | # Bug report
2 |
3 | Create a report to help us improve.
4 |
5 | /label ~bug
6 |
7 | **Describe the bug**
8 | A clear and concise description of what the bug is.
9 |
10 | **To Reproduce**
11 | Steps to reproduce the behavior:
12 | 1. Go to '...'
13 | 2. Click on '....'
14 | 3. Scroll down to '....'
15 | 4. See error
16 |
17 | **Expected behavior**
18 | A clear and concise description of what you expected to happen.
19 |
20 | **Screenshots**
21 | If applicable, add screenshots to help explain your problem.
22 |
23 | **Desktop (please complete the following information):**
24 |
25 | - OS: (e.g. iOS)
26 | - Browser (e.g. chrome, safari)
27 | - Version (e.g. 22)
28 |
29 | **Smartphone (please complete the following information):**
30 |
31 | - Device: (e.g. iPhone6)
32 | - OS: (e.g. iOS8.1)
33 | - Browser (e.g. stock browser, safari)
34 | - Version (e.g. 22)
35 |
36 | **Additional context**
37 | Add any other context about the problem here.
38 |
--------------------------------------------------------------------------------
/.gitlab/issue_templates/feature_request.md:
--------------------------------------------------------------------------------
1 | # Feature request
2 |
3 | Suggest an idea for this project.
4 |
5 | /label ~enhancement
6 |
7 | **Is your feature request related to a problem? Please describe.**
8 |
9 | A clear and concise description of what the problem is. Ex. I'm always frustrated when (...)
10 |
11 | **Describe the solution you'd like**
12 |
13 | A clear and concise description of what you want to happen.
14 |
15 | **Describe alternatives you've considered**
16 |
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 |
21 | Add any other context or screenshots about the feature request here.
22 |
--------------------------------------------------------------------------------
/.gitlab/merge_request_templates/merge_request_template.md:
--------------------------------------------------------------------------------
1 |
18 |
19 | > Please provide enough information so that others can review your pull request:
20 |
21 |
22 |
23 | > Explain the **details** for making this change. What existing problem does the pull request solve?
24 |
25 |
26 |
27 | > Screenshots/GIFs
28 |
29 |
30 |
--------------------------------------------------------------------------------
/.gitpod.yml:
--------------------------------------------------------------------------------
1 | image:
2 | file: Dockerfile.gitpod
3 |
4 | ports:
5 | - port: 8080
6 |
7 | tasks:
8 | - init: ./manage.sh build
9 | command: ./manage.sh run
10 |
11 | github:
12 | prebuilds:
13 | # enable for the master/default branch (defaults to true)
14 | master: true
15 | # enable for all branches in this repo (defaults to false)
16 | branches: false
17 | # enable for pull requests coming from this repo (defaults to true)
18 | pullRequests: true
19 | # enable for pull requests coming from forks (defaults to false)
20 | pullRequestsFromForks: false
21 | # add a check to pull requests (defaults to true)
22 | addCheck: true
23 | # add a "Review in Gitpod" button as a comment to pull requests (defaults to false)
24 | addComment: true
25 | # add a "Review in Gitpod" button to the pull request's description (defaults to false)
26 | addBadge: false
27 | # add a label once the prebuild is ready to pull requests (defaults to false)
28 | addLabel: true
29 |
--------------------------------------------------------------------------------
/.theia/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | // Use IntelliSense to learn about possible attributes.
3 | // Hover to view descriptions of existing attributes.
4 | "version": "0.2.0",
5 | "configurations": [
6 | {
7 | "type": "java",
8 | "name": "Debug (Launch) - Current File",
9 | "request": "launch",
10 | "mainClass": "${file}"
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/.theia/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "files.exclude": {
3 | "**/.classpath": true,
4 | "**/.project": true,
5 | "**/.settings": true,
6 | "**/.factorypath": true
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | os: linux
2 | dist: trusty
3 |
4 | services: docker
5 |
6 | language: java
7 |
8 | branches:
9 | only:
10 | - master
11 |
12 | jdk:
13 | - oraclejdk11
14 |
15 | before_install:
16 | - env | sort
17 | - export DOCKER_REPO="monogramm/spring-rest-api-starter"
18 |
19 | install:
20 | # Execute CI build hooks
21 | # TODO Mount local dir as volume to retrieve test results (-v "$(pwd)":/usr/src/app)
22 | - ./hooks/run build "${VARIANT}"
23 |
24 | before_script:
25 | # Display docker images
26 | - docker images
27 |
28 | script:
29 | # Execute CI test hooks
30 | - ./hooks/run test "${VARIANT}"
31 |
32 | after_success:
33 | # TODO Send test coverage report to CodeCov
34 | - bash <(curl -s https://codecov.io/bash)
35 |
36 | #jobs:
37 | # allow_failures:
38 | # - env: DATABASE=h2
39 |
40 | env: # Environments
41 | - VARIANT=alpine
42 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Contributing
2 | ============
3 |
4 | First of all, **thank you** for contributing, **you are awesome**!
5 |
6 | Here are a few rules to follow in order to ease code reviews, and discussions before maintainers accept and merge your work.
7 |
8 | You MUST follow the [Java Coding Standards](https://google.github.io/styleguide/javaguide.html). If you don't know about any of them, you should really read the recommendations. Can't wait? Use [Sonar Qube](http://www.sonarqube.org/).
9 |
10 | You MUST run the test suite.
11 |
12 | You MUST write (or update) unit tests.
13 |
14 | You SHOULD write documentation.
15 |
16 | Please, write [commit messages that make sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing)
17 | before submitting your Pull Request.
18 |
19 | One may ask you to [squash your commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) too.This is used to "clean" your Pull Request before merging it (we don't want commits such as `fix tests`, `fix 2`, `fix 3`, etc.).
20 |
21 | Also, while creating your Pull Request on GitHub, you MUST write a description which gives the context and/or explains why you are creating it.
22 |
23 | Thank you!
24 |
--------------------------------------------------------------------------------
/Dockerfile.develop:
--------------------------------------------------------------------------------
1 | FROM maven:3-jdk-8-slim AS builder
2 |
3 | RUN set -ex; \
4 | apt-get update; \
5 | apt-get install -y --allow-unauthenticated \
6 | git \
7 | graphviz \
8 | ; \
9 | dot -V; \
10 | rm -rf /var/lib/apt/lists/*
11 |
12 | WORKDIR /usr/src/app
13 |
14 | EXPOSE 8080 8443 35729
15 |
16 | # Application configuration
17 | # Database configuration
18 | # Mail configuration
19 | ENV \
20 | APP_TITLE=App \
21 | APP_CONFIG=/srv/app/config/application.properties \
22 | APP_SERVER_CONTEXT_PATH=/api \
23 | APP_SERVER_PORT=8080 \
24 | APP_MAX_FILE_SIZE=20MB \
25 | APP_MAX_REQUEST_SIZE=20MB \
26 | APP_DOMAIN_NAME=example.com \
27 | APP_ADMIN_PASSWORD=youshouldoverwritethiswithsomethingelse \
28 | APP_SIGNING_KEY=youshouldoverwritethiswithsomethingelse \
29 | APP_SIGNING_KEYPAIR_PASS='' \
30 | APP_SIGNING_KEYPAIR_ALIAS=spring_rest_api_starter_key \
31 | APP_DEMO_DATA=false \
32 | DB_DIALECT='' \
33 | DB_STORAGE='' \
34 | DB_DRIVER='' \
35 | DB_PLATFORM='h2' \
36 | DB_HOST='' \
37 | DB_PORT='' \
38 | DB_NAME='spring_rest_api_starter' \
39 | DB_USER='spring_rest_api_starter' \
40 | DB_PASSWORD='spring_rest_api_starter_password' \
41 | MAIL_HOST= \
42 | MAIL_PORT= \
43 | MAIL_PROTOCOL= \
44 | MAIL_USER= \
45 | MAIL_PASSWORD= \
46 | MAIL_SSL=false \
47 | MAIL_STARTTLS=false
48 |
49 | COPY docker/maven/settings-docker.xml /usr/share/maven/ref/settings-docker.xml
50 | COPY . .
51 |
52 | # Credentials to private Package Repository
53 | ARG PACKAGE_REPO_LOGIN
54 | ARG PACKAGE_REPO_PASSWORD
55 |
56 | RUN set -ex; \
57 | mvn \
58 | clean \
59 | install \
60 | -DskipTests=true \
61 | -Dmaven.javadoc.skip=true \
62 | -B \
63 | -V \
64 | -s /usr/share/maven/ref/settings-docker.xml \
65 | -P "${MAVEN_PROFILE}" \
66 | ;
67 |
68 | CMD [ "mvn", "spring-boot:run" ]
69 |
--------------------------------------------------------------------------------
/Dockerfile.gitpod:
--------------------------------------------------------------------------------
1 | FROM gitpod/workspace-full
2 |
3 | # Install custom tools, runtimes, etc.
4 | # For example "bastet", a command-line tetris clone:
5 | # RUN brew install bastet
6 | #
7 | # More information: https://www.gitpod.io/docs/config-docker/
8 |
9 | #RUN set -ex; \
10 | # bash -c ". /home/gitpod/.sdkman/bin/sdkman-init.sh \
11 | # && sdk install java 8.0.275.open"
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | mavenCentral()
4 | }
5 | dependencies {
6 | classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.3.RELEASE")
7 | }
8 | }
9 |
10 | apply plugin: 'java'
11 | apply plugin: 'eclipse'
12 | apply plugin: 'idea'
13 | apply plugin: 'org.springframework.boot'
14 |
15 | jar {
16 | baseName = 'gs-accessing-data-mysql'
17 | version = '0.1.0'
18 | }
19 |
20 | repositories {
21 | mavenCentral()
22 | }
23 |
24 | sourceCompatibility = 1.8
25 | targetCompatibility = 1.8
26 |
27 | dependencies {
28 | compile("org.springframework.boot:spring-boot-starter-web")
29 |
30 | // JPA Data (We are going to use Repositories, Entities, Hibernate, etc...)
31 | compile 'org.springframework.boot:spring-boot-starter-data-jpa'
32 |
33 | // Use H2 connector
34 | compile 'com.h2database:h2'
35 |
36 | testCompile('org.springframework.boot:spring-boot-starter-test')
37 | }
38 |
39 | configurations.all {
40 | exclude module: 'spring-boot-starter-logging'
41 | }
42 |
--------------------------------------------------------------------------------
/docker/README.md:
--------------------------------------------------------------------------------
1 |
2 | Docker build related files.
3 |
--------------------------------------------------------------------------------
/docker/maven/settings-docker.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
25 |
26 |
27 |
28 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/docker/test/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM php:alpine
2 |
3 | COPY docker_test.sh /docker_test.sh
4 |
5 | RUN set -ex; \
6 | chmod 755 /docker_test.sh; \
7 | apk add --update \
8 | curl \
9 | git \
10 | ; \
11 | \
12 | rm -rf /var/cache/apk/*
13 |
14 | CMD ["/docker_test.sh"]
15 |
--------------------------------------------------------------------------------
/docker/test/docker_test.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | set -e
4 |
5 | log() {
6 | echo "[$0] [$(date +%Y-%m-%dT%H:%M:%S)] $*"
7 | }
8 |
9 | ################################################################################
10 | # Testing docker containers
11 |
12 | log "Waiting to ensure everything is fully ready for the tests..."
13 | sleep 60
14 |
15 | log "Checking main containers are reachable..."
16 | if ! ping -c 10 -q "${DOCKER_TEST_CONTAINER}" ; then
17 | log 'Main container is not responding!'
18 | # TODO Display logs to help bug fixing
19 | #log 'Check the following logs for details:'
20 | #tail -n 100 logs/*.log
21 | exit 2
22 | fi
23 |
24 |
25 | ################################################################################
26 | # Success
27 | log 'Docker tests successful'
28 |
29 |
30 | ################################################################################
31 | # Automated Service Unit tests
32 | # https://docs.docker.com/docker-hub/builds/automated-testing/
33 | ################################################################################
34 |
35 | if [ -n "${DOCKER_WEB_CONTAINER}" ]; then
36 |
37 | if ! ping -c 10 -q "${DOCKER_WEB_CONTAINER}" ; then
38 | log 'Web container is not responding!'
39 | # TODO Display logs to help bug fixing
40 | #log 'Check the following logs for details:'
41 | #tail -n 100 logs/*.log
42 | exit 2
43 | fi
44 |
45 | DOCKER_WEB_HEALTH_URL="http://${DOCKER_WEB_CONTAINER}:${DOCKER_WEB_PORT-:80}/${DOCKER_WEB_HEALTH_API:-health}"
46 | log "TODO Checking Health API: ${DOCKER_WEB_HEALTH_URL}"
47 | curl "${DOCKER_WEB_HEALTH_URL}"
48 | #curl --fail "${DOCKER_WEB_HEALTH_URL}" | grep -q -e 'UP' || exit 1
49 | fi
50 |
51 | ################################################################################
52 | # Success
53 | echo "Docker app '${DOCKER_TEST_CONTAINER}' tests finished"
54 | echo 'Check the CI reports and logs for details.'
55 | exit 0
56 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # **LDAP All-For-One Manager** Documentation site
2 |
3 | **Spring REST API Starter**: A 'simple' starter project custom RESTful API.
4 |
5 | The objective of the project is to provide a user-friendly REST API.
6 |
7 | It comes with full build / tests / deploy automation while providing as much "_standard_" features as usually found in recent REST APIs.
8 |
9 | ## How to use
10 |
11 | Check repository on GitHub for details:
12 |
13 | ## Contributing
14 |
15 | For information about contributing, see the [Contributing page](https://github.com/Monogramm/spring-rest-api-starter/blob/main/CONTRIBUTING.md).
16 |
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-cayman
--------------------------------------------------------------------------------
/hooks/README.md:
--------------------------------------------------------------------------------
1 | # DockerHub automated tests hooks
2 |
3 | See documentation for details:
4 |
--------------------------------------------------------------------------------
/hooks/build:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # See documentation for details:
4 | # https://docs.docker.com/docker-hub/builds/advanced/
5 | # https://microbadger.com/labels
6 |
7 | docker build \
8 | --build-arg "VCS_REF=${SOURCE_COMMIT}" \
9 | --build-arg "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" \
10 | --build-arg "TAG=${DOCKER_TAG}" \
11 | --build-arg "MAVEN_PROFILE=${MAVEN_PROFILE}" \
12 | --build-arg "PACKAGE_REPO_LOGIN=${PACKAGE_REPO_LOGIN}" \
13 | --build-arg "PACKAGE_REPO_PASSWORD=${PACKAGE_REPO_PASSWORD}" \
14 | -f "$DOCKERFILE_PATH" \
15 | -t "$IMAGE_NAME" .
16 |
--------------------------------------------------------------------------------
/hooks/post_push:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # See documentation for details:
4 | # https://docs.docker.com/docker-hub/builds/advanced/
5 |
6 | if [ -n "${DOCKER_REGISTRY}" ]; then
7 | export DOCKER_BASE_IMAGE=${DOCKER_REGISTRY}/${DOCKER_REPO}
8 | else
9 | export DOCKER_BASE_IMAGE=${DOCKER_REPO}
10 | fi
11 |
12 | if [ -f ./.dockertags ]; then
13 | for tag in $(cat ./.dockertags); do
14 | if [ ! "${tag}" = "${DOCKER_TAG}" ]; then
15 | docker tag "$IMAGE_NAME" "$DOCKER_BASE_IMAGE:$tag"
16 | docker push "$DOCKER_BASE_IMAGE:$tag"
17 | fi
18 | done
19 | fi
20 |
21 | # Push image with tag set to commit hash
22 | docker tag "$IMAGE_NAME" "$DOCKER_BASE_IMAGE:$SOURCE_COMMIT"
23 | docker push "$DOCKER_BASE_IMAGE:$SOURCE_COMMIT"
24 |
25 | if [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_LOGIN}" ]; then
26 | if [ -n "${DOCKER_REGISTRY}" ]; then
27 | echo "Logout of Docker Registry ${DOCKER_REGISTRY}..."
28 | docker logout "${DOCKER_REGISTRY}"
29 | else
30 | echo "Logout of Docker default Registry..."
31 | docker logout
32 | fi
33 | fi
34 |
--------------------------------------------------------------------------------
/hooks/post_test:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # See documentation for details:
4 | # https://docs.docker.com/docker-hub/builds/advanced/
5 |
6 | if [ ! -d ./coverage ]; then
7 | mkdir -p ./coverage
8 | fi
9 |
10 | # Update Code Coverage Reports container path with local path
11 | for f in cobertura.xml clover.xml; do
12 | if [ -f "${APP_HOME:-.docker/app}/html/.docker/coverage-phpunit-$f" ]; then
13 | sed -e "s|/usr/src/symfony/src|$(pwd)/app/src|g" "${APP_HOME:-.docker/app}/html/.docker/coverage-phpunit-$f" > "./coverage/coverage-phpunit-$f"
14 | fi
15 | done
16 |
17 | if [ -d "${APP_HOME:-.docker/app}/html/.docker/coverage-phpunit-html" ]; then
18 | cp -r "${APP_HOME:-.docker/app}/html/.docker/coverage-phpunit-html" ./coverage/coverage-phpunit-html
19 | fi
20 |
21 | #echo 'Removing persisted data...'
22 | #rm -rf "${APP_HOME:-.docker/app}"
23 |
--------------------------------------------------------------------------------
/hooks/pre_push:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # See documentation for details:
4 | # https://docs.docker.com/docker-hub/builds/advanced/
5 |
6 | if [ -n "${DOCKER_PASSWORD}" ] && [ -n "${DOCKER_LOGIN}" ]; then
7 | if [ -n "${DOCKER_REGISTRY}" ]; then
8 | echo "Login to Docker Registry ${DOCKER_REGISTRY}..."
9 | docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}" "${DOCKER_REGISTRY}"
10 | else
11 | echo "Login to Docker default Registry..."
12 | docker login -u "${DOCKER_LOGIN}" -p "${DOCKER_PASSWORD}"
13 | fi
14 | fi
15 |
--------------------------------------------------------------------------------
/hooks/pre_test:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # See documentation for details:
4 | # https://docs.docker.com/docker-hub/builds/advanced/
5 |
6 | if [ ! -f '.env' ]; then
7 | echo 'Init docker compose environment variables...'
8 | cp .env_template .env.tmp
9 |
10 | sed -i \
11 | -e "s|APP_PACKAGE_REPO_LOGIN=.*|APP_PACKAGE_REPO_LOGIN=${PACKAGE_REPO_LOGIN}|" \
12 | -e "s|APP_PACKAGE_REPO_PASSWORD=.*|APP_PACKAGE_REPO_PASSWORD=${PACKAGE_REPO_PASSWORD}|" \
13 | .env.tmp
14 |
15 | mv .env.tmp .env
16 | fi
17 |
18 | #echo 'Preparing persisted data...'
19 | #mkdir -p "${APP_HOME:-.docker/app}"
20 | #chmod 777 "${APP_HOME:-.docker/app}"
21 |
--------------------------------------------------------------------------------
/hooks/push:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # See documentation for details:
4 | # https://docs.docker.com/docker-hub/builds/advanced/
5 |
6 | docker push "$IMAGE_NAME"
7 |
--------------------------------------------------------------------------------
/hooks/run:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Custom script to run locally DockerHub hooks
4 | # See documentation for details:
5 | # https://docs.docker.com/docker-hub/builds/advanced/
6 |
7 | echo "Custom script to run locally DockerHub hooks..."
8 | set -e
9 |
10 | export SOURCE_BRANCH
11 | SOURCE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
12 | export SOURCE_COMMIT
13 | SOURCE_COMMIT=$(git rev-parse --short HEAD)
14 | export COMMIT_MSG
15 | COMMIT_MSG=$(git log -1 --format=%s)
16 |
17 | export VARIANT=${2:-alpine}
18 |
19 | export DOCKER_REPO=${DOCKER_REPO:-monogramm/spring-rest-api-starter}
20 | export DOCKERFILE_PATH=Dockerfile.${VARIANT}
21 | export DOCKER_TAG=${VARIANT}
22 | export DOCKER_TAG=${DOCKER_TAG:-${VARIANT}}
23 |
24 | if [ -n "${DOCKER_REGISTRY}" ]; then
25 | export IMAGE_NAME=${DOCKER_REGISTRY}/${DOCKER_REPO}:${DOCKER_TAG}
26 | else
27 | export IMAGE_NAME=${DOCKER_REPO}:${DOCKER_TAG}
28 | fi
29 |
30 | # Execute hooks in given order
31 | IFS=',' read -ra STEPS <<< "${1:-build,test}"
32 | for step in "${STEPS[@]}"
33 | do
34 | for hook in "pre_${step}" "${step}" "post_${step}"; do
35 | if [ -f "./hooks/${hook}" ]; then
36 | echo "Executing ${hook} hook..."
37 | "./hooks/${hook}"
38 | fi
39 | done
40 | done
41 |
42 | echo "DockerHub hooks finished"
43 |
--------------------------------------------------------------------------------
/hooks/test:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # See documentation for details:
4 | # https://docs.docker.com/docker-hub/builds/advanced/
5 |
6 | if [ "${DOCKERFILE_PATH}" = "Dockerfile.develop" ] || [ "${DOCKERFILE_PATH}" = "Dockerfile.gitpod" ]; then
7 | echo "No tests (yet) for ${DOCKERFILE_PATH} images."
8 | exit 0
9 | fi
10 |
11 | for file in docker-compose.*.test.yml; do
12 |
13 | echo "Starting Test in ${file}..."
14 |
15 | # Build test container
16 | docker-compose --no-ansi -f "${file}" build sut
17 | # Test container run
18 | docker-compose --no-ansi -f "${file}" up -d && sleep 60
19 | docker-compose --no-ansi -f "${file}" logs -f "sut"
20 | docker-compose --no-ansi -f "${file}" ps
21 | #docker-compose --no-ansi -f "${file}" logs --no-color "app_db"
22 | docker-compose --no-ansi -f "${file}" logs --no-color "app_backend"
23 | docker-compose --no-ansi -f "${file}" ps "sut" | grep "Exit 0" || exit 1
24 | docker-compose --no-ansi -f "${file}" down
25 |
26 | # Test container restart
27 | docker-compose --no-ansi -f "${file}" up -d && sleep 60
28 | docker-compose --no-ansi -f "${file}" logs -f "sut"
29 | docker-compose --no-ansi -f "${file}" ps
30 | #docker-compose --no-ansi -f "${file}" logs --no-color "app_db"
31 | docker-compose --no-ansi -f "${file}" logs --no-color "app_backend"
32 | docker-compose --no-ansi -f "${file}" ps "sut" | grep "Exit 0" || exit 1
33 | docker-compose --no-ansi -f "${file}" down -v
34 |
35 | done
36 |
--------------------------------------------------------------------------------
/jitpack.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk:
3 | - oraclejdk8
4 |
--------------------------------------------------------------------------------
/pmdruleset.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | This ruleset checks my code for bad stuff
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/integration-test/java/com/monogramm/ApplicationIT.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-09-08.
3 | */
4 |
5 | package com.monogramm;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 | import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
10 | import org.springframework.boot.test.context.SpringBootTest;
11 | import org.springframework.test.context.junit4.SpringRunner;
12 |
13 | /**
14 | * {@link Application} Integration Test.
15 | *
16 | *
17 | * Spring boot test is searching @SpringBootConfiguration or @SpringBootApplication. In this case it
18 | * will automatically find {@link Application} boot main class.
19 | *
9 | * The main purpose of this package is to centralize all the objects needed to interact with the
10 | * API, making it easy to export to a separate project and importing it independently in a Client
11 | * application project.
12 | *
18 | * This should be used as a base class for a registration request.
19 | *
20 | *
21 | * @author madmath03
22 | */
23 | public class RegistrationDto extends PasswordConfirmationDto {
24 | @NotNull
25 | @NotEmpty
26 | private String username = null;
27 |
28 | @ValidEmail
29 | @NotNull
30 | @NotEmpty
31 | private String email = null;
32 |
33 | /**
34 | * Create a {@link RegistrationDto}.
35 | */
36 | public RegistrationDto() {
37 | super();
38 | }
39 |
40 | /**
41 | * Create a {@link RegistrationDto}.
42 | *
43 | * @param username the registration username.
44 | * @param email the registration email.
45 | * @param password the password.
46 | * @param matchingPassword the matching password.
47 | *
48 | * @throws NullPointerException if {@code password} or {@code matchingPassword} is {@code null}.
49 | */
50 | public RegistrationDto(final String username, final String email, final char[] password,
51 | final char[] matchingPassword) {
52 | super(password, matchingPassword);
53 | this.username = username;
54 | this.email = email;
55 | }
56 |
57 | /**
58 | * Get the {@link #username}.
59 | *
60 | * @return the {@link #username}.
61 | */
62 | public final String getUsername() {
63 | return username;
64 | }
65 |
66 | /**
67 | * Set the {@link username}.
68 | *
69 | * @param username the {@link #username} to set.
70 | */
71 | public final void setUsername(final String username) {
72 | this.username = username;
73 | }
74 |
75 | /**
76 | * Get the {@link #email}.
77 | *
78 | * @return the {@link #email}.
79 | */
80 | public final String getEmail() {
81 | return email;
82 | }
83 |
84 | /**
85 | * Set the {@link email}.
86 | *
87 | * @param email the {@link #email} to set.
88 | */
89 | public final void setEmail(final String email) {
90 | this.email = email;
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/dto/user/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-18.
3 | */
4 |
5 | /**
6 | * The Users related DTOs.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.dto.user;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The root package of the starter application.
3 | *
4 | * @author madmath03
5 | */
6 | package com.monogramm.starter;
7 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/AbstractParameterBridge.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-12-20.
3 | */
4 |
5 | package com.monogramm.starter.persistence;
6 |
7 | import com.monogramm.starter.dto.AbstractParameterDto;
8 | import com.monogramm.starter.persistence.user.dao.UserRepository;
9 |
10 | /**
11 | * AbstractParameterBridge.
12 | *
13 | * @author madmath03
14 | */
15 | public abstract class AbstractParameterBridge extends AbstractGenericBridge {
17 |
18 | /**
19 | * Create a {@link AbstractParameterBridge}.
20 | *
21 | */
22 | protected AbstractParameterBridge() {
23 | super();
24 | }
25 |
26 | /**
27 | * Create a {@link AbstractParameterBridge}.
28 | *
29 | * @param userRepository repository to lookup users.
30 | */
31 | public AbstractParameterBridge(UserRepository userRepository) {
32 | super(userRepository);
33 | }
34 |
35 | @Override
36 | public T toEntity(final D dto) {
37 | final T entity = super.toEntity(dto);
38 |
39 | entity.setName(dto.getName());
40 | entity.setDescription(dto.getDescription());
41 | if (dto.getType() != null) {
42 | entity.setType(ParameterType.valueOf(dto.getType().toUpperCase()));
43 | }
44 | entity.setValue(dto.getValue());
45 |
46 | return entity;
47 | }
48 |
49 | @Override
50 | public D toDto(final T entity) {
51 | final D dto = super.toDto(entity);
52 |
53 | dto.setName(entity.getName());
54 | dto.setDescription(entity.getDescription());
55 | if (entity.getType() != null) {
56 | dto.setType(entity.getType().toString());
57 | }
58 | dto.setValue(entity.getValue());
59 |
60 | return dto;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/AbstractTokenBridge.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-12-20.
3 | */
4 |
5 | package com.monogramm.starter.persistence;
6 |
7 | import com.monogramm.starter.dto.AbstractTokenDto;
8 | import com.monogramm.starter.persistence.user.dao.UserRepository;
9 | import com.monogramm.starter.persistence.user.entity.User;
10 |
11 | /**
12 | * AbstractTokenBridge.
13 | *
14 | * @author madmath03
15 | */
16 | public abstract class AbstractTokenBridge extends AbstractGenericBridge {
18 |
19 | /**
20 | * Create a {@link AbstractTokenBridge}.
21 | *
22 | */
23 | protected AbstractTokenBridge() {
24 | super();
25 | }
26 |
27 | /**
28 | * Create a {@link AbstractTokenBridge}.
29 | *
30 | * @param userRepository repository to lookup users.
31 | */
32 | public AbstractTokenBridge(UserRepository userRepository) {
33 | super(userRepository);
34 | }
35 |
36 | @Override
37 | public T toEntity(final D dto) {
38 | final T entity = super.toEntity(dto);
39 |
40 | entity.setCode(dto.getCode());
41 | entity.setExpiryDate(dto.getExpiryDate());
42 |
43 | if (dto.getUser() != null) {
44 | final User user;
45 | if (getUserRepository() == null) {
46 | user = User.builder().id(dto.getUser()).build();
47 | } else {
48 | user = this.getUserRepository().findById(dto.getUser());
49 | }
50 | entity.setUser(user);
51 | }
52 |
53 | return entity;
54 | }
55 |
56 | @Override
57 | public D toDto(final T entity) {
58 | final D dto = super.toDto(entity);
59 |
60 | dto.setCode(entity.getCode());
61 | dto.setExpiryDate(entity.getExpiryDate());
62 |
63 | if (entity.getUser() != null) {
64 | dto.setUser(entity.getUser().getId());
65 | }
66 |
67 | return dto;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/EntityNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-09-03.
3 | */
4 |
5 | package com.monogramm.starter.persistence;
6 |
7 | /**
8 | * "{@link AbstractGenericEntity} not found" Exception.
9 | *
10 | * @author madmath03
11 | */
12 | public abstract class EntityNotFoundException extends RuntimeException {
13 |
14 | /**
15 | * The {@code serialVersionUID}.
16 | */
17 | private static final long serialVersionUID = 2016265732131475104L;
18 |
19 | /**
20 | * Create a {@link EntityNotFoundException}.
21 | *
22 | */
23 | public EntityNotFoundException() {
24 | super();
25 | }
26 |
27 | /**
28 | * Create a {@link EntityNotFoundException}.
29 | *
30 | * @param message the detail message.
31 | */
32 | public EntityNotFoundException(String message) {
33 | super(message);
34 | }
35 |
36 | /**
37 | * Create a {@link EntityNotFoundException}.
38 | *
39 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
40 | * nonexistent or unknown.)
41 | */
42 | public EntityNotFoundException(Throwable cause) {
43 | super(cause);
44 | }
45 |
46 | /**
47 | * Create a {@link EntityNotFoundException}.
48 | *
49 | * @param message the detail message.
50 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
51 | * nonexistent or unknown.)
52 | */
53 | public EntityNotFoundException(String message, Throwable cause) {
54 | super(message, cause);
55 | }
56 |
57 | /**
58 | * Create a {@link EntityNotFoundException}.
59 | *
60 | * @param message the detail message.
61 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
62 | * nonexistent or unknown.)
63 | * @param enableSuppression whether or not suppression is enabled or disabled
64 | * @param writableStackTrace whether or not the stack trace should be writable
65 | */
66 | public EntityNotFoundException(String message, Throwable cause, boolean enableSuppression,
67 | boolean writableStackTrace) {
68 | super(message, cause, enableSuppression, writableStackTrace);
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/media/dao/MediaRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2019-01-24.
3 | */
4 |
5 | package com.monogramm.starter.persistence.media.dao;
6 |
7 | import com.monogramm.starter.persistence.GenericRepository;
8 | import com.monogramm.starter.persistence.media.entity.Media;
9 |
10 | import java.util.List;
11 | import java.util.UUID;
12 |
13 | import javax.persistence.NoResultException;
14 | import javax.persistence.NonUniqueResultException;
15 |
16 | import org.springframework.data.jpa.repository.Query;
17 | import org.springframework.data.repository.query.Param;
18 | import org.springframework.stereotype.Repository;
19 |
20 | /**
21 | * The {@link Media} Data Access Object (DAO) interface.
22 | *
23 | * @author madmath03
24 | */
25 | @Repository
26 | public interface MediaRepository extends GenericRepository {
27 |
28 | /**
29 | * Find all Medias from the repository containing the name while ignoring case.
30 | *
31 | * @param name the name content to search.
32 | *
33 | * @return the list of all the Medias matching the search through the repository.
34 | */
35 | @Query("FROM Media AS m " + "WHERE LOWER(m.name) LIKE concat('%', LOWER(:name), '%')")
36 | List findAllContainingNameIgnoreCase(@Param("name") final String name);
37 |
38 | /**
39 | * Find an Media through its name while ignoring case.
40 | *
41 | * @param name the name to search.
42 | *
43 | * @return the Media matching the name.
44 | *
45 | * @throws NoResultException if no Media matches the name in the repository.
46 | * @throws NonUniqueResultException if several Medias match the name in the repository.
47 | */
48 | Media findByNameIgnoreCase(final String name);
49 |
50 | /**
51 | * Tests if an entity exists in the repository for the given primary key or the name.
52 | *
53 | * @param mediaId the identifier of the Media to check existence.
54 | * @param name the name of the Media to check existence.
55 | *
56 | * @return {@code true} if Media exists, {@code false} otherwise.
57 | */
58 | @Query("SELECT count(m) > 0 FROM Media AS m "
59 | + "WHERE m.id = :MediaId OR LOWER(m.name) = LOWER(:name)")
60 | boolean exists(@Param("MediaId") final UUID mediaId, @Param("name") final String name);
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/media/dao/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2019-01-24.
3 | */
4 |
5 | /**
6 | * The Medias Data Access Objects.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.media.dao;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/media/entity/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2019-01-24.
3 | */
4 |
5 | /**
6 | * The Medias entity.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.media.entity;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/media/exception/MediaNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2019-01-24.
3 | */
4 |
5 | package com.monogramm.starter.persistence.media.exception;
6 |
7 | import com.monogramm.starter.persistence.EntityNotFoundException;
8 | import com.monogramm.starter.persistence.media.entity.Media;
9 |
10 | /**
11 | * "{@link Media} not found" Exception.
12 | *
13 | * @author madmath03
14 | */
15 | public class MediaNotFoundException extends EntityNotFoundException {
16 |
17 | /**
18 | * The {@code serialVersionUID}.
19 | */
20 | private static final long serialVersionUID = -856246176128256794L;
21 |
22 | /**
23 | * Create a {@link MediaNotFoundException}.
24 | *
25 | */
26 | public MediaNotFoundException() {
27 | super();
28 | }
29 |
30 | /**
31 | * Create a {@link MediaNotFoundException}.
32 | *
33 | * @param message the detail message.
34 | */
35 | public MediaNotFoundException(String message) {
36 | super(message);
37 | }
38 |
39 | /**
40 | * Create a {@link MediaNotFoundException}.
41 | *
42 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
43 | * nonexistent or unknown.)
44 | */
45 | public MediaNotFoundException(Throwable cause) {
46 | super(cause);
47 | }
48 |
49 | /**
50 | * Create a {@link MediaNotFoundException}.
51 | *
52 | * @param message the detail message.
53 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
54 | * nonexistent or unknown.)
55 | */
56 | public MediaNotFoundException(String message, Throwable cause) {
57 | super(message, cause);
58 | }
59 |
60 | /**
61 | * Create a {@link MediaNotFoundException}.
62 | *
63 | * @param message the detail message.
64 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
65 | * nonexistent or unknown.)
66 | * @param enableSuppression whether or not suppression is enabled or disabled
67 | * @param writableStackTrace whether or not the stack trace should be writable
68 | */
69 | public MediaNotFoundException(String message, Throwable cause, boolean enableSuppression,
70 | boolean writableStackTrace) {
71 | super(message, cause, enableSuppression, writableStackTrace);
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/media/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2019-01-24.
3 | */
4 |
5 | /**
6 | * The Medias exceptions.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.media.exception;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/media/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2019-01-24.
3 | */
4 |
5 | /**
6 | * The Medias Persistence.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.media;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/media/properties/FileStorageProperties.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2019-01-24.
3 | */
4 |
5 | package com.monogramm.starter.persistence.media.properties;
6 |
7 | import com.monogramm.starter.config.properties.ApplicationProperties;
8 |
9 | import java.nio.file.Path;
10 | import java.nio.file.Paths;
11 |
12 | import org.springframework.boot.context.properties.ConfigurationProperties;
13 | import org.springframework.context.annotation.Configuration;
14 | import org.springframework.validation.annotation.Validated;
15 |
16 | /**
17 | * File Storage Properties.
18 | *
19 | * @see ApplicationProperties
20 | *
21 | * @see Spring Boot
23 | * File Upload / Download Rest API Example
24 | *
25 | * @author madmath03
26 | */
27 | @Configuration
28 | @ConfigurationProperties(prefix = "application.file")
29 | @Validated
30 | public class FileStorageProperties {
31 |
32 | /**
33 | * {@code application.file.upload_dir} property.
34 | */
35 | private Path uploadDir;
36 |
37 | /**
38 | * Create a {@link FileStorageProperties}.
39 | *
40 | */
41 | public FileStorageProperties() {
42 | super();
43 | }
44 |
45 | /**
46 | * Create a {@link FileStorageProperties}.
47 | *
48 | * @param uploadDir the upload directory
49 | */
50 | public FileStorageProperties(Path uploadDir) {
51 | super();
52 |
53 | this.uploadDir = uploadDir;
54 | }
55 |
56 | /**
57 | * Create a {@link FileStorageProperties}.
58 | *
59 | * @param uploadDir the upload directory
60 | */
61 | public FileStorageProperties(String uploadDir) {
62 | this(Paths.get(uploadDir));
63 | }
64 |
65 | /**
66 | * Get the media upload directory.
67 | *
68 | * @return the upload directory.
69 | */
70 | public Path getUploadDir() {
71 | return uploadDir;
72 | }
73 |
74 | /**
75 | * Set the upload directory.
76 | *
77 | * @param uploadDir the {@link #uploadDir} to set.
78 | */
79 | public void setUploadDir(Path uploadDir) {
80 | this.uploadDir = uploadDir;
81 | }
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/media/properties/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2019-01-24.
3 | */
4 |
5 | /**
6 | * The Medias related configuration properties.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.media.properties;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/media/service/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2019-01-24.
3 | */
4 |
5 | /**
6 | * The Medias service.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.media.service;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/oauth/dao/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-20.
3 | */
4 |
5 | /**
6 | * The OAuth related DAOs.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.oauth.dao;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/oauth/entity/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-20.
3 | */
4 |
5 | /**
6 | * The OAuth related entities.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.oauth.entity;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/oauth/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-18.
3 | */
4 |
5 | /**
6 | * The OAuth Persistence.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.oauth;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/oauth/service/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-09.
3 | */
4 |
5 | /**
6 | * The OAuth related services.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.oauth.service;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-18.
3 | */
4 |
5 | /**
6 | * The main package of the starter application Persistence mechanisms.
7 | *
8 | *
9 | * The main purpose of this package is to centralize all the objects needed to interact with a
10 | * Persistence Storage, making it easy to export to a separate project and importing it
11 | * independently in a Batch project.
12 | *
13 | *
14 | * @author madmath03
15 | */
16 | package com.monogramm.starter.persistence;
17 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/parameter/dao/ParameterRepository.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2018-01-09.
3 | */
4 |
5 | package com.monogramm.starter.persistence.parameter.dao;
6 |
7 | import com.monogramm.starter.persistence.GenericRepository;
8 | import com.monogramm.starter.persistence.parameter.entity.Parameter;
9 |
10 | import java.util.UUID;
11 |
12 | import javax.persistence.NoResultException;
13 | import javax.persistence.NonUniqueResultException;
14 |
15 | import org.springframework.data.jpa.repository.Query;
16 | import org.springframework.data.repository.query.Param;
17 | import org.springframework.stereotype.Repository;
18 |
19 | /**
20 | * The {@link Parameter} Data Access Object (DAO) interface.
21 | *
22 | * @author madmath03
23 | */
24 | @Repository
25 | public interface ParameterRepository extends GenericRepository {
26 |
27 | /**
28 | * Find a parameter through its name while ignoring case.
29 | *
30 | * @param name the name to search.
31 | *
32 | * @return the parameter matching the name.
33 | *
34 | * @throws NoResultException if no parameter matches the name in the repository.
35 | * @throws NonUniqueResultException if several parameters match the name in the repository.
36 | */
37 | Parameter findByNameIgnoreCase(final String name);
38 |
39 | /**
40 | * Tests if an entity exists in the repository for the given primary key or the name.
41 | *
42 | * @param id the identifier of the parameter to check existence.
43 | * @param name the name of the parameter to check existence.
44 | *
45 | * @return {@code true} if parameter exists, {@code false} otherwise.
46 | */
47 | @Query("SELECT count(p) > 0 FROM Parameter AS p "
48 | + "WHERE p.id = :id OR LOWER(p.name) = LOWER(:name)")
49 | boolean exists(@Param("id") final UUID id, @Param("name") final String name);
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/parameter/dao/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2018-01-09.
3 | */
4 |
5 | /**
6 | * The Parameters Data Access Objects.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.parameter.dao;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/parameter/entity/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2018-01-09.
3 | */
4 |
5 | /**
6 | * The Parameters entity.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.parameter.entity;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/parameter/exception/ParameterNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2018-01-09.
3 | */
4 |
5 | package com.monogramm.starter.persistence.parameter.exception;
6 |
7 | import com.monogramm.starter.persistence.EntityNotFoundException;
8 | import com.monogramm.starter.persistence.parameter.entity.Parameter;
9 |
10 | /**
11 | * "{@link Parameter} not found" Exception.
12 | *
13 | * @author madmath03
14 | */
15 | public class ParameterNotFoundException extends EntityNotFoundException {
16 |
17 | /**
18 | * The {@code serialVersionUID}.
19 | */
20 | private static final long serialVersionUID = 5143585822244266125L;
21 |
22 | /**
23 | * Create a {@link ParameterNotFoundException}.
24 | *
25 | */
26 | public ParameterNotFoundException() {
27 | super();
28 | }
29 |
30 | /**
31 | * Create a {@link ParameterNotFoundException}.
32 | *
33 | * @param message the detail message.
34 | */
35 | public ParameterNotFoundException(String message) {
36 | super(message);
37 | }
38 |
39 | /**
40 | * Create a {@link ParameterNotFoundException}.
41 | *
42 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
43 | * nonexistent or unknown.)
44 | */
45 | public ParameterNotFoundException(Throwable cause) {
46 | super(cause);
47 | }
48 |
49 | /**
50 | * Create a {@link ParameterNotFoundException}.
51 | *
52 | * @param message the detail message.
53 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
54 | * nonexistent or unknown.)
55 | */
56 | public ParameterNotFoundException(String message, Throwable cause) {
57 | super(message, cause);
58 | }
59 |
60 | /**
61 | * Create a {@link ParameterNotFoundException}.
62 | *
63 | * @param message the detail message.
64 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
65 | * nonexistent or unknown.)
66 | * @param enableSuppression whether or not suppression is enabled or disabled
67 | * @param writableStackTrace whether or not the stack trace should be writable
68 | */
69 | public ParameterNotFoundException(String message, Throwable cause, boolean enableSuppression,
70 | boolean writableStackTrace) {
71 | super(message, cause, enableSuppression, writableStackTrace);
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/parameter/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2018-01-09.
3 | */
4 |
5 | /**
6 | * The Parameters exceptions.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.parameter.exception;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/parameter/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2018-01-09.
3 | */
4 |
5 | /**
6 | * The Parameters Persistence.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.parameter;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/parameter/service/ParameterBridge.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2018-01-09.
3 | */
4 |
5 | package com.monogramm.starter.persistence.parameter.service;
6 |
7 | import com.monogramm.starter.dto.parameter.ParameterDto;
8 | import com.monogramm.starter.persistence.AbstractParameterBridge;
9 | import com.monogramm.starter.persistence.parameter.entity.Parameter;
10 | import com.monogramm.starter.persistence.user.dao.UserRepository;
11 |
12 | /**
13 | * ParameterBridge.
14 | *
15 | * @author madmath03
16 | */
17 | public class ParameterBridge extends AbstractParameterBridge {
18 |
19 | /**
20 | * Create a {@link ParameterBridge}.
21 | *
22 | */
23 | public ParameterBridge() {
24 | super();
25 | }
26 |
27 | /**
28 | * Create a {@link ParameterBridge}.
29 | *
30 | * @param userRepository repository to lookup users.
31 | */
32 | public ParameterBridge(UserRepository userRepository) {
33 | super(userRepository);
34 | }
35 |
36 | @Override
37 | protected Parameter buildEntity() {
38 | return new Parameter();
39 | }
40 |
41 | @Override
42 | protected ParameterDto buildDto() {
43 | return new ParameterDto();
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/parameter/service/ParameterService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2018-01-09.
3 | */
4 |
5 | package com.monogramm.starter.persistence.parameter.service;
6 |
7 | import com.monogramm.starter.dto.parameter.ParameterDto;
8 | import com.monogramm.starter.persistence.GenericService;
9 | import com.monogramm.starter.persistence.parameter.entity.Parameter;
10 | import com.monogramm.starter.persistence.parameter.exception.ParameterNotFoundException;
11 |
12 | /**
13 | * {@link Parameter} service interface.
14 | *
15 | * @author madmath03
16 | */
17 | public interface ParameterService extends GenericService {
18 |
19 | @Override
20 | ParameterBridge getBridge();
21 |
22 | /**
23 | * Find an parameter through its name while ignoring case.
24 | *
25 | * @param name the name to search.
26 | *
27 | * @return the parameter matching the name.
28 | *
29 | * @throws ParameterNotFoundException if no parameter matches the name in the repository.
30 | */
31 | Parameter findByName(final String name);
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/parameter/service/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2018-01-09.
3 | */
4 |
5 | /**
6 | * The Parameters service.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.parameter.service;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/permission/dao/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-25
3 | */
4 |
5 | /**
6 | * The Permissions Data Access Objects.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.permission.dao;
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/permission/entity/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-25
3 | */
4 |
5 | /**
6 | * The Permissions entity.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.permission.entity;
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/permission/exception/PermissionNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-25
3 | */
4 |
5 | package com.monogramm.starter.persistence.permission.exception;
6 |
7 | import com.monogramm.starter.persistence.EntityNotFoundException;
8 | import com.monogramm.starter.persistence.permission.entity.Permission;
9 |
10 | /**
11 | * "{@link Permission} not found" Exception.
12 | *
13 | * @author madmath03
14 | */
15 | public class PermissionNotFoundException extends EntityNotFoundException {
16 |
17 | /**
18 | * The {@code serialVersionUID}.
19 | */
20 | private static final long serialVersionUID = 4331389591826563678L;
21 |
22 | /**
23 | * Create a {@link PermissionNotFoundException}.
24 | *
25 | */
26 | public PermissionNotFoundException() {
27 | super();
28 | }
29 |
30 | /**
31 | * Create a {@link PermissionNotFoundException}.
32 | *
33 | * @param message the detail message.
34 | */
35 | public PermissionNotFoundException(String message) {
36 | super(message);
37 | }
38 |
39 | /**
40 | * Create a {@link PermissionNotFoundException}.
41 | *
42 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
43 | * nonexistent or unknown.)
44 | */
45 | public PermissionNotFoundException(Throwable cause) {
46 | super(cause);
47 | }
48 |
49 | /**
50 | * Create a {@link PermissionNotFoundException}.
51 | *
52 | * @param message the detail message.
53 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
54 | * nonexistent or unknown.)
55 | */
56 | public PermissionNotFoundException(String message, Throwable cause) {
57 | super(message, cause);
58 | }
59 |
60 | /**
61 | * Create a {@link PermissionNotFoundException}.
62 | *
63 | * @param message the detail message.
64 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
65 | * nonexistent or unknown.)
66 | * @param enableSuppression whether or not suppression is enabled or disabled
67 | * @param writableStackTrace whether or not the stack trace should be writable
68 | */
69 | public PermissionNotFoundException(String message, Throwable cause,
70 | boolean enableSuppression, boolean writableStackTrace) {
71 | super(message, cause, enableSuppression, writableStackTrace);
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/permission/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-25
3 | */
4 |
5 | /**
6 | * The Permissions exceptions.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.permission.exception;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/permission/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-25
3 | */
4 |
5 | /**
6 | * The Permissions Persistence.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.permission;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/permission/service/PermissionBridge.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-25
3 | */
4 |
5 | package com.monogramm.starter.persistence.permission.service;
6 |
7 | import com.monogramm.starter.dto.permission.PermissionDto;
8 | import com.monogramm.starter.persistence.AbstractGenericBridge;
9 | import com.monogramm.starter.persistence.permission.entity.Permission;
10 | import com.monogramm.starter.persistence.user.dao.UserRepository;
11 |
12 | import org.springframework.beans.factory.annotation.Autowired;
13 |
14 | /**
15 | * Bridge to convert a {@link PermissionDto} to a {@link Permission} and vice versa.
16 | *
17 | * @author madmath03
18 | */
19 | public class PermissionBridge extends AbstractGenericBridge {
20 |
21 | /**
22 | * Create a {@link PermissionBridge}.
23 | *
24 | *
25 | * Use with caution: this constructor will not set the @{code userRepository},
26 | * preventing any search in the Persistence Storage for the relations objects. This might be
27 | * dangerous when converting {@link #toEntity(PermissionDto)} as no consistency check will be done
28 | * but it will definitely improve performance.
29 | *
30 | *
31 | */
32 | public PermissionBridge() {
33 | super();
34 | }
35 |
36 | /**
37 | * Create a {@link PermissionBridge}.
38 | *
39 | * @param userRepository repository to lookup users.
40 | */
41 | @Autowired
42 | public PermissionBridge(UserRepository userRepository) {
43 | super(userRepository);
44 | }
45 |
46 | @Override
47 | protected Permission buildEntity() {
48 | return new Permission();
49 | }
50 |
51 | @Override
52 | protected PermissionDto buildDto() {
53 | return new PermissionDto();
54 | }
55 |
56 | @Override
57 | public Permission toEntity(final PermissionDto dto) {
58 | final Permission entity = super.toEntity(dto);
59 |
60 | entity.setName(dto.getName());
61 |
62 | return entity;
63 | }
64 |
65 | @Override
66 | public PermissionDto toDto(final Permission entity) {
67 | final PermissionDto dto = super.toDto(entity);
68 |
69 | dto.setName(entity.getName());
70 |
71 | return dto;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/permission/service/PermissionService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-25
3 | */
4 |
5 | package com.monogramm.starter.persistence.permission.service;
6 |
7 | import com.monogramm.starter.dto.permission.PermissionDto;
8 | import com.monogramm.starter.persistence.GenericService;
9 | import com.monogramm.starter.persistence.permission.entity.Permission;
10 | import com.monogramm.starter.persistence.permission.exception.PermissionNotFoundException;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * {@link Permission} service interface.
16 | *
17 | * @author madmath03
18 | */
19 | public interface PermissionService extends GenericService {
20 |
21 | @Override
22 | PermissionBridge getBridge();
23 |
24 | /**
25 | * Find all permissions by their name while ignoring case.
26 | *
27 | * @param name the name content to search.
28 | *
29 | * @return the list of all the permissions matching the search.
30 | */
31 | List findAllByName(final String name);
32 |
33 | /**
34 | * Find an permission through its name while ignoring case.
35 | *
36 | * @param name the name to search.
37 | *
38 | * @return the permission matching the name.
39 | *
40 | * @throws PermissionNotFoundException if no permission matches the name in the repository.
41 | */
42 | Permission findByName(final String name);
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/permission/service/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The Permissions service.
3 | *
4 | * @author madmath03
5 | */
6 | package com.monogramm.starter.persistence.permission.service;
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/role/dao/RoleRepository.java:
--------------------------------------------------------------------------------
1 | package com.monogramm.starter.persistence.role.dao;
2 |
3 | import com.monogramm.starter.persistence.GenericRepository;
4 | import com.monogramm.starter.persistence.role.entity.Role;
5 |
6 | import java.util.List;
7 | import java.util.UUID;
8 |
9 | import javax.persistence.NoResultException;
10 | import javax.persistence.NonUniqueResultException;
11 |
12 | import org.springframework.data.jpa.repository.Query;
13 | import org.springframework.data.repository.query.Param;
14 | import org.springframework.stereotype.Repository;
15 |
16 | /**
17 | * The {@link Role} Data Access Object (DAO) interface.
18 | *
19 | * @author madmath03
20 | */
21 | @Repository
22 | public interface RoleRepository extends GenericRepository {
23 |
24 | /**
25 | * Find all roles from the repository containing the name while ignoring case.
26 | *
27 | * @param name the name content to search.
28 | *
29 | * @return the list of all the roles matching the search through the repository.
30 | */
31 | @Query("FROM Role AS r " + "WHERE LOWER(r.name) LIKE concat('%', LOWER(:name), '%')")
32 | List findAllContainingNameIgnoreCase(@Param("name") final String name);
33 |
34 | /**
35 | * Find an role through its name while ignoring case.
36 | *
37 | * @param name the name to search.
38 | *
39 | * @return the role matching the name.
40 | *
41 | * @throws NoResultException if no role matches the name in the repository.
42 | * @throws NonUniqueResultException if several roles match the name in the repository.
43 | */
44 | Role findByNameIgnoreCase(final String name);
45 |
46 | /**
47 | * Tests if an entity exists in the repository for the given primary key or the name.
48 | *
49 | * @param roleId the identifier of the role to check existence.
50 | * @param name the name of the role to check existence.
51 | *
52 | * @return {@code true} if role exists, {@code false} otherwise.
53 | */
54 | @Query("SELECT count(r) > 0 FROM Role AS r "
55 | + "WHERE r.id = :roleId OR LOWER(r.name) = LOWER(:name)")
56 | boolean exists(@Param("roleId") final UUID roleId, @Param("name") final String name);
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/role/dao/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The Roles Data Access Objects.
3 | *
4 | * @author madmath03
5 | */
6 | package com.monogramm.starter.persistence.role.dao;
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/role/entity/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The Roles entity.
3 | *
4 | * @author madmath03
5 | */
6 | package com.monogramm.starter.persistence.role.entity;
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/role/exception/RoleNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-09-03.
3 | */
4 |
5 | package com.monogramm.starter.persistence.role.exception;
6 |
7 | import com.monogramm.starter.persistence.EntityNotFoundException;
8 | import com.monogramm.starter.persistence.role.entity.Role;
9 |
10 | /**
11 | * "{@link Role} not found" Exception.
12 | *
13 | * @author madmath03
14 | */
15 | public class RoleNotFoundException extends EntityNotFoundException {
16 |
17 | /**
18 | * The {@code serialVersionUID}.
19 | */
20 | private static final long serialVersionUID = 4331389591826563678L;
21 |
22 | /**
23 | * Create a {@link RoleNotFoundException}.
24 | *
25 | */
26 | public RoleNotFoundException() {
27 | super();
28 | }
29 |
30 | /**
31 | * Create a {@link RoleNotFoundException}.
32 | *
33 | * @param message the detail message.
34 | */
35 | public RoleNotFoundException(String message) {
36 | super(message);
37 | }
38 |
39 | /**
40 | * Create a {@link RoleNotFoundException}.
41 | *
42 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
43 | * nonexistent or unknown.)
44 | */
45 | public RoleNotFoundException(Throwable cause) {
46 | super(cause);
47 | }
48 |
49 | /**
50 | * Create a {@link RoleNotFoundException}.
51 | *
52 | * @param message the detail message.
53 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
54 | * nonexistent or unknown.)
55 | */
56 | public RoleNotFoundException(String message, Throwable cause) {
57 | super(message, cause);
58 | }
59 |
60 | /**
61 | * Create a {@link RoleNotFoundException}.
62 | *
63 | * @param message the detail message.
64 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
65 | * nonexistent or unknown.)
66 | * @param enableSuppression whether or not suppression is enabled or disabled
67 | * @param writableStackTrace whether or not the stack trace should be writable
68 | */
69 | public RoleNotFoundException(String message, Throwable cause,
70 | boolean enableSuppression, boolean writableStackTrace) {
71 | super(message, cause, enableSuppression, writableStackTrace);
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/role/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-09-03.
3 | */
4 |
5 | /**
6 | * The Roles exceptions.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.role.exception;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/role/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-18.
3 | */
4 |
5 | /**
6 | * The Roles Persistence.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.role;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/role/service/RoleService.java:
--------------------------------------------------------------------------------
1 | package com.monogramm.starter.persistence.role.service;
2 |
3 | import com.monogramm.starter.dto.role.RoleDto;
4 | import com.monogramm.starter.persistence.GenericService;
5 | import com.monogramm.starter.persistence.role.entity.Role;
6 | import com.monogramm.starter.persistence.role.exception.RoleNotFoundException;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * {@link Role} service interface.
12 | *
13 | * @author madmath03
14 | */
15 | public interface RoleService extends GenericService {
16 |
17 | @Override
18 | RoleBridge getBridge();
19 |
20 | /**
21 | * Find all roles by their name while ignoring case.
22 | *
23 | * @param name the name content to search.
24 | *
25 | * @return the list of all the roles matching the search.
26 | */
27 | List findAllByName(final String name);
28 |
29 | /**
30 | * Find an role through its name while ignoring case.
31 | *
32 | * @param name the name to search.
33 | *
34 | * @return the role matching the name.
35 | *
36 | * @throws RoleNotFoundException if no role matches the name in the repository.
37 | */
38 | Role findByName(final String name);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/role/service/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The Roles service.
3 | *
4 | * @author madmath03
5 | */
6 | package com.monogramm.starter.persistence.role.service;
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/type/dao/TypeRepository.java:
--------------------------------------------------------------------------------
1 | package com.monogramm.starter.persistence.type.dao;
2 |
3 | import com.monogramm.starter.persistence.GenericRepository;
4 | import com.monogramm.starter.persistence.type.entity.Type;
5 |
6 | import java.util.List;
7 | import java.util.UUID;
8 |
9 | import javax.persistence.NoResultException;
10 | import javax.persistence.NonUniqueResultException;
11 |
12 | import org.springframework.data.jpa.repository.Query;
13 | import org.springframework.data.repository.query.Param;
14 | import org.springframework.stereotype.Repository;
15 |
16 | /**
17 | * The {@link Type} Data Access Object (DAO) interface.
18 | *
19 | * @author madmath03
20 | */
21 | @Repository
22 | public interface TypeRepository extends GenericRepository {
23 |
24 | /**
25 | * Find all types from the repository containing the name while ignoring case.
26 | *
27 | * @param name the name content to search.
28 | *
29 | * @return the list of all the types matching the search through the repository.
30 | */
31 | @Query("FROM Type AS t " + "WHERE LOWER(t.name) LIKE concat('%', LOWER(:name), '%')")
32 | List findAllContainingNameIgnoreCase(@Param("name") final String name);
33 |
34 | /**
35 | * Find an type through its name while ignoring case.
36 | *
37 | * @param name the name to search.
38 | *
39 | * @return the type matching the name.
40 | *
41 | * @throws NoResultException if no type matches the name in the repository.
42 | * @throws NonUniqueResultException if several types match the name in the repository.
43 | */
44 | Type findByNameIgnoreCase(final String name);
45 |
46 | /**
47 | * Tests if an entity exists in the repository for the given primary key or the name.
48 | *
49 | * @param typeId the identifier of the type to check existence.
50 | * @param name the name of the type to check existence.
51 | *
52 | * @return {@code true} if type exists, {@code false} otherwise.
53 | */
54 | @Query("SELECT count(t) > 0 FROM Type AS t "
55 | + "WHERE t.id = :typeId OR LOWER(t.name) = LOWER(:name)")
56 | boolean exists(@Param("typeId") final UUID typeId, @Param("name") final String name);
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/type/dao/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The Types Data Access Objects.
3 | *
4 | * @author madmath03
5 | */
6 | package com.monogramm.starter.persistence.type.dao;
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/type/entity/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The Types entity.
3 | *
4 | * @author madmath03
5 | */
6 | package com.monogramm.starter.persistence.type.entity;
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/type/exception/TypeNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-09-03.
3 | */
4 |
5 | package com.monogramm.starter.persistence.type.exception;
6 |
7 | import com.monogramm.starter.persistence.EntityNotFoundException;
8 | import com.monogramm.starter.persistence.type.entity.Type;
9 |
10 | /**
11 | * "{@link Type} not found" Exception.
12 | *
13 | * @author madmath03
14 | */
15 | public class TypeNotFoundException extends EntityNotFoundException {
16 |
17 | /**
18 | * The {@code serialVersionUID}.
19 | */
20 | private static final long serialVersionUID = 4331389591826563678L;
21 |
22 | /**
23 | * Create a {@link TypeNotFoundException}.
24 | *
25 | */
26 | public TypeNotFoundException() {
27 | super();
28 | }
29 |
30 | /**
31 | * Create a {@link TypeNotFoundException}.
32 | *
33 | * @param message the detail message.
34 | */
35 | public TypeNotFoundException(String message) {
36 | super(message);
37 | }
38 |
39 | /**
40 | * Create a {@link TypeNotFoundException}.
41 | *
42 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
43 | * nonexistent or unknown.)
44 | */
45 | public TypeNotFoundException(Throwable cause) {
46 | super(cause);
47 | }
48 |
49 | /**
50 | * Create a {@link TypeNotFoundException}.
51 | *
52 | * @param message the detail message.
53 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
54 | * nonexistent or unknown.)
55 | */
56 | public TypeNotFoundException(String message, Throwable cause) {
57 | super(message, cause);
58 | }
59 |
60 | /**
61 | * Create a {@link TypeNotFoundException}.
62 | *
63 | * @param message the detail message.
64 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
65 | * nonexistent or unknown.)
66 | * @param enableSuppression whether or not suppression is enabled or disabled
67 | * @param writableStackTrace whether or not the stack trace should be writable
68 | */
69 | public TypeNotFoundException(String message, Throwable cause,
70 | boolean enableSuppression, boolean writableStackTrace) {
71 | super(message, cause, enableSuppression, writableStackTrace);
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/type/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-09-03.
3 | */
4 |
5 | /**
6 | * The Types exceptions.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.type.exception;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/type/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-18.
3 | */
4 |
5 | /**
6 | * The Types Persistence.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.type;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/type/service/TypeBridge.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-18.
3 | */
4 |
5 | package com.monogramm.starter.persistence.type.service;
6 |
7 | import com.monogramm.starter.dto.type.TypeDto;
8 | import com.monogramm.starter.persistence.AbstractGenericBridge;
9 | import com.monogramm.starter.persistence.type.entity.Type;
10 | import com.monogramm.starter.persistence.user.dao.UserRepository;
11 |
12 | /**
13 | * Bridge to convert a {@link TypeDto} to a {@link Type} and vice versa.
14 | *
15 | * @author madmath03
16 | */
17 | public class TypeBridge extends AbstractGenericBridge {
18 |
19 | /**
20 | * Create a {@link TypeBridge}.
21 | *
22 | *
23 | * Use with caution: this constructor will not set the @{code userRepository},
24 | * preventing any search in the Persistence Storage for the relations objects. This might be
25 | * dangerous when converting {@link #toEntity(TypeDto)} as no consistency check will be done but
26 | * it will definitely improve performance.
27 | *
28 | *
29 | */
30 | public TypeBridge() {
31 | super();
32 | }
33 |
34 | /**
35 | * Create a {@link TypeBridge}.
36 | *
37 | * @param userRepository repository to lookup users.
38 | */
39 | public TypeBridge(UserRepository userRepository) {
40 | super(userRepository);
41 | }
42 |
43 | @Override
44 | protected Type buildEntity() {
45 | return new Type();
46 | }
47 |
48 | @Override
49 | protected TypeDto buildDto() {
50 | return new TypeDto();
51 | }
52 |
53 | @Override
54 | public Type toEntity(final TypeDto dto) {
55 | final Type entity = super.toEntity(dto);
56 |
57 | entity.setName(dto.getName());
58 |
59 | return entity;
60 | }
61 |
62 | @Override
63 | public TypeDto toDto(final Type entity) {
64 | final TypeDto dto = super.toDto(entity);
65 |
66 | dto.setName(entity.getName());
67 |
68 | return dto;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/type/service/TypeService.java:
--------------------------------------------------------------------------------
1 | package com.monogramm.starter.persistence.type.service;
2 |
3 | import com.monogramm.starter.dto.type.TypeDto;
4 | import com.monogramm.starter.persistence.GenericService;
5 | import com.monogramm.starter.persistence.type.entity.Type;
6 | import com.monogramm.starter.persistence.type.exception.TypeNotFoundException;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * {@link Type} service interface.
12 | *
13 | * @author madmath03
14 | */
15 | public interface TypeService extends GenericService {
16 |
17 | @Override
18 | TypeBridge getBridge();
19 |
20 | /**
21 | * Find all types by their name while ignoring case.
22 | *
23 | * @param name the name content to search.
24 | *
25 | * @return the list of all the types matching the search.
26 | */
27 | List findAllByName(final String name);
28 |
29 | /**
30 | * Find an type through its name while ignoring case.
31 | *
32 | * @param name the name to search.
33 | *
34 | * @return the type matching the name.
35 | *
36 | * @throws TypeNotFoundException if no type matches the name in the repository.
37 | */
38 | Type findByName(final String name);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/type/service/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The Types service.
3 | *
4 | * @author madmath03
5 | */
6 | package com.monogramm.starter.persistence.type.service;
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/user/dao/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The Users Data Access Objects.
3 | *
4 | * @author madmath03
5 | */
6 | package com.monogramm.starter.persistence.user.dao;
7 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/user/entity/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The Users entity.
3 | *
4 | * @author madmath03
5 | */
6 | package com.monogramm.starter.persistence.user.entity;
7 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/user/exception/UserNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-09-03.
3 | */
4 |
5 | package com.monogramm.starter.persistence.user.exception;
6 |
7 | import com.monogramm.starter.persistence.EntityNotFoundException;
8 | import com.monogramm.starter.persistence.user.entity.User;
9 |
10 | /**
11 | * "{@link User} not found" Exception.
12 | *
13 | * @author madmath03
14 | */
15 | public class UserNotFoundException extends EntityNotFoundException {
16 |
17 | /**
18 | * The {@code serialVersionUID}.
19 | */
20 | private static final long serialVersionUID = -5718978633699801683L;
21 |
22 | /**
23 | * Create a {@link UserNotFoundException}.
24 | *
25 | */
26 | public UserNotFoundException() {
27 | super();
28 | }
29 |
30 | /**
31 | * Create a {@link UserNotFoundException}.
32 | *
33 | * @param message the detail message.
34 | */
35 | public UserNotFoundException(String message) {
36 | super(message);
37 | }
38 |
39 | /**
40 | * Create a {@link UserNotFoundException}.
41 | *
42 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
43 | * nonexistent or unknown.)
44 | */
45 | public UserNotFoundException(Throwable cause) {
46 | super(cause);
47 | }
48 |
49 | /**
50 | * Create a {@link UserNotFoundException}.
51 | *
52 | * @param message the detail message.
53 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
54 | * nonexistent or unknown.)
55 | */
56 | public UserNotFoundException(String message, Throwable cause) {
57 | super(message, cause);
58 | }
59 |
60 | /**
61 | * Create a {@link UserNotFoundException}.
62 | *
63 | * @param message the detail message.
64 | * @param cause the cause. (A {@code null} value is permitted, and indicates that the cause is
65 | * nonexistent or unknown.)
66 | * @param enableSuppression whether or not suppression is enabled or disabled
67 | * @param writableStackTrace whether or not the stack trace should be writable
68 | */
69 | public UserNotFoundException(String message, Throwable cause,
70 | boolean enableSuppression, boolean writableStackTrace) {
71 | super(message, cause, enableSuppression, writableStackTrace);
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/user/exception/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-09-03.
3 | */
4 |
5 | /**
6 | * The Users exceptions.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.user.exception;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/user/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-18.
3 | */
4 |
5 | /**
6 | * The Users Persistence.
7 | *
8 | * @author madmath03
9 | */
10 | package com.monogramm.starter.persistence.user;
11 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/user/service/PasswordResetTokenBridge.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-12-20.
3 | */
4 |
5 | package com.monogramm.starter.persistence.user.service;
6 |
7 | import com.monogramm.starter.dto.user.PasswordResetTokenDto;
8 | import com.monogramm.starter.persistence.AbstractTokenBridge;
9 | import com.monogramm.starter.persistence.user.dao.UserRepository;
10 | import com.monogramm.starter.persistence.user.entity.PasswordResetToken;
11 |
12 | import org.springframework.beans.factory.annotation.Autowired;
13 |
14 | /**
15 | * Bridge to convert a {@link PasswordResetTokenDto} to a {@link PasswordResetToken} and vice versa.
16 | *
17 | * @author madmath03
18 | */
19 | public class PasswordResetTokenBridge
20 | extends AbstractTokenBridge {
21 |
22 | /**
23 | * Create a {@link PasswordResetTokenBridge}.
24 | *
25 | *
26 | * Use with caution: this constructor will not set the @{code userRepository},
27 | * preventing any search in the Persistence Storage for the relations objects. This might be
28 | * dangerous when converting
29 | * {@link AbstractTokenBridge#toEntity(com.monogramm.starter.dto.AbstractTokenDto)}
30 | * as no consistency check will be done but it will definitely improve performance.
31 | *
32 | *
33 | */
34 | public PasswordResetTokenBridge() {
35 | super();
36 | }
37 |
38 | /**
39 | * Create a {@link PasswordResetTokenBridge}.
40 | *
41 | * @param userRepository repository to lookup users.
42 | */
43 | @Autowired
44 | public PasswordResetTokenBridge(UserRepository userRepository) {
45 | super(userRepository);
46 | }
47 |
48 | @Override
49 | protected PasswordResetToken buildEntity() {
50 | return new PasswordResetToken();
51 | }
52 |
53 | @Override
54 | protected PasswordResetTokenDto buildDto() {
55 | return new PasswordResetTokenDto();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/user/service/PasswordResetTokenService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-12-20.
3 | */
4 |
5 | package com.monogramm.starter.persistence.user.service;
6 |
7 | import com.monogramm.starter.dto.user.PasswordResetTokenDto;
8 | import com.monogramm.starter.persistence.GenericService;
9 | import com.monogramm.starter.persistence.user.entity.PasswordResetToken;
10 | import com.monogramm.starter.persistence.user.entity.User;
11 | import com.monogramm.starter.persistence.user.exception.PasswordResetTokenNotFoundException;
12 |
13 | import java.util.UUID;
14 |
15 | /**
16 | * {@link PasswordResetToken} service interface.
17 | *
18 | * @author madmath03
19 | */
20 | public interface PasswordResetTokenService
21 | extends GenericService {
22 |
23 | @Override
24 | PasswordResetTokenBridge getBridge();
25 |
26 | /**
27 | * Find a token through its token code and user.
28 | *
29 | * @param user the user to search.
30 | * @param code the token code to search.
31 | *
32 | * @return the token matching the token code.
33 | *
34 | * @throws PasswordResetTokenNotFoundException if no token matches the code in the repository.
35 | */
36 | PasswordResetToken findByUserAndCode(final User user, final String code);
37 |
38 | /**
39 | * Find a token through its token code and user id.
40 | *
41 | * @param userId the user id to search.
42 | * @param code the token code to search.
43 | *
44 | * @return the token matching the token code.
45 | *
46 | * @throws PasswordResetTokenNotFoundException if no token matches the code in the repository.
47 | */
48 | PasswordResetToken findByUserAndCode(final UUID userId, final String code);
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/user/service/VerificationTokenBridge.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-12-18.
3 | */
4 |
5 | package com.monogramm.starter.persistence.user.service;
6 |
7 | import com.monogramm.starter.dto.user.VerificationTokenDto;
8 | import com.monogramm.starter.persistence.AbstractTokenBridge;
9 | import com.monogramm.starter.persistence.user.dao.UserRepository;
10 | import com.monogramm.starter.persistence.user.entity.VerificationToken;
11 |
12 | import org.springframework.beans.factory.annotation.Autowired;
13 |
14 | /**
15 | * Bridge to convert a {@link VerificationTokenDto} to a {@link VerificationToken} and vice versa.
16 | *
17 | * @author madmath03
18 | */
19 | public class VerificationTokenBridge
20 | extends AbstractTokenBridge {
21 |
22 | /**
23 | * Create a {@link VerificationTokenBridge}.
24 | *
25 | *
26 | * Use with caution: this constructor will not set the @{code userRepository},
27 | * preventing any search in the Persistence Storage for the relations objects. This might be
28 | * dangerous when converting
29 | * {@link AbstractTokenBridge#toEntity(com.monogramm.starter.dto.AbstractTokenDto)}
30 | * as no consistency check will be done but it will definitely improve performance.
31 | *
32 | *
33 | */
34 | public VerificationTokenBridge() {
35 | super();
36 | }
37 |
38 | /**
39 | * Create a {@link VerificationTokenBridge}.
40 | *
41 | * @param userRepository repository to lookup users.
42 | */
43 | @Autowired
44 | public VerificationTokenBridge(UserRepository userRepository) {
45 | super(userRepository);
46 | }
47 |
48 | @Override
49 | protected VerificationToken buildEntity() {
50 | return new VerificationToken();
51 | }
52 |
53 | @Override
54 | protected VerificationTokenDto buildDto() {
55 | return new VerificationTokenDto();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/user/service/VerificationTokenService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-12-18.
3 | */
4 |
5 | package com.monogramm.starter.persistence.user.service;
6 |
7 | import com.monogramm.starter.dto.user.VerificationTokenDto;
8 | import com.monogramm.starter.persistence.GenericService;
9 | import com.monogramm.starter.persistence.user.entity.User;
10 | import com.monogramm.starter.persistence.user.entity.VerificationToken;
11 | import com.monogramm.starter.persistence.user.exception.VerificationTokenNotFoundException;
12 |
13 | import java.util.UUID;
14 |
15 | /**
16 | * {@link VerificationToken} service interface.
17 | *
18 | * @author madmath03
19 | */
20 | public interface VerificationTokenService
21 | extends GenericService {
22 |
23 | @Override
24 | VerificationTokenBridge getBridge();
25 |
26 | /**
27 | * Find a token through its token code and user.
28 | *
29 | * @param user the user to search.
30 | * @param code the token code to search.
31 | *
32 | * @return the token matching the token code.
33 | *
34 | * @throws VerificationTokenNotFoundException if no token matches the code in the repository.
35 | */
36 | VerificationToken findByUserAndCode(final User user, final String code);
37 |
38 | /**
39 | * Find an token through its token code and user id.
40 | *
41 | * @param userId the user id to search.
42 | * @param code the token code to search.
43 | *
44 | * @return the token matching the token code.
45 | *
46 | * @throws VerificationTokenNotFoundException if no token matches the code in the repository.
47 | */
48 | VerificationToken findByUserAndCode(final UUID userId, final String code);
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/persistence/user/service/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * The Users service.
3 | *
4 | * @author madmath03
5 | */
6 | package com.monogramm.starter.persistence.user.service;
7 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/utils/Jsonable.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2017-11-13.
3 | */
4 |
5 | package com.monogramm.starter.utils;
6 |
7 | import com.fasterxml.jackson.core.JsonProcessingException;
8 |
9 | /**
10 | * A JSON compatible object.
11 | *
12 | * @author madmath03
13 | */
14 | public interface Jsonable {
15 |
16 | /**
17 | * Returns a JSON string representation of this object.
18 | *
19 | *
20 | * This method is generally intended to serialize objects during JSON serialization.
21 | *
22 | *
23 | * @return a JSON string representation of this.
24 | *
25 | * @throws JsonProcessingException if the object could not be serialized to JSON.
26 | */
27 | public default String toJson() throws JsonProcessingException {
28 | return JsonUtils.toJson(this);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/com/monogramm/starter/utils/converter/AnyConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Creation by madmath03 the 2019-01-06.
3 | */
4 |
5 | package com.monogramm.starter.utils.converter;
6 |
7 | import com.monogramm.starter.utils.JsonUtils;
8 |
9 | import javax.persistence.AttributeConverter;
10 |
11 | /**
12 | * Any Converter.
13 | *
14 | * @author madmath03
15 | */
16 | public class AnyConverter implements AttributeConverter