- * Spring profiles can be configured with a program argument --spring.profiles.active=your-active-profile
- *
- * You can find more information on how profiles work with JHipster on https://www.jhipster.tech/profiles/.
- */
- @PostConstruct
- public void initApplication() {
- Collection activeProfiles = Arrays.asList(env.getActiveProfiles());
- if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
- log.error("You have misconfigured your application! It should not run " +
- "with both the 'dev' and 'prod' profiles at the same time.");
- }
- if (activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT) && activeProfiles.contains(JHipsterConstants.SPRING_PROFILE_CLOUD)) {
- log.error("You have misconfigured your application! It should not " +
- "run with both the 'dev' and 'cloud' profiles at the same time.");
- }
- }
-
- /**
- * Main method, used to run the application.
- *
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- SpringApplication app = new SpringApplication(BookstoreApp.class);
- DefaultProfileUtil.addDefaultProfile(app);
- Environment env = app.run(args).getEnvironment();
- logApplicationStartup(env);
- }
-
- private static void logApplicationStartup(Environment env) {
- String protocol = "http";
- if (env.getProperty("server.ssl.key-store") != null) {
- protocol = "https";
- }
- String serverPort = env.getProperty("server.port");
- String contextPath = env.getProperty("server.servlet.context-path");
- if (StringUtils.isBlank(contextPath)) {
- contextPath = "/";
- }
- String hostAddress = "localhost";
- try {
- hostAddress = InetAddress.getLocalHost().getHostAddress();
- } catch (UnknownHostException e) {
- log.warn("The host name could not be determined, using `localhost` as fallback");
- }
- log.info("\n----------------------------------------------------------\n\t" +
- "Application '{}' is running! Access URLs:\n\t" +
- "Local: \t\t{}://localhost:{}{}\n\t" +
- "External: \t{}://{}:{}{}\n\t" +
- "Profile(s): \t{}\n----------------------------------------------------------",
- env.getProperty("spring.application.name"),
- protocol,
- serverPort,
- contextPath,
- protocol,
- hostAddress,
- serverPort,
- contextPath,
- env.getActiveProfiles());
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/aop/logging/LoggingAspect.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/aop/logging/LoggingAspect.java
deleted file mode 100644
index 0379637061..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/aop/logging/LoggingAspect.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package com.baeldung.jhipster5.aop.logging;
-
-import io.github.jhipster.config.JHipsterConstants;
-
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.AfterThrowing;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Pointcut;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.env.Environment;
-
-import java.util.Arrays;
-
-/**
- * Aspect for logging execution of service and repository Spring components.
- *
- * By default, it only runs with the "dev" profile.
- */
-@Aspect
-public class LoggingAspect {
-
- private final Logger log = LoggerFactory.getLogger(this.getClass());
-
- private final Environment env;
-
- public LoggingAspect(Environment env) {
- this.env = env;
- }
-
- /**
- * Pointcut that matches all repositories, services and Web REST endpoints.
- */
- @Pointcut("within(@org.springframework.stereotype.Repository *)" +
- " || within(@org.springframework.stereotype.Service *)" +
- " || within(@org.springframework.web.bind.annotation.RestController *)")
- public void springBeanPointcut() {
- // Method is empty as this is just a Pointcut, the implementations are in the advices.
- }
-
- /**
- * Pointcut that matches all Spring beans in the application's main packages.
- */
- @Pointcut("within(com.baeldung.jhipster5.repository..*)"+
- " || within(com.baeldung.jhipster5.service..*)"+
- " || within(com.baeldung.jhipster5.web.rest..*)")
- public void applicationPackagePointcut() {
- // Method is empty as this is just a Pointcut, the implementations are in the advices.
- }
-
- /**
- * Advice that logs methods throwing exceptions.
- *
- * @param joinPoint join point for advice
- * @param e exception
- */
- @AfterThrowing(pointcut = "applicationPackagePointcut() && springBeanPointcut()", throwing = "e")
- public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
- if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
- log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
- joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL", e.getMessage(), e);
-
- } else {
- log.error("Exception in {}.{}() with cause = {}", joinPoint.getSignature().getDeclaringTypeName(),
- joinPoint.getSignature().getName(), e.getCause() != null? e.getCause() : "NULL");
- }
- }
-
- /**
- * Advice that logs when a method is entered and exited.
- *
- * @param joinPoint join point for advice
- * @return result
- * @throws Throwable throws IllegalArgumentException
- */
- @Around("applicationPackagePointcut() && springBeanPointcut()")
- public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
- if (log.isDebugEnabled()) {
- log.debug("Enter: {}.{}() with argument[s] = {}", joinPoint.getSignature().getDeclaringTypeName(),
- joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs()));
- }
- try {
- Object result = joinPoint.proceed();
- if (log.isDebugEnabled()) {
- log.debug("Exit: {}.{}() with result = {}", joinPoint.getSignature().getDeclaringTypeName(),
- joinPoint.getSignature().getName(), result);
- }
- return result;
- } catch (IllegalArgumentException e) {
- log.error("Illegal argument: {} in {}.{}()", Arrays.toString(joinPoint.getArgs()),
- joinPoint.getSignature().getDeclaringTypeName(), joinPoint.getSignature().getName());
-
- throw e;
- }
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/ApplicationProperties.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/ApplicationProperties.java
deleted file mode 100644
index 4ca3e9bd85..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/ApplicationProperties.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-/**
- * Properties specific to Bookstore.
- *
- * Properties are configured in the application.yml file.
- * See {@link io.github.jhipster.config.JHipsterProperties} for a good example.
- */
-@ConfigurationProperties(prefix = "application", ignoreUnknownFields = false)
-public class ApplicationProperties {
-
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/AsyncConfiguration.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/AsyncConfiguration.java
deleted file mode 100644
index 414fe152bf..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/AsyncConfiguration.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor;
-import io.github.jhipster.config.JHipsterProperties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
-import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.annotation.*;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-import org.springframework.scheduling.annotation.SchedulingConfigurer;
-import org.springframework.scheduling.config.ScheduledTaskRegistrar;
-
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-
-@Configuration
-@EnableAsync
-@EnableScheduling
-public class AsyncConfiguration implements AsyncConfigurer, SchedulingConfigurer {
-
- private final Logger log = LoggerFactory.getLogger(AsyncConfiguration.class);
-
- private final JHipsterProperties jHipsterProperties;
-
- public AsyncConfiguration(JHipsterProperties jHipsterProperties) {
- this.jHipsterProperties = jHipsterProperties;
- }
-
- @Override
- @Bean(name = "taskExecutor")
- public Executor getAsyncExecutor() {
- log.debug("Creating Async Task Executor");
- ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
- executor.setCorePoolSize(jHipsterProperties.getAsync().getCorePoolSize());
- executor.setMaxPoolSize(jHipsterProperties.getAsync().getMaxPoolSize());
- executor.setQueueCapacity(jHipsterProperties.getAsync().getQueueCapacity());
- executor.setThreadNamePrefix("bookstore-Executor-");
- return new ExceptionHandlingAsyncTaskExecutor(executor);
- }
-
- @Override
- public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
- return new SimpleAsyncUncaughtExceptionHandler();
- }
-
- @Override
- public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
- taskRegistrar.setScheduler(scheduledTaskExecutor());
- }
-
- @Bean
- public Executor scheduledTaskExecutor() {
- return Executors.newScheduledThreadPool(jHipsterProperties.getAsync().getCorePoolSize());
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/CloudDatabaseConfiguration.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/CloudDatabaseConfiguration.java
deleted file mode 100644
index 887a1bae89..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/CloudDatabaseConfiguration.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import io.github.jhipster.config.JHipsterConstants;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.cloud.config.java.AbstractCloudConfig;
-import org.springframework.context.annotation.*;
-
-import javax.sql.DataSource;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-
-
-@Configuration
-@Profile(JHipsterConstants.SPRING_PROFILE_CLOUD)
-public class CloudDatabaseConfiguration extends AbstractCloudConfig {
-
- private final Logger log = LoggerFactory.getLogger(CloudDatabaseConfiguration.class);
-
- private static final String CLOUD_CONFIGURATION_HIKARI_PREFIX = "spring.datasource.hikari";
-
- @Bean
- @ConfigurationProperties(CLOUD_CONFIGURATION_HIKARI_PREFIX)
- public DataSource dataSource() {
- log.info("Configuring JDBC datasource from a cloud provider");
- return connectionFactory().dataSource();
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/Constants.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/Constants.java
deleted file mode 100644
index dd8f717f98..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/Constants.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-/**
- * Application constants.
- */
-public final class Constants {
-
- // Regex for acceptable logins
- public static final String LOGIN_REGEX = "^[_.@A-Za-z0-9-]*$";
-
- public static final String SYSTEM_ACCOUNT = "system";
- public static final String ANONYMOUS_USER = "anonymoususer";
- public static final String DEFAULT_LANGUAGE = "en";
-
- private Constants() {
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/DatabaseConfiguration.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/DatabaseConfiguration.java
deleted file mode 100644
index 007b1d6431..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/DatabaseConfiguration.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import io.github.jhipster.config.JHipsterConstants;
-import io.github.jhipster.config.h2.H2ConfigurationHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Profile;
-
-import org.springframework.core.env.Environment;
-import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-import java.sql.SQLException;
-
-@Configuration
-@EnableJpaRepositories("com.baeldung.jhipster5.repository")
-@EnableJpaAuditing(auditorAwareRef = "springSecurityAuditorAware")
-@EnableTransactionManagement
-public class DatabaseConfiguration {
-
- private final Logger log = LoggerFactory.getLogger(DatabaseConfiguration.class);
-
- private final Environment env;
-
- public DatabaseConfiguration(Environment env) {
- this.env = env;
- }
-
- /**
- * Open the TCP port for the H2 database, so it is available remotely.
- *
- * @return the H2 database TCP server
- * @throws SQLException if the server failed to start
- */
- @Bean(initMethod = "start", destroyMethod = "stop")
- @Profile(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)
- public Object h2TCPServer() throws SQLException {
- String port = getValidPortForH2();
- log.debug("H2 database is available on port {}", port);
- return H2ConfigurationHelper.createServer(port);
- }
-
- private String getValidPortForH2() {
- int port = Integer.parseInt(env.getProperty("server.port"));
- if (port < 10000) {
- port = 10000 + port;
- } else {
- if (port < 63536) {
- port = port + 2000;
- } else {
- port = port - 2000;
- }
- }
- return String.valueOf(port);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/DateTimeFormatConfiguration.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/DateTimeFormatConfiguration.java
deleted file mode 100644
index 4415ce0b1e..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/DateTimeFormatConfiguration.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.format.FormatterRegistry;
-import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-
-/**
- * Configure the converters to use the ISO format for dates by default.
- */
-@Configuration
-public class DateTimeFormatConfiguration implements WebMvcConfigurer {
-
- @Override
- public void addFormatters(FormatterRegistry registry) {
- DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
- registrar.setUseIsoFormat(true);
- registrar.registerFormatters(registry);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/DefaultProfileUtil.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/DefaultProfileUtil.java
deleted file mode 100644
index 2cfe16a1ae..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/DefaultProfileUtil.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import io.github.jhipster.config.JHipsterConstants;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.core.env.Environment;
-
-import java.util.*;
-
-/**
- * Utility class to load a Spring profile to be used as default
- * when there is no spring.profiles.active set in the environment or as command line argument.
- * If the value is not available in application.yml then dev profile will be used as default.
- */
-public final class DefaultProfileUtil {
-
- private static final String SPRING_PROFILE_DEFAULT = "spring.profiles.default";
-
- private DefaultProfileUtil() {
- }
-
- /**
- * Set a default to use when no profile is configured.
- *
- * @param app the Spring application
- */
- public static void addDefaultProfile(SpringApplication app) {
- Map defProperties = new HashMap<>();
- /*
- * The default profile to use when no other profiles are defined
- * This cannot be set in the application.yml file.
- * See https://github.com/spring-projects/spring-boot/issues/1219
- */
- defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
- app.setDefaultProperties(defProperties);
- }
-
- /**
- * Get the profiles that are applied else get default profiles.
- *
- * @param env spring environment
- * @return profiles
- */
- public static String[] getActiveProfiles(Environment env) {
- String[] profiles = env.getActiveProfiles();
- if (profiles.length == 0) {
- return env.getDefaultProfiles();
- }
- return profiles;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/JacksonConfiguration.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/JacksonConfiguration.java
deleted file mode 100644
index 119cd5f0c6..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/JacksonConfiguration.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import com.fasterxml.jackson.datatype.hibernate5.Hibernate5Module;
-import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
-import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-import com.fasterxml.jackson.module.afterburner.AfterburnerModule;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.zalando.problem.ProblemModule;
-import org.zalando.problem.violations.ConstraintViolationProblemModule;
-
-@Configuration
-public class JacksonConfiguration {
-
- /**
- * Support for Java date and time API.
- * @return the corresponding Jackson module.
- */
- @Bean
- public JavaTimeModule javaTimeModule() {
- return new JavaTimeModule();
- }
-
- @Bean
- public Jdk8Module jdk8TimeModule() {
- return new Jdk8Module();
- }
-
-
- /*
- * Support for Hibernate types in Jackson.
- */
- @Bean
- public Hibernate5Module hibernate5Module() {
- return new Hibernate5Module();
- }
-
- /*
- * Jackson Afterburner module to speed up serialization/deserialization.
- */
- @Bean
- public AfterburnerModule afterburnerModule() {
- return new AfterburnerModule();
- }
-
- /*
- * Module for serialization/deserialization of RFC7807 Problem.
- */
- @Bean
- ProblemModule problemModule() {
- return new ProblemModule();
- }
-
- /*
- * Module for serialization/deserialization of ConstraintViolationProblem.
- */
- @Bean
- ConstraintViolationProblemModule constraintViolationProblemModule() {
- return new ConstraintViolationProblemModule();
- }
-
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/LiquibaseConfiguration.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/LiquibaseConfiguration.java
deleted file mode 100644
index 4b2a7b1e66..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/LiquibaseConfiguration.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import javax.sql.DataSource;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.env.Environment;
-import org.springframework.core.task.TaskExecutor;
-
-import io.github.jhipster.config.JHipsterConstants;
-import io.github.jhipster.config.liquibase.AsyncSpringLiquibase;
-import liquibase.integration.spring.SpringLiquibase;
-
-@Configuration
-public class LiquibaseConfiguration {
-
- private final Logger log = LoggerFactory.getLogger(LiquibaseConfiguration.class);
-
- private final Environment env;
-
-
- public LiquibaseConfiguration(Environment env) {
- this.env = env;
- }
-
- @Bean
- public SpringLiquibase liquibase(@Qualifier("taskExecutor") TaskExecutor taskExecutor,
- DataSource dataSource, LiquibaseProperties liquibaseProperties) {
-
- // Use liquibase.integration.spring.SpringLiquibase if you don't want Liquibase to start asynchronously
- SpringLiquibase liquibase = new AsyncSpringLiquibase(taskExecutor, env);
- liquibase.setDataSource(dataSource);
- liquibase.setChangeLog("classpath:config/liquibase/master.xml");
- liquibase.setContexts(liquibaseProperties.getContexts());
- liquibase.setDefaultSchema(liquibaseProperties.getDefaultSchema());
- liquibase.setDropFirst(liquibaseProperties.isDropFirst());
- liquibase.setChangeLogParameters(liquibaseProperties.getParameters());
- if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_NO_LIQUIBASE)) {
- liquibase.setShouldRun(false);
- } else {
- liquibase.setShouldRun(liquibaseProperties.isEnabled());
- log.debug("Configuring Liquibase");
- }
- return liquibase;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/LocaleConfiguration.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/LocaleConfiguration.java
deleted file mode 100644
index 256c6b77b9..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/LocaleConfiguration.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import io.github.jhipster.config.locale.AngularCookieLocaleResolver;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.LocaleResolver;
-import org.springframework.web.servlet.config.annotation.*;
-import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
-
-@Configuration
-public class LocaleConfiguration implements WebMvcConfigurer {
-
- @Bean(name = "localeResolver")
- public LocaleResolver localeResolver() {
- AngularCookieLocaleResolver cookieLocaleResolver = new AngularCookieLocaleResolver();
- cookieLocaleResolver.setCookieName("NG_TRANSLATE_LANG_KEY");
- return cookieLocaleResolver;
- }
-
- @Override
- public void addInterceptors(InterceptorRegistry registry) {
- LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
- localeChangeInterceptor.setParamName("language");
- registry.addInterceptor(localeChangeInterceptor);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/LoggingAspectConfiguration.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/LoggingAspectConfiguration.java
deleted file mode 100644
index 25d7ba3792..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/LoggingAspectConfiguration.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import com.baeldung.jhipster5.aop.logging.LoggingAspect;
-
-import io.github.jhipster.config.JHipsterConstants;
-
-import org.springframework.context.annotation.*;
-import org.springframework.core.env.Environment;
-
-@Configuration
-@EnableAspectJAutoProxy
-public class LoggingAspectConfiguration {
-
- @Bean
- @Profile(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)
- public LoggingAspect loggingAspect(Environment env) {
- return new LoggingAspect(env);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/LoggingConfiguration.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/LoggingConfiguration.java
deleted file mode 100644
index 9402a1bc36..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/LoggingConfiguration.java
+++ /dev/null
@@ -1,154 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import java.net.InetSocketAddress;
-import java.util.Iterator;
-
-import io.github.jhipster.config.JHipsterProperties;
-
-import ch.qos.logback.classic.AsyncAppender;
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.boolex.OnMarkerEvaluator;
-import ch.qos.logback.classic.spi.ILoggingEvent;
-import ch.qos.logback.classic.spi.LoggerContextListener;
-import ch.qos.logback.core.Appender;
-import ch.qos.logback.core.filter.EvaluatorFilter;
-import ch.qos.logback.core.spi.ContextAwareBase;
-import ch.qos.logback.core.spi.FilterReply;
-import net.logstash.logback.appender.LogstashTcpSocketAppender;
-import net.logstash.logback.encoder.LogstashEncoder;
-import net.logstash.logback.stacktrace.ShortenedThrowableConverter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class LoggingConfiguration {
-
- private static final String LOGSTASH_APPENDER_NAME = "LOGSTASH";
-
- private static final String ASYNC_LOGSTASH_APPENDER_NAME = "ASYNC_LOGSTASH";
-
- private final Logger log = LoggerFactory.getLogger(LoggingConfiguration.class);
-
- private LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
-
- private final String appName;
-
- private final String serverPort;
-
- private final JHipsterProperties jHipsterProperties;
-
- public LoggingConfiguration(@Value("${spring.application.name}") String appName, @Value("${server.port}") String serverPort,
- JHipsterProperties jHipsterProperties) {
- this.appName = appName;
- this.serverPort = serverPort;
- this.jHipsterProperties = jHipsterProperties;
- if (jHipsterProperties.getLogging().getLogstash().isEnabled()) {
- addLogstashAppender(context);
- addContextListener(context);
- }
- if (jHipsterProperties.getMetrics().getLogs().isEnabled()) {
- setMetricsMarkerLogbackFilter(context);
- }
- }
-
- private void addContextListener(LoggerContext context) {
- LogbackLoggerContextListener loggerContextListener = new LogbackLoggerContextListener();
- loggerContextListener.setContext(context);
- context.addListener(loggerContextListener);
- }
-
- private void addLogstashAppender(LoggerContext context) {
- log.info("Initializing Logstash logging");
-
- LogstashTcpSocketAppender logstashAppender = new LogstashTcpSocketAppender();
- logstashAppender.setName(LOGSTASH_APPENDER_NAME);
- logstashAppender.setContext(context);
- String customFields = "{\"app_name\":\"" + appName + "\",\"app_port\":\"" + serverPort + "\"}";
-
- // More documentation is available at: https://github.com/logstash/logstash-logback-encoder
- LogstashEncoder logstashEncoder = new LogstashEncoder();
- // Set the Logstash appender config from JHipster properties
- logstashAppender.addDestinations(new InetSocketAddress(jHipsterProperties.getLogging().getLogstash().getHost(), jHipsterProperties.getLogging().getLogstash().getPort()));
-
- ShortenedThrowableConverter throwableConverter = new ShortenedThrowableConverter();
- throwableConverter.setRootCauseFirst(true);
- logstashEncoder.setThrowableConverter(throwableConverter);
- logstashEncoder.setCustomFields(customFields);
-
- logstashAppender.setEncoder(logstashEncoder);
- logstashAppender.start();
-
- // Wrap the appender in an Async appender for performance
- AsyncAppender asyncLogstashAppender = new AsyncAppender();
- asyncLogstashAppender.setContext(context);
- asyncLogstashAppender.setName(ASYNC_LOGSTASH_APPENDER_NAME);
- asyncLogstashAppender.setQueueSize(jHipsterProperties.getLogging().getLogstash().getQueueSize());
- asyncLogstashAppender.addAppender(logstashAppender);
- asyncLogstashAppender.start();
-
- context.getLogger("ROOT").addAppender(asyncLogstashAppender);
- }
-
- // Configure a log filter to remove "metrics" logs from all appenders except the "LOGSTASH" appender
- private void setMetricsMarkerLogbackFilter(LoggerContext context) {
- log.info("Filtering metrics logs from all appenders except the {} appender", LOGSTASH_APPENDER_NAME);
- OnMarkerEvaluator onMarkerMetricsEvaluator = new OnMarkerEvaluator();
- onMarkerMetricsEvaluator.setContext(context);
- onMarkerMetricsEvaluator.addMarker("metrics");
- onMarkerMetricsEvaluator.start();
- EvaluatorFilter metricsFilter = new EvaluatorFilter<>();
- metricsFilter.setContext(context);
- metricsFilter.setEvaluator(onMarkerMetricsEvaluator);
- metricsFilter.setOnMatch(FilterReply.DENY);
- metricsFilter.start();
-
- for (ch.qos.logback.classic.Logger logger : context.getLoggerList()) {
- for (Iterator> it = logger.iteratorForAppenders(); it.hasNext();) {
- Appender appender = it.next();
- if (!appender.getName().equals(ASYNC_LOGSTASH_APPENDER_NAME)) {
- log.debug("Filter metrics logs from the {} appender", appender.getName());
- appender.setContext(context);
- appender.addFilter(metricsFilter);
- appender.start();
- }
- }
- }
- }
-
- /**
- * Logback configuration is achieved by configuration file and API.
- * When configuration file change is detected, the configuration is reset.
- * This listener ensures that the programmatic configuration is also re-applied after reset.
- */
- class LogbackLoggerContextListener extends ContextAwareBase implements LoggerContextListener {
-
- @Override
- public boolean isResetResistant() {
- return true;
- }
-
- @Override
- public void onStart(LoggerContext context) {
- addLogstashAppender(context);
- }
-
- @Override
- public void onReset(LoggerContext context) {
- addLogstashAppender(context);
- }
-
- @Override
- public void onStop(LoggerContext context) {
- // Nothing to do.
- }
-
- @Override
- public void onLevelChange(ch.qos.logback.classic.Logger logger, Level level) {
- // Nothing to do.
- }
- }
-
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/SecurityConfiguration.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/SecurityConfiguration.java
deleted file mode 100644
index f07944271e..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/SecurityConfiguration.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import com.baeldung.jhipster5.security.*;
-import com.baeldung.jhipster5.security.jwt.*;
-
-import org.springframework.beans.factory.BeanInitializationException;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import org.springframework.http.HttpMethod;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.builders.WebSecurity;
-import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-import org.springframework.security.config.http.SessionCreationPolicy;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
-import org.springframework.web.filter.CorsFilter;
-import org.zalando.problem.spring.web.advice.security.SecurityProblemSupport;
-
-import javax.annotation.PostConstruct;
-
-@Configuration
-@EnableWebSecurity
-@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
-@Import(SecurityProblemSupport.class)
-public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
-
- private final AuthenticationManagerBuilder authenticationManagerBuilder;
-
- private final UserDetailsService userDetailsService;
-
- private final TokenProvider tokenProvider;
-
- private final CorsFilter corsFilter;
-
- private final SecurityProblemSupport problemSupport;
-
- public SecurityConfiguration(AuthenticationManagerBuilder authenticationManagerBuilder, UserDetailsService userDetailsService, TokenProvider tokenProvider, CorsFilter corsFilter, SecurityProblemSupport problemSupport) {
- this.authenticationManagerBuilder = authenticationManagerBuilder;
- this.userDetailsService = userDetailsService;
- this.tokenProvider = tokenProvider;
- this.corsFilter = corsFilter;
- this.problemSupport = problemSupport;
- }
-
- @PostConstruct
- public void init() {
- try {
- authenticationManagerBuilder
- .userDetailsService(userDetailsService)
- .passwordEncoder(passwordEncoder());
- } catch (Exception e) {
- throw new BeanInitializationException("Security configuration failed", e);
- }
- }
-
- @Override
- @Bean
- public AuthenticationManager authenticationManagerBean() throws Exception {
- return super.authenticationManagerBean();
- }
-
- @Bean
- public PasswordEncoder passwordEncoder() {
- return new BCryptPasswordEncoder();
- }
-
- @Override
- public void configure(WebSecurity web) throws Exception {
- web.ignoring()
- .antMatchers(HttpMethod.OPTIONS, "/**")
- .antMatchers("/app/**/*.{js,html}")
- .antMatchers("/i18n/**")
- .antMatchers("/content/**")
- .antMatchers("/h2-console/**")
- .antMatchers("/swagger-ui/index.html")
- .antMatchers("/test/**");
- }
-
- @Override
- public void configure(HttpSecurity http) throws Exception {
- http
- .csrf()
- .disable()
- .addFilterBefore(corsFilter, UsernamePasswordAuthenticationFilter.class)
- .exceptionHandling()
- .authenticationEntryPoint(problemSupport)
- .accessDeniedHandler(problemSupport)
- .and()
- .headers()
- .frameOptions()
- .disable()
- .and()
- .sessionManagement()
- .sessionCreationPolicy(SessionCreationPolicy.STATELESS)
- .and()
- .authorizeRequests()
- .antMatchers("/api/books/purchase/**").authenticated()
- .antMatchers("/api/register").permitAll()
- .antMatchers("/api/activate").permitAll()
- .antMatchers("/api/authenticate").permitAll()
- .antMatchers("/api/account/reset-password/init").permitAll()
- .antMatchers("/api/account/reset-password/finish").permitAll()
- .antMatchers("/api/**").authenticated()
- .antMatchers("/management/health").permitAll()
- .antMatchers("/management/info").permitAll()
- .antMatchers("/management/**").hasAuthority(AuthoritiesConstants.ADMIN)
- .and()
- .apply(securityConfigurerAdapter());
-
- }
-
- private JWTConfigurer securityConfigurerAdapter() {
- return new JWTConfigurer(tokenProvider);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/WebConfigurer.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/WebConfigurer.java
deleted file mode 100644
index 26cfc92487..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/WebConfigurer.java
+++ /dev/null
@@ -1,170 +0,0 @@
-package com.baeldung.jhipster5.config;
-
-import io.github.jhipster.config.JHipsterConstants;
-import io.github.jhipster.config.JHipsterProperties;
-import io.github.jhipster.config.h2.H2ConfigurationHelper;
-import io.github.jhipster.web.filter.CachingHttpHeadersFilter;
-import io.undertow.UndertowOptions;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
-import org.springframework.boot.web.server.*;
-import org.springframework.boot.web.servlet.ServletContextInitializer;
-import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.env.Environment;
-import org.springframework.http.MediaType;
-import org.springframework.web.cors.CorsConfiguration;
-import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
-import org.springframework.web.filter.CorsFilter;
-
-import javax.servlet.*;
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Paths;
-import java.util.*;
-
-import static java.net.URLDecoder.decode;
-
-/**
- * Configuration of web application with Servlet 3.0 APIs.
- */
-@Configuration
-public class WebConfigurer implements ServletContextInitializer, WebServerFactoryCustomizer {
-
- private final Logger log = LoggerFactory.getLogger(WebConfigurer.class);
-
- private final Environment env;
-
- private final JHipsterProperties jHipsterProperties;
-
- public WebConfigurer(Environment env, JHipsterProperties jHipsterProperties) {
-
- this.env = env;
- this.jHipsterProperties = jHipsterProperties;
- }
-
- @Override
- public void onStartup(ServletContext servletContext) throws ServletException {
- if (env.getActiveProfiles().length != 0) {
- log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles());
- }
- EnumSet disps = EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC);
- if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_PRODUCTION)) {
- initCachingHttpHeadersFilter(servletContext, disps);
- }
- if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
- initH2Console(servletContext);
- }
- log.info("Web application fully configured");
- }
-
- /**
- * Customize the Servlet engine: Mime types, the document root, the cache.
- */
- @Override
- public void customize(WebServerFactory server) {
- setMimeMappings(server);
- // When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets.
- setLocationForStaticAssets(server);
-
- /*
- * Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288
- * HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1.
- * See the JHipsterProperties class and your application-*.yml configuration files
- * for more information.
- */
- if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) &&
- server instanceof UndertowServletWebServerFactory) {
-
- ((UndertowServletWebServerFactory) server)
- .addBuilderCustomizers(builder ->
- builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true));
- }
- }
-
- private void setMimeMappings(WebServerFactory server) {
- if (server instanceof ConfigurableServletWebServerFactory) {
- MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT);
- // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711
- mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase());
- // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64
- mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase());
- ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server;
- servletWebServer.setMimeMappings(mappings);
- }
- }
-
- private void setLocationForStaticAssets(WebServerFactory server) {
- if (server instanceof ConfigurableServletWebServerFactory) {
- ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server;
- File root;
- String prefixPath = resolvePathPrefix();
- root = new File(prefixPath + "target/www/");
- if (root.exists() && root.isDirectory()) {
- servletWebServer.setDocumentRoot(root);
- }
- }
- }
-
- /**
- * Resolve path prefix to static resources.
- */
- private String resolvePathPrefix() {
- String fullExecutablePath;
- try {
- fullExecutablePath = decode(this.getClass().getResource("").getPath(), StandardCharsets.UTF_8.name());
- } catch (UnsupportedEncodingException e) {
- /* try without decoding if this ever happens */
- fullExecutablePath = this.getClass().getResource("").getPath();
- }
- String rootPath = Paths.get(".").toUri().normalize().getPath();
- String extractedPath = fullExecutablePath.replace(rootPath, "");
- int extractionEndIndex = extractedPath.indexOf("target/");
- if (extractionEndIndex <= 0) {
- return "";
- }
- return extractedPath.substring(0, extractionEndIndex);
- }
-
- /**
- * Initializes the caching HTTP Headers Filter.
- */
- private void initCachingHttpHeadersFilter(ServletContext servletContext,
- EnumSet disps) {
- log.debug("Registering Caching HTTP Headers Filter");
- FilterRegistration.Dynamic cachingHttpHeadersFilter =
- servletContext.addFilter("cachingHttpHeadersFilter",
- new CachingHttpHeadersFilter(jHipsterProperties));
-
- cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/i18n/*");
- cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/content/*");
- cachingHttpHeadersFilter.addMappingForUrlPatterns(disps, true, "/app/*");
- cachingHttpHeadersFilter.setAsyncSupported(true);
- }
-
- @Bean
- public CorsFilter corsFilter() {
- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
- CorsConfiguration config = jHipsterProperties.getCors();
- if (config.getAllowedOrigins() != null && !config.getAllowedOrigins().isEmpty()) {
- log.debug("Registering CORS filter");
- source.registerCorsConfiguration("/api/**", config);
- source.registerCorsConfiguration("/management/**", config);
- source.registerCorsConfiguration("/v2/api-docs", config);
- }
- return new CorsFilter(source);
- }
-
- /**
- * Initializes H2 console.
- */
- private void initH2Console(ServletContext servletContext) {
- log.debug("Initialize H2 console");
- H2ConfigurationHelper.initH2Console(servletContext);
- }
-
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/audit/AuditEventConverter.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/audit/AuditEventConverter.java
deleted file mode 100644
index 6dd87bb82d..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/audit/AuditEventConverter.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.baeldung.jhipster5.config.audit;
-
-import com.baeldung.jhipster5.domain.PersistentAuditEvent;
-
-import org.springframework.boot.actuate.audit.AuditEvent;
-import org.springframework.security.web.authentication.WebAuthenticationDetails;
-import org.springframework.stereotype.Component;
-
-import java.util.*;
-
-@Component
-public class AuditEventConverter {
-
- /**
- * Convert a list of PersistentAuditEvent to a list of AuditEvent
- *
- * @param persistentAuditEvents the list to convert
- * @return the converted list.
- */
- public List convertToAuditEvent(Iterable persistentAuditEvents) {
- if (persistentAuditEvents == null) {
- return Collections.emptyList();
- }
- List auditEvents = new ArrayList<>();
- for (PersistentAuditEvent persistentAuditEvent : persistentAuditEvents) {
- auditEvents.add(convertToAuditEvent(persistentAuditEvent));
- }
- return auditEvents;
- }
-
- /**
- * Convert a PersistentAuditEvent to an AuditEvent
- *
- * @param persistentAuditEvent the event to convert
- * @return the converted list.
- */
- public AuditEvent convertToAuditEvent(PersistentAuditEvent persistentAuditEvent) {
- if (persistentAuditEvent == null) {
- return null;
- }
- return new AuditEvent(persistentAuditEvent.getAuditEventDate(), persistentAuditEvent.getPrincipal(),
- persistentAuditEvent.getAuditEventType(), convertDataToObjects(persistentAuditEvent.getData()));
- }
-
- /**
- * Internal conversion. This is needed to support the current SpringBoot actuator AuditEventRepository interface
- *
- * @param data the data to convert
- * @return a map of String, Object
- */
- public Map convertDataToObjects(Map data) {
- Map results = new HashMap<>();
-
- if (data != null) {
- for (Map.Entry entry : data.entrySet()) {
- results.put(entry.getKey(), entry.getValue());
- }
- }
- return results;
- }
-
- /**
- * Internal conversion. This method will allow to save additional data.
- * By default, it will save the object as string
- *
- * @param data the data to convert
- * @return a map of String, String
- */
- public Map convertDataToStrings(Map data) {
- Map results = new HashMap<>();
-
- if (data != null) {
- for (Map.Entry entry : data.entrySet()) {
- // Extract the data that will be saved.
- if (entry.getValue() instanceof WebAuthenticationDetails) {
- WebAuthenticationDetails authenticationDetails = (WebAuthenticationDetails) entry.getValue();
- results.put("remoteAddress", authenticationDetails.getRemoteAddress());
- results.put("sessionId", authenticationDetails.getSessionId());
- } else {
- results.put(entry.getKey(), Objects.toString(entry.getValue()));
- }
- }
- }
- return results;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/audit/package-info.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/audit/package-info.java
deleted file mode 100644
index 49a2a73a61..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/audit/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Audit specific code.
- */
-package com.baeldung.jhipster5.config.audit;
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/package-info.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/package-info.java
deleted file mode 100644
index 868155ce9f..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/config/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Spring Framework configuration files.
- */
-package com.baeldung.jhipster5.config;
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/AbstractAuditingEntity.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/AbstractAuditingEntity.java
deleted file mode 100644
index 861674ccc9..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/AbstractAuditingEntity.java
+++ /dev/null
@@ -1,79 +0,0 @@
-package com.baeldung.jhipster5.domain;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import org.hibernate.envers.Audited;
-import org.springframework.data.annotation.CreatedBy;
-import org.springframework.data.annotation.CreatedDate;
-import org.springframework.data.annotation.LastModifiedBy;
-import org.springframework.data.annotation.LastModifiedDate;
-import org.springframework.data.jpa.domain.support.AuditingEntityListener;
-
-import java.io.Serializable;
-import java.time.Instant;
-import javax.persistence.Column;
-import javax.persistence.EntityListeners;
-import javax.persistence.MappedSuperclass;
-
-/**
- * Base abstract class for entities which will hold definitions for created, last modified by and created,
- * last modified by date.
- */
-@MappedSuperclass
-@Audited
-@EntityListeners(AuditingEntityListener.class)
-public abstract class AbstractAuditingEntity implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @CreatedBy
- @Column(name = "created_by", nullable = false, length = 50, updatable = false)
- @JsonIgnore
- private String createdBy;
-
- @CreatedDate
- @Column(name = "created_date", updatable = false)
- @JsonIgnore
- private Instant createdDate = Instant.now();
-
- @LastModifiedBy
- @Column(name = "last_modified_by", length = 50)
- @JsonIgnore
- private String lastModifiedBy;
-
- @LastModifiedDate
- @Column(name = "last_modified_date")
- @JsonIgnore
- private Instant lastModifiedDate = Instant.now();
-
- public String getCreatedBy() {
- return createdBy;
- }
-
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- public Instant getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Instant createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getLastModifiedBy() {
- return lastModifiedBy;
- }
-
- public void setLastModifiedBy(String lastModifiedBy) {
- this.lastModifiedBy = lastModifiedBy;
- }
-
- public Instant getLastModifiedDate() {
- return lastModifiedDate;
- }
-
- public void setLastModifiedDate(Instant lastModifiedDate) {
- this.lastModifiedDate = lastModifiedDate;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/Authority.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/Authority.java
deleted file mode 100644
index fbd4596fc7..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/Authority.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.baeldung.jhipster5.domain;
-
-import javax.persistence.Entity;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Column;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-import java.io.Serializable;
-
-/**
- * An authority (a security role) used by Spring Security.
- */
-@Entity
-@Table(name = "jhi_authority")
-public class Authority implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @NotNull
- @Size(max = 50)
- @Id
- @Column(length = 50)
- private String name;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- Authority authority = (Authority) o;
-
- return !(name != null ? !name.equals(authority.name) : authority.name != null);
- }
-
- @Override
- public int hashCode() {
- return name != null ? name.hashCode() : 0;
- }
-
- @Override
- public String toString() {
- return "Authority{" +
- "name='" + name + '\'' +
- "}";
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/Book.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/Book.java
deleted file mode 100644
index 16771d9e09..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/Book.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package com.baeldung.jhipster5.domain;
-
-
-
-import javax.persistence.*;
-import javax.validation.constraints.*;
-
-import java.io.Serializable;
-import java.time.LocalDate;
-import java.util.Objects;
-
-/**
- * A Book.
- */
-@Entity
-@Table(name = "book")
-public class Book implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
-
- @NotNull
- @Column(name = "title", nullable = false)
- private String title;
-
- @NotNull
- @Column(name = "author", nullable = false)
- private String author;
-
- @NotNull
- @Column(name = "published", nullable = false)
- private LocalDate published;
-
- @NotNull
- @Min(value = 0)
- @Column(name = "quantity", nullable = false)
- private Integer quantity;
-
- @NotNull
- @DecimalMin(value = "0")
- @Column(name = "price", nullable = false)
- private Double price;
-
- // jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getTitle() {
- return title;
- }
-
- public Book title(String title) {
- this.title = title;
- return this;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getAuthor() {
- return author;
- }
-
- public Book author(String author) {
- this.author = author;
- return this;
- }
-
- public void setAuthor(String author) {
- this.author = author;
- }
-
- public LocalDate getPublished() {
- return published;
- }
-
- public Book published(LocalDate published) {
- this.published = published;
- return this;
- }
-
- public void setPublished(LocalDate published) {
- this.published = published;
- }
-
- public Integer getQuantity() {
- return quantity;
- }
-
- public Book quantity(Integer quantity) {
- this.quantity = quantity;
- return this;
- }
-
- public void setQuantity(Integer quantity) {
- this.quantity = quantity;
- }
-
- public Double getPrice() {
- return price;
- }
-
- public Book price(Double price) {
- this.price = price;
- return this;
- }
-
- public void setPrice(Double price) {
- this.price = price;
- }
- // jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- Book book = (Book) o;
- if (book.getId() == null || getId() == null) {
- return false;
- }
- return Objects.equals(getId(), book.getId());
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(getId());
- }
-
- @Override
- public String toString() {
- return "Book{" +
- "id=" + getId() +
- ", title='" + getTitle() + "'" +
- ", author='" + getAuthor() + "'" +
- ", published='" + getPublished() + "'" +
- ", quantity=" + getQuantity() +
- ", price=" + getPrice() +
- "}";
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/PersistentAuditEvent.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/PersistentAuditEvent.java
deleted file mode 100644
index 15e2eeda5a..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/PersistentAuditEvent.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package com.baeldung.jhipster5.domain;
-
-import javax.persistence.*;
-import javax.validation.constraints.NotNull;
-import java.io.Serializable;
-import java.time.Instant;
-import java.util.HashMap;
-import java.util.Objects;
-import java.util.Map;
-
-/**
- * Persist AuditEvent managed by the Spring Boot actuator.
- *
- * @see org.springframework.boot.actuate.audit.AuditEvent
- */
-@Entity
-@Table(name = "jhi_persistent_audit_event")
-public class PersistentAuditEvent implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- @Column(name = "event_id")
- private Long id;
-
- @NotNull
- @Column(nullable = false)
- private String principal;
-
- @Column(name = "event_date")
- private Instant auditEventDate;
-
- @Column(name = "event_type")
- private String auditEventType;
-
- @ElementCollection
- @MapKeyColumn(name = "name")
- @Column(name = "value")
- @CollectionTable(name = "jhi_persistent_audit_evt_data", joinColumns=@JoinColumn(name="event_id"))
- private Map data = new HashMap<>();
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getPrincipal() {
- return principal;
- }
-
- public void setPrincipal(String principal) {
- this.principal = principal;
- }
-
- public Instant getAuditEventDate() {
- return auditEventDate;
- }
-
- public void setAuditEventDate(Instant auditEventDate) {
- this.auditEventDate = auditEventDate;
- }
-
- public String getAuditEventType() {
- return auditEventType;
- }
-
- public void setAuditEventType(String auditEventType) {
- this.auditEventType = auditEventType;
- }
-
- public Map getData() {
- return data;
- }
-
- public void setData(Map data) {
- this.data = data;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- PersistentAuditEvent persistentAuditEvent = (PersistentAuditEvent) o;
- return !(persistentAuditEvent.getId() == null || getId() == null) && Objects.equals(getId(), persistentAuditEvent.getId());
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(getId());
- }
-
- @Override
- public String toString() {
- return "PersistentAuditEvent{" +
- "principal='" + principal + '\'' +
- ", auditEventDate=" + auditEventDate +
- ", auditEventType='" + auditEventType + '\'' +
- '}';
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/User.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/User.java
deleted file mode 100644
index ff12d1ca9c..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/User.java
+++ /dev/null
@@ -1,231 +0,0 @@
-package com.baeldung.jhipster5.domain;
-
-import com.baeldung.jhipster5.config.Constants;
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import org.apache.commons.lang3.StringUtils;
-import org.hibernate.annotations.BatchSize;
-import javax.validation.constraints.Email;
-
-import javax.persistence.*;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Pattern;
-import javax.validation.constraints.Size;
-import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Objects;
-import java.util.Set;
-import java.time.Instant;
-
-/**
- * A user.
- */
-@Entity
-@Table(name = "jhi_user")
-
-public class User extends AbstractAuditingEntity implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
-
- @NotNull
- @Pattern(regexp = Constants.LOGIN_REGEX)
- @Size(min = 1, max = 50)
- @Column(length = 50, unique = true, nullable = false)
- private String login;
-
- @JsonIgnore
- @NotNull
- @Size(min = 60, max = 60)
- @Column(name = "password_hash", length = 60, nullable = false)
- private String password;
-
- @Size(max = 50)
- @Column(name = "first_name", length = 50)
- private String firstName;
-
- @Size(max = 50)
- @Column(name = "last_name", length = 50)
- private String lastName;
-
- @Email
- @Size(min = 5, max = 254)
- @Column(length = 254, unique = true)
- private String email;
-
- @NotNull
- @Column(nullable = false)
- private boolean activated = false;
-
- @Size(min = 2, max = 6)
- @Column(name = "lang_key", length = 6)
- private String langKey;
-
- @Size(max = 256)
- @Column(name = "image_url", length = 256)
- private String imageUrl;
-
- @Size(max = 20)
- @Column(name = "activation_key", length = 20)
- @JsonIgnore
- private String activationKey;
-
- @Size(max = 20)
- @Column(name = "reset_key", length = 20)
- @JsonIgnore
- private String resetKey;
-
- @Column(name = "reset_date")
- private Instant resetDate = null;
-
- @JsonIgnore
- @ManyToMany
- @JoinTable(
- name = "jhi_user_authority",
- joinColumns = {@JoinColumn(name = "user_id", referencedColumnName = "id")},
- inverseJoinColumns = {@JoinColumn(name = "authority_name", referencedColumnName = "name")})
-
- @BatchSize(size = 20)
- private Set authorities = new HashSet<>();
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getLogin() {
- return login;
- }
-
- // Lowercase the login before saving it in database
- public void setLogin(String login) {
- this.login = StringUtils.lowerCase(login, Locale.ENGLISH);
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getImageUrl() {
- return imageUrl;
- }
-
- public void setImageUrl(String imageUrl) {
- this.imageUrl = imageUrl;
- }
-
- public boolean getActivated() {
- return activated;
- }
-
- public void setActivated(boolean activated) {
- this.activated = activated;
- }
-
- public String getActivationKey() {
- return activationKey;
- }
-
- public void setActivationKey(String activationKey) {
- this.activationKey = activationKey;
- }
-
- public String getResetKey() {
- return resetKey;
- }
-
- public void setResetKey(String resetKey) {
- this.resetKey = resetKey;
- }
-
- public Instant getResetDate() {
- return resetDate;
- }
-
- public void setResetDate(Instant resetDate) {
- this.resetDate = resetDate;
- }
-
- public String getLangKey() {
- return langKey;
- }
-
- public void setLangKey(String langKey) {
- this.langKey = langKey;
- }
-
- public Set getAuthorities() {
- return authorities;
- }
-
- public void setAuthorities(Set authorities) {
- this.authorities = authorities;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- User user = (User) o;
- return !(user.getId() == null || getId() == null) && Objects.equals(getId(), user.getId());
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(getId());
- }
-
- @Override
- public String toString() {
- return "User{" +
- "login='" + login + '\'' +
- ", firstName='" + firstName + '\'' +
- ", lastName='" + lastName + '\'' +
- ", email='" + email + '\'' +
- ", imageUrl='" + imageUrl + '\'' +
- ", activated='" + activated + '\'' +
- ", langKey='" + langKey + '\'' +
- ", activationKey='" + activationKey + '\'' +
- "}";
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/package-info.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/package-info.java
deleted file mode 100644
index eba92a598e..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/domain/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * JPA domain objects.
- */
-package com.baeldung.jhipster5.domain;
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/AuthorityRepository.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/AuthorityRepository.java
deleted file mode 100644
index 310735eb57..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/AuthorityRepository.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.baeldung.jhipster5.repository;
-
-import com.baeldung.jhipster5.domain.Authority;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-
-/**
- * Spring Data JPA repository for the Authority entity.
- */
-public interface AuthorityRepository extends JpaRepository {
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/BookRepository.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/BookRepository.java
deleted file mode 100644
index ebd3117e65..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/BookRepository.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.baeldung.jhipster5.repository;
-
-import com.baeldung.jhipster5.domain.Book;
-import org.springframework.data.jpa.repository.*;
-import org.springframework.stereotype.Repository;
-
-
-/**
- * Spring Data repository for the Book entity.
- */
-@SuppressWarnings("unused")
-@Repository
-public interface BookRepository extends JpaRepository {
-
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/CustomAuditEventRepository.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/CustomAuditEventRepository.java
deleted file mode 100644
index faa788ff5f..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/CustomAuditEventRepository.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package com.baeldung.jhipster5.repository;
-
-import com.baeldung.jhipster5.config.Constants;
-import com.baeldung.jhipster5.config.audit.AuditEventConverter;
-import com.baeldung.jhipster5.domain.PersistentAuditEvent;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.actuate.audit.AuditEvent;
-import org.springframework.boot.actuate.audit.AuditEventRepository;
-import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.time.Instant;
-import java.util.*;
-
-/**
- * An implementation of Spring Boot's AuditEventRepository.
- */
-@Repository
-public class CustomAuditEventRepository implements AuditEventRepository {
-
- private static final String AUTHORIZATION_FAILURE = "AUTHORIZATION_FAILURE";
-
- /**
- * Should be the same as in Liquibase migration.
- */
- protected static final int EVENT_DATA_COLUMN_MAX_LENGTH = 255;
-
- private final PersistenceAuditEventRepository persistenceAuditEventRepository;
-
- private final AuditEventConverter auditEventConverter;
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- public CustomAuditEventRepository(PersistenceAuditEventRepository persistenceAuditEventRepository,
- AuditEventConverter auditEventConverter) {
-
- this.persistenceAuditEventRepository = persistenceAuditEventRepository;
- this.auditEventConverter = auditEventConverter;
- }
-
- @Override
- public List find(String principal, Instant after, String type) {
- Iterable persistentAuditEvents =
- persistenceAuditEventRepository.findByPrincipalAndAuditEventDateAfterAndAuditEventType(principal, after, type);
- return auditEventConverter.convertToAuditEvent(persistentAuditEvents);
- }
-
- @Override
- @Transactional(propagation = Propagation.REQUIRES_NEW)
- public void add(AuditEvent event) {
- if (!AUTHORIZATION_FAILURE.equals(event.getType()) &&
- !Constants.ANONYMOUS_USER.equals(event.getPrincipal())) {
-
- PersistentAuditEvent persistentAuditEvent = new PersistentAuditEvent();
- persistentAuditEvent.setPrincipal(event.getPrincipal());
- persistentAuditEvent.setAuditEventType(event.getType());
- persistentAuditEvent.setAuditEventDate(event.getTimestamp());
- Map eventData = auditEventConverter.convertDataToStrings(event.getData());
- persistentAuditEvent.setData(truncate(eventData));
- persistenceAuditEventRepository.save(persistentAuditEvent);
- }
- }
-
- /**
- * Truncate event data that might exceed column length.
- */
- private Map truncate(Map data) {
- Map results = new HashMap<>();
-
- if (data != null) {
- for (Map.Entry entry : data.entrySet()) {
- String value = entry.getValue();
- if (value != null) {
- int length = value.length();
- if (length > EVENT_DATA_COLUMN_MAX_LENGTH) {
- value = value.substring(0, EVENT_DATA_COLUMN_MAX_LENGTH);
- log.warn("Event data for {} too long ({}) has been truncated to {}. Consider increasing column width.",
- entry.getKey(), length, EVENT_DATA_COLUMN_MAX_LENGTH);
- }
- }
- results.put(entry.getKey(), value);
- }
- }
- return results;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/PersistenceAuditEventRepository.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/PersistenceAuditEventRepository.java
deleted file mode 100644
index 2eb6f3b847..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/PersistenceAuditEventRepository.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.baeldung.jhipster5.repository;
-
-import com.baeldung.jhipster5.domain.PersistentAuditEvent;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.repository.JpaRepository;
-
-import java.time.Instant;
-import java.util.List;
-
-/**
- * Spring Data JPA repository for the PersistentAuditEvent entity.
- */
-public interface PersistenceAuditEventRepository extends JpaRepository {
-
- List findByPrincipal(String principal);
-
- List findByAuditEventDateAfter(Instant after);
-
- List findByPrincipalAndAuditEventDateAfter(String principal, Instant after);
-
- List findByPrincipalAndAuditEventDateAfterAndAuditEventType(String principal, Instant after, String type);
-
- Page findAllByAuditEventDateBetween(Instant fromDate, Instant toDate, Pageable pageable);
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/UserRepository.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/UserRepository.java
deleted file mode 100644
index 42a5588b22..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/UserRepository.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.baeldung.jhipster5.repository;
-
-import com.baeldung.jhipster5.domain.User;
-
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.data.jpa.repository.EntityGraph;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-import java.util.List;
-import java.util.Optional;
-import java.time.Instant;
-
-/**
- * Spring Data JPA repository for the User entity.
- */
-@Repository
-public interface UserRepository extends JpaRepository {
-
- Optional findOneByActivationKey(String activationKey);
-
- List findAllByActivatedIsFalseAndCreatedDateBefore(Instant dateTime);
-
- Optional findOneByResetKey(String resetKey);
-
- Optional findOneByEmailIgnoreCase(String email);
-
- Optional findOneByLogin(String login);
-
- @EntityGraph(attributePaths = "authorities")
- Optional findOneWithAuthoritiesById(Long id);
-
- @EntityGraph(attributePaths = "authorities")
- Optional findOneWithAuthoritiesByLogin(String login);
-
- @EntityGraph(attributePaths = "authorities")
- Optional findOneWithAuthoritiesByEmail(String email);
-
- Page findAllByLoginNot(Pageable pageable, String login);
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/package-info.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/package-info.java
deleted file mode 100644
index a5002eb201..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/repository/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Spring Data JPA repositories.
- */
-package com.baeldung.jhipster5.repository;
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/AuthoritiesConstants.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/AuthoritiesConstants.java
deleted file mode 100644
index 6ecf44394f..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/AuthoritiesConstants.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.baeldung.jhipster5.security;
-
-/**
- * Constants for Spring Security authorities.
- */
-public final class AuthoritiesConstants {
-
- public static final String ADMIN = "ROLE_ADMIN";
-
- public static final String USER = "ROLE_USER";
-
- public static final String ANONYMOUS = "ROLE_ANONYMOUS";
-
- private AuthoritiesConstants() {
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/CustomAuthenticationManager.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/CustomAuthenticationManager.java
deleted file mode 100644
index 0a7dd66b24..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/CustomAuthenticationManager.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package com.baeldung.jhipster5.security;
-
-import com.baeldung.jhipster5.domain.User;
-import com.baeldung.jhipster5.security.dto.LoginRequest;
-import com.baeldung.jhipster5.security.dto.LoginResponse;
-import com.baeldung.jhipster5.service.UserService;
-import com.baeldung.jhipster5.service.dto.UserDTO;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.ResponseEntity;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.authentication.AuthenticationServiceException;
-import org.springframework.security.authentication.BadCredentialsException;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.AuthenticationException;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
-import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.stream.Collectors;
-
-@Component
-public class CustomAuthenticationManager implements AuthenticationManager {
-
- private final static Logger LOG = LoggerFactory.getLogger(CustomAuthenticationManager.class);
-
- private final String REMOTE_LOGIN_URL = "https://example.com/login";
-
- private final RestTemplate restTemplate = new RestTemplate();
-
- @Autowired
- private UserService userService;
-
- @Override
- public Authentication authenticate(Authentication authentication) throws AuthenticationException {
-
- LoginRequest loginRequest = new LoginRequest();
- loginRequest.setUsername(authentication.getPrincipal().toString());
- loginRequest.setPassword(authentication.getCredentials().toString());
-
- try
- {
- ResponseEntity response =
- restTemplate.postForEntity(
- REMOTE_LOGIN_URL,
- loginRequest,
- LoginResponse.class);
-
- if(response.getStatusCode().is2xxSuccessful())
- {
- //
- // Need to create a new local user if this is the first time logging in; this
- // is required so they can be issued JWTs. We can use this flow to also keep
- // our local use entry up to date with data from the remote service if needed
- // (for example, if the first and last name might change, this is where we would
- // update the local user entry)
- //
-
- User user = userService.getUserWithAuthoritiesByLogin(authentication.getPrincipal().toString())
- .orElseGet(() -> userService.createUser(createUserDTO(response.getBody(), authentication)));
- return createAuthentication(authentication, user);
- }
- else
- {
- throw new BadCredentialsException("Invalid username or password");
- }
- }
- catch (Exception e)
- {
- LOG.warn("Failed to authenticate", e);
- throw new AuthenticationServiceException("Failed to login", e);
- }
- }
-
- /**
- * Creates a new authentication with basic roles
- * @param auth Contains auth details that will be copied into the new one.
- * @param user User object representing who is logging in
- * @return Authentication
- */
- private Authentication createAuthentication(Authentication auth, User user) {
-
- //
- // Honor any roles the user already has set; default is just USER role
- // but could be modified after account creation
- //
-
- Collection extends GrantedAuthority> authorities = user
- .getAuthorities()
- .stream()
- .map(a -> new SimpleGrantedAuthority(a.getName()))
- .collect(Collectors.toSet());
-
- UsernamePasswordAuthenticationToken token
- = new UsernamePasswordAuthenticationToken(
- user.getId(),
- auth.getCredentials().toString(),
- authorities);
-
- return token;
- }
-
- /**
- * Creates a new UserDTO with basic info.
- * @param loginResponse Response from peloton login API
- * @param authentication Contains user login info (namely username and password)
- * @return UserDTO
- */
- private UserDTO createUserDTO(LoginResponse loginResponse, Authentication authentication) {
-
- UserDTO dto = new UserDTO();
-
- dto.setActivated(true);
- dto.setEmail(loginResponse.getEmail());
- dto.setAuthorities(Collections.singleton(AuthoritiesConstants.USER));
- dto.setFirstName(loginResponse.getFirstName());
- dto.setLastName(loginResponse.getLastName());
-
- return dto;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/DomainUserDetailsService.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/DomainUserDetailsService.java
deleted file mode 100644
index d0014096df..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/DomainUserDetailsService.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.baeldung.jhipster5.security;
-
-import com.baeldung.jhipster5.domain.User;
-import com.baeldung.jhipster5.repository.UserRepository;
-import org.hibernate.validator.internal.constraintvalidators.hv.EmailValidator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
-import org.springframework.security.core.userdetails.UserDetails;
-import org.springframework.security.core.userdetails.UserDetailsService;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.stereotype.Component;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * Authenticate a user from the database.
- */
-@Component("userDetailsService")
-public class DomainUserDetailsService implements UserDetailsService {
-
- private final Logger log = LoggerFactory.getLogger(DomainUserDetailsService.class);
-
- private final UserRepository userRepository;
-
- public DomainUserDetailsService(UserRepository userRepository) {
- this.userRepository = userRepository;
- }
-
- @Override
- @Transactional
- public UserDetails loadUserByUsername(final String login) {
- log.debug("Authenticating {}", login);
-
- if (new EmailValidator().isValid(login, null)) {
- return userRepository.findOneWithAuthoritiesByEmail(login)
- .map(user -> createSpringSecurityUser(login, user))
- .orElseThrow(() -> new UsernameNotFoundException("User with email " + login + " was not found in the database"));
- }
-
- String lowercaseLogin = login.toLowerCase(Locale.ENGLISH);
- return userRepository.findOneWithAuthoritiesByLogin(lowercaseLogin)
- .map(user -> createSpringSecurityUser(lowercaseLogin, user))
- .orElseThrow(() -> new UsernameNotFoundException("User " + lowercaseLogin + " was not found in the database"));
-
- }
-
- private org.springframework.security.core.userdetails.User createSpringSecurityUser(String lowercaseLogin, User user) {
- if (!user.getActivated()) {
- throw new UserNotActivatedException("User " + lowercaseLogin + " was not activated");
- }
- List grantedAuthorities = user.getAuthorities().stream()
- .map(authority -> new SimpleGrantedAuthority(authority.getName()))
- .collect(Collectors.toList());
- return new org.springframework.security.core.userdetails.User(user.getLogin(),
- user.getPassword(),
- grantedAuthorities);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/SecurityUtils.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/SecurityUtils.java
deleted file mode 100644
index 462bb8abc9..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/SecurityUtils.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.baeldung.jhipster5.security;
-
-import org.springframework.security.core.context.SecurityContext;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.core.userdetails.UserDetails;
-
-import java.util.Optional;
-
-/**
- * Utility class for Spring Security.
- */
-public final class SecurityUtils {
-
- private SecurityUtils() {
- }
-
- /**
- * Get the login of the current user.
- *
- * @return the login of the current user
- */
- public static Optional getCurrentUserLogin() {
- SecurityContext securityContext = SecurityContextHolder.getContext();
- return Optional.ofNullable(securityContext.getAuthentication())
- .map(authentication -> {
- if (authentication.getPrincipal() instanceof UserDetails) {
- UserDetails springSecurityUser = (UserDetails) authentication.getPrincipal();
- return springSecurityUser.getUsername();
- } else if (authentication.getPrincipal() instanceof String) {
- return (String) authentication.getPrincipal();
- }
- return null;
- });
- }
-
- /**
- * Get the JWT of the current user.
- *
- * @return the JWT of the current user
- */
- public static Optional getCurrentUserJWT() {
- SecurityContext securityContext = SecurityContextHolder.getContext();
- return Optional.ofNullable(securityContext.getAuthentication())
- .filter(authentication -> authentication.getCredentials() instanceof String)
- .map(authentication -> (String) authentication.getCredentials());
- }
-
- /**
- * Check if a user is authenticated.
- *
- * @return true if the user is authenticated, false otherwise
- */
- public static boolean isAuthenticated() {
- SecurityContext securityContext = SecurityContextHolder.getContext();
- return Optional.ofNullable(securityContext.getAuthentication())
- .map(authentication -> authentication.getAuthorities().stream()
- .noneMatch(grantedAuthority -> grantedAuthority.getAuthority().equals(AuthoritiesConstants.ANONYMOUS)))
- .orElse(false);
- }
-
- /**
- * If the current user has a specific authority (security role).
- *
- * The name of this method comes from the isUserInRole() method in the Servlet API
- *
- * @param authority the authority to check
- * @return true if the current user has the authority, false otherwise
- */
- public static boolean isCurrentUserInRole(String authority) {
- SecurityContext securityContext = SecurityContextHolder.getContext();
- return Optional.ofNullable(securityContext.getAuthentication())
- .map(authentication -> authentication.getAuthorities().stream()
- .anyMatch(grantedAuthority -> grantedAuthority.getAuthority().equals(authority)))
- .orElse(false);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/SpringSecurityAuditorAware.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/SpringSecurityAuditorAware.java
deleted file mode 100644
index c1d6405ae3..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/SpringSecurityAuditorAware.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.baeldung.jhipster5.security;
-
-import com.baeldung.jhipster5.config.Constants;
-
-import java.util.Optional;
-
-import org.springframework.data.domain.AuditorAware;
-import org.springframework.stereotype.Component;
-
-/**
- * Implementation of AuditorAware based on Spring Security.
- */
-@Component
-public class SpringSecurityAuditorAware implements AuditorAware {
-
- @Override
- public Optional getCurrentAuditor() {
- return Optional.of(SecurityUtils.getCurrentUserLogin().orElse(Constants.SYSTEM_ACCOUNT));
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/UserNotActivatedException.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/UserNotActivatedException.java
deleted file mode 100644
index 4b2d91983c..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/UserNotActivatedException.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package com.baeldung.jhipster5.security;
-
-import org.springframework.security.core.AuthenticationException;
-
-/**
- * This exception is thrown in case of a not activated user trying to authenticate.
- */
-public class UserNotActivatedException extends AuthenticationException {
-
- private static final long serialVersionUID = 1L;
-
- public UserNotActivatedException(String message) {
- super(message);
- }
-
- public UserNotActivatedException(String message, Throwable t) {
- super(message, t);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/dto/LoginRequest.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/dto/LoginRequest.java
deleted file mode 100644
index f45c23fa39..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/dto/LoginRequest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.baeldung.jhipster5.security.dto;
-
-/**
- * Simple DTO representing a login request to a remote service.
- */
-public class LoginRequest {
-
- private String username;
-
- private String password;
-
- public LoginRequest() {
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/dto/LoginResponse.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/dto/LoginResponse.java
deleted file mode 100644
index ad1fe37a2f..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/dto/LoginResponse.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.baeldung.jhipster5.security.dto;
-
-/**
- * Simple DTO representing the response of logging in using a remote service.
- */
-public class LoginResponse {
-
- private String username;
-
- private String firstName;
-
- private String lastName;
-
- private String email;
-
- public LoginResponse() {
- }
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/jwt/JWTConfigurer.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/jwt/JWTConfigurer.java
deleted file mode 100644
index 944255e37d..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/jwt/JWTConfigurer.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.baeldung.jhipster5.security.jwt;
-
-import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.web.DefaultSecurityFilterChain;
-import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
-
-public class JWTConfigurer extends SecurityConfigurerAdapter {
-
- private TokenProvider tokenProvider;
-
- public JWTConfigurer(TokenProvider tokenProvider) {
- this.tokenProvider = tokenProvider;
- }
-
- @Override
- public void configure(HttpSecurity http) throws Exception {
- JWTFilter customFilter = new JWTFilter(tokenProvider);
- http.addFilterBefore(customFilter, UsernamePasswordAuthenticationFilter.class);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/jwt/JWTFilter.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/jwt/JWTFilter.java
deleted file mode 100644
index cf1060282c..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/jwt/JWTFilter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.baeldung.jhipster5.security.jwt;
-
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.util.StringUtils;
-import org.springframework.web.filter.GenericFilterBean;
-
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-
-/**
- * Filters incoming requests and installs a Spring Security principal if a header corresponding to a valid user is
- * found.
- */
-public class JWTFilter extends GenericFilterBean {
-
- public static final String AUTHORIZATION_HEADER = "Authorization";
-
- private TokenProvider tokenProvider;
-
- public JWTFilter(TokenProvider tokenProvider) {
- this.tokenProvider = tokenProvider;
- }
-
- @Override
- public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
- throws IOException, ServletException {
- HttpServletRequest httpServletRequest = (HttpServletRequest) servletRequest;
- String jwt = resolveToken(httpServletRequest);
- if (StringUtils.hasText(jwt) && this.tokenProvider.validateToken(jwt)) {
- Authentication authentication = this.tokenProvider.getAuthentication(jwt);
- SecurityContextHolder.getContext().setAuthentication(authentication);
- }
- filterChain.doFilter(servletRequest, servletResponse);
- }
-
- private String resolveToken(HttpServletRequest request){
- String bearerToken = request.getHeader(AUTHORIZATION_HEADER);
- if (StringUtils.hasText(bearerToken) && bearerToken.startsWith("Bearer ")) {
- return bearerToken.substring(7);
- }
- return null;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/jwt/TokenProvider.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/jwt/TokenProvider.java
deleted file mode 100644
index 248d45e050..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/jwt/TokenProvider.java
+++ /dev/null
@@ -1,119 +0,0 @@
-package com.baeldung.jhipster5.security.jwt;
-
-import java.nio.charset.StandardCharsets;
-import java.security.Key;
-import java.util.*;
-import java.util.stream.Collectors;
-import javax.annotation.PostConstruct;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.authority.SimpleGrantedAuthority;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.stereotype.Component;
-import org.springframework.util.StringUtils;
-
-import io.github.jhipster.config.JHipsterProperties;
-import io.jsonwebtoken.*;
-import io.jsonwebtoken.io.Decoders;
-import io.jsonwebtoken.security.Keys;
-
-@Component
-public class TokenProvider {
-
- private final Logger log = LoggerFactory.getLogger(TokenProvider.class);
-
- private static final String AUTHORITIES_KEY = "auth";
-
- private Key key;
-
- private long tokenValidityInMilliseconds;
-
- private long tokenValidityInMillisecondsForRememberMe;
-
- private final JHipsterProperties jHipsterProperties;
-
- public TokenProvider(JHipsterProperties jHipsterProperties) {
- this.jHipsterProperties = jHipsterProperties;
- }
-
- @PostConstruct
- public void init() {
- byte[] keyBytes;
- String secret = jHipsterProperties.getSecurity().getAuthentication().getJwt().getSecret();
- if (!StringUtils.isEmpty(secret)) {
- log.warn("Warning: the JWT key used is not Base64-encoded. " +
- "We recommend using the `jhipster.security.authentication.jwt.base64-secret` key for optimum security.");
- keyBytes = secret.getBytes(StandardCharsets.UTF_8);
- } else {
- log.debug("Using a Base64-encoded JWT secret key");
- keyBytes = Decoders.BASE64.decode(jHipsterProperties.getSecurity().getAuthentication().getJwt().getBase64Secret());
- }
- this.key = Keys.hmacShaKeyFor(keyBytes);
- this.tokenValidityInMilliseconds =
- 1000 * jHipsterProperties.getSecurity().getAuthentication().getJwt().getTokenValidityInSeconds();
- this.tokenValidityInMillisecondsForRememberMe =
- 1000 * jHipsterProperties.getSecurity().getAuthentication().getJwt()
- .getTokenValidityInSecondsForRememberMe();
- }
-
- public String createToken(Authentication authentication, boolean rememberMe) {
- String authorities = authentication.getAuthorities().stream()
- .map(GrantedAuthority::getAuthority)
- .collect(Collectors.joining(","));
-
- long now = (new Date()).getTime();
- Date validity;
- if (rememberMe) {
- validity = new Date(now + this.tokenValidityInMillisecondsForRememberMe);
- } else {
- validity = new Date(now + this.tokenValidityInMilliseconds);
- }
-
- return Jwts.builder()
- .setSubject(authentication.getName())
- .claim(AUTHORITIES_KEY, authorities)
- .signWith(key, SignatureAlgorithm.HS512)
- .setExpiration(validity)
- .compact();
- }
-
- public Authentication getAuthentication(String token) {
- Claims claims = Jwts.parser()
- .setSigningKey(key)
- .parseClaimsJws(token)
- .getBody();
-
- Collection extends GrantedAuthority> authorities =
- Arrays.stream(claims.get(AUTHORITIES_KEY).toString().split(","))
- .map(SimpleGrantedAuthority::new)
- .collect(Collectors.toList());
-
- User principal = new User(claims.getSubject(), "", authorities);
-
- return new UsernamePasswordAuthenticationToken(principal, token, authorities);
- }
-
- public boolean validateToken(String authToken) {
- try {
- Jwts.parser().setSigningKey(key).parseClaimsJws(authToken);
- return true;
- } catch (io.jsonwebtoken.security.SecurityException | MalformedJwtException e) {
- log.info("Invalid JWT signature.");
- log.trace("Invalid JWT signature trace: {}", e);
- } catch (ExpiredJwtException e) {
- log.info("Expired JWT token.");
- log.trace("Expired JWT token trace: {}", e);
- } catch (UnsupportedJwtException e) {
- log.info("Unsupported JWT token.");
- log.trace("Unsupported JWT token trace: {}", e);
- } catch (IllegalArgumentException e) {
- log.info("JWT token compact of handler are invalid.");
- log.trace("JWT token compact of handler are invalid trace: {}", e);
- }
- return false;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/package-info.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/package-info.java
deleted file mode 100644
index 4759050c56..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/security/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Spring Security configuration.
- */
-package com.baeldung.jhipster5.security;
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/AuditEventService.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/AuditEventService.java
deleted file mode 100644
index 852eb951c9..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/AuditEventService.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.baeldung.jhipster5.service;
-
-import com.baeldung.jhipster5.config.audit.AuditEventConverter;
-import com.baeldung.jhipster5.repository.PersistenceAuditEventRepository;
-import org.springframework.boot.actuate.audit.AuditEvent;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.time.Instant;
-import java.util.Optional;
-
-/**
- * Service for managing audit events.
- *
- * This is the default implementation to support SpringBoot Actuator AuditEventRepository
- */
-@Service
-@Transactional
-public class AuditEventService {
-
- private final PersistenceAuditEventRepository persistenceAuditEventRepository;
-
- private final AuditEventConverter auditEventConverter;
-
- public AuditEventService(
- PersistenceAuditEventRepository persistenceAuditEventRepository,
- AuditEventConverter auditEventConverter) {
-
- this.persistenceAuditEventRepository = persistenceAuditEventRepository;
- this.auditEventConverter = auditEventConverter;
- }
-
- public Page findAll(Pageable pageable) {
- return persistenceAuditEventRepository.findAll(pageable)
- .map(auditEventConverter::convertToAuditEvent);
- }
-
- public Page findByDates(Instant fromDate, Instant toDate, Pageable pageable) {
- return persistenceAuditEventRepository.findAllByAuditEventDateBetween(fromDate, toDate, pageable)
- .map(auditEventConverter::convertToAuditEvent);
- }
-
- public Optional find(Long id) {
- return Optional.ofNullable(persistenceAuditEventRepository.findById(id))
- .filter(Optional::isPresent)
- .map(Optional::get)
- .map(auditEventConverter::convertToAuditEvent);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/BookService.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/BookService.java
deleted file mode 100644
index 6422d1a424..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/BookService.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.baeldung.jhipster5.service;
-
-import com.baeldung.jhipster5.service.dto.BookDTO;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * Service Interface for managing Book.
- */
-public interface BookService {
-
- /**
- * Save a book.
- *
- * @param bookDTO the entity to save
- * @return the persisted entity
- */
- BookDTO save(BookDTO bookDTO);
-
- /**
- * Get all the books.
- *
- * @return the list of entities
- */
- List findAll();
-
-
- /**
- * Get the "id" book.
- *
- * @param id the id of the entity
- * @return the entity
- */
- Optional findOne(Long id);
-
- /**
- * Delete the "id" book.
- *
- * @param id the id of the entity
- */
- void delete(Long id);
-
- /**
- * Simulates purchasing a book by reducing the stock of a book by 1.
- * @param id the id of the book
- * @return Updated BookDTO, empty if not found, or throws exception if an error occurs.
- */
- Optional purchase(Long id);
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/MailService.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/MailService.java
deleted file mode 100644
index b15a7faff2..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/MailService.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package com.baeldung.jhipster5.service;
-
-import com.baeldung.jhipster5.domain.User;
-
-import io.github.jhipster.config.JHipsterProperties;
-
-import java.nio.charset.StandardCharsets;
-import java.util.Locale;
-import javax.mail.internet.MimeMessage;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.context.MessageSource;
-import org.springframework.mail.javamail.JavaMailSender;
-import org.springframework.mail.javamail.MimeMessageHelper;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Service;
-import org.thymeleaf.context.Context;
-import org.thymeleaf.spring5.SpringTemplateEngine;
-
-/**
- * Service for sending emails.
- *
- * We use the @Async annotation to send emails asynchronously.
- */
-@Service
-public class MailService {
-
- private final Logger log = LoggerFactory.getLogger(MailService.class);
-
- private static final String USER = "user";
-
- private static final String BASE_URL = "baseUrl";
-
- private final JHipsterProperties jHipsterProperties;
-
- private final JavaMailSender javaMailSender;
-
- private final MessageSource messageSource;
-
- private final SpringTemplateEngine templateEngine;
-
- public MailService(JHipsterProperties jHipsterProperties, JavaMailSender javaMailSender,
- MessageSource messageSource, SpringTemplateEngine templateEngine) {
-
- this.jHipsterProperties = jHipsterProperties;
- this.javaMailSender = javaMailSender;
- this.messageSource = messageSource;
- this.templateEngine = templateEngine;
- }
-
- @Async
- public void sendEmail(String to, String subject, String content, boolean isMultipart, boolean isHtml) {
- log.debug("Send email[multipart '{}' and html '{}'] to '{}' with subject '{}' and content={}",
- isMultipart, isHtml, to, subject, content);
-
- // Prepare message using a Spring helper
- MimeMessage mimeMessage = javaMailSender.createMimeMessage();
- try {
- MimeMessageHelper message = new MimeMessageHelper(mimeMessage, isMultipart, StandardCharsets.UTF_8.name());
- message.setTo(to);
- message.setFrom(jHipsterProperties.getMail().getFrom());
- message.setSubject(subject);
- message.setText(content, isHtml);
- javaMailSender.send(mimeMessage);
- log.debug("Sent email to User '{}'", to);
- } catch (Exception e) {
- if (log.isDebugEnabled()) {
- log.warn("Email could not be sent to user '{}'", to, e);
- } else {
- log.warn("Email could not be sent to user '{}': {}", to, e.getMessage());
- }
- }
- }
-
- @Async
- public void sendEmailFromTemplate(User user, String templateName, String titleKey) {
- Locale locale = Locale.forLanguageTag(user.getLangKey());
- Context context = new Context(locale);
- context.setVariable(USER, user);
- context.setVariable(BASE_URL, jHipsterProperties.getMail().getBaseUrl());
- String content = templateEngine.process(templateName, context);
- String subject = messageSource.getMessage(titleKey, null, locale);
- sendEmail(user.getEmail(), subject, content, false, true);
-
- }
-
- @Async
- public void sendActivationEmail(User user) {
- log.debug("Sending activation email to '{}'", user.getEmail());
- sendEmailFromTemplate(user, "mail/activationEmail", "email.activation.title");
- }
-
- @Async
- public void sendCreationEmail(User user) {
- log.debug("Sending creation email to '{}'", user.getEmail());
- sendEmailFromTemplate(user, "mail/creationEmail", "email.activation.title");
- }
-
- @Async
- public void sendPasswordResetMail(User user) {
- log.debug("Sending password reset email to '{}'", user.getEmail());
- sendEmailFromTemplate(user, "mail/passwordResetEmail", "email.reset.title");
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/UserService.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/UserService.java
deleted file mode 100644
index 82d028f3ca..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/UserService.java
+++ /dev/null
@@ -1,273 +0,0 @@
-package com.baeldung.jhipster5.service;
-
-import com.baeldung.jhipster5.config.Constants;
-import com.baeldung.jhipster5.domain.Authority;
-import com.baeldung.jhipster5.domain.User;
-import com.baeldung.jhipster5.repository.AuthorityRepository;
-import com.baeldung.jhipster5.repository.UserRepository;
-import com.baeldung.jhipster5.security.AuthoritiesConstants;
-import com.baeldung.jhipster5.security.SecurityUtils;
-import com.baeldung.jhipster5.service.dto.UserDTO;
-import com.baeldung.jhipster5.service.util.RandomUtil;
-import com.baeldung.jhipster5.web.rest.errors.*;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.security.crypto.password.PasswordEncoder;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.time.Instant;
-import java.time.temporal.ChronoUnit;
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * Service class for managing users.
- */
-@Service
-@Transactional
-public class UserService {
-
- private final Logger log = LoggerFactory.getLogger(UserService.class);
-
- private final UserRepository userRepository;
-
- private final PasswordEncoder passwordEncoder;
-
- private final AuthorityRepository authorityRepository;
-
- public UserService(UserRepository userRepository, PasswordEncoder passwordEncoder, AuthorityRepository authorityRepository) {
- this.userRepository = userRepository;
- this.passwordEncoder = passwordEncoder;
- this.authorityRepository = authorityRepository;
- }
-
- public Optional activateRegistration(String key) {
- log.debug("Activating user for activation key {}", key);
- return userRepository.findOneByActivationKey(key)
- .map(user -> {
- // activate given user for the registration key.
- user.setActivated(true);
- user.setActivationKey(null);
- log.debug("Activated user: {}", user);
- return user;
- });
- }
-
- public Optional completePasswordReset(String newPassword, String key) {
- log.debug("Reset user password for reset key {}", key);
- return userRepository.findOneByResetKey(key)
- .filter(user -> user.getResetDate().isAfter(Instant.now().minusSeconds(86400)))
- .map(user -> {
- user.setPassword(passwordEncoder.encode(newPassword));
- user.setResetKey(null);
- user.setResetDate(null);
- return user;
- });
- }
-
- public Optional requestPasswordReset(String mail) {
- return userRepository.findOneByEmailIgnoreCase(mail)
- .filter(User::getActivated)
- .map(user -> {
- user.setResetKey(RandomUtil.generateResetKey());
- user.setResetDate(Instant.now());
- return user;
- });
- }
-
- public User registerUser(UserDTO userDTO, String password) {
- userRepository.findOneByLogin(userDTO.getLogin().toLowerCase()).ifPresent(existingUser -> {
- boolean removed = removeNonActivatedUser(existingUser);
- if (!removed) {
- throw new LoginAlreadyUsedException();
- }
- });
- userRepository.findOneByEmailIgnoreCase(userDTO.getEmail()).ifPresent(existingUser -> {
- boolean removed = removeNonActivatedUser(existingUser);
- if (!removed) {
- throw new EmailAlreadyUsedException();
- }
- });
- User newUser = new User();
- String encryptedPassword = passwordEncoder.encode(password);
- newUser.setLogin(userDTO.getLogin().toLowerCase());
- // new user gets initially a generated password
- newUser.setPassword(encryptedPassword);
- newUser.setFirstName(userDTO.getFirstName());
- newUser.setLastName(userDTO.getLastName());
- newUser.setEmail(userDTO.getEmail().toLowerCase());
- newUser.setImageUrl(userDTO.getImageUrl());
- newUser.setLangKey(userDTO.getLangKey());
- // new user is not active
- newUser.setActivated(false);
- // new user gets registration key
- newUser.setActivationKey(RandomUtil.generateActivationKey());
- Set authorities = new HashSet<>();
- authorityRepository.findById(AuthoritiesConstants.USER).ifPresent(authorities::add);
- newUser.setAuthorities(authorities);
- userRepository.save(newUser);
- log.debug("Created Information for User: {}", newUser);
- return newUser;
- }
-
- private boolean removeNonActivatedUser(User existingUser){
- if (existingUser.getActivated()) {
- return false;
- }
- userRepository.delete(existingUser);
- userRepository.flush();
- return true;
- }
-
- public User createUser(UserDTO userDTO) {
- User user = new User();
- user.setLogin(userDTO.getLogin().toLowerCase());
- user.setFirstName(userDTO.getFirstName());
- user.setLastName(userDTO.getLastName());
- user.setEmail(userDTO.getEmail().toLowerCase());
- user.setImageUrl(userDTO.getImageUrl());
- if (userDTO.getLangKey() == null) {
- user.setLangKey(Constants.DEFAULT_LANGUAGE); // default language
- } else {
- user.setLangKey(userDTO.getLangKey());
- }
- String encryptedPassword = passwordEncoder.encode(RandomUtil.generatePassword());
- user.setPassword(encryptedPassword);
- user.setResetKey(RandomUtil.generateResetKey());
- user.setResetDate(Instant.now());
- user.setActivated(true);
- if (userDTO.getAuthorities() != null) {
- Set authorities = userDTO.getAuthorities().stream()
- .map(authorityRepository::findById)
- .filter(Optional::isPresent)
- .map(Optional::get)
- .collect(Collectors.toSet());
- user.setAuthorities(authorities);
- }
- userRepository.save(user);
- log.debug("Created Information for User: {}", user);
- return user;
- }
-
- /**
- * Update basic information (first name, last name, email, language) for the current user.
- *
- * @param firstName first name of user
- * @param lastName last name of user
- * @param email email id of user
- * @param langKey language key
- * @param imageUrl image URL of user
- */
- public void updateUser(String firstName, String lastName, String email, String langKey, String imageUrl) {
- SecurityUtils.getCurrentUserLogin()
- .flatMap(userRepository::findOneByLogin)
- .ifPresent(user -> {
- user.setFirstName(firstName);
- user.setLastName(lastName);
- user.setEmail(email.toLowerCase());
- user.setLangKey(langKey);
- user.setImageUrl(imageUrl);
- log.debug("Changed Information for User: {}", user);
- });
- }
-
- /**
- * Update all information for a specific user, and return the modified user.
- *
- * @param userDTO user to update
- * @return updated user
- */
- public Optional updateUser(UserDTO userDTO) {
- return Optional.of(userRepository
- .findById(userDTO.getId()))
- .filter(Optional::isPresent)
- .map(Optional::get)
- .map(user -> {
- user.setLogin(userDTO.getLogin().toLowerCase());
- user.setFirstName(userDTO.getFirstName());
- user.setLastName(userDTO.getLastName());
- user.setEmail(userDTO.getEmail().toLowerCase());
- user.setImageUrl(userDTO.getImageUrl());
- user.setActivated(userDTO.isActivated());
- user.setLangKey(userDTO.getLangKey());
- Set managedAuthorities = user.getAuthorities();
- managedAuthorities.clear();
- userDTO.getAuthorities().stream()
- .map(authorityRepository::findById)
- .filter(Optional::isPresent)
- .map(Optional::get)
- .forEach(managedAuthorities::add);
- log.debug("Changed Information for User: {}", user);
- return user;
- })
- .map(UserDTO::new);
- }
-
- public void deleteUser(String login) {
- userRepository.findOneByLogin(login).ifPresent(user -> {
- userRepository.delete(user);
- log.debug("Deleted User: {}", user);
- });
- }
-
- public void changePassword(String currentClearTextPassword, String newPassword) {
- SecurityUtils.getCurrentUserLogin()
- .flatMap(userRepository::findOneByLogin)
- .ifPresent(user -> {
- String currentEncryptedPassword = user.getPassword();
- if (!passwordEncoder.matches(currentClearTextPassword, currentEncryptedPassword)) {
- throw new InvalidPasswordException();
- }
- String encryptedPassword = passwordEncoder.encode(newPassword);
- user.setPassword(encryptedPassword);
- log.debug("Changed password for User: {}", user);
- });
- }
-
- @Transactional(readOnly = true)
- public Page getAllManagedUsers(Pageable pageable) {
- return userRepository.findAllByLoginNot(pageable, Constants.ANONYMOUS_USER).map(UserDTO::new);
- }
-
- @Transactional(readOnly = true)
- public Optional getUserWithAuthoritiesByLogin(String login) {
- return userRepository.findOneWithAuthoritiesByLogin(login);
- }
-
- @Transactional(readOnly = true)
- public Optional getUserWithAuthorities(Long id) {
- return userRepository.findOneWithAuthoritiesById(id);
- }
-
- @Transactional(readOnly = true)
- public Optional getUserWithAuthorities() {
- return SecurityUtils.getCurrentUserLogin().flatMap(userRepository::findOneWithAuthoritiesByLogin);
- }
-
- /**
- * Not activated users should be automatically deleted after 3 days.
- *
- * This is scheduled to get fired everyday, at 01:00 (am).
- */
- @Scheduled(cron = "0 0 1 * * ?")
- public void removeNotActivatedUsers() {
- userRepository
- .findAllByActivatedIsFalseAndCreatedDateBefore(Instant.now().minus(3, ChronoUnit.DAYS))
- .forEach(user -> {
- log.debug("Deleting not activated user {}", user.getLogin());
- userRepository.delete(user);
- });
- }
-
- /**
- * @return a list of all the authorities
- */
- public List getAuthorities() {
- return authorityRepository.findAll().stream().map(Authority::getName).collect(Collectors.toList());
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/dto/BookDTO.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/dto/BookDTO.java
deleted file mode 100644
index 5aa550e989..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/dto/BookDTO.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package com.baeldung.jhipster5.service.dto;
-import java.time.LocalDate;
-import javax.validation.constraints.*;
-import java.io.Serializable;
-import java.util.Objects;
-
-/**
- * A DTO for the Book entity.
- */
-public class BookDTO implements Serializable {
-
- private Long id;
-
- @NotNull
- private String title;
-
- @NotNull
- private String author;
-
- @NotNull
- private LocalDate published;
-
- @NotNull
- @Min(value = 0)
- private Integer quantity;
-
- @NotNull
- @DecimalMin(value = "0")
- private Double price;
-
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public String getAuthor() {
- return author;
- }
-
- public void setAuthor(String author) {
- this.author = author;
- }
-
- public LocalDate getPublished() {
- return published;
- }
-
- public void setPublished(LocalDate published) {
- this.published = published;
- }
-
- public Integer getQuantity() {
- return quantity;
- }
-
- public void setQuantity(Integer quantity) {
- this.quantity = quantity;
- }
-
- public Double getPrice() {
- return price;
- }
-
- public void setPrice(Double price) {
- this.price = price;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- BookDTO bookDTO = (BookDTO) o;
- if (bookDTO.getId() == null || getId() == null) {
- return false;
- }
- return Objects.equals(getId(), bookDTO.getId());
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(getId());
- }
-
- @Override
- public String toString() {
- return "BookDTO{" +
- "id=" + getId() +
- ", title='" + getTitle() + "'" +
- ", author='" + getAuthor() + "'" +
- ", published='" + getPublished() + "'" +
- ", quantity=" + getQuantity() +
- ", price=" + getPrice() +
- "}";
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/dto/PasswordChangeDTO.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/dto/PasswordChangeDTO.java
deleted file mode 100644
index 0711c97f44..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/dto/PasswordChangeDTO.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.baeldung.jhipster5.service.dto;
-
-/**
- * A DTO representing a password change required data - current and new password.
- */
-public class PasswordChangeDTO {
- private String currentPassword;
- private String newPassword;
-
- public PasswordChangeDTO() {
- // Empty constructor needed for Jackson.
- }
-
- public PasswordChangeDTO(String currentPassword, String newPassword) {
- this.currentPassword = currentPassword;
- this.newPassword = newPassword;
- }
-
- public String getCurrentPassword() {
-
- return currentPassword;
- }
-
- public void setCurrentPassword(String currentPassword) {
- this.currentPassword = currentPassword;
- }
-
- public String getNewPassword() {
- return newPassword;
- }
-
- public void setNewPassword(String newPassword) {
- this.newPassword = newPassword;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/dto/UserDTO.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/dto/UserDTO.java
deleted file mode 100644
index 9142b3825e..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/dto/UserDTO.java
+++ /dev/null
@@ -1,199 +0,0 @@
-package com.baeldung.jhipster5.service.dto;
-
-import com.baeldung.jhipster5.config.Constants;
-
-import com.baeldung.jhipster5.domain.Authority;
-import com.baeldung.jhipster5.domain.User;
-
-import javax.validation.constraints.Email;
-import javax.validation.constraints.NotBlank;
-
-import javax.validation.constraints.*;
-import java.time.Instant;
-import java.util.Set;
-import java.util.stream.Collectors;
-
-/**
- * A DTO representing a user, with his authorities.
- */
-public class UserDTO {
-
- private Long id;
-
- @NotBlank
- @Pattern(regexp = Constants.LOGIN_REGEX)
- @Size(min = 1, max = 50)
- private String login;
-
- @Size(max = 50)
- private String firstName;
-
- @Size(max = 50)
- private String lastName;
-
- @Email
- @Size(min = 5, max = 254)
- private String email;
-
- @Size(max = 256)
- private String imageUrl;
-
- private boolean activated = false;
-
- @Size(min = 2, max = 6)
- private String langKey;
-
- private String createdBy;
-
- private Instant createdDate;
-
- private String lastModifiedBy;
-
- private Instant lastModifiedDate;
-
- private Set authorities;
-
- public UserDTO() {
- // Empty constructor needed for Jackson.
- }
-
- public UserDTO(User user) {
- this.id = user.getId();
- this.login = user.getLogin();
- this.firstName = user.getFirstName();
- this.lastName = user.getLastName();
- this.email = user.getEmail();
- this.activated = user.getActivated();
- this.imageUrl = user.getImageUrl();
- this.langKey = user.getLangKey();
- this.createdBy = user.getCreatedBy();
- this.createdDate = user.getCreatedDate();
- this.lastModifiedBy = user.getLastModifiedBy();
- this.lastModifiedDate = user.getLastModifiedDate();
- this.authorities = user.getAuthorities().stream()
- .map(Authority::getName)
- .collect(Collectors.toSet());
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getLogin() {
- return login;
- }
-
- public void setLogin(String login) {
- this.login = login;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getImageUrl() {
- return imageUrl;
- }
-
- public void setImageUrl(String imageUrl) {
- this.imageUrl = imageUrl;
- }
-
- public boolean isActivated() {
- return activated;
- }
-
- public void setActivated(boolean activated) {
- this.activated = activated;
- }
-
- public String getLangKey() {
- return langKey;
- }
-
- public void setLangKey(String langKey) {
- this.langKey = langKey;
- }
-
- public String getCreatedBy() {
- return createdBy;
- }
-
- public void setCreatedBy(String createdBy) {
- this.createdBy = createdBy;
- }
-
- public Instant getCreatedDate() {
- return createdDate;
- }
-
- public void setCreatedDate(Instant createdDate) {
- this.createdDate = createdDate;
- }
-
- public String getLastModifiedBy() {
- return lastModifiedBy;
- }
-
- public void setLastModifiedBy(String lastModifiedBy) {
- this.lastModifiedBy = lastModifiedBy;
- }
-
- public Instant getLastModifiedDate() {
- return lastModifiedDate;
- }
-
- public void setLastModifiedDate(Instant lastModifiedDate) {
- this.lastModifiedDate = lastModifiedDate;
- }
-
- public Set getAuthorities() {
- return authorities;
- }
-
- public void setAuthorities(Set authorities) {
- this.authorities = authorities;
- }
-
- @Override
- public String toString() {
- return "UserDTO{" +
- "login='" + login + '\'' +
- ", firstName='" + firstName + '\'' +
- ", lastName='" + lastName + '\'' +
- ", email='" + email + '\'' +
- ", imageUrl='" + imageUrl + '\'' +
- ", activated=" + activated +
- ", langKey='" + langKey + '\'' +
- ", createdBy=" + createdBy +
- ", createdDate=" + createdDate +
- ", lastModifiedBy='" + lastModifiedBy + '\'' +
- ", lastModifiedDate=" + lastModifiedDate +
- ", authorities=" + authorities +
- "}";
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/dto/package-info.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/dto/package-info.java
deleted file mode 100644
index 87951796ea..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/dto/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Data Transfer Objects.
- */
-package com.baeldung.jhipster5.service.dto;
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/impl/BookServiceImpl.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/impl/BookServiceImpl.java
deleted file mode 100644
index 23cd59584c..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/impl/BookServiceImpl.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package com.baeldung.jhipster5.service.impl;
-
-import com.baeldung.jhipster5.service.BookService;
-import com.baeldung.jhipster5.domain.Book;
-import com.baeldung.jhipster5.repository.BookRepository;
-import com.baeldung.jhipster5.service.dto.BookDTO;
-import com.baeldung.jhipster5.service.mapper.BookMapper;
-import com.baeldung.jhipster5.web.rest.errors.BadRequestAlertException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Optional;
-import java.util.stream.Collectors;
-
-/**
- * Service Implementation for managing Book.
- */
-@Service
-@Transactional
-public class BookServiceImpl implements BookService {
-
- private final Logger log = LoggerFactory.getLogger(BookServiceImpl.class);
-
- private final BookRepository bookRepository;
-
- private final BookMapper bookMapper;
-
- public BookServiceImpl(BookRepository bookRepository, BookMapper bookMapper) {
- this.bookRepository = bookRepository;
- this.bookMapper = bookMapper;
- }
-
- /**
- * Save a book.
- *
- * @param bookDTO the entity to save
- * @return the persisted entity
- */
- @Override
- public BookDTO save(BookDTO bookDTO) {
- log.debug("Request to save Book : {}", bookDTO);
- Book book = bookMapper.toEntity(bookDTO);
- book = bookRepository.save(book);
- return bookMapper.toDto(book);
- }
-
- /**
- * Get all the books.
- *
- * @return the list of entities
- */
- @Override
- @Transactional(readOnly = true)
- public List findAll() {
- log.debug("Request to get all Books");
- return bookRepository.findAll().stream()
- .map(bookMapper::toDto)
- .collect(Collectors.toCollection(LinkedList::new));
- }
-
-
- /**
- * Get one book by id.
- *
- * @param id the id of the entity
- * @return the entity
- */
- @Override
- @Transactional(readOnly = true)
- public Optional findOne(Long id) {
- log.debug("Request to get Book : {}", id);
- return bookRepository.findById(id)
- .map(bookMapper::toDto);
- }
-
- /**
- * Delete the book by id.
- *
- * @param id the id of the entity
- */
- @Override
- public void delete(Long id) {
- log.debug("Request to delete Book : {}", id);
- bookRepository.deleteById(id);
- }
-
- @Override
- public Optional purchase(Long id) {
- Optional bookDTO = findOne(id);
- if(bookDTO.isPresent()) {
- int quantity = bookDTO.get().getQuantity();
- if(quantity > 0) {
- bookDTO.get().setQuantity(quantity - 1);
- Book book = bookMapper.toEntity(bookDTO.get());
- book = bookRepository.save(book);
- return bookDTO;
- }
- else {
- throw new BadRequestAlertException("Book is not in stock", "book", "notinstock");
- }
- }
- return Optional.empty();
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/mapper/BookMapper.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/mapper/BookMapper.java
deleted file mode 100644
index cd24c7088e..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/mapper/BookMapper.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.baeldung.jhipster5.service.mapper;
-
-import com.baeldung.jhipster5.domain.*;
-import com.baeldung.jhipster5.service.dto.BookDTO;
-
-import org.mapstruct.*;
-
-/**
- * Mapper for the entity Book and its DTO BookDTO.
- */
-@Mapper(componentModel = "spring", uses = {})
-public interface BookMapper extends EntityMapper {
-
-
-
- default Book fromId(Long id) {
- if (id == null) {
- return null;
- }
- Book book = new Book();
- book.setId(id);
- return book;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/mapper/EntityMapper.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/mapper/EntityMapper.java
deleted file mode 100644
index 68af78179d..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/mapper/EntityMapper.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.baeldung.jhipster5.service.mapper;
-
-import java.util.List;
-
-/**
- * Contract for a generic dto to entity mapper.
- *
- * @param - DTO type parameter.
- * @param - Entity type parameter.
- */
-
-public interface EntityMapper {
-
- E toEntity(D dto);
-
- D toDto(E entity);
-
- List toEntity(List dtoList);
-
- List toDto(List entityList);
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/mapper/UserMapper.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/mapper/UserMapper.java
deleted file mode 100644
index 485c03813e..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/mapper/UserMapper.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package com.baeldung.jhipster5.service.mapper;
-
-import com.baeldung.jhipster5.domain.Authority;
-import com.baeldung.jhipster5.domain.User;
-import com.baeldung.jhipster5.service.dto.UserDTO;
-
-import org.springframework.stereotype.Service;
-
-import java.util.*;
-import java.util.stream.Collectors;
-
-/**
- * Mapper for the entity User and its DTO called UserDTO.
- *
- * Normal mappers are generated using MapStruct, this one is hand-coded as MapStruct
- * support is still in beta, and requires a manual step with an IDE.
- */
-@Service
-public class UserMapper {
-
- public List usersToUserDTOs(List users) {
- return users.stream()
- .filter(Objects::nonNull)
- .map(this::userToUserDTO)
- .collect(Collectors.toList());
- }
-
- public UserDTO userToUserDTO(User user) {
- return new UserDTO(user);
- }
-
- public List userDTOsToUsers(List userDTOs) {
- return userDTOs.stream()
- .filter(Objects::nonNull)
- .map(this::userDTOToUser)
- .collect(Collectors.toList());
- }
-
- public User userDTOToUser(UserDTO userDTO) {
- if (userDTO == null) {
- return null;
- } else {
- User user = new User();
- user.setId(userDTO.getId());
- user.setLogin(userDTO.getLogin());
- user.setFirstName(userDTO.getFirstName());
- user.setLastName(userDTO.getLastName());
- user.setEmail(userDTO.getEmail());
- user.setImageUrl(userDTO.getImageUrl());
- user.setActivated(userDTO.isActivated());
- user.setLangKey(userDTO.getLangKey());
- Set authorities = this.authoritiesFromStrings(userDTO.getAuthorities());
- user.setAuthorities(authorities);
- return user;
- }
- }
-
-
- private Set authoritiesFromStrings(Set authoritiesAsString) {
- Set authorities = new HashSet<>();
-
- if(authoritiesAsString != null){
- authorities = authoritiesAsString.stream().map(string -> {
- Authority auth = new Authority();
- auth.setName(string);
- return auth;
- }).collect(Collectors.toSet());
- }
-
- return authorities;
- }
-
- public User userFromId(Long id) {
- if (id == null) {
- return null;
- }
- User user = new User();
- user.setId(id);
- return user;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/mapper/package-info.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/mapper/package-info.java
deleted file mode 100644
index 7d402321e7..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/mapper/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * MapStruct mappers for mapping domain objects and Data Transfer Objects.
- */
-package com.baeldung.jhipster5.service.mapper;
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/package-info.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/package-info.java
deleted file mode 100644
index a54ed5cca0..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Service layer beans.
- */
-package com.baeldung.jhipster5.service;
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/util/RandomUtil.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/util/RandomUtil.java
deleted file mode 100644
index 97e4d9c672..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/service/util/RandomUtil.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.baeldung.jhipster5.service.util;
-
-import org.apache.commons.lang3.RandomStringUtils;
-
-/**
- * Utility class for generating random Strings.
- */
-public final class RandomUtil {
-
- private static final int DEF_COUNT = 20;
-
- private RandomUtil() {
- }
-
- /**
- * Generate a password.
- *
- * @return the generated password
- */
- public static String generatePassword() {
- return RandomStringUtils.randomAlphanumeric(DEF_COUNT);
- }
-
- /**
- * Generate an activation key.
- *
- * @return the generated activation key
- */
- public static String generateActivationKey() {
- return RandomStringUtils.randomNumeric(DEF_COUNT);
- }
-
- /**
- * Generate a reset key.
- *
- * @return the generated reset key
- */
- public static String generateResetKey() {
- return RandomStringUtils.randomNumeric(DEF_COUNT);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/AccountResource.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/AccountResource.java
deleted file mode 100644
index 2109e93999..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/AccountResource.java
+++ /dev/null
@@ -1,179 +0,0 @@
-package com.baeldung.jhipster5.web.rest;
-
-
-import com.baeldung.jhipster5.domain.User;
-import com.baeldung.jhipster5.repository.UserRepository;
-import com.baeldung.jhipster5.security.SecurityUtils;
-import com.baeldung.jhipster5.service.MailService;
-import com.baeldung.jhipster5.service.UserService;
-import com.baeldung.jhipster5.service.dto.PasswordChangeDTO;
-import com.baeldung.jhipster5.service.dto.UserDTO;
-import com.baeldung.jhipster5.web.rest.errors.*;
-import com.baeldung.jhipster5.web.rest.vm.KeyAndPasswordVM;
-import com.baeldung.jhipster5.web.rest.vm.ManagedUserVM;
-
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.validation.Valid;
-import java.util.*;
-
-/**
- * REST controller for managing the current user's account.
- */
-@RestController
-@RequestMapping("/api")
-public class AccountResource {
-
- private final Logger log = LoggerFactory.getLogger(AccountResource.class);
-
- private final UserRepository userRepository;
-
- private final UserService userService;
-
- private final MailService mailService;
-
- public AccountResource(UserRepository userRepository, UserService userService, MailService mailService) {
-
- this.userRepository = userRepository;
- this.userService = userService;
- this.mailService = mailService;
- }
-
- /**
- * POST /register : register the user.
- *
- * @param managedUserVM the managed user View Model
- * @throws InvalidPasswordException 400 (Bad Request) if the password is incorrect
- * @throws EmailAlreadyUsedException 400 (Bad Request) if the email is already used
- * @throws LoginAlreadyUsedException 400 (Bad Request) if the login is already used
- */
- @PostMapping("/register")
- @ResponseStatus(HttpStatus.CREATED)
- public void registerAccount(@Valid @RequestBody ManagedUserVM managedUserVM) {
- if (!checkPasswordLength(managedUserVM.getPassword())) {
- throw new InvalidPasswordException();
- }
- User user = userService.registerUser(managedUserVM, managedUserVM.getPassword());
- mailService.sendActivationEmail(user);
- }
-
- /**
- * GET /activate : activate the registered user.
- *
- * @param key the activation key
- * @throws RuntimeException 500 (Internal Server Error) if the user couldn't be activated
- */
- @GetMapping("/activate")
- public void activateAccount(@RequestParam(value = "key") String key) {
- Optional user = userService.activateRegistration(key);
- if (!user.isPresent()) {
- throw new InternalServerErrorException("No user was found for this activation key");
- }
- }
-
- /**
- * GET /authenticate : check if the user is authenticated, and return its login.
- *
- * @param request the HTTP request
- * @return the login if the user is authenticated
- */
- @GetMapping("/authenticate")
- public String isAuthenticated(HttpServletRequest request) {
- log.debug("REST request to check if the current user is authenticated");
- return request.getRemoteUser();
- }
-
- /**
- * GET /account : get the current user.
- *
- * @return the current user
- * @throws RuntimeException 500 (Internal Server Error) if the user couldn't be returned
- */
- @GetMapping("/account")
- public UserDTO getAccount() {
- return userService.getUserWithAuthorities()
- .map(UserDTO::new)
- .orElseThrow(() -> new InternalServerErrorException("User could not be found"));
- }
-
- /**
- * POST /account : update the current user information.
- *
- * @param userDTO the current user information
- * @throws EmailAlreadyUsedException 400 (Bad Request) if the email is already used
- * @throws RuntimeException 500 (Internal Server Error) if the user login wasn't found
- */
- @PostMapping("/account")
- public void saveAccount(@Valid @RequestBody UserDTO userDTO) {
- String userLogin = SecurityUtils.getCurrentUserLogin().orElseThrow(() -> new InternalServerErrorException("Current user login not found"));
- Optional existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
- if (existingUser.isPresent() && (!existingUser.get().getLogin().equalsIgnoreCase(userLogin))) {
- throw new EmailAlreadyUsedException();
- }
- Optional user = userRepository.findOneByLogin(userLogin);
- if (!user.isPresent()) {
- throw new InternalServerErrorException("User could not be found");
- }
- userService.updateUser(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail(),
- userDTO.getLangKey(), userDTO.getImageUrl());
- }
-
- /**
- * POST /account/change-password : changes the current user's password
- *
- * @param passwordChangeDto current and new password
- * @throws InvalidPasswordException 400 (Bad Request) if the new password is incorrect
- */
- @PostMapping(path = "/account/change-password")
- public void changePassword(@RequestBody PasswordChangeDTO passwordChangeDto) {
- if (!checkPasswordLength(passwordChangeDto.getNewPassword())) {
- throw new InvalidPasswordException();
- }
- userService.changePassword(passwordChangeDto.getCurrentPassword(), passwordChangeDto.getNewPassword());
- }
-
- /**
- * POST /account/reset-password/init : Send an email to reset the password of the user
- *
- * @param mail the mail of the user
- * @throws EmailNotFoundException 400 (Bad Request) if the email address is not registered
- */
- @PostMapping(path = "/account/reset-password/init")
- public void requestPasswordReset(@RequestBody String mail) {
- mailService.sendPasswordResetMail(
- userService.requestPasswordReset(mail)
- .orElseThrow(EmailNotFoundException::new)
- );
- }
-
- /**
- * POST /account/reset-password/finish : Finish to reset the password of the user
- *
- * @param keyAndPassword the generated key and the new password
- * @throws InvalidPasswordException 400 (Bad Request) if the password is incorrect
- * @throws RuntimeException 500 (Internal Server Error) if the password could not be reset
- */
- @PostMapping(path = "/account/reset-password/finish")
- public void finishPasswordReset(@RequestBody KeyAndPasswordVM keyAndPassword) {
- if (!checkPasswordLength(keyAndPassword.getNewPassword())) {
- throw new InvalidPasswordException();
- }
- Optional user =
- userService.completePasswordReset(keyAndPassword.getNewPassword(), keyAndPassword.getKey());
-
- if (!user.isPresent()) {
- throw new InternalServerErrorException("No user was found for this reset key");
- }
- }
-
- private static boolean checkPasswordLength(String password) {
- return !StringUtils.isEmpty(password) &&
- password.length() >= ManagedUserVM.PASSWORD_MIN_LENGTH &&
- password.length() <= ManagedUserVM.PASSWORD_MAX_LENGTH;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/AuditResource.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/AuditResource.java
deleted file mode 100644
index d0182d5d9d..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/AuditResource.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package com.baeldung.jhipster5.web.rest;
-
-import com.baeldung.jhipster5.service.AuditEventService;
-import com.baeldung.jhipster5.web.rest.util.PaginationUtil;
-
-import io.github.jhipster.web.util.ResponseUtil;
-import org.springframework.boot.actuate.audit.AuditEvent;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-
-import java.time.LocalDate;
-import java.time.ZoneId;
-import java.util.List;
-
-/**
- * REST controller for getting the audit events.
- */
-@RestController
-@RequestMapping("/management/audits")
-public class AuditResource {
-
- private final AuditEventService auditEventService;
-
- public AuditResource(AuditEventService auditEventService) {
- this.auditEventService = auditEventService;
- }
-
- /**
- * GET /audits : get a page of AuditEvents.
- *
- * @param pageable the pagination information
- * @return the ResponseEntity with status 200 (OK) and the list of AuditEvents in body
- */
- @GetMapping
- public ResponseEntity> getAll(Pageable pageable) {
- Page page = auditEventService.findAll(pageable);
- HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/management/audits");
- return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
- }
-
- /**
- * GET /audits : get a page of AuditEvents between the fromDate and toDate.
- *
- * @param fromDate the start of the time period of AuditEvents to get
- * @param toDate the end of the time period of AuditEvents to get
- * @param pageable the pagination information
- * @return the ResponseEntity with status 200 (OK) and the list of AuditEvents in body
- */
- @GetMapping(params = {"fromDate", "toDate"})
- public ResponseEntity> getByDates(
- @RequestParam(value = "fromDate") LocalDate fromDate,
- @RequestParam(value = "toDate") LocalDate toDate,
- Pageable pageable) {
-
- Page page = auditEventService.findByDates(
- fromDate.atStartOfDay(ZoneId.systemDefault()).toInstant(),
- toDate.atStartOfDay(ZoneId.systemDefault()).plusDays(1).toInstant(),
- pageable);
- HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/management/audits");
- return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
- }
-
- /**
- * GET /audits/:id : get an AuditEvent by id.
- *
- * @param id the id of the entity to get
- * @return the ResponseEntity with status 200 (OK) and the AuditEvent in body, or status 404 (Not Found)
- */
- @GetMapping("/{id:.+}")
- public ResponseEntity get(@PathVariable Long id) {
- return ResponseUtil.wrapOrNotFound(auditEventService.find(id));
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/BookResource.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/BookResource.java
deleted file mode 100644
index 0360ea05ed..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/BookResource.java
+++ /dev/null
@@ -1,118 +0,0 @@
-package com.baeldung.jhipster5.web.rest;
-import com.baeldung.jhipster5.service.BookService;
-import com.baeldung.jhipster5.web.rest.errors.BadRequestAlertException;
-import com.baeldung.jhipster5.web.rest.util.HeaderUtil;
-import com.baeldung.jhipster5.service.dto.BookDTO;
-import io.github.jhipster.web.util.ResponseUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.*;
-
-import javax.validation.Valid;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import java.util.List;
-import java.util.Optional;
-
-/**
- * REST controller for managing Book.
- */
-@RestController
-@RequestMapping("/api")
-public class BookResource {
-
- private final Logger log = LoggerFactory.getLogger(BookResource.class);
-
- private static final String ENTITY_NAME = "book";
-
- private final BookService bookService;
-
- public BookResource(BookService bookService) {
- this.bookService = bookService;
- }
-
- /**
- * POST /books : Create a new book.
- *
- * @param bookDTO the bookDTO to create
- * @return the ResponseEntity with status 201 (Created) and with body the new bookDTO, or with status 400 (Bad Request) if the book has already an ID
- * @throws URISyntaxException if the Location URI syntax is incorrect
- */
- @PostMapping("/books")
- public ResponseEntity createBook(@Valid @RequestBody BookDTO bookDTO) throws URISyntaxException {
- log.debug("REST request to save Book : {}", bookDTO);
- if (bookDTO.getId() != null) {
- throw new BadRequestAlertException("A new book cannot already have an ID", ENTITY_NAME, "idexists");
- }
- BookDTO result = bookService.save(bookDTO);
- return ResponseEntity.created(new URI("/api/books/" + result.getId()))
- .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
- .body(result);
- }
-
- /**
- * PUT /books : Updates an existing book.
- *
- * @param bookDTO the bookDTO to update
- * @return the ResponseEntity with status 200 (OK) and with body the updated bookDTO,
- * or with status 400 (Bad Request) if the bookDTO is not valid,
- * or with status 500 (Internal Server Error) if the bookDTO couldn't be updated
- * @throws URISyntaxException if the Location URI syntax is incorrect
- */
- @PutMapping("/books")
- public ResponseEntity updateBook(@Valid @RequestBody BookDTO bookDTO) throws URISyntaxException {
- log.debug("REST request to update Book : {}", bookDTO);
- if (bookDTO.getId() == null) {
- throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
- }
- BookDTO result = bookService.save(bookDTO);
- return ResponseEntity.ok()
- .headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, bookDTO.getId().toString()))
- .body(result);
- }
-
- /**
- * GET /books : get all the books.
- *
- * @return the ResponseEntity with status 200 (OK) and the list of books in body
- */
- @GetMapping("/books")
- public List getAllBooks() {
- log.debug("REST request to get all Books");
- return bookService.findAll();
- }
-
- /**
- * GET /books/:id : get the "id" book.
- *
- * @param id the id of the bookDTO to retrieve
- * @return the ResponseEntity with status 200 (OK) and with body the bookDTO, or with status 404 (Not Found)
- */
- @GetMapping("/books/{id}")
- public ResponseEntity getBook(@PathVariable Long id) {
- log.debug("REST request to get Book : {}", id);
- Optional bookDTO = bookService.findOne(id);
- return ResponseUtil.wrapOrNotFound(bookDTO);
- }
-
- /**
- * DELETE /books/:id : delete the "id" book.
- *
- * @param id the id of the bookDTO to delete
- * @return the ResponseEntity with status 200 (OK)
- */
- @DeleteMapping("/books/{id}")
- public ResponseEntity deleteBook(@PathVariable Long id) {
- log.debug("REST request to delete Book : {}", id);
- bookService.delete(id);
- return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
- }
-
- @GetMapping("/books/purchase/{id}")
- public ResponseEntity purchase(@PathVariable Long id) {
- Optional bookDTO = bookService.purchase(id);
- return ResponseUtil.wrapOrNotFound(bookDTO);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/LogsResource.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/LogsResource.java
deleted file mode 100644
index f35b5f2d5c..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/LogsResource.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package com.baeldung.jhipster5.web.rest;
-
-import com.baeldung.jhipster5.web.rest.vm.LoggerVM;
-
-import ch.qos.logback.classic.Level;
-import ch.qos.logback.classic.LoggerContext;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.*;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-/**
- * Controller for view and managing Log Level at runtime.
- */
-@RestController
-@RequestMapping("/management")
-public class LogsResource {
-
- @GetMapping("/logs")
- public List getList() {
- LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
- return context.getLoggerList()
- .stream()
- .map(LoggerVM::new)
- .collect(Collectors.toList());
- }
-
- @PutMapping("/logs")
- @ResponseStatus(HttpStatus.NO_CONTENT)
- public void changeLevel(@RequestBody LoggerVM jsonLogger) {
- LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
- context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel()));
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/UserJWTController.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/UserJWTController.java
deleted file mode 100644
index aeea587089..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/UserJWTController.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.baeldung.jhipster5.web.rest;
-
-import com.baeldung.jhipster5.security.jwt.JWTFilter;
-import com.baeldung.jhipster5.security.jwt.TokenProvider;
-import com.baeldung.jhipster5.web.rest.vm.LoginVM;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.web.bind.annotation.*;
-
-import javax.validation.Valid;
-
-/**
- * Controller to authenticate users.
- */
-@RestController
-@RequestMapping("/api")
-public class UserJWTController {
-
- private final TokenProvider tokenProvider;
-
- private final AuthenticationManager authenticationManager;
-
- public UserJWTController(TokenProvider tokenProvider, AuthenticationManager authenticationManager) {
- this.tokenProvider = tokenProvider;
- this.authenticationManager = authenticationManager;
- }
-
- @PostMapping("/authenticate")
- public ResponseEntity authorize(@Valid @RequestBody LoginVM loginVM) {
-
- UsernamePasswordAuthenticationToken authenticationToken =
- new UsernamePasswordAuthenticationToken(loginVM.getUsername(), loginVM.getPassword());
-
- Authentication authentication = this.authenticationManager.authenticate(authenticationToken);
- SecurityContextHolder.getContext().setAuthentication(authentication);
- boolean rememberMe = (loginVM.isRememberMe() == null) ? false : loginVM.isRememberMe();
- String jwt = tokenProvider.createToken(authentication, rememberMe);
- HttpHeaders httpHeaders = new HttpHeaders();
- httpHeaders.add(JWTFilter.AUTHORIZATION_HEADER, "Bearer " + jwt);
- return new ResponseEntity<>(new JWTToken(jwt), httpHeaders, HttpStatus.OK);
- }
-
- /**
- * Object to return as body in JWT Authentication.
- */
- static class JWTToken {
-
- private String idToken;
-
- JWTToken(String idToken) {
- this.idToken = idToken;
- }
-
- @JsonProperty("id_token")
- String getIdToken() {
- return idToken;
- }
-
- void setIdToken(String idToken) {
- this.idToken = idToken;
- }
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/UserResource.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/UserResource.java
deleted file mode 100644
index a95acf6759..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/UserResource.java
+++ /dev/null
@@ -1,183 +0,0 @@
-package com.baeldung.jhipster5.web.rest;
-
-import com.baeldung.jhipster5.config.Constants;
-import com.baeldung.jhipster5.domain.User;
-import com.baeldung.jhipster5.repository.UserRepository;
-import com.baeldung.jhipster5.security.AuthoritiesConstants;
-import com.baeldung.jhipster5.service.MailService;
-import com.baeldung.jhipster5.service.UserService;
-import com.baeldung.jhipster5.service.dto.UserDTO;
-import com.baeldung.jhipster5.web.rest.errors.BadRequestAlertException;
-import com.baeldung.jhipster5.web.rest.errors.EmailAlreadyUsedException;
-import com.baeldung.jhipster5.web.rest.errors.LoginAlreadyUsedException;
-import com.baeldung.jhipster5.web.rest.util.HeaderUtil;
-import com.baeldung.jhipster5.web.rest.util.PaginationUtil;
-import io.github.jhipster.web.util.ResponseUtil;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.data.domain.Page;
-import org.springframework.data.domain.Pageable;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
-
-import javax.validation.Valid;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.*;
-
-/**
- * REST controller for managing users.
- *
- * This class accesses the User entity, and needs to fetch its collection of authorities.
- *
- * For a normal use-case, it would be better to have an eager relationship between User and Authority,
- * and send everything to the client side: there would be no View Model and DTO, a lot less code, and an outer-join
- * which would be good for performance.
- *
- * We use a View Model and a DTO for 3 reasons:
- *
- *
We want to keep a lazy association between the user and the authorities, because people will
- * quite often do relationships with the user, and we don't want them to get the authorities all
- * the time for nothing (for performance reasons). This is the #1 goal: we should not impact our users'
- * application because of this use-case.
- *
Not having an outer join causes n+1 requests to the database. This is not a real issue as
- * we have by default a second-level cache. This means on the first HTTP call we do the n+1 requests,
- * but then all authorities come from the cache, so in fact it's much better than doing an outer join
- * (which will get lots of data from the database, for each HTTP call).
- *
As this manages users, for security reasons, we'd rather have a DTO layer.
- *
- *
- * Another option would be to have a specific JPA entity graph to handle this case.
- */
-@RestController
-@RequestMapping("/api")
-public class UserResource {
-
- private final Logger log = LoggerFactory.getLogger(UserResource.class);
-
- private final UserService userService;
-
- private final UserRepository userRepository;
-
- private final MailService mailService;
-
- public UserResource(UserService userService, UserRepository userRepository, MailService mailService) {
-
- this.userService = userService;
- this.userRepository = userRepository;
- this.mailService = mailService;
- }
-
- /**
- * POST /users : Creates a new user.
- *
- * Creates a new user if the login and email are not already used, and sends an
- * mail with an activation link.
- * The user needs to be activated on creation.
- *
- * @param userDTO the user to create
- * @return the ResponseEntity with status 201 (Created) and with body the new user, or with status 400 (Bad Request) if the login or email is already in use
- * @throws URISyntaxException if the Location URI syntax is incorrect
- * @throws BadRequestAlertException 400 (Bad Request) if the login or email is already in use
- */
- @PostMapping("/users")
- @PreAuthorize("hasRole(\"" + AuthoritiesConstants.ADMIN + "\")")
- public ResponseEntity createUser(@Valid @RequestBody UserDTO userDTO) throws URISyntaxException {
- log.debug("REST request to save User : {}", userDTO);
-
- if (userDTO.getId() != null) {
- throw new BadRequestAlertException("A new user cannot already have an ID", "userManagement", "idexists");
- // Lowercase the user login before comparing with database
- } else if (userRepository.findOneByLogin(userDTO.getLogin().toLowerCase()).isPresent()) {
- throw new LoginAlreadyUsedException();
- } else if (userRepository.findOneByEmailIgnoreCase(userDTO.getEmail()).isPresent()) {
- throw new EmailAlreadyUsedException();
- } else {
- User newUser = userService.createUser(userDTO);
- mailService.sendCreationEmail(newUser);
- return ResponseEntity.created(new URI("/api/users/" + newUser.getLogin()))
- .headers(HeaderUtil.createAlert( "A user is created with identifier " + newUser.getLogin(), newUser.getLogin()))
- .body(newUser);
- }
- }
-
- /**
- * PUT /users : Updates an existing User.
- *
- * @param userDTO the user to update
- * @return the ResponseEntity with status 200 (OK) and with body the updated user
- * @throws EmailAlreadyUsedException 400 (Bad Request) if the email is already in use
- * @throws LoginAlreadyUsedException 400 (Bad Request) if the login is already in use
- */
- @PutMapping("/users")
- @PreAuthorize("hasRole(\"" + AuthoritiesConstants.ADMIN + "\")")
- public ResponseEntity updateUser(@Valid @RequestBody UserDTO userDTO) {
- log.debug("REST request to update User : {}", userDTO);
- Optional existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
- if (existingUser.isPresent() && (!existingUser.get().getId().equals(userDTO.getId()))) {
- throw new EmailAlreadyUsedException();
- }
- existingUser = userRepository.findOneByLogin(userDTO.getLogin().toLowerCase());
- if (existingUser.isPresent() && (!existingUser.get().getId().equals(userDTO.getId()))) {
- throw new LoginAlreadyUsedException();
- }
- Optional updatedUser = userService.updateUser(userDTO);
-
- return ResponseUtil.wrapOrNotFound(updatedUser,
- HeaderUtil.createAlert("A user is updated with identifier " + userDTO.getLogin(), userDTO.getLogin()));
- }
-
- /**
- * GET /users : get all users.
- *
- * @param pageable the pagination information
- * @return the ResponseEntity with status 200 (OK) and with body all users
- */
- @GetMapping("/users")
- public ResponseEntity> getAllUsers(Pageable pageable) {
- final Page page = userService.getAllManagedUsers(pageable);
- HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/users");
- return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
- }
-
- /**
- * @return a string list of the all of the roles
- */
- @GetMapping("/users/authorities")
- @PreAuthorize("hasRole(\"" + AuthoritiesConstants.ADMIN + "\")")
- public List getAuthorities() {
- return userService.getAuthorities();
- }
-
- /**
- * GET /users/:login : get the "login" user.
- *
- * @param login the login of the user to find
- * @return the ResponseEntity with status 200 (OK) and with body the "login" user, or with status 404 (Not Found)
- */
- @GetMapping("/users/{login:" + Constants.LOGIN_REGEX + "}")
- public ResponseEntity getUser(@PathVariable String login) {
- log.debug("REST request to get User : {}", login);
- return ResponseUtil.wrapOrNotFound(
- userService.getUserWithAuthoritiesByLogin(login)
- .map(UserDTO::new));
- }
-
- /**
- * DELETE /users/:login : delete the "login" User.
- *
- * @param login the login of the user to delete
- * @return the ResponseEntity with status 200 (OK)
- */
- @DeleteMapping("/users/{login:" + Constants.LOGIN_REGEX + "}")
- @PreAuthorize("hasRole(\"" + AuthoritiesConstants.ADMIN + "\")")
- public ResponseEntity deleteUser(@PathVariable String login) {
- log.debug("REST request to delete User: {}", login);
- userService.deleteUser(login);
- return ResponseEntity.ok().headers(HeaderUtil.createAlert( "A user is deleted with identifier " + login, login)).build();
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/BadRequestAlertException.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/BadRequestAlertException.java
deleted file mode 100644
index c4c403351a..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/BadRequestAlertException.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.baeldung.jhipster5.web.rest.errors;
-
-import org.zalando.problem.AbstractThrowableProblem;
-import org.zalando.problem.Status;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-public class BadRequestAlertException extends AbstractThrowableProblem {
-
- private static final long serialVersionUID = 1L;
-
- private final String entityName;
-
- private final String errorKey;
-
- public BadRequestAlertException(String defaultMessage, String entityName, String errorKey) {
- this(ErrorConstants.DEFAULT_TYPE, defaultMessage, entityName, errorKey);
- }
-
- public BadRequestAlertException(URI type, String defaultMessage, String entityName, String errorKey) {
- super(type, defaultMessage, Status.BAD_REQUEST, null, null, null, getAlertParameters(entityName, errorKey));
- this.entityName = entityName;
- this.errorKey = errorKey;
- }
-
- public String getEntityName() {
- return entityName;
- }
-
- public String getErrorKey() {
- return errorKey;
- }
-
- private static Map getAlertParameters(String entityName, String errorKey) {
- Map parameters = new HashMap<>();
- parameters.put("message", "error." + errorKey);
- parameters.put("params", entityName);
- return parameters;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/CustomParameterizedException.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/CustomParameterizedException.java
deleted file mode 100644
index 8c3df82b83..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/CustomParameterizedException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.baeldung.jhipster5.web.rest.errors;
-
-import org.zalando.problem.AbstractThrowableProblem;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.zalando.problem.Status.BAD_REQUEST;
-
-/**
- * Custom, parameterized exception, which can be translated on the client side.
- * For example:
- *
- *
- * throw new CustomParameterizedException("myCustomError", "hello", "world");
- *
- *
- * Can be translated with:
- *
- *
- * "error.myCustomError" : "The server says {{param0}} to {{param1}}"
- *
- */
-public class CustomParameterizedException extends AbstractThrowableProblem {
-
- private static final long serialVersionUID = 1L;
-
- private static final String PARAM = "param";
-
- public CustomParameterizedException(String message, String... params) {
- this(message, toParamMap(params));
- }
-
- public CustomParameterizedException(String message, Map paramMap) {
- super(ErrorConstants.PARAMETERIZED_TYPE, "Parameterized Exception", BAD_REQUEST, null, null, null, toProblemParameters(message, paramMap));
- }
-
- public static Map toParamMap(String... params) {
- Map paramMap = new HashMap<>();
- if (params != null && params.length > 0) {
- for (int i = 0; i < params.length; i++) {
- paramMap.put(PARAM + i, params[i]);
- }
- }
- return paramMap;
- }
-
- public static Map toProblemParameters(String message, Map paramMap) {
- Map parameters = new HashMap<>();
- parameters.put("message", message);
- parameters.put("params", paramMap);
- return parameters;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/EmailAlreadyUsedException.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/EmailAlreadyUsedException.java
deleted file mode 100644
index b3dcc0279e..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/EmailAlreadyUsedException.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.baeldung.jhipster5.web.rest.errors;
-
-public class EmailAlreadyUsedException extends BadRequestAlertException {
-
- private static final long serialVersionUID = 1L;
-
- public EmailAlreadyUsedException() {
- super(ErrorConstants.EMAIL_ALREADY_USED_TYPE, "Email is already in use!", "userManagement", "emailexists");
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/EmailNotFoundException.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/EmailNotFoundException.java
deleted file mode 100644
index b93081cacb..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/EmailNotFoundException.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.baeldung.jhipster5.web.rest.errors;
-
-import org.zalando.problem.AbstractThrowableProblem;
-import org.zalando.problem.Status;
-
-public class EmailNotFoundException extends AbstractThrowableProblem {
-
- private static final long serialVersionUID = 1L;
-
- public EmailNotFoundException() {
- super(ErrorConstants.EMAIL_NOT_FOUND_TYPE, "Email address not registered", Status.BAD_REQUEST);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/ErrorConstants.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/ErrorConstants.java
deleted file mode 100644
index 06be9254a9..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/ErrorConstants.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.baeldung.jhipster5.web.rest.errors;
-
-import java.net.URI;
-
-public final class ErrorConstants {
-
- public static final String ERR_CONCURRENCY_FAILURE = "error.concurrencyFailure";
- public static final String ERR_VALIDATION = "error.validation";
- public static final String PROBLEM_BASE_URL = "https://www.jhipster.tech/problem";
- public static final URI DEFAULT_TYPE = URI.create(PROBLEM_BASE_URL + "/problem-with-message");
- public static final URI CONSTRAINT_VIOLATION_TYPE = URI.create(PROBLEM_BASE_URL + "/constraint-violation");
- public static final URI PARAMETERIZED_TYPE = URI.create(PROBLEM_BASE_URL + "/parameterized");
- public static final URI ENTITY_NOT_FOUND_TYPE = URI.create(PROBLEM_BASE_URL + "/entity-not-found");
- public static final URI INVALID_PASSWORD_TYPE = URI.create(PROBLEM_BASE_URL + "/invalid-password");
- public static final URI EMAIL_ALREADY_USED_TYPE = URI.create(PROBLEM_BASE_URL + "/email-already-used");
- public static final URI LOGIN_ALREADY_USED_TYPE = URI.create(PROBLEM_BASE_URL + "/login-already-used");
- public static final URI EMAIL_NOT_FOUND_TYPE = URI.create(PROBLEM_BASE_URL + "/email-not-found");
-
- private ErrorConstants() {
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/ExceptionTranslator.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/ExceptionTranslator.java
deleted file mode 100644
index 3f7cc6b565..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/ExceptionTranslator.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package com.baeldung.jhipster5.web.rest.errors;
-
-import com.baeldung.jhipster5.web.rest.util.HeaderUtil;
-
-import org.springframework.dao.ConcurrencyFailureException;
-import org.springframework.http.ResponseEntity;
-import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.MethodArgumentNotValidException;
-import org.springframework.web.bind.annotation.ControllerAdvice;
-import org.springframework.web.bind.annotation.ExceptionHandler;
-import org.springframework.web.context.request.NativeWebRequest;
-import org.zalando.problem.DefaultProblem;
-import org.zalando.problem.Problem;
-import org.zalando.problem.ProblemBuilder;
-import org.zalando.problem.Status;
-import org.zalando.problem.spring.web.advice.ProblemHandling;
-import org.zalando.problem.violations.ConstraintViolationProblem;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-import javax.servlet.http.HttpServletRequest;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.stream.Collectors;
-
-/**
- * Controller advice to translate the server side exceptions to client-friendly json structures.
- * The error response follows RFC7807 - Problem Details for HTTP APIs (https://tools.ietf.org/html/rfc7807)
- */
-@ControllerAdvice
-public class ExceptionTranslator implements ProblemHandling {
-
- private static final String FIELD_ERRORS_KEY = "fieldErrors";
- private static final String MESSAGE_KEY = "message";
- private static final String PATH_KEY = "path";
- private static final String VIOLATIONS_KEY = "violations";
-
- /**
- * Post-process the Problem payload to add the message key for the front-end if needed
- */
- @Override
- public ResponseEntity process(@Nullable ResponseEntity entity, NativeWebRequest request) {
- if (entity == null) {
- return entity;
- }
- Problem problem = entity.getBody();
- if (!(problem instanceof ConstraintViolationProblem || problem instanceof DefaultProblem)) {
- return entity;
- }
- ProblemBuilder builder = Problem.builder()
- .withType(Problem.DEFAULT_TYPE.equals(problem.getType()) ? ErrorConstants.DEFAULT_TYPE : problem.getType())
- .withStatus(problem.getStatus())
- .withTitle(problem.getTitle())
- .with(PATH_KEY, request.getNativeRequest(HttpServletRequest.class).getRequestURI());
-
- if (problem instanceof ConstraintViolationProblem) {
- builder
- .with(VIOLATIONS_KEY, ((ConstraintViolationProblem) problem).getViolations())
- .with(MESSAGE_KEY, ErrorConstants.ERR_VALIDATION);
- } else {
- builder
- .withCause(((DefaultProblem) problem).getCause())
- .withDetail(problem.getDetail())
- .withInstance(problem.getInstance());
- problem.getParameters().forEach(builder::with);
- if (!problem.getParameters().containsKey(MESSAGE_KEY) && problem.getStatus() != null) {
- builder.with(MESSAGE_KEY, "error.http." + problem.getStatus().getStatusCode());
- }
- }
- return new ResponseEntity<>(builder.build(), entity.getHeaders(), entity.getStatusCode());
- }
-
- @Override
- public ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex, @Nonnull NativeWebRequest request) {
- BindingResult result = ex.getBindingResult();
- List fieldErrors = result.getFieldErrors().stream()
- .map(f -> new FieldErrorVM(f.getObjectName(), f.getField(), f.getCode()))
- .collect(Collectors.toList());
-
- Problem problem = Problem.builder()
- .withType(ErrorConstants.CONSTRAINT_VIOLATION_TYPE)
- .withTitle("Method argument not valid")
- .withStatus(defaultConstraintViolationStatus())
- .with(MESSAGE_KEY, ErrorConstants.ERR_VALIDATION)
- .with(FIELD_ERRORS_KEY, fieldErrors)
- .build();
- return create(ex, problem, request);
- }
-
- @ExceptionHandler
- public ResponseEntity handleNoSuchElementException(NoSuchElementException ex, NativeWebRequest request) {
- Problem problem = Problem.builder()
- .withStatus(Status.NOT_FOUND)
- .with(MESSAGE_KEY, ErrorConstants.ENTITY_NOT_FOUND_TYPE)
- .build();
- return create(ex, problem, request);
- }
-
- @ExceptionHandler
- public ResponseEntity handleBadRequestAlertException(BadRequestAlertException ex, NativeWebRequest request) {
- return create(ex, request, HeaderUtil.createFailureAlert(ex.getEntityName(), ex.getErrorKey(), ex.getMessage()));
- }
-
- @ExceptionHandler
- public ResponseEntity handleConcurrencyFailure(ConcurrencyFailureException ex, NativeWebRequest request) {
- Problem problem = Problem.builder()
- .withStatus(Status.CONFLICT)
- .with(MESSAGE_KEY, ErrorConstants.ERR_CONCURRENCY_FAILURE)
- .build();
- return create(ex, problem, request);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/FieldErrorVM.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/FieldErrorVM.java
deleted file mode 100644
index 349f548850..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/FieldErrorVM.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.baeldung.jhipster5.web.rest.errors;
-
-import java.io.Serializable;
-
-public class FieldErrorVM implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private final String objectName;
-
- private final String field;
-
- private final String message;
-
- public FieldErrorVM(String dto, String field, String message) {
- this.objectName = dto;
- this.field = field;
- this.message = message;
- }
-
- public String getObjectName() {
- return objectName;
- }
-
- public String getField() {
- return field;
- }
-
- public String getMessage() {
- return message;
- }
-
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/InternalServerErrorException.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/InternalServerErrorException.java
deleted file mode 100644
index 13e128237b..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/InternalServerErrorException.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.baeldung.jhipster5.web.rest.errors;
-
-import org.zalando.problem.AbstractThrowableProblem;
-import org.zalando.problem.Status;
-
-/**
- * Simple exception with a message, that returns an Internal Server Error code.
- */
-public class InternalServerErrorException extends AbstractThrowableProblem {
-
- private static final long serialVersionUID = 1L;
-
- public InternalServerErrorException(String message) {
- super(ErrorConstants.DEFAULT_TYPE, message, Status.INTERNAL_SERVER_ERROR);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/InvalidPasswordException.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/InvalidPasswordException.java
deleted file mode 100644
index 6bb91247ff..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/InvalidPasswordException.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package com.baeldung.jhipster5.web.rest.errors;
-
-import org.zalando.problem.AbstractThrowableProblem;
-import org.zalando.problem.Status;
-
-public class InvalidPasswordException extends AbstractThrowableProblem {
-
- private static final long serialVersionUID = 1L;
-
- public InvalidPasswordException() {
- super(ErrorConstants.INVALID_PASSWORD_TYPE, "Incorrect password", Status.BAD_REQUEST);
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/LoginAlreadyUsedException.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/LoginAlreadyUsedException.java
deleted file mode 100644
index 987a94193d..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/LoginAlreadyUsedException.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.baeldung.jhipster5.web.rest.errors;
-
-public class LoginAlreadyUsedException extends BadRequestAlertException {
-
- private static final long serialVersionUID = 1L;
-
- public LoginAlreadyUsedException() {
- super(ErrorConstants.LOGIN_ALREADY_USED_TYPE, "Login name already used!", "userManagement", "userexists");
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/package-info.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/package-info.java
deleted file mode 100644
index 7f57af4429..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/errors/package-info.java
+++ /dev/null
@@ -1,6 +0,0 @@
-/**
- * Specific errors used with Zalando's "problem-spring-web" library.
- *
- * More information on https://github.com/zalando/problem-spring-web
- */
-package com.baeldung.jhipster5.web.rest.errors;
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/package-info.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/package-info.java
deleted file mode 100644
index 75bf6840f6..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * Spring MVC REST controllers.
- */
-package com.baeldung.jhipster5.web.rest;
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/util/HeaderUtil.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/util/HeaderUtil.java
deleted file mode 100644
index 91fdd68261..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/util/HeaderUtil.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.baeldung.jhipster5.web.rest.util;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.http.HttpHeaders;
-
-/**
- * Utility class for HTTP headers creation.
- */
-public final class HeaderUtil {
-
- private static final Logger log = LoggerFactory.getLogger(HeaderUtil.class);
-
- private static final String APPLICATION_NAME = "bookstoreApp";
-
- private HeaderUtil() {
- }
-
- public static HttpHeaders createAlert(String message, String param) {
- HttpHeaders headers = new HttpHeaders();
- headers.add("X-" + APPLICATION_NAME + "-alert", message);
- headers.add("X-" + APPLICATION_NAME + "-params", param);
- return headers;
- }
-
- public static HttpHeaders createEntityCreationAlert(String entityName, String param) {
- return createAlert("A new " + entityName + " is created with identifier " + param, param);
- }
-
- public static HttpHeaders createEntityUpdateAlert(String entityName, String param) {
- return createAlert("A " + entityName + " is updated with identifier " + param, param);
- }
-
- public static HttpHeaders createEntityDeletionAlert(String entityName, String param) {
- return createAlert("A " + entityName + " is deleted with identifier " + param, param);
- }
-
- public static HttpHeaders createFailureAlert(String entityName, String errorKey, String defaultMessage) {
- log.error("Entity processing failed, {}", defaultMessage);
- HttpHeaders headers = new HttpHeaders();
- headers.add("X-" + APPLICATION_NAME + "-error", defaultMessage);
- headers.add("X-" + APPLICATION_NAME + "-params", entityName);
- return headers;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/util/PaginationUtil.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/util/PaginationUtil.java
deleted file mode 100644
index 9928dbe171..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/util/PaginationUtil.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.baeldung.jhipster5.web.rest.util;
-
-import org.springframework.data.domain.Page;
-import org.springframework.http.HttpHeaders;
-import org.springframework.web.util.UriComponentsBuilder;
-
-/**
- * Utility class for handling pagination.
- *
- *
- * Pagination uses the same principles as the GitHub API,
- * and follow RFC 5988 (Link header).
- */
-public final class PaginationUtil {
-
- private PaginationUtil() {
- }
-
- public static HttpHeaders generatePaginationHttpHeaders(Page page, String baseUrl) {
-
- HttpHeaders headers = new HttpHeaders();
- headers.add("X-Total-Count", Long.toString(page.getTotalElements()));
- String link = "";
- if ((page.getNumber() + 1) < page.getTotalPages()) {
- link = "<" + generateUri(baseUrl, page.getNumber() + 1, page.getSize()) + ">; rel=\"next\",";
- }
- // prev link
- if ((page.getNumber()) > 0) {
- link += "<" + generateUri(baseUrl, page.getNumber() - 1, page.getSize()) + ">; rel=\"prev\",";
- }
- // last and first link
- int lastPage = 0;
- if (page.getTotalPages() > 0) {
- lastPage = page.getTotalPages() - 1;
- }
- link += "<" + generateUri(baseUrl, lastPage, page.getSize()) + ">; rel=\"last\",";
- link += "<" + generateUri(baseUrl, 0, page.getSize()) + ">; rel=\"first\"";
- headers.add(HttpHeaders.LINK, link);
- return headers;
- }
-
- private static String generateUri(String baseUrl, int page, int size) {
- return UriComponentsBuilder.fromUriString(baseUrl).queryParam("page", page).queryParam("size", size).toUriString();
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/KeyAndPasswordVM.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/KeyAndPasswordVM.java
deleted file mode 100644
index 840fa02cfc..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/KeyAndPasswordVM.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.baeldung.jhipster5.web.rest.vm;
-
-/**
- * View Model object for storing the user's key and password.
- */
-public class KeyAndPasswordVM {
-
- private String key;
-
- private String newPassword;
-
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public String getNewPassword() {
- return newPassword;
- }
-
- public void setNewPassword(String newPassword) {
- this.newPassword = newPassword;
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/LoggerVM.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/LoggerVM.java
deleted file mode 100644
index 952e7df298..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/LoggerVM.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.baeldung.jhipster5.web.rest.vm;
-
-import ch.qos.logback.classic.Logger;
-
-/**
- * View Model object for storing a Logback logger.
- */
-public class LoggerVM {
-
- private String name;
-
- private String level;
-
- public LoggerVM(Logger logger) {
- this.name = logger.getName();
- this.level = logger.getEffectiveLevel().toString();
- }
-
- public LoggerVM() {
- // Empty public constructor used by Jackson.
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getLevel() {
- return level;
- }
-
- public void setLevel(String level) {
- this.level = level;
- }
-
- @Override
- public String toString() {
- return "LoggerVM{" +
- "name='" + name + '\'' +
- ", level='" + level + '\'' +
- '}';
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/LoginVM.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/LoginVM.java
deleted file mode 100644
index 8fc119ab69..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/LoginVM.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.baeldung.jhipster5.web.rest.vm;
-
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-
-/**
- * View Model object for storing a user's credentials.
- */
-public class LoginVM {
-
- @NotNull
- @Size(min = 1, max = 50)
- private String username;
-
- @NotNull
- @Size(min = ManagedUserVM.PASSWORD_MIN_LENGTH, max = ManagedUserVM.PASSWORD_MAX_LENGTH)
- private String password;
-
- private Boolean rememberMe;
-
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- public Boolean isRememberMe() {
- return rememberMe;
- }
-
- public void setRememberMe(Boolean rememberMe) {
- this.rememberMe = rememberMe;
- }
-
- @Override
- public String toString() {
- return "LoginVM{" +
- "username='" + username + '\'' +
- ", rememberMe=" + rememberMe +
- '}';
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/ManagedUserVM.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/ManagedUserVM.java
deleted file mode 100644
index 314577c456..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/ManagedUserVM.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.baeldung.jhipster5.web.rest.vm;
-
-import com.baeldung.jhipster5.service.dto.UserDTO;
-import javax.validation.constraints.Size;
-
-/**
- * View Model extending the UserDTO, which is meant to be used in the user management UI.
- */
-public class ManagedUserVM extends UserDTO {
-
- public static final int PASSWORD_MIN_LENGTH = 4;
-
- public static final int PASSWORD_MAX_LENGTH = 100;
-
- @Size(min = PASSWORD_MIN_LENGTH, max = PASSWORD_MAX_LENGTH)
- private String password;
-
- public ManagedUserVM() {
- // Empty constructor needed for Jackson.
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
- @Override
- public String toString() {
- return "ManagedUserVM{" +
- "} " + super.toString();
- }
-}
diff --git a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/package-info.java b/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/package-info.java
deleted file mode 100644
index ff58799037..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/java/com/baeldung/jhipster5/web/rest/vm/package-info.java
+++ /dev/null
@@ -1,4 +0,0 @@
-/**
- * View Models used by Spring MVC REST controllers.
- */
-package com.baeldung.jhipster5.web.rest.vm;
diff --git a/jhipster-5/bookstore-monolith/src/main/jib/entrypoint.sh b/jhipster-5/bookstore-monolith/src/main/jib/entrypoint.sh
deleted file mode 100644
index b3c4541011..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/jib/entrypoint.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-echo "The application will start in ${JHIPSTER_SLEEP}s..." && sleep ${JHIPSTER_SLEEP}
-exec java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -cp /app/resources/:/app/classes/:/app/libs/* "com.baeldung.jhipster5.BookstoreApp" "$@"
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/.h2.server.properties b/jhipster-5/bookstore-monolith/src/main/resources/.h2.server.properties
deleted file mode 100644
index 99767b3a8a..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/.h2.server.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-#H2 Server Properties
-0=JHipster H2 (Memory)|org.h2.Driver|jdbc\:h2\:mem\:bookstore|Bookstore
-webAllowOthers=true
-webPort=8082
-webSSL=false
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/banner.txt b/jhipster-5/bookstore-monolith/src/main/resources/banner.txt
deleted file mode 100644
index e0bc55aaff..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/banner.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-
- ${AnsiColor.GREEN} ██╗${AnsiColor.RED} ██╗ ██╗ ████████╗ ███████╗ ██████╗ ████████╗ ████████╗ ███████╗
- ${AnsiColor.GREEN} ██║${AnsiColor.RED} ██║ ██║ ╚══██╔══╝ ██╔═══██╗ ██╔════╝ ╚══██╔══╝ ██╔═════╝ ██╔═══██╗
- ${AnsiColor.GREEN} ██║${AnsiColor.RED} ████████║ ██║ ███████╔╝ ╚█████╗ ██║ ██████╗ ███████╔╝
- ${AnsiColor.GREEN}██╗ ██║${AnsiColor.RED} ██╔═══██║ ██║ ██╔════╝ ╚═══██╗ ██║ ██╔═══╝ ██╔══██║
- ${AnsiColor.GREEN}╚██████╔╝${AnsiColor.RED} ██║ ██║ ████████╗ ██║ ██████╔╝ ██║ ████████╗ ██║ ╚██╗
- ${AnsiColor.GREEN} ╚═════╝ ${AnsiColor.RED} ╚═╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══════╝ ╚═╝ ╚═╝
-
-${AnsiColor.BRIGHT_BLUE}:: JHipster 🤓 :: Running Spring Boot ${spring-boot.version} ::
-:: https://www.jhipster.tech ::${AnsiColor.DEFAULT}
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/config/application-dev.yml b/jhipster-5/bookstore-monolith/src/main/resources/config/application-dev.yml
deleted file mode 100644
index 64742feb45..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/config/application-dev.yml
+++ /dev/null
@@ -1,122 +0,0 @@
-# ===================================================================
-# Spring Boot configuration for the "dev" profile.
-#
-# This configuration overrides the application.yml file.
-#
-# More information on profiles: https://www.jhipster.tech/profiles/
-# More information on configuration properties: https://www.jhipster.tech/common-application-properties/
-# ===================================================================
-
-# ===================================================================
-# Standard Spring Boot properties.
-# Full reference is available at:
-# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
-# ===================================================================
-
-logging:
- level:
- ROOT: DEBUG
- io.github.jhipster: DEBUG
- com.baeldung.jhipster5: DEBUG
-
-spring:
- profiles:
- active: dev
- include:
- - swagger
- # Uncomment to activate TLS for the dev profile
- #- tls
- devtools:
- restart:
- enabled: true
- additional-exclude: .h2.server.properties
- livereload:
- enabled: false # we use Webpack dev server + BrowserSync for livereload
- jackson:
- serialization:
- indent-output: true
- datasource:
- type: com.zaxxer.hikari.HikariDataSource
- url: jdbc:h2:mem:bookstore;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
- username: Bookstore
- password:
- hikari:
- poolName: Hikari
- auto-commit: false
- h2:
- console:
- enabled: false
- jpa:
- database-platform: io.github.jhipster.domain.util.FixedH2Dialect
- database: H2
- show-sql: true
- properties:
- hibernate.id.new_generator_mappings: true
- hibernate.connection.provider_disables_autocommit: true
- hibernate.cache.use_second_level_cache: false
- hibernate.cache.use_query_cache: false
- hibernate.generate_statistics: true
- liquibase:
- contexts: dev
- mail:
- host: localhost
- port: 25
- username:
- password:
- messages:
- cache-duration: PT1S # 1 second, see the ISO 8601 standard
- thymeleaf:
- cache: false
-
-server:
- port: 8080
-
-# ===================================================================
-# JHipster specific properties
-#
-# Full reference is available at: https://www.jhipster.tech/common-application-properties/
-# ===================================================================
-
-jhipster:
- http:
- version: V_1_1 # To use HTTP/2 you will need to activate TLS (see application-tls.yml)
- # CORS is only enabled by default with the "dev" profile, so BrowserSync can access the API
- cors:
- allowed-origins: "*"
- allowed-methods: "*"
- allowed-headers: "*"
- exposed-headers: "Authorization,Link,X-Total-Count"
- allow-credentials: true
- max-age: 1800
- security:
- authentication:
- jwt:
- # This token must be encoded using Base64 and be at least 256 bits long (you can type `openssl rand -base64 64` on your command line to generate a 512 bits one)
- base64-secret: NDJmOTVlZjI2NzhlZDRjNmVkNTM1NDE2NjkyNDljZDJiNzBlMjI5YmZjMjY3MzdjZmZlMjI3NjE4OTRkNzc5MWYzNDNlYWMzYmJjOWRmMjc5ZWQyZTZmOWZkOTMxZWZhNWE1MTVmM2U2NjFmYjhlNDc2Y2Q3NzliMGY0YzFkNmI=
- # Token is valid 24 hours
- token-validity-in-seconds: 86400
- token-validity-in-seconds-for-remember-me: 2592000
- mail: # specific JHipster mail property, for standard properties see MailProperties
- from: Bookstore@localhost
- base-url: http://127.0.0.1:8080
- metrics:
- logs: # Reports metrics in the logs
- enabled: false
- report-frequency: 60 # in seconds
- logging:
- logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration
- enabled: false
- host: localhost
- port: 5000
- queue-size: 512
-
-# ===================================================================
-# Application specific properties
-# Add your own application properties here, see the ApplicationProperties class
-# to have type-safe configuration, like in the JHipsterProperties above
-#
-# More documentation is available at:
-# https://www.jhipster.tech/common-application-properties/
-# ===================================================================
-
-# application:
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/config/application-prod.yml b/jhipster-5/bookstore-monolith/src/main/resources/config/application-prod.yml
deleted file mode 100644
index d698099fac..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/config/application-prod.yml
+++ /dev/null
@@ -1,133 +0,0 @@
-# ===================================================================
-# Spring Boot configuration for the "prod" profile.
-#
-# This configuration overrides the application.yml file.
-#
-# More information on profiles: https://www.jhipster.tech/profiles/
-# More information on configuration properties: https://www.jhipster.tech/common-application-properties/
-# ===================================================================
-
-# ===================================================================
-# Standard Spring Boot properties.
-# Full reference is available at:
-# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
-# ===================================================================
-
-logging:
- level:
- ROOT: INFO
- com.baeldung.jhipster5: INFO
- io.github.jhipster: INFO
-
-spring:
- devtools:
- restart:
- enabled: false
- livereload:
- enabled: false
- datasource:
- type: com.zaxxer.hikari.HikariDataSource
- url: jdbc:mysql://localhost:3306/Bookstore?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC
- username: root
- password:
- hikari:
- poolName: Hikari
- auto-commit: false
- data-source-properties:
- cachePrepStmts: true
- prepStmtCacheSize: 250
- prepStmtCacheSqlLimit: 2048
- useServerPrepStmts: true
- jpa:
- database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
- database: MYSQL
- show-sql: false
- properties:
- hibernate.id.new_generator_mappings: true
- hibernate.connection.provider_disables_autocommit: true
- hibernate.cache.use_second_level_cache: false
- hibernate.cache.use_query_cache: false
- hibernate.generate_statistics: true
- liquibase:
- contexts: prod
- mail:
- host: localhost
- port: 25
- username:
- password:
- thymeleaf:
- cache: true
-
-# ===================================================================
-# To enable TLS in production, generate a certificate using:
-# keytool -genkey -alias bookstore -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650
-#
-# You can also use Let's Encrypt:
-# https://maximilian-boehm.com/hp2121/Create-a-Java-Keystore-JKS-from-Let-s-Encrypt-Certificates.htm
-#
-# Then, modify the server.ssl properties so your "server" configuration looks like:
-#
-# server:
-# port: 443
-# ssl:
-# key-store: classpath:config/tls/keystore.p12
-# key-store-password: password
-# key-store-type: PKCS12
-# key-alias: bookstore
-# # The ciphers suite enforce the security by deactivating some old and deprecated SSL cipher, this list was tested against SSL Labs (https://www.ssllabs.com/ssltest/)
-# ciphers: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 ,TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 ,TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 ,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_RSA_WITH_AES_128_GCM_SHA256,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA,TLS_RSA_WITH_CAMELLIA_256_CBC_SHA,TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA,TLS_RSA_WITH_CAMELLIA_128_CBC_SHA
-# ===================================================================
-server:
- port: 8080
- compression:
- enabled: true
- mime-types: text/html,text/xml,text/plain,text/css, application/javascript, application/json
- min-response-size: 1024
-
-# ===================================================================
-# JHipster specific properties
-#
-# Full reference is available at: https://www.jhipster.tech/common-application-properties/
-# ===================================================================
-
-jhipster:
- http:
- version: V_1_1 # To use HTTP/2 you will need SSL support (see above the "server.ssl" configuration)
- cache: # Used by the CachingHttpHeadersFilter
- timeToLiveInDays: 1461
- security:
- authentication:
- jwt:
- # This token must be encoded using Base64 and be at least 256 bits long (you can type `openssl rand -base64 64` on your command line to generate a 512 bits one)
- # As this is the PRODUCTION configuration, you MUST change the default key, and store it securely:
- # - In the JHipster Registry (which includes a Spring Cloud Config server)
- # - In a separate `application-prod.yml` file, in the same folder as your executable WAR file
- # - In the `JHIPSTER_SECURITY_AUTHENTICATION_JWT_BASE64_SECRET` environment variable
- base64-secret: NDJmOTVlZjI2NzhlZDRjNmVkNTM1NDE2NjkyNDljZDJiNzBlMjI5YmZjMjY3MzdjZmZlMjI3NjE4OTRkNzc5MWYzNDNlYWMzYmJjOWRmMjc5ZWQyZTZmOWZkOTMxZWZhNWE1MTVmM2U2NjFmYjhlNDc2Y2Q3NzliMGY0YzFkNmI=
- # Token is valid 24 hours
- token-validity-in-seconds: 86400
- token-validity-in-seconds-for-remember-me: 2592000
- mail: # specific JHipster mail property, for standard properties see MailProperties
- from: Bookstore@localhost
- base-url: http://my-server-url-to-change # Modify according to your server's URL
- metrics:
- logs: # Reports metrics in the logs
- enabled: false
- report-frequency: 60 # in seconds
- logging:
- logstash: # Forward logs to logstash over a socket, used by LoggingConfiguration
- enabled: false
- host: localhost
- port: 5000
- queue-size: 512
-
-# ===================================================================
-# Application specific properties
-# Add your own application properties here, see the ApplicationProperties class
-# to have type-safe configuration, like in the JHipsterProperties above
-#
-# More documentation is available at:
-# https://www.jhipster.tech/common-application-properties/
-# ===================================================================
-
-# application:
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/config/application-tls.yml b/jhipster-5/bookstore-monolith/src/main/resources/config/application-tls.yml
deleted file mode 100644
index c4e0565cc7..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/config/application-tls.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-# ===================================================================
-# Activate this profile to enable TLS and HTTP/2.
-#
-# JHipster has generated a self-signed certificate, which will be used to encrypt traffic.
-# As your browser will not understand this certificate, you will need to import it.
-#
-# Another (easiest) solution with Chrome is to enable the "allow-insecure-localhost" flag
-# at chrome://flags/#allow-insecure-localhost
-# ===================================================================
-server:
- ssl:
- key-store: classpath:config/tls/keystore.p12
- key-store-password: password
- key-store-type: PKCS12
- key-alias: selfsigned
- ciphers: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256
- enabled-protocols: TLSv1.2
-jhipster:
- http:
- version: V_2_0
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/config/application.yml b/jhipster-5/bookstore-monolith/src/main/resources/config/application.yml
deleted file mode 100644
index 5b28b7f00d..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/config/application.yml
+++ /dev/null
@@ -1,140 +0,0 @@
-# ===================================================================
-# Spring Boot configuration.
-#
-# This configuration will be overridden by the Spring profile you use,
-# for example application-dev.yml if you use the "dev" profile.
-#
-# More information on profiles: https://www.jhipster.tech/profiles/
-# More information on configuration properties: https://www.jhipster.tech/common-application-properties/
-# ===================================================================
-
-# ===================================================================
-# Standard Spring Boot properties.
-# Full reference is available at:
-# http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
-# ===================================================================
-
-management:
- endpoints:
- web:
- base-path: /management
- exposure:
- include: ["configprops", "env", "health", "info", "threaddump", "logfile", "jhi-metrics", "prometheus" ]
- endpoint:
- health:
- show-details: when-authorized
- jhi-metrics:
- enabled: true
- info:
- git:
- mode: full
- health:
- mail:
- enabled: false # When using the MailService, configure an SMTP server and set this to true
- metrics:
- export:
- # Prometheus is the default metrics backend
- prometheus:
- enabled: true
- step: 60
- binders:
- jvm:
- enabled: true
- processor:
- enabled: true
- uptime:
- enabled: true
- logback:
- enabled: true
- files:
- enabled: true
- integration:
- enabled: true
- distribution:
- percentiles-histogram:
- all: true
- percentiles:
- all: 0, 0.5, 0.75, 0.95, 0.99, 1.0
- web:
- server:
- auto-time-requests: true
-
-spring:
- application:
- name: Bookstore
- profiles:
- # The commented value for `active` can be replaced with valid Spring profiles to load.
- # Otherwise, it will be filled in by maven when building the WAR file
- # Either way, it can be overridden by `--spring.profiles.active` value passed in the commandline or `-Dspring.profiles.active` set in `JAVA_OPTS`
- active: #spring.profiles.active#
- jpa:
- open-in-view: false
- properties:
- hibernate.jdbc.time_zone: UTC
- hibernate:
- ddl-auto: none
- naming:
- physical-strategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
- implicit-strategy: org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
- messages:
- basename: i18n/messages
- mvc:
- favicon:
- enabled: false
- thymeleaf:
- mode: HTML
-
-server:
- servlet:
- session:
- cookie:
- http-only: true
-
-# Properties to be exposed on the /info management endpoint
-info:
- # Comma separated list of profiles that will trigger the ribbon to show
- display-ribbon-on-profiles: "dev"
-
-# ===================================================================
-# JHipster specific properties
-#
-# Full reference is available at: https://www.jhipster.tech/common-application-properties/
-# ===================================================================
-
-jhipster:
- async:
- core-pool-size: 2
- max-pool-size: 50
- queue-capacity: 10000
- # By default CORS is disabled. Uncomment to enable.
- #cors:
- #allowed-origins: "*"
- #allowed-methods: "*"
- #allowed-headers: "*"
- #exposed-headers: "Authorization,Link,X-Total-Count"
- #allow-credentials: true
- #max-age: 1800
- mail:
- from: Bookstore@localhost
- swagger:
- default-include-pattern: /api/.*
- title: Bookstore API
- description: Bookstore API documentation
- version: 0.0.1
- terms-of-service-url:
- contact-name:
- contact-url:
- contact-email:
- license:
- license-url:
-
-# ===================================================================
-# Application specific properties
-# Add your own application properties here, see the ApplicationProperties class
-# to have type-safe configuration, like in the JHipsterProperties above
-#
-# More documentation is available at:
-# https://www.jhipster.tech/common-application-properties/
-# ===================================================================
-
-# application:
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/authorities.csv b/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/authorities.csv
deleted file mode 100644
index af5c6dfa18..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/authorities.csv
+++ /dev/null
@@ -1,3 +0,0 @@
-name
-ROLE_ADMIN
-ROLE_USER
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/changelog/00000000000000_initial_schema.xml b/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/changelog/00000000000000_initial_schema.xml
deleted file mode 100644
index dd4b01d487..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/changelog/00000000000000_initial_schema.xml
+++ /dev/null
@@ -1,152 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/changelog/20190319124041_added_entity_Book.xml b/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/changelog/20190319124041_added_entity_Book.xml
deleted file mode 100644
index f040387cf1..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/changelog/20190319124041_added_entity_Book.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/master.xml b/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/master.xml
deleted file mode 100644
index e045ee0100..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/master.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/users.csv b/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/users.csv
deleted file mode 100644
index b25922b699..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/users.csv
+++ /dev/null
@@ -1,5 +0,0 @@
-id;login;password_hash;first_name;last_name;email;image_url;activated;lang_key;created_by;last_modified_by
-1;system;$2a$10$mE.qmcV0mFU5NcKh73TZx.z4ueI/.bDWbj0T1BYyqP481kGGarKLG;System;System;system@localhost;;true;en;system;system
-2;anonymoususer;$2a$10$j8S5d7Sr7.8VTOYNviDPOeWX8KcYILUVJBsYV83Y5NtECayypx9lO;Anonymous;User;anonymous@localhost;;true;en;system;system
-3;admin;$2a$10$gSAhZrxMllrbgj/kkK9UceBPpChGWJA7SYIb1Mqo.n5aNLq1/oRrC;Administrator;Administrator;admin@localhost;;true;en;system;system
-4;user;$2a$10$VEjxo0jq2YG9Rbk2HmX9S.k1uZBGYUHdUcid3g/vfiEl7lwWgOH/K;User;User;user@localhost;;true;en;system;system
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/users_authorities.csv b/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/users_authorities.csv
deleted file mode 100644
index 06c5feeeea..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/config/liquibase/users_authorities.csv
+++ /dev/null
@@ -1,6 +0,0 @@
-user_id;authority_name
-1;ROLE_ADMIN
-1;ROLE_USER
-3;ROLE_ADMIN
-3;ROLE_USER
-4;ROLE_USER
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/config/tls/keystore.p12 b/jhipster-5/bookstore-monolith/src/main/resources/config/tls/keystore.p12
deleted file mode 100644
index 364fad7435..0000000000
Binary files a/jhipster-5/bookstore-monolith/src/main/resources/config/tls/keystore.p12 and /dev/null differ
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/i18n/messages.properties b/jhipster-5/bookstore-monolith/src/main/resources/i18n/messages.properties
deleted file mode 100644
index 52a60093c5..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/i18n/messages.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-# Error page
-error.title=Your request cannot be processed
-error.subtitle=Sorry, an error has occurred.
-error.status=Status:
-error.message=Message:
-
-# Activation email
-email.activation.title=Bookstore account activation
-email.activation.greeting=Dear {0}
-email.activation.text1=Your Bookstore account has been created, please click on the URL below to activate it:
-email.activation.text2=Regards,
-email.signature=Bookstore Team.
-
-# Creation email
-email.creation.text1=Your Bookstore account has been created, please click on the URL below to access it:
-
-# Reset email
-email.reset.title=Bookstore password reset
-email.reset.greeting=Dear {0}
-email.reset.text1=For your Bookstore account a password reset was requested, please click on the URL below to reset it:
-email.reset.text2=Regards,
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/logback-spring.xml b/jhipster-5/bookstore-monolith/src/main/resources/logback-spring.xml
deleted file mode 100644
index 4aa548af35..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/logback-spring.xml
+++ /dev/null
@@ -1,66 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
-
diff --git a/jhipster-5/bookstore-monolith/src/main/resources/templates/error.html b/jhipster-5/bookstore-monolith/src/main/resources/templates/error.html
deleted file mode 100644
index 08616bcf1e..0000000000
--- a/jhipster-5/bookstore-monolith/src/main/resources/templates/error.html
+++ /dev/null
@@ -1,163 +0,0 @@
-
-
-
-
-
- Your request cannot be processed
-
-
-
-
- Registration saved! Please check your email for confirmation.
-
-
-
- Registration failed! Please try again later.
-
-
-
- Login name already registered! Please choose another one.
-
-
-
- Email is already in use! Please choose another one.
-
-
-
- The password and its confirmation do not match!
-
-
-
-
-
-
-
-
- If you want to
- sign in, you can try the default accounts: - Administrator (login="admin" and password="admin") - User (login="user" and password="user").
-
- You are logged in as user "{{account.login}}".
-
-
-
- If you want to
- sign in, you can try the default accounts: - Administrator (login="admin" and password="admin") - User (login="user" and password="user").
-