@@ -636,11 +623,11 @@
${project.basedir}/src/main/resources/config/liquibase/master.xml
${project.basedir}/src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml
org.h2.Driver
- jdbc:h2:file:${project.build.directory}/h2db/db/collectiontrackingapplication
+ jdbc:h2:file:${project.build.directory}/h2db/db/ccwapplication
- CollectionTrackingApplication
+ CCWApplication
- hibernate:spring:com.finca.ccwapp.domain?dialect=org.hibernate.dialect.H2Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
+ hibernate:spring:com.finca.ccw.domain?dialect=org.hibernate.dialect.H2Dialect&hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy
true
debug
!test
diff --git a/sonar-project.properties b/sonar-project.properties
index e8ce67d..44be08b 100644
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -1,5 +1,5 @@
-sonar.projectKey=CollectionTrackingApplication
-sonar.projectName=CollectionTrackingApplication generated by jhipster
+sonar.projectKey=CCWApplication
+sonar.projectName=CCWApplication generated by jhipster
sonar.projectVersion=1.0
sonar.sources=src/main/
diff --git a/src/main/docker/app.yml b/src/main/docker/app.yml
index e0a0e96..93c85a4 100644
--- a/src/main/docker/app.yml
+++ b/src/main/docker/app.yml
@@ -1,16 +1,16 @@
version: '2'
services:
- collectiontrackingapplication-app:
- image: collectiontrackingapplication
+ ccwapplication-app:
+ image: ccwapplication
environment:
- _JAVA_OPTIONS=-Xmx512m -Xms256m
- SPRING_PROFILES_ACTIVE=prod,swagger
- MANAGEMENT_METRICS_EXPORT_PROMETHEUS_ENABLED=true
- - SPRING_DATASOURCE_URL=jdbc:mysql://collectiontrackingapplication-mysql:3306/collectiontrackingapplication?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
+ - SPRING_DATASOURCE_URL=jdbc:mysql://ccwapplication-mysql:3306/ccwapplication?useUnicode=true&characterEncoding=utf8&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC&createDatabaseIfNotExist=true
- JHIPSTER_SLEEP=30 # gives time for other services to boot before the application
ports:
- 8080:8080
- collectiontrackingapplication-mysql:
+ ccwapplication-mysql:
extends:
file: mysql.yml
- service: collectiontrackingapplication-mysql
+ service: ccwapplication-mysql
diff --git a/src/main/docker/monitoring.yml b/src/main/docker/monitoring.yml
index 7ce2238..2277ef7 100644
--- a/src/main/docker/monitoring.yml
+++ b/src/main/docker/monitoring.yml
@@ -1,6 +1,6 @@
version: '2'
services:
- collectiontrackingapplication-prometheus:
+ ccwapplication-prometheus:
image: prom/prometheus:v2.18.1
volumes:
- ./prometheus/:/etc/prometheus/
@@ -11,7 +11,7 @@ services:
# On MacOS, remove next line and replace localhost by host.docker.internal in prometheus/prometheus.yml and
# grafana/provisioning/datasources/datasource.yml
network_mode: 'host' # to test locally running service
- collectiontrackingapplication-grafana:
+ ccwapplication-grafana:
image: grafana/grafana:7.0.1
volumes:
- ./grafana/provisioning/:/etc/grafana/provisioning/
diff --git a/src/main/docker/mysql.yml b/src/main/docker/mysql.yml
index a7e1f47..0d457e7 100644
--- a/src/main/docker/mysql.yml
+++ b/src/main/docker/mysql.yml
@@ -1,13 +1,13 @@
version: '2'
services:
- collectiontrackingapplication-mysql:
+ ccwapplication-mysql:
image: mysql:8.0.20
# volumes:
- # - ~/volumes/jhipster/CollectionTrackingApplication/mysql/:/var/lib/mysql/
+ # - ~/volumes/jhipster/CCWApplication/mysql/:/var/lib/mysql/
environment:
- MYSQL_USER=root
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
- - MYSQL_DATABASE=collectiontrackingapplication
+ - MYSQL_DATABASE=ccwapplication
ports:
- 3306:3306
command: mysqld --lower_case_table_names=1 --skip-ssl --character_set_server=utf8mb4 --explicit_defaults_for_timestamp
diff --git a/src/main/docker/sonar.yml b/src/main/docker/sonar.yml
index b6c0edd..f854e17 100644
--- a/src/main/docker/sonar.yml
+++ b/src/main/docker/sonar.yml
@@ -1,6 +1,6 @@
version: '2'
services:
- collectiontrackingapplication-sonar:
+ ccwapplication-sonar:
image: sonarqube:8.3.1-community
ports:
- 9001:9000
diff --git a/src/main/java/com/finca/ccw/ApplicationWebXml.java b/src/main/java/com/finca/ccw/ApplicationWebXml.java
new file mode 100644
index 0000000..8c821d1
--- /dev/null
+++ b/src/main/java/com/finca/ccw/ApplicationWebXml.java
@@ -0,0 +1,19 @@
+package com.finca.ccw;
+
+import io.github.jhipster.config.DefaultProfileUtil;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+/**
+ * This is a helper Java class that provides an alternative to creating a {@code web.xml}.
+ * This will be invoked only when the application is deployed to a Servlet container like Tomcat, JBoss etc.
+ */
+public class ApplicationWebXml extends SpringBootServletInitializer {
+
+ @Override
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+ // set a default to use when no profile is configured.
+ DefaultProfileUtil.addDefaultProfile(application.application());
+ return application.sources(CcwApplicationApp.class);
+ }
+}
diff --git a/src/main/java/com/finca/ccw/CcwApplicationApp.java b/src/main/java/com/finca/ccw/CcwApplicationApp.java
new file mode 100644
index 0000000..8963bb9
--- /dev/null
+++ b/src/main/java/com/finca/ccw/CcwApplicationApp.java
@@ -0,0 +1,104 @@
+package com.finca.ccw;
+
+import com.finca.ccw.config.ApplicationProperties;
+import io.github.jhipster.config.DefaultProfileUtil;
+import io.github.jhipster.config.JHipsterConstants;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+import java.util.Collection;
+import javax.annotation.PostConstruct;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.core.env.Environment;
+
+@SpringBootApplication
+@EnableConfigurationProperties({ LiquibaseProperties.class, ApplicationProperties.class })
+public class CcwApplicationApp {
+ private static final Logger log = LoggerFactory.getLogger(CcwApplicationApp.class);
+
+ private final Environment env;
+
+ public CcwApplicationApp(Environment env) {
+ this.env = env;
+ }
+
+ /**
+ * Initializes CCWApplication.
+ *
+ * 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(CcwApplicationApp.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/src/main/java/com/finca/ccw/aop/logging/LoggingAspect.java b/src/main/java/com/finca/ccw/aop/logging/LoggingAspect.java
new file mode 100644
index 0000000..d842ca1
--- /dev/null
+++ b/src/main/java/com/finca/ccw/aop/logging/LoggingAspect.java
@@ -0,0 +1,110 @@
+package com.finca.ccw.aop.logging;
+
+import io.github.jhipster.config.JHipsterConstants;
+import java.util.Arrays;
+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 org.springframework.core.env.Profiles;
+
+/**
+ * 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 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.finca.ccw.repository..*)" + " || within(com.finca.ccw.service..*)" + " || within(com.finca.ccw.web.rest..*)")
+ public void applicationPackagePointcut() {
+ // Method is empty as this is just a Pointcut, the implementations are in the advices.
+ }
+
+ /**
+ * Retrieves the {@link Logger} associated to the given {@link JoinPoint}.
+ *
+ * @param joinPoint join point we want the logger for.
+ * @return {@link Logger} associated to the given {@link JoinPoint}.
+ */
+ private Logger logger(JoinPoint joinPoint) {
+ return LoggerFactory.getLogger(joinPoint.getSignature().getDeclaringTypeName());
+ }
+
+ /**
+ * 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(Profiles.of(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT))) {
+ logger(joinPoint)
+ .error(
+ "Exception in {}() with cause = \'{}\' and exception = \'{}\'",
+ joinPoint.getSignature().getName(),
+ e.getCause() != null ? e.getCause() : "NULL",
+ e.getMessage(),
+ e
+ );
+ } else {
+ logger(joinPoint)
+ .error(
+ "Exception in {}() with cause = {}",
+ 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 {@link IllegalArgumentException}.
+ */
+ @Around("applicationPackagePointcut() && springBeanPointcut()")
+ public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
+ Logger log = logger(joinPoint);
+ if (log.isDebugEnabled()) {
+ log.debug("Enter: {}() with argument[s] = {}", joinPoint.getSignature().getName(), Arrays.toString(joinPoint.getArgs()));
+ }
+ try {
+ Object result = joinPoint.proceed();
+ if (log.isDebugEnabled()) {
+ log.debug("Exit: {}() with result = {}", joinPoint.getSignature().getName(), result);
+ }
+ return result;
+ } catch (IllegalArgumentException e) {
+ log.error("Illegal argument: {} in {}()", Arrays.toString(joinPoint.getArgs()), joinPoint.getSignature().getName());
+ throw e;
+ }
+ }
+}
diff --git a/src/main/java/com/finca/ccw/config/ApplicationProperties.java b/src/main/java/com/finca/ccw/config/ApplicationProperties.java
new file mode 100644
index 0000000..85ee3a1
--- /dev/null
+++ b/src/main/java/com/finca/ccw/config/ApplicationProperties.java
@@ -0,0 +1,12 @@
+package com.finca.ccw.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+/**
+ * Properties specific to CCW Application.
+ *
+ * Properties are configured in the {@code 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/src/main/java/com/finca/ccw/config/AsyncConfiguration.java b/src/main/java/com/finca/ccw/config/AsyncConfiguration.java
new file mode 100644
index 0000000..0d61bc1
--- /dev/null
+++ b/src/main/java/com/finca/ccw/config/AsyncConfiguration.java
@@ -0,0 +1,45 @@
+package com.finca.ccw.config;
+
+import io.github.jhipster.async.ExceptionHandlingAsyncTaskExecutor;
+import java.util.concurrent.Executor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
+import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
+import org.springframework.boot.autoconfigure.task.TaskExecutionProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.AsyncConfigurer;
+import org.springframework.scheduling.annotation.EnableAsync;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+@Configuration
+@EnableAsync
+@EnableScheduling
+public class AsyncConfiguration implements AsyncConfigurer {
+ private final Logger log = LoggerFactory.getLogger(AsyncConfiguration.class);
+
+ private final TaskExecutionProperties taskExecutionProperties;
+
+ public AsyncConfiguration(TaskExecutionProperties taskExecutionProperties) {
+ this.taskExecutionProperties = taskExecutionProperties;
+ }
+
+ @Override
+ @Bean(name = "taskExecutor")
+ public Executor getAsyncExecutor() {
+ log.debug("Creating Async Task Executor");
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ executor.setCorePoolSize(taskExecutionProperties.getPool().getCoreSize());
+ executor.setMaxPoolSize(taskExecutionProperties.getPool().getMaxSize());
+ executor.setQueueCapacity(taskExecutionProperties.getPool().getQueueCapacity());
+ executor.setThreadNamePrefix(taskExecutionProperties.getThreadNamePrefix());
+ return new ExceptionHandlingAsyncTaskExecutor(executor);
+ }
+
+ @Override
+ public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
+ return new SimpleAsyncUncaughtExceptionHandler();
+ }
+}
diff --git a/src/main/java/com/finca/ccw/config/CacheConfiguration.java b/src/main/java/com/finca/ccw/config/CacheConfiguration.java
new file mode 100644
index 0000000..9cc094f
--- /dev/null
+++ b/src/main/java/com/finca/ccw/config/CacheConfiguration.java
@@ -0,0 +1,78 @@
+package com.finca.ccw.config;
+
+import io.github.jhipster.config.JHipsterProperties;
+import io.github.jhipster.config.cache.PrefixedKeyGenerator;
+import java.time.Duration;
+import org.ehcache.config.builders.*;
+import org.ehcache.jsr107.Eh107Configuration;
+import org.hibernate.cache.jcache.ConfigSettings;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer;
+import org.springframework.boot.autoconfigure.orm.jpa.HibernatePropertiesCustomizer;
+import org.springframework.boot.info.BuildProperties;
+import org.springframework.boot.info.GitProperties;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.cache.interceptor.KeyGenerator;
+import org.springframework.context.annotation.*;
+
+@Configuration
+@EnableCaching
+public class CacheConfiguration {
+ private GitProperties gitProperties;
+ private BuildProperties buildProperties;
+ private final javax.cache.configuration.Configuration