diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index f83012e..0210047 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -1,4 +1,4 @@
-# These are supported funding model platforms
-
-patreon: apssouza
-custom: ["https://www.buymeacoffee.com/apssouza"]
+# These are supported funding model platforms
+
+patreon: apssouza
+custom: ["https://www.buymeacoffee.com/apssouza"]
diff --git a/.gitignore b/.gitignore
index 281006b..766a5d2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,54 +1,54 @@
-# Compiled source #
-###################
-*.com
-*.class
-*.dll
-*.exe
-*.o
-*.so
-
-# Packages #
-############
-# it's better to unpack these files and commit the raw source
-# git has its own built in compression methods
-*.7z
-*.dmg
-*.gz
-*.iso
-*.rar
-*.tar
-*.zip
-
-# Logs and databases #
-######################
-*.log
-*.sqlite
-
-# OS generated files #
-######################
-.DS_Store
-.DS_Store?
-._*
-.Spotlight-V100
-.Trashes
-ehthumbs.db
-Thumbs.db
-.cache
-.settings
-.tmproj
-.idea
-*nbprojects
-*nbproject
-*nbactions.xml
-*nb-configuration.xml
-*.svn
-nb_jr_remoting.cfg
-
-.project
-.classpath
-.idea
-*.iml
-atlassian-ide-plugin.xml
-target
-*rebel*
+# Compiled source #
+###################
+*.com
+*.class
+*.dll
+*.exe
+*.o
+*.so
+
+# Packages #
+############
+# it's better to unpack these files and commit the raw source
+# git has its own built in compression methods
+*.7z
+*.dmg
+*.gz
+*.iso
+*.rar
+*.tar
+*.zip
+
+# Logs and databases #
+######################
+*.log
+*.sqlite
+
+# OS generated files #
+######################
+.DS_Store
+.DS_Store?
+._*
+.Spotlight-V100
+.Trashes
+ehthumbs.db
+Thumbs.db
+.cache
+.settings
+.tmproj
+.idea
+*nbprojects
+*nbproject
+*nbactions.xml
+*nb-configuration.xml
+*.svn
+nb_jr_remoting.cfg
+
+.project
+.classpath
+.idea
+*.iml
+atlassian-ide-plugin.xml
+target
+*rebel*
*mvn*
\ No newline at end of file
diff --git a/Jenkinsfile b/Jenkinsfile
index e7974b2..e161c54 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,11 +1,11 @@
-node {
- stage('Fetch changes') {
- git 'https://github.com/apssouza22/java-microservice.git'
- }
- stage('Build images') {
- sh "./package-projects.sh"
- }
- stage('Deploy ECS') {
- sh "./aws-deploy.sh"
- }
-}
+node {
+ stage('Fetch changes') {
+ git 'https://github.com/apssouza22/java-microservice.git'
+ }
+ stage('Build images') {
+ sh "./package-projects.sh"
+ }
+ stage('Deploy ECS') {
+ sh "./aws-deploy.sh"
+ }
+}
diff --git a/LICENSE b/LICENSE
index d783389..decc3d1 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,21 +1,21 @@
-MIT License
-
-Copyright (c) 2017 Alexsandro Souza
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
+MIT License
+
+Copyright (c) 2017 Alexsandro Souza
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index 88815ef..a0e25c5 100644
--- a/README.md
+++ b/README.md
@@ -1,210 +1,210 @@
-# Bootstrap project to work with microservices using Java
-
-Watch the videos demonstrating the project
-
-
-
-Read about the project [here](https://dzone.com/articles/bootstrapping-microservices-your-microservice-arch)
-
-The idea of this project is to provide you a bootstrap for your next microservice architecture using Java. we are addressing main challenges that everyone faces when is starting with microservices. This project will definitely help you get an understand about microservices world and save you a lot of time in setting your initial microservice architecture.
-
-Basically, if you are interested in microservice, either study or want to implement microservice approach at your work, this project is for you!
-
-
-
-Microservice principles addressed:
-
-* Scalability
-* Availability
-* Resiliency
-* Independent, autonomous
-* Decentralized governance
-* Failure isolation
-* Auto-Provisioning
-* Continuous delivery through DevOps
-
-Microservice patterns:
-
-* Circuit Breakers
-* API Gateway
-* Command Query Responsibility Segregation (CQRS)
-* Saga Pattern
-* Event Sourcing
-* Log Aggregation
-* Health Check
-* Service Discovery
-* External Configuration
-* Distributed authentication
-
-
------
-## Free Advanced Java Course
-I am the author of the [Advanced Java for adults course](https://www.udemy.com/course/advanced-java-for-adults/?referralCode=8014CCF0A5A931ADED5F). This course contains advanced and not conventional lessons. In this course, you will learn to think differently from those who have a limited view of software development. I will provoke you to reflect on decisions that you take in your day to day job, which might not be the best ones. This course is for middle to senior developers and we will not teach Java language features but how to lead complex Java projects.
-
-This course's lectures are based on a Trading system, an opensource project hosted on my [Github](https://github.com/apssouza22/trading-system).
-
------
-
-
-Technologies that you will see in this system:
-
-Spring Boot, Spring Data, Spring Cloud Eureka, Load Balancing with Ribbon,
-Declarative REST Clients with Feign, Software Circuit Breakers with Hystrix,
-Administrating using Spring admin,Log management with Elastic search, Logstash and Kibana (ELK),
-Server load balancing with Nginx,
-Infrastructure management with Docker-compose, JMX application monitoring,
-Security with Spring Security OAuth, Oauth2 with JWT, Aspect Oriented Programing,
-Distributed events with Kafka, Spring Stream Maven Multimodule project, Event Sourcing,
-CQRS, REST, Web Sockets, Continuous deploy with Jenkins, and all developed using Java 8.
-
-
-
-
-
-## How to use
-
-* run `package-projects.sh`
-* run `docker-orchestrate.sh`
-* `docker-compose -p todo up`
-
-## Continuous deploy using Jenkins Pipeline
-We have created a docker image in order to have continuous deploy in our project [here](https://github.com/apssouza22/build-deploy).
-
-This image will contain all necessary to build our project, create the Docker images and
-deploy on AWS using ECS containers.
-
-To make this integration easy, we have added the `Jenkinsfile` with the steps necessary to have
-the Docker image built. To use it, you will need just to configure a Job on Jenkins using Pipeline plugin
-and paste the content of the Jenkinsfile in the Pipeline script box. Have a look at this
-[video](https://www.youtube.com/watch?v=u3xLXEnlu2M&t=1023s&index=2&list=PLoO1q0-ZB3v6ZN6qvk0dsRRuxjiAQDuZx)
-to check how to work with Jenkins pipeline
-
-### Deploy on AWS
-* Create your credentials on AWS
-* Create your cluster on AWS console
-* Have the build-deploy container running (Checkout in the project's README how to do it)
-* Access Jenkins painal
-* Create a pipeline job
-* Run the Job
-
-### Accessing the services
-* Authenticate -> ```curl -X POST -vu todo-app:123456 http://localhost:8017/oauth/token -H "Accept: application/json" -d "password=1234&username=apssouza22@gmail.com&grant_type=password&scope=write&client_secret=123456&client_id=todo-app"```
-
-* Get data using the access_token -> `localhost:8018/accounts?access_token={access_token}` or `curl -H "Authorization: Bearer $TOKEN" "localhost:8018/path"`
-
-### Scaling
-NGINX will be configured for browser caching of the static content and Load balance. For that we will need to scale our App Gateway
-and update manually the ports in `default.conf` file, in the upstream configuration section:
-
-```
-upstream backend {
- server gateway:8018;
- server gateway:DYNAMICPORT;
- server gateway:DYNAMICPORT;
-}
-```
-
-And we will run the compose file with `--scale` parameter:
-
-`docker-compose -f proxy-docker-compose.yml -p todo up --scale gateway=2`
-
-### URLs
-Monitoring stream - http://localhost:8022/turbine.stream
-
-To-dos http://localhost:8015/todos
-
-Users http://localhost:8016/accounts
-
-Eureka server - http://localhost:8010/
-
-Config server - http://localhost:8888/
-
-Boot admin - http://localhost:8026
-
-Kimbana - http://localhost:5601
-
-Elasticsearch Info: http://localhost:9200
-
-Elasticsearch Status: http://localhost:9200/_status?pretty
-
-NGINX Status: localhost:8055/nginx_status
-
-docker-compose -p todo up
-docker-compose -p todo down
-
-## OBS
-* In order to make ELK work we need to reserve 3GB RAM to docker(docker settings - advanced - memory )
-* Have a look at the Readme of each service/ module to see the explanation about it.
-* On Kimbana create a filter called `filebeat-*` to see the logs
-
-## Useful Commands
-
-### Creating to-do via Curl
-```
-curl -d '{"userEmail":"alex@test.com", "caption":"post caption", "description":"desc", "priority": 1}' -H "Content-Type: application/json" -X POST http://localhost:8015/todos
-```
-
-### Stopping, Starting, Restarting...
-
-```
-# running separated container and link to the network infrastructure
-docker run -d -p 8018:8018 --network todo_net --add-host eureka:172.19.0.5 --add-host config:172.19.0.2 todo/reminder-service
-
-# orchestrate start-up of containers, tailing the logs...
-docker-compose -p music up -d container-name && docker logs elk --follow # ^C to break
-
-# stopping containers
-docker-compose todo stop
-docker-compose todo down
-
-# starting containers
-docker-compose -p todo up
-
-# removing containers
-docker-compose todo rm
-
-```
-
-### Application Startup Issues
-
-```bash
-# stop / start Tomcat
-docker exec -it container-name sh /usr/local/tomcat/bin/startup.sh
-docker exec -it container-name sh /usr/local/tomcat/bin/shutdown.sh
-
-# check logs for start-up issues...
-docker exec -it container-name cat /usr/local/tomcat/logs/catalina.out
-docker logs container-name
-```
-
-### Kafka
-Inside the Kafka container
-
-```
-# event consume
-/opt/kafka/bin/kafka-console-consumer.sh --zookeeper zookeeper:2181 --topic todo-mail --from-beginning
-
-# producer console
-/opt/kafka/bin/kafka-console-producer.sh --broker-list kafka:9092 --topic todo-mail
-
-# Listing topics
-/opt/kafka/bin/kafka-topics.sh --list --zookeeper zookeeper:2181
-
-# Create topic
-/opt/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic pcs
-```
-
-### Data
-```
-#create a new To-Do
-curl -H "Content-Type: application/json" -X POST -d '{"id":161,"caption":"Test caption 3","userEmail":"marcia@gmail.com","description":"description 3","createdat":null,"priority":2,"status":"PENDING","version":0,"valid":true}' http://localhost:8015/todos
-```
-
-## TODO
-* Add private maven repository Artifactory
-* Manager services integration through Spring Webflow
-* Add Distributed Tracing
-
-
-## That's all. Leave a star if it helped you!
+s# Bootstrap project to work with microservices using Java
+
+Watch the videos demonstrating the project
+
+
+
+Read about the project [here](https://dzone.com/articles/bootstrapping-microservices-your-microservice-arch)
+
+The idea of this project is to provide you a bootstrap for your next microservice architecture using Java. we are addressing main challenges that everyone faces when is starting with microservices. This project will definitely help you get an understand about microservices world and save you a lot of time in setting your initial microservice architecture.
+
+Basically, if you are interested in microservice, either study or want to implement microservice approach at your work, this project is for you!
+
+
+
+Microservice principles addressed:
+
+* Scalability
+* Availability
+* Resiliency
+* Independent, autonomous
+* Decentralized governance
+* Failure isolation
+* Auto-Provisioning
+* Continuous delivery through DevOps
+
+Microservice patterns:
+
+* Circuit Breakers
+* API Gateway
+* Command Query Responsibility Segregation (CQRS)
+* Saga Pattern
+* Event Sourcing
+* Log Aggregation
+* Health Check
+* Service Discovery
+* External Configuration
+* Distributed authentication
+
+
+-----
+## Free Advanced Java Course
+I am the author of the [Advanced Java for adults course](https://www.udemy.com/course/advanced-java-for-adults/?referralCode=8014CCF0A5A931ADED5F). This course contains advanced and not conventional lessons. In this course, you will learn to think differently from those who have a limited view of software development. I will provoke you to reflect on decisions that you take in your day to day job, which might not be the best ones. This course is for middle to senior developers and we will not teach Java language features but how to lead complex Java projects.
+
+This course's lectures are based on a Trading system, an opensource project hosted on my [Github](https://github.com/apssouza22/trading-system).
+
+-----
+
+
+Technologies that you will see in this system:
+
+Spring Boot, Spring Data, Spring Cloud Eureka, Load Balancing with Ribbon,
+Declarative REST Clients with Feign, Software Circuit Breakers with Hystrix,
+Administrating using Spring admin,Log management with Elastic search, Logstash and Kibana (ELK),
+Server load balancing with Nginx,
+Infrastructure management with Docker-compose, JMX application monitoring,
+Security with Spring Security OAuth, Oauth2 with JWT, Aspect Oriented Programing,
+Distributed events with Kafka, Spring Stream Maven Multimodule project, Event Sourcing,
+CQRS, REST, Web Sockets, Continuous deploy with Jenkins, and all developed using Java 8.
+
+
+
+
+
+## How to use
+
+* run `package-projects.sh`
+* run `docker-orchestrate.sh`
+* `docker-compose -p todo up`
+
+## Continuous deploy using Jenkins Pipeline
+We have created a docker image in order to have continuous deploy in our project [here](https://github.com/apssouza22/build-deploy).
+
+This image will contain all necessary to build our project, create the Docker images and
+deploy on AWS using ECS containers.
+
+To make this integration easy, we have added the `Jenkinsfile` with the steps necessary to have
+the Docker image built. To use it, you will need just to configure a Job on Jenkins using Pipeline plugin
+and paste the content of the Jenkinsfile in the Pipeline script box. Have a look at this
+[video](https://www.youtube.com/watch?v=u3xLXEnlu2M&t=1023s&index=2&list=PLoO1q0-ZB3v6ZN6qvk0dsRRuxjiAQDuZx)
+to check how to work with Jenkins pipeline
+
+### Deploy on AWS
+* Create your credentials on AWS
+* Create your cluster on AWS console
+* Have the build-deploy container running (Checkout in the project's README how to do it)
+* Access Jenkins painal
+* Create a pipeline job
+* Run the Job
+
+### Accessing the services
+* Authenticate -> ```curl -X POST -vu todo-app:123456 http://localhost:8017/oauth/token -H "Accept: application/json" -d "password=1234&username=apssouza22@gmail.com&grant_type=password&scope=write&client_secret=123456&client_id=todo-app"```
+
+* Get data using the access_token -> `localhost:8018/accounts?access_token={access_token}` or `curl -H "Authorization: Bearer dG9kby1hcHA6MTIzNDU2" "localhost:8018/path"`
+
+### Scaling
+NGINX will be configured for browser caching of the static content and Load balance. For that we will need to scale our App Gateway
+and update manually the ports in `default.conf` file, in the upstream configuration section:
+
+```
+upstream backend {
+ server gateway:8018;
+ server gateway:DYNAMICPORT;
+ server gateway:DYNAMICPORT;
+}
+```
+
+And we will run the compose file with `--scale` parameter:
+
+`docker-compose -f proxy-docker-compose.yml -p todo up --scale gateway=2`
+
+### URLs
+Monitoring stream - http://localhost:8022/turbine.stream
+
+To-dos http://localhost:8015/todos
+
+Users http://localhost:8016/accounts
+
+Eureka server - http://localhost:8010/
+
+Config server - http://localhost:8888/
+
+Boot admin - http://localhost:8026
+
+Kimbana - http://localhost:5601
+
+Elasticsearch Info: http://localhost:9200
+
+Elasticsearch Status: http://localhost:9200/_status?pretty
+
+NGINX Status: localhost:8055/nginx_status
+
+docker-compose -p todo up
+docker-compose -p todo down
+
+## OBS
+* In order to make ELK work we need to reserve 3GB RAM to docker(docker settings - advanced - memory )
+* Have a look at the Readme of each service/ module to see the explanation about it.
+* On Kimbana create a filter called `filebeat-*` to see the logs
+
+## Useful Commands
+
+### Creating to-do via Curl
+```
+curl -d '{"userEmail":"alex@test.com", "caption":"post caption", "description":"desc", "priority": 1}' -H "Content-Type: application/json" -X POST http://localhost:8015/todos
+```
+
+### Stopping, Starting, Restarting...
+
+```
+# running separated container and link to the network infrastructure
+docker run -d -p 8018:8018 --network todo_net --add-host eureka:172.19.0.5 --add-host config:172.19.0.2 todo/reminder-service
+
+# orchestrate start-up of containers, tailing the logs...
+docker-compose -p music up -d container-name && docker logs elk --follow # ^C to break
+
+# stopping containers
+docker-compose todo stop
+docker-compose todo down
+
+# starting containers
+docker-compose -p todo up
+
+# removing containers
+docker-compose todo rm
+
+```
+
+### Application Startup Issues
+
+```bash
+# stop / start Tomcat
+docker exec -it container-name sh /usr/local/tomcat/bin/startup.sh
+docker exec -it container-name sh /usr/local/tomcat/bin/shutdown.sh
+
+# check logs for start-up issues...
+docker exec -it container-name cat /usr/local/tomcat/logs/catalina.out
+docker logs container-name
+```
+
+### Kafka
+Inside the Kafka container
+
+```
+# event consume
+/opt/kafka/bin/kafka-console-consumer.sh --zookeeper zookeeper:2181 --topic todo-mail --from-beginning
+
+# producer console
+/opt/kafka/bin/kafka-console-producer.sh --broker-list kafka:9092 --topic todo-mail
+
+# Listing topics
+/opt/kafka/bin/kafka-topics.sh --list --zookeeper zookeeper:2181
+
+# Create topic
+/opt/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic pcs
+```
+
+### Data
+```
+#create a new To-Do
+curl -H "Content-Type: application/json" -X POST -d '{"id":161,"caption":"Test caption 3","userEmail":"marcia@gmail.com","description":"description 3","createdat":null,"priority":2,"status":"PENDING","version":0,"valid":true}' http://localhost:8015/todos
+```
+
+## TODO
+* Add private maven repository Artifactory
+* Manager services integration through Spring Webflow
+* Add Distributed Tracing
+
+
+## That's all. Leave a star if it helped you!
diff --git a/admin-server/Jenkinsfile b/admin-server/Jenkinsfile
index dce49f6..877ff2e 100644
--- a/admin-server/Jenkinsfile
+++ b/admin-server/Jenkinsfile
@@ -1,16 +1,16 @@
-node {
- stage('Fetch changes') {
- git 'https://github.com/apssouza22/java-microservice.git'
- }
- stage('Build image') {
- // Run the maven build
- if (isUnix()) {
- sh "mvn -f ./admin-server/pom.xml -Pdockerimage docker:build "
- } else {
- echo "Not ready for windows"
- }
- }
- stage('Deploy ECS') {
- echo "TODO deploy on AWS"
- }
-}
+node {
+ stage('Fetch changes') {
+ git 'https://github.com/apssouza22/java-microservice.git'
+ }
+ stage('Build image') {
+ // Run the maven build
+ if (isUnix()) {
+ sh "mvn -f ./admin-server/pom.xml -Pdockerimage docker:build "
+ } else {
+ echo "Not ready for windows"
+ }
+ }
+ stage('Deploy ECS') {
+ echo "TODO deploy on AWS"
+ }
+}
diff --git a/admin-server/README b/admin-server/README
index 98a45f4..08ca15d 100644
--- a/admin-server/README
+++ b/admin-server/README
@@ -1,5 +1,5 @@
-# Admin server
-
-This is a simple admin interface for Spring Boot applications.
-
-Have a look at the project to get a better Idea fo it. https://github.com/codecentric/spring-boot-admin
+# Admin server
+
+This is a simple admin interface for Spring Boot applications.
+
+Have a look at the project to get a better Idea fo it. https://github.com/codecentric/spring-boot-admin
diff --git a/admin-server/pom.xml b/admin-server/pom.xml
index 72a5fe2..e26c9cd 100644
--- a/admin-server/pom.xml
+++ b/admin-server/pom.xml
@@ -1,165 +1,165 @@
-
- 4.0.0
-
- parent-todo-ms
- com.apssouza
- 0.0.1-SNAPSHOT
-
- admin-server
-
-
-
-
-
-
-
- de.codecentric
- spring-boot-admin-server
- 1.5.3
-
-
- de.codecentric
- spring-boot-admin-server-ui
- 1.5.3
-
-
- org.springframework.cloud
- spring-cloud-starter-eureka
-
-
-
- org.springframework.cloud
- spring-cloud-starter-config
-
-
- de.codecentric
- spring-boot-admin-server-ui-activiti
- 1.4.3
-
-
- de.codecentric
- spring-boot-admin-server-ui-hystrix
- 1.4.3
-
-
-
- ${project.artifactId}
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
- repackage
- build-info
-
-
-
-
- de.codecentric.boot.admin.SpringBootAdminApplication
- false
-
-
-
-
-
-
- dockerimage
-
- todo/admin-server
- src/main/resources/docker
- ${project.build.directory}/dockerimgbuild
- Dockerfile
-
-
-
-
-
- maven-resources-plugin
-
-
- copy-resources
- package
-
- copy-resources
-
-
- ${docker.build.directory}
-
-
- ${docker.image.src.root}
- false
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- copy
- package
-
- copy
-
-
-
-
- ${project.groupId}
- ${project.artifactId}
- ${project.version}
- jar
- true
- ${docker.build.directory}/application/lib
- springboot-webapp.jar
-
-
-
-
- ${docker.build.directory}
- true
- true
-
-
-
-
-
-
-
- io.fabric8
- docker-maven-plugin
- 0.19.0
-
-
- unix:///var/run/docker.sock
-
-
- ${docker.image.name}
-
-
- latest
-
- ${docker.build.directory}/${docker.file.name}
-
-
-
-
-
-
-
-
-
-
+
+ 4.0.0
+
+ parent-todo-ms
+ com.apssouza
+ 0.0.1-SNAPSHOT
+
+ admin-server
+
+
+
+
+
+
+
+ de.codecentric
+ spring-boot-admin-server
+ 1.5.3
+
+
+ de.codecentric
+ spring-boot-admin-server-ui
+ 1.5.3
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+ de.codecentric
+ spring-boot-admin-server-ui-activiti
+ 1.4.3
+
+
+ de.codecentric
+ spring-boot-admin-server-ui-hystrix
+ 1.4.3
+
+
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+ build-info
+
+
+
+
+ de.codecentric.boot.admin.SpringBootAdminApplication
+ false
+
+
+
+
+
+
+ dockerimage
+
+ todo/admin-server
+ src/main/resources/docker
+ ${project.build.directory}/dockerimgbuild
+ Dockerfile
+
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-resources
+ package
+
+ copy-resources
+
+
+ ${docker.build.directory}
+
+
+ ${docker.image.src.root}
+ false
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy
+ package
+
+ copy
+
+
+
+
+ ${project.groupId}
+ ${project.artifactId}
+ ${project.version}
+ jar
+ true
+ ${docker.build.directory}/application/lib
+ springboot-webapp.jar
+
+
+
+
+ ${docker.build.directory}
+ true
+ true
+
+
+
+
+
+
+
+ io.fabric8
+ docker-maven-plugin
+ 0.19.0
+
+
+ unix:///var/run/docker.sock
+
+
+ ${docker.image.name}
+
+
+ latest
+
+ ${docker.build.directory}/${docker.file.name}
+
+
+
+
+
+
+
+
+
+
diff --git a/admin-server/src/main/java/de/codecentric/boot/admin/SpringBootAdminApplication.java b/admin-server/src/main/java/de/codecentric/boot/admin/SpringBootAdminApplication.java
index 878303d..0f39842 100644
--- a/admin-server/src/main/java/de/codecentric/boot/admin/SpringBootAdminApplication.java
+++ b/admin-server/src/main/java/de/codecentric/boot/admin/SpringBootAdminApplication.java
@@ -1,36 +1,36 @@
-/*
- * Copyright 2014 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package de.codecentric.boot.admin;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.context.annotation.Configuration;
-
-import de.codecentric.boot.admin.config.EnableAdminServer;
-
-
-// tag::application-eureka[]
-@Configuration
-@EnableAutoConfiguration
-@EnableDiscoveryClient
-@EnableAdminServer
-public class SpringBootAdminApplication {
- public static void main(String[] args) {
- SpringApplication.run(SpringBootAdminApplication.class, args);
- }
-}
-// end::application-eureka[]
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package de.codecentric.boot.admin;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.context.annotation.Configuration;
+
+import de.codecentric.boot.admin.config.EnableAdminServer;
+
+
+// tag::application-eureka[]
+@Configuration
+@EnableAutoConfiguration
+@EnableDiscoveryClient
+@EnableAdminServer
+public class SpringBootAdminApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(SpringBootAdminApplication.class, args);
+ }
+}
+// end::application-eureka[]
diff --git a/admin-server/src/main/resources/application.yml b/admin-server/src/main/resources/application.yml
index ce95b24..48e5a06 100644
--- a/admin-server/src/main/resources/application.yml
+++ b/admin-server/src/main/resources/application.yml
@@ -1,3 +1,3 @@
-spring:
- application:
- name: admin
+spring:
+ application:
+ name: admin
diff --git a/admin-server/src/main/resources/bootstrap.yml b/admin-server/src/main/resources/bootstrap.yml
index b940bf4..47aefda 100644
--- a/admin-server/src/main/resources/bootstrap.yml
+++ b/admin-server/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
----
-spring:
- cloud:
- config:
- uri: http://config:8888
+---
+spring:
+ cloud:
+ config:
+ uri: http://config:8888
\ No newline at end of file
diff --git a/admin-server/src/main/resources/docker/Dockerfile b/admin-server/src/main/resources/docker/Dockerfile
index ab30719..fe9779e 100644
--- a/admin-server/src/main/resources/docker/Dockerfile
+++ b/admin-server/src/main/resources/docker/Dockerfile
@@ -1,37 +1,37 @@
-FROM openjdk:8
-
-
-MAINTAINER Alexsandro
-ENV REFRESHED_AT 2017-09-17
-
-ENV TERM xterm
-ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
-
-RUN apt-get update -qq \
- && apt-get install -qqy curl wget \
- && apt-get clean \
- \
- && touch /var/log/todo.log \
- && chmod 666 /var/log/todo.log
-
-ADD application/lib/springboot-webapp.jar /app.jar
-ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
-RUN bash -c 'chmod +x wait-for-it.sh'
-
-# install Filebeat
-ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
-RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
- && dpkg -i ${FILEBEAT_VERSION} \
- && rm ${FILEBEAT_VERSION}
-
-# configure Filebeat
-ADD filebeat.yml /etc/filebeat/filebeat.yml
-
-# CA cert
-RUN mkdir -p /etc/pki/tls/certs
-ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
-
-# start Filebeat
-ADD ./start.sh /usr/local/bin/start.sh
-RUN chmod +x /usr/local/bin/start.sh
+FROM openjdk:8
+
+
+MAINTAINER Alexsandro
+ENV REFRESHED_AT 2017-09-17
+
+ENV TERM xterm
+ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
+
+RUN apt-get update -qq \
+ && apt-get install -qqy curl wget \
+ && apt-get clean \
+ \
+ && touch /var/log/todo.log \
+ && chmod 666 /var/log/todo.log
+
+ADD application/lib/springboot-webapp.jar /app.jar
+ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
+RUN bash -c 'chmod +x wait-for-it.sh'
+
+# install Filebeat
+ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
+RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
+ && dpkg -i ${FILEBEAT_VERSION} \
+ && rm ${FILEBEAT_VERSION}
+
+# configure Filebeat
+ADD filebeat.yml /etc/filebeat/filebeat.yml
+
+# CA cert
+RUN mkdir -p /etc/pki/tls/certs
+ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
+
+# start Filebeat
+ADD ./start.sh /usr/local/bin/start.sh
+RUN chmod +x /usr/local/bin/start.sh
CMD [ "/usr/local/bin/start.sh" ]
\ No newline at end of file
diff --git a/admin-server/src/main/resources/docker/filebeat.yml b/admin-server/src/main/resources/docker/filebeat.yml
index 09119d8..480a94e 100644
--- a/admin-server/src/main/resources/docker/filebeat.yml
+++ b/admin-server/src/main/resources/docker/filebeat.yml
@@ -1,30 +1,30 @@
-output:
- logstash:
- enabled: true
- hosts:
- - elk:5044
- timeout: 15
- tls:
- certificate_authorities:
- - /etc/pki/tls/certs/logstash-beats.crt
-
-filebeat:
- prospectors:
- -
- paths:
- - /var/log/syslog
- - /var/log/auth.log
- document_type: syslog
- -
- paths:
- - /var/log/spring-music.log
- document_type: log4j
- multiline:
- pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
- negate: true
- match: after
- -
- paths:
- - /usr/local/tomcat/logs/*.out
- - /usr/local/tomcat/logs/*.log
- document_type: tomcat
+output:
+ logstash:
+ enabled: true
+ hosts:
+ - elk:5044
+ timeout: 15
+ tls:
+ certificate_authorities:
+ - /etc/pki/tls/certs/logstash-beats.crt
+
+filebeat:
+ prospectors:
+ -
+ paths:
+ - /var/log/syslog
+ - /var/log/auth.log
+ document_type: syslog
+ -
+ paths:
+ - /var/log/spring-music.log
+ document_type: log4j
+ multiline:
+ pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
+ negate: true
+ match: after
+ -
+ paths:
+ - /usr/local/tomcat/logs/*.out
+ - /usr/local/tomcat/logs/*.log
+ document_type: tomcat
diff --git a/admin-server/src/main/resources/docker/logstash-beats.crt b/admin-server/src/main/resources/docker/logstash-beats.crt
index d9b71cf..1c86bc3 100644
--- a/admin-server/src/main/resources/docker/logstash-beats.crt
+++ b/admin-server/src/main/resources/docker/logstash-beats.crt
@@ -1,18 +1,18 @@
------BEGIN CERTIFICATE-----
-MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
-BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
-DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
-0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
-9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
-PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
-qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
-KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
-4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
-VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
-hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
-okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
-T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
-ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
-kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
-Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
------END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
+BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
+DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
+0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
+9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
+PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
+qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
+KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
+4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
+VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
+hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
+okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
+T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
+ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
+kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
+Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
+-----END CERTIFICATE-----
diff --git a/admin-server/src/main/resources/docker/start.sh b/admin-server/src/main/resources/docker/start.sh
index b68b2fb..eff4532 100644
--- a/admin-server/src/main/resources/docker/start.sh
+++ b/admin-server/src/main/resources/docker/start.sh
@@ -1,5 +1,4 @@
#!/bin/bash
-
curl -XPUT 'http://elk:9200/_template/filebeat?pretty' -d@/etc/filebeat/filebeat.template.json
/etc/init.d/filebeat start
-java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
+java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
\ No newline at end of file
diff --git a/admin-server/src/main/resources/logback-spring.xml b/admin-server/src/main/resources/logback-spring.xml
index 1d1b77d..4effdda 100644
--- a/admin-server/src/main/resources/logback-spring.xml
+++ b/admin-server/src/main/resources/logback-spring.xml
@@ -1,5 +1,5 @@
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/api-gateway/Jenkinsfile b/api-gateway/Jenkinsfile
index c798b20..a1eeb71 100644
--- a/api-gateway/Jenkinsfile
+++ b/api-gateway/Jenkinsfile
@@ -1,16 +1,16 @@
-node {
- stage('Fetch changes') {
- git 'https://github.com/apssouza22/java-microservice.git'
- }
- stage('Build image') {
- // Run the maven build
- if (isUnix()) {
- sh "mvn -f ./api-gateway/pom.xml -Pdockerimage docker:build"
- } else {
- echo "Not ready for windows"
- }
- }
- stage('Deploy ECS') {
- echo "TODO deploy on AWS"
- }
-}
+node {
+ stage('Fetch changes') {
+ git 'https://github.com/apssouza22/java-microservice.git'
+ }
+ stage('Build image') {
+ // Run the maven build
+ if (isUnix()) {
+ sh "mvn -f ./api-gateway/pom.xml -Pdockerimage docker:build"
+ } else {
+ echo "Not ready for windows"
+ }
+ }
+ stage('Deploy ECS') {
+ echo "TODO deploy on AWS"
+ }
+}
diff --git a/api-gateway/README b/api-gateway/README
index 0f64af1..5e69267 100644
--- a/api-gateway/README
+++ b/api-gateway/README
@@ -1,11 +1,11 @@
-# API Gateway
-
-We are implementing an API gateway pattern to our project.
-
-This is the single entry point for all clients. The API gateway handles the requests.
-At the moment we have in this layer only the authentication using JWT then the requests are simply proxied/routed to the appropriate service.
-
-## To-do
-
-* Add cache handling
-
+# API Gateway
+
+We are implementing an API gateway pattern to our project.
+
+This is the single entry point for all clients. The API gateway handles the requests.
+At the moment we have in this layer only the authentication using JWT then the requests are simply proxied/routed to the appropriate service.
+
+## To-do
+
+* Add cache handling
+
diff --git a/api-gateway/nbactions.xml b/api-gateway/nbactions.xml
index fb90e79..98f1236 100644
--- a/api-gateway/nbactions.xml
+++ b/api-gateway/nbactions.xml
@@ -1,18 +1,18 @@
-
-
-
- debug
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.apssouza.BasicApplication
- java
- true
-
-
-
+
+
+
+ debug
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
+
+
+ -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.apssouza.BasicApplication
+ java
+ true
+
+
+
diff --git a/api-gateway/pom.xml b/api-gateway/pom.xml
index 1ecc1cc..3a9f34e 100644
--- a/api-gateway/pom.xml
+++ b/api-gateway/pom.xml
@@ -1,226 +1,226 @@
-
-
- 4.0.0
-
- com.apssouza
- api-gateway
- 0.0.1-SNAPSHOT
- jar
-
- Api Gateway
- A hub service to access others services and compose responses
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 1.5.2.RELEASE
-
-
-
-
- UTF-8
- UTF-8
- com.apssouza.BasicApplication
- 1.8
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-parent
- Camden.SR2
- pom
- import
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter
-
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
- org.springframework.plugin
- spring-plugin-core
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.cloud
- spring-cloud-starter-eureka
-
-
-
- org.springframework.cloud
- spring-cloud-starter-feign
-
-
-
- org.springframework.cloud
- spring-cloud-starter-ribbon
-
-
-
- org.springframework.cloud
- spring-cloud-starter-hystrix
-
-
-
- org.springframework.cloud
- spring-cloud-starter-hystrix-dashboard
-
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
- org.springframework.security.oauth
- spring-security-oauth2
-
-
-
- org.springframework.security
- spring-security-jwt
-
-
-
- com.h2database
- h2
-
-
-
- org.springframework.cloud
- spring-cloud-starter-config
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
- true
- true
-
-
-
-
-
-
- dockerimage
-
- todo/api-gateway
- src/main/resources/docker
- ${project.build.directory}/dockerimgbuild
- Dockerfile
-
-
-
-
-
- maven-resources-plugin
-
-
- copy-resources
- package
-
- copy-resources
-
-
- ${docker.build.directory}
-
-
- ${docker.image.src.root}
- false
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- copy
- package
-
- copy
-
-
-
-
- ${project.groupId}
- ${project.artifactId}
- ${project.version}
- jar
- true
- ${docker.build.directory}/application/lib
- springboot-webapp.jar
-
-
-
-
- ${docker.build.directory}
- true
- true
-
-
-
-
-
-
-
- io.fabric8
- docker-maven-plugin
- 0.19.0
-
-
- unix:///var/run/docker.sock
-
-
- ${docker.image.name}
-
-
- latest
-
- ${docker.build.directory}/${docker.file.name}
-
-
-
-
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ com.apssouza
+ api-gateway
+ 0.0.1-SNAPSHOT
+ jar
+
+ Api Gateway
+ A hub service to access others services and compose responses
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.2.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ com.apssouza.BasicApplication
+ 1.8
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-parent
+ Camden.SR2
+ pom
+ import
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.plugin
+ spring-plugin-core
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-feign
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-ribbon
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-hystrix
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-hystrix-dashboard
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.springframework.security.oauth
+ spring-security-oauth2
+
+
+
+ org.springframework.security
+ spring-security-jwt
+
+
+
+ com.h2database
+ h2
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ true
+ true
+
+
+
+
+
+
+ dockerimage
+
+ todo/api-gateway
+ src/main/resources/docker
+ ${project.build.directory}/dockerimgbuild
+ Dockerfile
+
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-resources
+ package
+
+ copy-resources
+
+
+ ${docker.build.directory}
+
+
+ ${docker.image.src.root}
+ false
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy
+ package
+
+ copy
+
+
+
+
+ ${project.groupId}
+ ${project.artifactId}
+ ${project.version}
+ jar
+ true
+ ${docker.build.directory}/application/lib
+ springboot-webapp.jar
+
+
+
+
+ ${docker.build.directory}
+ true
+ true
+
+
+
+
+
+
+
+ io.fabric8
+ docker-maven-plugin
+ 0.19.0
+
+
+ unix:///var/run/docker.sock
+
+
+ ${docker.image.name}
+
+
+ latest
+
+ ${docker.build.directory}/${docker.file.name}
+
+
+
+
+
+
+
+
+
+
diff --git a/api-gateway/src/main/java/com/apssouza/BasicApplication.java b/api-gateway/src/main/java/com/apssouza/BasicApplication.java
index 319b923..903995f 100644
--- a/api-gateway/src/main/java/com/apssouza/BasicApplication.java
+++ b/api-gateway/src/main/java/com/apssouza/BasicApplication.java
@@ -1,17 +1,17 @@
-package com.apssouza;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.netflix.feign.EnableFeignClients;
-import org.springframework.cloud.netflix.hystrix.EnableHystrix;
-
-@SpringBootApplication
-@EnableFeignClients
-@EnableHystrix
-public class BasicApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(BasicApplication.class, args);
- }
-
-}
+package com.apssouza;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
+import org.springframework.cloud.netflix.hystrix.EnableHystrix;
+
+@SpringBootApplication
+@EnableFeignClients
+@EnableHystrix
+public class BasicApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(BasicApplication.class, args);
+ }
+
+}
diff --git a/api-gateway/src/main/java/com/apssouza/clients/TodoClient.java b/api-gateway/src/main/java/com/apssouza/clients/TodoClient.java
index f9f6c14..1ac73a7 100644
--- a/api-gateway/src/main/java/com/apssouza/clients/TodoClient.java
+++ b/api-gateway/src/main/java/com/apssouza/clients/TodoClient.java
@@ -1,30 +1,30 @@
-package com.apssouza.clients;
-
-import com.apssouza.pojos.Todo;
-import com.apssouza.pojos.User;
-import java.util.List;
-import org.springframework.cloud.netflix.feign.FeignClient;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-/**
- * Declarative To do REST client
- *
- * @author apssouza
- */
-@FeignClient("todo")
-public interface TodoClient {
-
- @RequestMapping(value = "/todos", method = RequestMethod.GET)
- public List getAll();
-
- @RequestMapping(value = "/todos/search", method = RequestMethod.GET)
- public List getTodoByUserEmaill(@RequestParam("email") String email);
-
- @RequestMapping(
- value = "/todos",
- method = RequestMethod.POST
- )
- Todo createTodo(Todo todo);
-}
+package com.apssouza.clients;
+
+import com.apssouza.pojos.Todo;
+import com.apssouza.pojos.User;
+import java.util.List;
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * Declarative To do REST client
+ *
+ * @author apssouza
+ */
+@FeignClient("todo")
+public interface TodoClient {
+
+ @RequestMapping(value = "/todos", method = RequestMethod.GET)
+ public List getAll();
+
+ @RequestMapping(value = "/todos/search", method = RequestMethod.GET)
+ public List getTodoByUserEmaill(@RequestParam("email") String email);
+
+ @RequestMapping(
+ value = "/todos",
+ method = RequestMethod.POST
+ )
+ Todo createTodo(Todo todo);
+}
diff --git a/api-gateway/src/main/java/com/apssouza/clients/UserClient.java b/api-gateway/src/main/java/com/apssouza/clients/UserClient.java
index 37d8dd2..fdc754f 100644
--- a/api-gateway/src/main/java/com/apssouza/clients/UserClient.java
+++ b/api-gateway/src/main/java/com/apssouza/clients/UserClient.java
@@ -1,27 +1,27 @@
-package com.apssouza.clients;
-
-import com.apssouza.pojos.Todo;
-import com.apssouza.pojos.User;
-import java.util.List;
-import org.springframework.cloud.netflix.feign.FeignClient;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-/**
- * Declarative User REST client
- *
- * @author apssouza
- */
-@FeignClient("user")
-public interface UserClient {
-
- @RequestMapping(value = "/accounts", method = RequestMethod.GET)
- public List getAll();
-
- @RequestMapping(value = "/accounts/search", method = RequestMethod.GET)
- public User getUserByEmail(@RequestParam("email") String email);
-
- @RequestMapping(value = "/users", method = RequestMethod.POST)
- Todo createUser(User user);
-}
+package com.apssouza.clients;
+
+import com.apssouza.pojos.Todo;
+import com.apssouza.pojos.User;
+import java.util.List;
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * Declarative User REST client
+ *
+ * @author apssouza
+ */
+@FeignClient("user")
+public interface UserClient {
+
+ @RequestMapping(value = "/accounts", method = RequestMethod.GET)
+ public List getAll();
+
+ @RequestMapping(value = "/accounts/search", method = RequestMethod.GET)
+ public User getUserByEmail(@RequestParam("email") String email);
+
+ @RequestMapping(value = "/users", method = RequestMethod.POST)
+ Todo createUser(User user);
+}
diff --git a/api-gateway/src/main/java/com/apssouza/configuration/JwtConfiguration.java b/api-gateway/src/main/java/com/apssouza/configuration/JwtConfiguration.java
index e9c7bba..6d70979 100644
--- a/api-gateway/src/main/java/com/apssouza/configuration/JwtConfiguration.java
+++ b/api-gateway/src/main/java/com/apssouza/configuration/JwtConfiguration.java
@@ -1,45 +1,46 @@
-package com.apssouza.configuration;
-
-import java.io.IOException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.core.io.Resource;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
-import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
-import org.springframework.util.FileCopyUtils;
-
-/**
- * Json web token configuration
- *
- * @author apssouza
- */
-@Configuration
-public class JwtConfiguration {
-
- @Autowired
- JwtAccessTokenConverter jwtAccessTokenConverter;
-
- @Bean
- @Qualifier("tokenStore")
- public TokenStore tokenStore() {
- return new JwtTokenStore(jwtAccessTokenConverter);
- }
-
- @Bean
- protected JwtAccessTokenConverter jwtTokenEnhancer() {
- JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
- Resource resource = new ClassPathResource("public.cert");
- String publicKey = null;
- try {
- publicKey = new String(FileCopyUtils.copyToByteArray(resource.getInputStream()));
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- converter.setVerifierKey(publicKey);
- return converter;
- }
-}
+package com.apssouza.configuration;
+
+import java.io.IOException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.springframework.security.oauth2.provider.token.TokenStore;
+import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
+import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
+import org.springframework.util.FileCopyUtils;
+
+/**
+ * Json web token configuration
+ *
+ * @author apssouza
+ */
+@Configuration
+public class JwtConfiguration {
+
+ @Autowired
+ JwtAccessTokenConverter jwtAccessTokenConverter;
+
+ @Bean
+ @Qualifier("tokenStore")
+ public TokenStore tokenStore() {
+ return new JwtTokenStore(jwtAccessTokenConverter);
+ }
+
+ @Bean
+ protected JwtAccessTokenConverter jwtTokenEnhancer() {
+ JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
+ Resource resource = new ClassPathResource("public.cert");
+ String publicKey = null;
+ try {
+ publicKey = new String(FileCopyUtils.copyToByteArray(resource.getInputStream()));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ converter.setVerifierKey(publicKey);
+ converter.setSigningKey(publicKey);//added as per stack overflow to solve
+ return converter;
+ }
+}
diff --git a/api-gateway/src/main/java/com/apssouza/configuration/OAuth2ResourceServerConfiguration.java b/api-gateway/src/main/java/com/apssouza/configuration/OAuth2ResourceServerConfiguration.java
index d7113b3..c9c0e61 100644
--- a/api-gateway/src/main/java/com/apssouza/configuration/OAuth2ResourceServerConfiguration.java
+++ b/api-gateway/src/main/java/com/apssouza/configuration/OAuth2ResourceServerConfiguration.java
@@ -1,44 +1,44 @@
-package com.apssouza.configuration;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.http.HttpMethod;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
-import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
-
-/**
- * OAuth2 resource server configuration
- *
- * @author apssouza
- */
-@Configuration
-@EnableResourceServer
-public class OAuth2ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
-
- @Override
- public void configure(HttpSecurity http) throws Exception {
- http
- .csrf().disable()
- .authorizeRequests()
- .antMatchers("/hystrix.stream").permitAll()
- .antMatchers("/**").authenticated()
- .antMatchers(HttpMethod.GET, "/todos").hasAuthority("USER_READ");
- //.antMatchers(HttpMethod.POST, "/foo").hasAuthority("FOO_WRITE");
- //you can implement it like this, but I show method invocation security on write
- }
-
- @Override
- public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
- resources.resourceId("todo").tokenStore(tokenStore);
- }
-
- @Autowired
- TokenStore tokenStore;
-
- @Autowired
- JwtAccessTokenConverter tokenConverter;
-}
+package com.apssouza.configuration;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpMethod;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
+import org.springframework.security.oauth2.provider.token.TokenStore;
+import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
+
+/**
+ * OAuth2 resource server configuration
+ *
+ * @author apssouza
+ */
+@Configuration
+@EnableResourceServer
+public class OAuth2ResourceServerConfiguration extends ResourceServerConfigurerAdapter {
+
+ @Override
+ public void configure(HttpSecurity http) throws Exception {
+ http
+ .csrf().disable()
+ .authorizeRequests()
+ .antMatchers("/hystrix.stream").permitAll()
+ .antMatchers("/**").authenticated()
+ .antMatchers(HttpMethod.GET, "/todos").hasAuthority("USER_READ");
+ //.antMatchers(HttpMethod.POST, "/foo").hasAuthority("FOO_WRITE");
+ //you can implement it like this, but I show method invocation security on write
+ }
+
+ @Override
+ public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
+ resources.resourceId("todo").tokenStore(tokenStore);
+ }
+
+ @Autowired
+ TokenStore tokenStore;
+
+ @Autowired
+ JwtAccessTokenConverter tokenConverter;
+}
diff --git a/api-gateway/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java b/api-gateway/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java
index 8ef608b..624f5d9 100644
--- a/api-gateway/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java
+++ b/api-gateway/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java
@@ -1,15 +1,15 @@
-package com.apssouza.configuration;
-
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * Eureka client configuration
- *
- * @author apssouza
- */
-@Configuration
-@EnableDiscoveryClient
-public class ServiceDiscoveryConfiguration {
-
-}
+package com.apssouza.configuration;
+
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Eureka client configuration
+ *
+ * @author apssouza
+ */
+@Configuration
+@EnableDiscoveryClient
+public class ServiceDiscoveryConfiguration {
+
+}
diff --git a/api-gateway/src/main/java/com/apssouza/controllers/TodoController.java b/api-gateway/src/main/java/com/apssouza/controllers/TodoController.java
index a639f71..250049e 100644
--- a/api-gateway/src/main/java/com/apssouza/controllers/TodoController.java
+++ b/api-gateway/src/main/java/com/apssouza/controllers/TodoController.java
@@ -1,30 +1,46 @@
-package com.apssouza.controllers;
-
-import com.apssouza.clients.TodoClient;
-import com.apssouza.pojos.User;
-import com.apssouza.services.TodoService;
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * To Do entry point
- *
- * @author apssouza
- */
-@RequestMapping("/todos")
-@RestController
-public class TodoController {
-
- @Autowired
- TodoService todoService;
-
- @GetMapping
- public List all() {
- return this.todoService.getAll();
- }
-
-}
+package com.apssouza.controllers;
+
+import com.apssouza.clients.TodoClient;
+import com.apssouza.pojos.Todo;
+import com.apssouza.pojos.User;
+import com.apssouza.services.TodoService;
+
+import java.net.URI;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
+
+import javax.validation.Valid;
+
+/**
+ * To Do entry point
+ *
+ * @author apssouza
+ */
+@RequestMapping("/todos")
+@RestController
+public class TodoController {
+
+ @Autowired
+ TodoService todoService;
+
+ @GetMapping
+ public List all() {
+ return this.todoService.getAll();
+ }
+
+ @PostMapping
+ public ResponseEntity> save(@RequestBody @Valid Todo todo, BindingResult result) {
+ todoService.createTodo(todo);
+ if (result.hasErrors()) {
+ return ResponseEntity.badRequest().build();
+ }
+ return ResponseEntity.noContent().build();
+
+ }
+
+}
diff --git a/api-gateway/src/main/java/com/apssouza/controllers/UserController.java b/api-gateway/src/main/java/com/apssouza/controllers/UserController.java
index 8860561..e9c1222 100644
--- a/api-gateway/src/main/java/com/apssouza/controllers/UserController.java
+++ b/api-gateway/src/main/java/com/apssouza/controllers/UserController.java
@@ -1,54 +1,54 @@
-package com.apssouza.controllers;
-
-import com.apssouza.clients.TodoClient;
-import com.apssouza.clients.UserClient;
-import com.apssouza.pojos.Todo;
-import com.apssouza.pojos.User;
-import com.apssouza.services.TodoService;
-import com.apssouza.services.UserService;
-import java.util.List;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.oauth2.provider.OAuth2Authentication;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * User entry point
- *
- * @author apssouza
- */
-@RequestMapping("/accounts")
-@RestController
-public class UserController {
-
- @Autowired
- UserService userService;
-
- @Autowired
- TodoService todoService;
-
- @GetMapping
- public List all() {
- return this.userService.getAll();
- }
-
- @GetMapping("/me")
- public User me(OAuth2Authentication auth) {
- return this.userService.getUserByEmail(auth.getName());
- }
-
- @GetMapping("/me/todos")
- public List todos(OAuth2Authentication auth) {
- return this.todoService.getTodoByUserEmaill(auth.getName());
- }
-
- @PostMapping("/me/todos")
- public Todo create(@RequestBody Todo todo) {
- return this.todoService.createTodo(todo);
- }
-
-}
+package com.apssouza.controllers;
+
+import com.apssouza.clients.TodoClient;
+import com.apssouza.clients.UserClient;
+import com.apssouza.pojos.Todo;
+import com.apssouza.pojos.User;
+import com.apssouza.services.TodoService;
+import com.apssouza.services.UserService;
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * User entry point
+ *
+ * @author apssouza
+ */
+@RequestMapping("/accounts")
+@RestController
+public class UserController {
+
+ @Autowired
+ UserService userService;
+
+ @Autowired
+ TodoService todoService;
+
+ @GetMapping
+ public List all() {
+ return this.userService.getAll();
+ }
+
+ @GetMapping("/me")
+ public User me(OAuth2Authentication auth) {
+ return this.userService.getUserByEmail(auth.getName());
+ }
+
+ @GetMapping("/me/todos")
+ public List todos(OAuth2Authentication auth) {
+ return this.todoService.getTodoByUserEmaill(auth.getName());
+ }
+
+ @PostMapping("/me/todos")
+ public Todo create(@RequestBody Todo todo) {
+ return this.todoService.createTodo(todo);
+ }
+
+}
diff --git a/api-gateway/src/main/java/com/apssouza/exceptions/DataNotFoundException.java b/api-gateway/src/main/java/com/apssouza/exceptions/DataNotFoundException.java
index 51ff374..8a0e56e 100644
--- a/api-gateway/src/main/java/com/apssouza/exceptions/DataNotFoundException.java
+++ b/api-gateway/src/main/java/com/apssouza/exceptions/DataNotFoundException.java
@@ -1,17 +1,17 @@
-package com.apssouza.exceptions;
-
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-/**
- * Data not found exception. It will return the Not found HTTP status code
- *
- * @author Apssouza
- */
-@ResponseStatus(HttpStatus.NOT_FOUND)
-public class DataNotFoundException extends RuntimeException {
-
- public DataNotFoundException(String msg) {
- super(msg);
- }
-}
+package com.apssouza.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Data not found exception. It will return the Not found HTTP status code
+ *
+ * @author Apssouza
+ */
+@ResponseStatus(HttpStatus.NOT_FOUND)
+public class DataNotFoundException extends RuntimeException {
+
+ public DataNotFoundException(String msg) {
+ super(msg);
+ }
+}
diff --git a/api-gateway/src/main/java/com/apssouza/pojos/Todo.java b/api-gateway/src/main/java/com/apssouza/pojos/Todo.java
index fe310a6..2ef7d33 100644
--- a/api-gateway/src/main/java/com/apssouza/pojos/Todo.java
+++ b/api-gateway/src/main/java/com/apssouza/pojos/Todo.java
@@ -1,60 +1,60 @@
-package com.apssouza.pojos;
-
-/**
- * To do PoJo
- *
- * @author apssouza
- */
-public class Todo {
-
- private long id;
-
- private String caption;
-
- private String userEmail;
-
- private String description;
-
- private int priority;
-
- public int getPriority() {
- return priority;
- }
-
- public void setPriority(int priority) {
- this.priority = priority;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getCaption() {
- return caption;
- }
-
- public void setCaption(String caption) {
- this.caption = caption;
- }
-
- public String getUserEmail() {
- return userEmail;
- }
-
- public void setUserEmail(String userEmail) {
- this.userEmail = userEmail;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
-}
+package com.apssouza.pojos;
+
+/**
+ * To do PoJo
+ *
+ * @author apssouza
+ */
+public class Todo {
+
+ private long id;
+
+ private String caption;
+
+ private String userEmail;
+
+ private String description;
+
+ private int priority;
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public void setCaption(String caption) {
+ this.caption = caption;
+ }
+
+ public String getUserEmail() {
+ return userEmail;
+ }
+
+ public void setUserEmail(String userEmail) {
+ this.userEmail = userEmail;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}
diff --git a/api-gateway/src/main/java/com/apssouza/pojos/User.java b/api-gateway/src/main/java/com/apssouza/pojos/User.java
index ad033a8..5940c9a 100644
--- a/api-gateway/src/main/java/com/apssouza/pojos/User.java
+++ b/api-gateway/src/main/java/com/apssouza/pojos/User.java
@@ -1,59 +1,59 @@
-package com.apssouza.pojos;
-
-/**
- * User Pojo
- *
- * @author apssouza
- */
-public class User {
-
- private long id;
-
- private long authId;
-
- private String name;
-
- private String email;
-
- public User() {
- }
-
- public User(String name, String email, long authId) {
- this.name = name;
- this.email = email;
- this.authId = authId;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public long getAuthId() {
- return authId;
- }
-
- public void setAuthId(long authId) {
- this.authId = authId;
- }
-
-}
+package com.apssouza.pojos;
+
+/**
+ * User Pojo
+ *
+ * @author apssouza
+ */
+public class User {
+
+ private long id;
+
+ private long authId;
+
+ private String name;
+
+ private String email;
+
+ public User() {
+ }
+
+ public User(String name, String email, long authId) {
+ this.name = name;
+ this.email = email;
+ this.authId = authId;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public long getAuthId() {
+ return authId;
+ }
+
+ public void setAuthId(long authId) {
+ this.authId = authId;
+ }
+
+}
diff --git a/api-gateway/src/main/java/com/apssouza/services/TodoService.java b/api-gateway/src/main/java/com/apssouza/services/TodoService.java
index 8173b1a..6d81165 100644
--- a/api-gateway/src/main/java/com/apssouza/services/TodoService.java
+++ b/api-gateway/src/main/java/com/apssouza/services/TodoService.java
@@ -1,18 +1,18 @@
-package com.apssouza.services;
-
-import com.apssouza.pojos.Todo;
-import com.apssouza.pojos.User;
-import java.util.List;
-
-/**
- *
- * @author apssouza
- */
-public interface TodoService {
-
- public List getAll();
-
- public List getTodoByUserEmaill(String email);
-
- Todo createTodo(Todo todo);
-}
+package com.apssouza.services;
+
+import com.apssouza.pojos.Todo;
+import com.apssouza.pojos.User;
+import java.util.List;
+
+/**
+ *
+ * @author apssouza
+ */
+public interface TodoService {
+
+ public List getAll();
+
+ public List getTodoByUserEmaill(String email);
+
+ Todo createTodo(Todo todo);
+}
diff --git a/api-gateway/src/main/java/com/apssouza/services/TodoServiceImpl.java b/api-gateway/src/main/java/com/apssouza/services/TodoServiceImpl.java
index e7b11f5..48affbb 100644
--- a/api-gateway/src/main/java/com/apssouza/services/TodoServiceImpl.java
+++ b/api-gateway/src/main/java/com/apssouza/services/TodoServiceImpl.java
@@ -1,41 +1,41 @@
-package com.apssouza.services;
-
-import com.apssouza.clients.TodoClient;
-import com.apssouza.pojos.Todo;
-import com.apssouza.pojos.User;
-import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
-import java.util.Collections;
-import java.util.List;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * ToDo service
- * @author apssouza
- */
-@Component
-public class TodoServiceImpl implements TodoService {
-
- @Autowired
- TodoClient todoClient;
-
- @Override
- public List getAll() {
- return todoClient.getAll();
- }
-
- @Override
- @HystrixCommand(fallbackMethod = "getFallbackTodos")
- public List getTodoByUserEmaill(String email) {
- return todoClient.getTodoByUserEmaill(email);
- }
-
- @Override
- public Todo createTodo(Todo todo) {
- return todoClient.createTodo(todo);
- }
-
- public List getFallbackTodos(String email) {
- return Collections.emptyList();
- }
-}
+package com.apssouza.services;
+
+import com.apssouza.clients.TodoClient;
+import com.apssouza.pojos.Todo;
+import com.apssouza.pojos.User;
+import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
+import java.util.Collections;
+import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * ToDo service
+ * @author apssouza
+ */
+@Component
+public class TodoServiceImpl implements TodoService {
+
+ @Autowired
+ TodoClient todoClient;
+
+ @Override
+ public List getAll() {
+ return todoClient.getAll();
+ }
+
+ @Override
+ @HystrixCommand(fallbackMethod = "getFallbackTodos")
+ public List getTodoByUserEmaill(String email) {
+ return todoClient.getTodoByUserEmaill(email);
+ }
+
+ @Override
+ public Todo createTodo(Todo todo) {
+ return todoClient.createTodo(todo);
+ }
+
+ public List getFallbackTodos(String email) {
+ return Collections.emptyList();
+ }
+}
diff --git a/api-gateway/src/main/java/com/apssouza/services/UserService.java b/api-gateway/src/main/java/com/apssouza/services/UserService.java
index a5ad153..2eb6564 100644
--- a/api-gateway/src/main/java/com/apssouza/services/UserService.java
+++ b/api-gateway/src/main/java/com/apssouza/services/UserService.java
@@ -1,18 +1,18 @@
-package com.apssouza.services;
-
-import com.apssouza.pojos.Todo;
-import com.apssouza.pojos.User;
-import java.util.List;
-
-/**
- *
- * @author apssouza
- */
-public interface UserService {
-
- List getAll();
-
- User getUserByEmail(String email);
-
- Todo createUser(User user);
-}
+package com.apssouza.services;
+
+import com.apssouza.pojos.Todo;
+import com.apssouza.pojos.User;
+import java.util.List;
+
+/**
+ *
+ * @author apssouza
+ */
+public interface UserService {
+
+ List getAll();
+
+ User getUserByEmail(String email);
+
+ Todo createUser(User user);
+}
diff --git a/api-gateway/src/main/java/com/apssouza/services/UserServiceImpl.java b/api-gateway/src/main/java/com/apssouza/services/UserServiceImpl.java
index 181402f..55d0f1d 100644
--- a/api-gateway/src/main/java/com/apssouza/services/UserServiceImpl.java
+++ b/api-gateway/src/main/java/com/apssouza/services/UserServiceImpl.java
@@ -1,36 +1,36 @@
-package com.apssouza.services;
-
-import com.apssouza.clients.UserClient;
-import com.apssouza.pojos.Todo;
-import com.apssouza.pojos.User;
-import java.util.List;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * User Service
- *
- * @author apssouza
- */
-@Component
-public class UserServiceImpl implements UserService {
-
- @Autowired
- UserClient userClient;
-
- @Override
- public List getAll() {
- return userClient.getAll();
- }
-
- @Override
- public User getUserByEmail(String email) {
- return userClient.getUserByEmail(email);
- }
-
- @Override
- public Todo createUser(User user) {
- return userClient.createUser(user);
- }
-
-}
+package com.apssouza.services;
+
+import com.apssouza.clients.UserClient;
+import com.apssouza.pojos.Todo;
+import com.apssouza.pojos.User;
+import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * User Service
+ *
+ * @author apssouza
+ */
+@Component
+public class UserServiceImpl implements UserService {
+
+ @Autowired
+ UserClient userClient;
+
+ @Override
+ public List getAll() {
+ return userClient.getAll();
+ }
+
+ @Override
+ public User getUserByEmail(String email) {
+ return userClient.getUserByEmail(email);
+ }
+
+ @Override
+ public Todo createUser(User user) {
+ return userClient.createUser(user);
+ }
+
+}
diff --git a/api-gateway/src/main/resources/bootstrap.yml b/api-gateway/src/main/resources/bootstrap.yml
index b940bf4..47aefda 100644
--- a/api-gateway/src/main/resources/bootstrap.yml
+++ b/api-gateway/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
----
-spring:
- cloud:
- config:
- uri: http://config:8888
+---
+spring:
+ cloud:
+ config:
+ uri: http://config:8888
\ No newline at end of file
diff --git a/api-gateway/src/main/resources/docker/Dockerfile b/api-gateway/src/main/resources/docker/Dockerfile
index 94b5954..916ab54 100644
--- a/api-gateway/src/main/resources/docker/Dockerfile
+++ b/api-gateway/src/main/resources/docker/Dockerfile
@@ -1,38 +1,38 @@
-FROM openjdk:8
-
-
-MAINTAINER Alexsandro
-ENV REFRESHED_AT 2017-09-17
-
-ENV TERM xterm
-ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
-
-RUN apt-get update -qq \
- && apt-get install -qqy curl wget \
- && apt-get clean \
- \
- && touch /var/log/todo.log \
- && chmod 666 /var/log/todo.log
-
-ADD application/lib/springboot-webapp.jar /app.jar
-ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
-RUN bash -c 'chmod +x wait-for-it.sh'
-
-
-# install Filebeat
-ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
-RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
- && dpkg -i ${FILEBEAT_VERSION} \
- && rm ${FILEBEAT_VERSION}
-
-# configure Filebeat
-ADD filebeat.yml /etc/filebeat/filebeat.yml
-
-# CA cert
-RUN mkdir -p /etc/pki/tls/certs
-ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
-
-# start Filebeat
-ADD ./start.sh /usr/local/bin/start.sh
-RUN chmod +x /usr/local/bin/start.sh
+FROM openjdk:8
+
+
+MAINTAINER Alexsandro
+ENV REFRESHED_AT 2017-09-17
+
+ENV TERM xterm
+ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
+
+RUN apt-get update -qq \
+ && apt-get install -qqy curl wget \
+ && apt-get clean \
+ \
+ && touch /var/log/todo.log \
+ && chmod 666 /var/log/todo.log
+
+ADD application/lib/springboot-webapp.jar /app.jar
+ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
+RUN bash -c 'chmod +x wait-for-it.sh'
+
+
+# install Filebeat
+ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
+RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
+ && dpkg -i ${FILEBEAT_VERSION} \
+ && rm ${FILEBEAT_VERSION}
+
+# configure Filebeat
+ADD filebeat.yml /etc/filebeat/filebeat.yml
+
+# CA cert
+RUN mkdir -p /etc/pki/tls/certs
+ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
+
+# start Filebeat
+ADD ./start.sh /usr/local/bin/start.sh
+RUN chmod +x /usr/local/bin/start.sh
CMD [ "/usr/local/bin/start.sh" ]
\ No newline at end of file
diff --git a/api-gateway/src/main/resources/docker/filebeat.yml b/api-gateway/src/main/resources/docker/filebeat.yml
index 09119d8..480a94e 100644
--- a/api-gateway/src/main/resources/docker/filebeat.yml
+++ b/api-gateway/src/main/resources/docker/filebeat.yml
@@ -1,30 +1,30 @@
-output:
- logstash:
- enabled: true
- hosts:
- - elk:5044
- timeout: 15
- tls:
- certificate_authorities:
- - /etc/pki/tls/certs/logstash-beats.crt
-
-filebeat:
- prospectors:
- -
- paths:
- - /var/log/syslog
- - /var/log/auth.log
- document_type: syslog
- -
- paths:
- - /var/log/spring-music.log
- document_type: log4j
- multiline:
- pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
- negate: true
- match: after
- -
- paths:
- - /usr/local/tomcat/logs/*.out
- - /usr/local/tomcat/logs/*.log
- document_type: tomcat
+output:
+ logstash:
+ enabled: true
+ hosts:
+ - elk:5044
+ timeout: 15
+ tls:
+ certificate_authorities:
+ - /etc/pki/tls/certs/logstash-beats.crt
+
+filebeat:
+ prospectors:
+ -
+ paths:
+ - /var/log/syslog
+ - /var/log/auth.log
+ document_type: syslog
+ -
+ paths:
+ - /var/log/spring-music.log
+ document_type: log4j
+ multiline:
+ pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
+ negate: true
+ match: after
+ -
+ paths:
+ - /usr/local/tomcat/logs/*.out
+ - /usr/local/tomcat/logs/*.log
+ document_type: tomcat
diff --git a/api-gateway/src/main/resources/docker/logstash-beats.crt b/api-gateway/src/main/resources/docker/logstash-beats.crt
index d9b71cf..1c86bc3 100644
--- a/api-gateway/src/main/resources/docker/logstash-beats.crt
+++ b/api-gateway/src/main/resources/docker/logstash-beats.crt
@@ -1,18 +1,18 @@
------BEGIN CERTIFICATE-----
-MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
-BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
-DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
-0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
-9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
-PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
-qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
-KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
-4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
-VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
-hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
-okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
-T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
-ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
-kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
-Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
------END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
+BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
+DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
+0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
+9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
+PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
+qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
+KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
+4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
+VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
+hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
+okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
+T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
+ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
+kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
+Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
+-----END CERTIFICATE-----
diff --git a/api-gateway/src/main/resources/docker/start.sh b/api-gateway/src/main/resources/docker/start.sh
index b68b2fb..eff4532 100644
--- a/api-gateway/src/main/resources/docker/start.sh
+++ b/api-gateway/src/main/resources/docker/start.sh
@@ -1,5 +1,4 @@
#!/bin/bash
-
curl -XPUT 'http://elk:9200/_template/filebeat?pretty' -d@/etc/filebeat/filebeat.template.json
/etc/init.d/filebeat start
-java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
+java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
\ No newline at end of file
diff --git a/api-gateway/src/main/resources/public.cert b/api-gateway/src/main/resources/public.cert
index 9247da4..acc4a25 100644
--- a/api-gateway/src/main/resources/public.cert
+++ b/api-gateway/src/main/resources/public.cert
@@ -1,9 +1,9 @@
------BEGIN PUBLIC KEY-----
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAybh3MPztT363c041gifD
-B1JKb7M/N6doCBIVJmbS1nVrCQRiVq4vcsMfTI/C6yNp4a2VF/UMuJTyy3c4iKe7
-A1jNn2dd4EBBN6ljavhQSZ6ImiSDqUF40BHs54b5ffZfzBIsNcvRPZVCt6Fs/OuX
-EaMkIesyaQxQS1xKH3gHFhWSS74MShqXDZwG/tc4CojSFTkhBPFh1/7x8XB+0UVK
-QYElIdMrSUZfNMJ+DIzphogwDbqzDoVxC1nqHDAju7x2FENtHg5Xs0UXeKFuDLfO
-WHG5z9HBSooEQnKrz/9G/Uvd6NNcXJYCgI/6MjRGlQ3MPSKMDpVHkBiK/XYw0Vs7
-DQIDAQAB
------END PUBLIC KEY-----
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAybh3MPztT363c041gifD
+B1JKb7M/N6doCBIVJmbS1nVrCQRiVq4vcsMfTI/C6yNp4a2VF/UMuJTyy3c4iKe7
+A1jNn2dd4EBBN6ljavhQSZ6ImiSDqUF40BHs54b5ffZfzBIsNcvRPZVCt6Fs/OuX
+EaMkIesyaQxQS1xKH3gHFhWSS74MShqXDZwG/tc4CojSFTkhBPFh1/7x8XB+0UVK
+QYElIdMrSUZfNMJ+DIzphogwDbqzDoVxC1nqHDAju7x2FENtHg5Xs0UXeKFuDLfO
+WHG5z9HBSooEQnKrz/9G/Uvd6NNcXJYCgI/6MjRGlQ3MPSKMDpVHkBiK/XYw0Vs7
+DQIDAQAB
+-----END PUBLIC KEY-----
diff --git a/assets/event-docker-compose.yml b/assets/event-docker-compose.yml
index b541e50..f903893 100644
--- a/assets/event-docker-compose.yml
+++ b/assets/event-docker-compose.yml
@@ -1,88 +1,88 @@
-version: '2'
-
-services:
-
- zookeeper:
- image: wurstmeister/zookeeper
- ports:
- - 2181:2181
- networks:
- - net
-
- kafka:
- image: wurstmeister/kafka
- ports:
- - 9092:9092
- depends_on:
- - zookeeper
- environment:
- KAFKA_ADVERTISED_HOST_NAME: 172.19.0.1
- KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
- KAFKA_CREATE_TOPICS: "todo-mail:1:1"
- KAFKA_ADVERTISED_HOST_NAME: "kafka"
- volumes:
- - /var/run/docker.sock:/var/run/docker.sock
- hostname: kafka
- container_name: kafka
- networks:
- - net
- reminder:
- image: todo/reminder-service
- ports:
- - 8015:8015
- - 8001:8001
- networks:
- - net
- depends_on:
- - kafka
- hostname: reminder
- command: ["./wait-for-it.sh","kafka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
-
- mail:
- image: todo/mail-service
- ports:
- - 8020:8020
- - 8000:8000
- networks:
- - net
- depends_on:
- - kafka
- hostname: mail
- container_name: mail
- command: ["./wait-for-it.sh","kafka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
-
- config:
- image: todo/config-server
- ports:
- - 8888:8888
- networks:
- - net
- hostname: config
- container_name: config
- external_links:
- - elk
-
- eureka:
- image: todo/eureka-server
- ports:
- - 8010:8010
- networks:
- - net
- depends_on:
- - config
- hostname: eureka
- container_name: eureka
- command: ["./wait-for-it.sh","config:8888","--timeout=100","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
-
-
-volumes:
- todo_data:
- external: true
- todo_elk:
- external: true
-
-networks:
- net:
- driver: bridge
+version: '2'
+
+services:
+
+ zookeeper:
+ image: wurstmeister/zookeeper
+ ports:
+ - 2181:2181
+ networks:
+ - net
+
+ kafka:
+ image: wurstmeister/kafka
+ ports:
+ - 9092:9092
+ depends_on:
+ - zookeeper
+ environment:
+ KAFKA_ADVERTISED_HOST_NAME: 172.19.0.1
+ KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
+ KAFKA_CREATE_TOPICS: "todo-mail:1:1"
+ KAFKA_ADVERTISED_HOST_NAME: "kafka"
+ volumes:
+ - /var/run/docker.sock:/var/run/docker.sock
+ hostname: kafka
+ container_name: kafka
+ networks:
+ - net
+ reminder:
+ image: todo/reminder-service
+ ports:
+ - 8015:8015
+ - 8001:8001
+ networks:
+ - net
+ depends_on:
+ - kafka
+ hostname: reminder
+ command: ["./wait-for-it.sh","kafka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+
+ mail:
+ image: todo/mail-service
+ ports:
+ - 8020:8020
+ - 8000:8000
+ networks:
+ - net
+ depends_on:
+ - kafka
+ hostname: mail
+ container_name: mail
+ command: ["./wait-for-it.sh","kafka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+
+ config:
+ image: todo/config-server
+ ports:
+ - 8888:8888
+ networks:
+ - net
+ hostname: config
+ container_name: config
+ external_links:
+ - elk
+
+ eureka:
+ image: todo/eureka-server
+ ports:
+ - 8010:8010
+ networks:
+ - net
+ depends_on:
+ - config
+ hostname: eureka
+ container_name: eureka
+ command: ["./wait-for-it.sh","config:8888","--timeout=100","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+
+
+volumes:
+ todo_data:
+ external: true
+ todo_elk:
+ external: true
+
+networks:
+ net:
+ driver: bridge
diff --git a/assets/infra-docker-compose.yml b/assets/infra-docker-compose.yml
index c11ddc7..5304497 100644
--- a/assets/infra-docker-compose.yml
+++ b/assets/infra-docker-compose.yml
@@ -1,56 +1,56 @@
-version: '2'
-
-services:
- elk:
- image: sebp/elk:latest
- ports:
- - 5601:5601
- - 9200:9200
- - 5044:5044
- - 5001:5000
- networks:
- - net
- volumes:
- - todo_elk:/var/lib/elasticsearch
- hostname: elk
- container_name: elk
- mem_limit: 4925288000
- cpu_shares: 500
-
- zookeeper:
- image: wurstmeister/zookeeper
- ports:
- - 2181:2181
- networks:
- - net
- mem_limit: 925288000
- cpu_shares: 100
-
- kafka:
- image: wurstmeister/kafka
- ports:
- - 9092
- depends_on:
- - zookeeper
- environment:
- KAFKA_ADVERTISED_HOST_NAME: 172.19.0.1
- KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
- KAFKA_CREATE_TOPICS: "todo-mail:1:1"
- volumes:
- - /var/run/docker.sock:/var/run/docker.sock
- hostname: kafka
- container_name: kafka
- networks:
- - net
- mem_limit: 925288000
- cpu_shares: 100
-
-volumes:
- todo_data:
- external: true
- todo_elk:
- external: true
-
-networks:
- net:
- driver: bridge
+version: '2'
+
+services:
+ elk:
+ image: sebp/elk:latest
+ ports:
+ - 5601:5601
+ - 9200:9200
+ - 5044:5044
+ - 5001:5000
+ networks:
+ - net
+ volumes:
+ - todo_elk:/var/lib/elasticsearch
+ hostname: elk
+ container_name: elk
+ mem_limit: 4925288000
+ cpu_shares: 500
+
+ zookeeper:
+ image: wurstmeister/zookeeper
+ ports:
+ - 2181:2181
+ networks:
+ - net
+ mem_limit: 925288000
+ cpu_shares: 100
+
+ kafka:
+ image: wurstmeister/kafka
+ ports:
+ - 9092
+ depends_on:
+ - zookeeper
+ environment:
+ KAFKA_ADVERTISED_HOST_NAME: 172.19.0.1
+ KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
+ KAFKA_CREATE_TOPICS: "todo-mail:1:1"
+ volumes:
+ - /var/run/docker.sock:/var/run/docker.sock
+ hostname: kafka
+ container_name: kafka
+ networks:
+ - net
+ mem_limit: 925288000
+ cpu_shares: 100
+
+volumes:
+ todo_data:
+ external: true
+ todo_elk:
+ external: true
+
+networks:
+ net:
+ driver: bridge
diff --git a/assets/logging-docker-compose.yml b/assets/logging-docker-compose.yml
index 5b6f679..7bd4165 100644
--- a/assets/logging-docker-compose.yml
+++ b/assets/logging-docker-compose.yml
@@ -1,53 +1,53 @@
-version: '2'
-
-services:
- config:
- image: todo/config-server
- ports:
- - 8888:8888
- networks:
- - net
- hostname: config
- container_name: config
- external_links:
- - elk
- command: ["./wait-for-it.sh","elk:5601","--timeout=90","--","/usr/local/bin/start.sh"]
-
- user:
- image: todo/user-service
- ports:
- - 8016:8016
- networks:
- - net
- hostname: user
- container_name: user
- command: ["./wait-for-it.sh","elk:5601","--timeout=90","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
- - kafka
-
- elk:
- image: sebp/elk:latest
- ports:
- - 5601:5601
- - 9200:9200
- - 5044:5044
- - 5000:5000
- networks:
- - net
- volumes:
- - todo_data:/var/lib/elasticsearch
- hostname: elk
- container_name: elk
- mem_limit: 4925288000
- cpu_shares: 500
-
-volumes:
- todo_data:
- external: true
- todo_elk:
- external: true
-
-networks:
- net:
- driver: bridge
+version: '2'
+
+services:
+ config:
+ image: todo/config-server
+ ports:
+ - 8888:8888
+ networks:
+ - net
+ hostname: config
+ container_name: config
+ external_links:
+ - elk
+ command: ["./wait-for-it.sh","elk:5601","--timeout=90","--","/usr/local/bin/start.sh"]
+
+ user:
+ image: todo/user-service
+ ports:
+ - 8016:8016
+ networks:
+ - net
+ hostname: user
+ container_name: user
+ command: ["./wait-for-it.sh","elk:5601","--timeout=90","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+ - kafka
+
+ elk:
+ image: sebp/elk:latest
+ ports:
+ - 5601:5601
+ - 9200:9200
+ - 5044:5044
+ - 5000:5000
+ networks:
+ - net
+ volumes:
+ - todo_data:/var/lib/elasticsearch
+ hostname: elk
+ container_name: elk
+ mem_limit: 4925288000
+ cpu_shares: 500
+
+volumes:
+ todo_data:
+ external: true
+ todo_elk:
+ external: true
+
+networks:
+ net:
+ driver: bridge
diff --git a/assets/oauth-docker-compose.yml b/assets/oauth-docker-compose.yml
index 0db7387..d9c2b2e 100644
--- a/assets/oauth-docker-compose.yml
+++ b/assets/oauth-docker-compose.yml
@@ -1,76 +1,76 @@
-version: '2'
-
-services:
- config:
- image: todo/config-server
- ports:
- - 8888:8888
- networks:
- - net
- hostname: config
- container_name: config
- external_links:
- - elk
- - kafka
-
- oauth:
- image: todo/oauth-server
- ports:
- - 8017:8017
- networks:
- - net
- depends_on:
- - user
- hostname: oauth
- container_name: oauth
- command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
-
- eureka:
- image: todo/eureka-server
- ports:
- - 8010:8010
- networks:
- - net
- depends_on:
- - config
- hostname: eureka
- container_name: eureka
- command: ["./wait-for-it.sh","config:8888","--timeout=100","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
-
- gateway:
- image: todo/api-gateway
- ports:
- - 8018:8018
- networks:
- - net
- hostname: gateway
- command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
-
- user:
- image: todo/user-service
- ports:
- - 8016:8016
- networks:
- - net
- hostname: user
- container_name: user
- command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
- - kafka
-
-volumes:
- todo_data:
- external: true
- todo_elk:
- external: true
-
-networks:
- net:
- driver: bridge
+version: '2'
+
+services:
+ config:
+ image: todo/config-server
+ ports:
+ - 8888:8888
+ networks:
+ - net
+ hostname: config
+ container_name: config
+ external_links:
+ - elk
+ - kafka
+
+ oauth:
+ image: todo/oauth-server
+ ports:
+ - 8017:8017
+ networks:
+ - net
+ depends_on:
+ - user
+ hostname: oauth
+ container_name: oauth
+ command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+
+ eureka:
+ image: todo/eureka-server
+ ports:
+ - 8010:8010
+ networks:
+ - net
+ depends_on:
+ - config
+ hostname: eureka
+ container_name: eureka
+ command: ["./wait-for-it.sh","config:8888","--timeout=100","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+
+ gateway:
+ image: todo/api-gateway
+ ports:
+ - 8018:8018
+ networks:
+ - net
+ hostname: gateway
+ command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+
+ user:
+ image: todo/user-service
+ ports:
+ - 8016:8016
+ networks:
+ - net
+ hostname: user
+ container_name: user
+ command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+ - kafka
+
+volumes:
+ todo_data:
+ external: true
+ todo_elk:
+ external: true
+
+networks:
+ net:
+ driver: bridge
diff --git a/assets/proxy-docker-compose.yml b/assets/proxy-docker-compose.yml
index 92ae33d..24a1c06 100644
--- a/assets/proxy-docker-compose.yml
+++ b/assets/proxy-docker-compose.yml
@@ -1,47 +1,47 @@
-version: '2'
-
-services:
- config:
- image: todo/config-server
- ports:
- - 8888:8888
- networks:
- - net
- hostname: config
- container_name: config
- external_links:
- - elk
- - kafka
-
- gateway:
- image: todo/api-gateway
- ports:
- - 8018
- networks:
- - net
- hostname: gateway
- command: ["./wait-for-it.sh","config:8888","--timeout=50","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
-
- proxy:
- build: proxy/
- ports:
- - 8055:80
- networks:
- - net
- depends_on:
- - gateway
- hostname: proxy
- container_name: proxy
- command: ["./wait-for-it.sh","gateway:8018","--timeout=50","--","/usr/local/bin/start.sh"]
-
-volumes:
- todo_data:
- external: true
- todo_elk:
- external: true
-
-networks:
- net:
- driver: bridge
+version: '2'
+
+services:
+ config:
+ image: todo/config-server
+ ports:
+ - 8888:8888
+ networks:
+ - net
+ hostname: config
+ container_name: config
+ external_links:
+ - elk
+ - kafka
+
+ gateway:
+ image: todo/api-gateway
+ ports:
+ - 8018
+ networks:
+ - net
+ hostname: gateway
+ command: ["./wait-for-it.sh","config:8888","--timeout=50","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+
+ proxy:
+ build: proxy/
+ ports:
+ - 8055:80
+ networks:
+ - net
+ depends_on:
+ - gateway
+ hostname: proxy
+ container_name: proxy
+ command: ["./wait-for-it.sh","gateway:8018","--timeout=50","--","/usr/local/bin/start.sh"]
+
+volumes:
+ todo_data:
+ external: true
+ todo_elk:
+ external: true
+
+networks:
+ net:
+ driver: bridge
diff --git a/aws-compose.yml b/aws-compose.yml
index c975c24..a0eaaa2 100644
--- a/aws-compose.yml
+++ b/aws-compose.yml
@@ -1,131 +1,130 @@
-version: '2'
-
-services:
-
- config:
- image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:config-server
- ports:
- - 8888:8888
- hostname: config
- container_name: config
- mem_limit: 1025288000
- cpu_shares: 100
- extra_hosts:
- - "eureka:EC2_INSTANCE_IP"
- environment:
- - JAVA_OPTS=' -Xmx800m'
-
- user:
- image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:user-service
- ports:
- - 8016:8016
- hostname: user
- container_name: user
- command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
- - kafka
- mem_limit: 1025288000
- cpu_shares: 100
- extra_hosts:
- - "config:EC2_INSTANCE_IP"
- - "eureka:EC2_INSTANCE_IP"
- environment:
- - JAVA_OPTS=' -Xmx800m'
-
-
- eureka:
- image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:eureka-server
- ports:
- - 8010:8010
- depends_on:
- - config
- hostname: eureka
- container_name: eureka
- command: ["./wait-for-it.sh","config:8888","--timeout=100","--","/usr/local/bin/start.sh"]
- mem_limit: 1025288000
- cpu_shares: 100
- extra_hosts:
- - "config:EC2_INSTANCE_IP"
- environment:
- - JAVA_OPTS=' -Xmx800m'
-
- oauth:
- image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:oauth-server
- ports:
- - 8017:8017
- hostname: oauth
- container_name: oauth
- command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- mem_limit: 1025288000
- cpu_shares: 100
- extra_hosts:
- - "config:EC2_INSTANCE_IP"
- - "eureka:EC2_INSTANCE_IP"
- environment:
- - JAVA_OPTS=' -Xmx800m'
-
- admin:
- image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:admin-server
- container_name: admin
- ports:
- - 8026:8026
- environment:
- - EUREKA_SERVICE_URL=http://EC2_INSTANCE_IP:8010
- - EUREKA_INSTANCE_PREFER_IP_ADDRESS=true
- - LOGGING_FILE=/tmp/admin.log
- - JAVA_OPTS=' -Xmx800m'
- command: ["./wait-for-it.sh","EC2_INSTANCE_IP:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- mem_limit: 1225288000
- cpu_shares: 100
- extra_hosts:
- - "config:EC2_INSTANCE_IP"
- - "eureka:EC2_INSTANCE_IP"
- environment:
- - JAVA_OPTS=' -Xmx800m'
-
- zookeeper:
- image: wurstmeister/zookeeper
- ports:
- - 2181:2181
- mem_limit: 925288000
- cpu_shares: 100
-
- kafka:
- image: wurstmeister/kafka
- ports:
- - 9092:9092
- environment:
- KAFKA_ZOOKEEPER_CONNECT: "EC2_INSTANCE_IP:2181"
- KAFKA_CREATE_TOPICS: "todo-mail:1:1"
- HOSTNAME_COMMAND: curl http://169.254.169.254/latest/meta-data/public-hostname
- KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
- KAFKA_ADVERTISED_PROTOCOL_NAME: OUTSIDE
- KAFKA_PROTOCOL_NAME: INSIDE
- KAFKA_ADVERTISED_PORT: 9094
- volumes:
- - /var/run/docker.sock:/var/run/docker.sock
- hostname: kafka
- container_name: kafka
- mem_limit: 1325288000
- cpu_shares: 100
- extra_hosts:
- - "zookeeper:EC2_INSTANCE_IP"
-
- reminder:
- image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:reminder-service
- ports:
- - 8015:8015
- networks:
- - net
- hostname: reminder
- command: ["./wait-for-it.sh","config:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- extra_hosts:
- - "config:52.50.116.215"
- - "eureka:52.50.116.215"
- - "kafka:52.50.116.215"
- - "zookeeper:52.50.116.215"
- environment:
- - JAVA_OPTS=' -Xmx800m'
- mem_limit: 1025288000
- cpu_shares: 100
+version: '2'
+
+services:
+
+ config:
+ image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:config-server
+ ports:
+ - 8888:8888
+ hostname: config
+ container_name: config
+ mem_limit: 1025288000
+ cpu_shares: 100
+ extra_hosts:
+ - "eureka:EC2_INSTANCE_IP"
+ environment:
+ - JAVA_OPTS=' -Xmx800m'
+
+ user:
+ image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:user-service
+ ports:
+ - 8016:8016
+ hostname: user
+ container_name: user
+ command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+ - kafka
+ mem_limit: 1025288000
+ cpu_shares: 100
+ extra_hosts:
+ - "config:EC2_INSTANCE_IP"
+ - "eureka:EC2_INSTANCE_IP"
+ environment:
+ - JAVA_OPTS=' -Xmx800m'
+
+
+ eureka:
+ image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:eureka-server
+ ports:
+ - 8010:8010
+ depends_on:
+ - config
+ hostname: eureka
+ container_name: eureka
+ command: ["./wait-for-it.sh","config:8888","--timeout=100","--","/usr/local/bin/start.sh"]
+ mem_limit: 1025288000
+ cpu_shares: 100
+ extra_hosts:
+ - "config:EC2_INSTANCE_IP"
+ environment:
+ - JAVA_OPTS=' -Xmx800m'
+
+ oauth:
+ image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:oauth-server
+ ports:
+ - 8017:8017
+ hostname: oauth
+ container_name: oauth
+ command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ mem_limit: 1025288000
+ cpu_shares: 100
+ extra_hosts:
+ - "config:EC2_INSTANCE_IP"
+ - "eureka:EC2_INSTANCE_IP"
+ environment:
+ - JAVA_OPTS=' -Xmx800m'
+
+ admin:
+ image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:admin-server
+ container_name: admin
+ ports:
+ - 8026:8026
+ environment:
+ - EUREKA_SERVICE_URL=http://EC2_INSTANCE_IP:8010
+ - EUREKA_INSTANCE_PREFER_IP_ADDRESS=true
+ - LOGGING_FILE=/tmp/admin.log
+ - JAVA_OPTS=' -Xmx800m'
+ command: ["./wait-for-it.sh","EC2_INSTANCE_IP:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ mem_limit: 1225288000
+ cpu_shares: 100
+ extra_hosts:
+ - "config:EC2_INSTANCE_IP"
+ - "eureka:EC2_INSTANCE_IP"
+
+
+ zookeeper:
+ image: wurstmeister/zookeeper
+ ports:
+ - 2181:2181
+ mem_limit: 925288000
+ cpu_shares: 100
+
+ kafka:
+ image: wurstmeister/kafka
+ ports:
+ - 9092:9092
+ environment:
+ KAFKA_ZOOKEEPER_CONNECT: "EC2_INSTANCE_IP:2181"
+ KAFKA_CREATE_TOPICS: "todo-mail:1:1"
+ HOSTNAME_COMMAND: curl http://169.254.169.254/latest/meta-data/public-hostname
+ KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
+ KAFKA_ADVERTISED_PROTOCOL_NAME: OUTSIDE
+ KAFKA_PROTOCOL_NAME: INSIDE
+ KAFKA_ADVERTISED_PORT: 9094
+ volumes:
+ - /var/run/docker.sock:/var/run/docker.sock
+ hostname: kafka
+ container_name: kafka
+ mem_limit: 1325288000
+ cpu_shares: 100
+ extra_hosts:
+ - "zookeeper:EC2_INSTANCE_IP"
+
+ reminder:
+ image: 004833468061.dkr.ecr.eu-west-1.amazonaws.com/alex:reminder-service
+ ports:
+ - 8015:8015
+ networks:
+ - net
+ hostname: reminder
+ command: ["./wait-for-it.sh","config:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ extra_hosts:
+ - "config:52.50.116.215"
+ - "eureka:52.50.116.215"
+ - "kafka:52.50.116.215"
+ - "zookeeper:52.50.116.215"
+ environment:
+ - JAVA_OPTS=' -Xmx800m'
+ mem_limit: 1025288000
+ cpu_shares: 100
diff --git a/aws-deploy.sh b/aws-deploy.sh
index c46e01c..091175b 100755
--- a/aws-deploy.sh
+++ b/aws-deploy.sh
@@ -1,37 +1,37 @@
-#!/bin/bash
-set -ex
-
-loginString="$(aws ecr get-login)"
-${loginString/-e none/ }
-REPOSITORY_URI=${REPOSITORY_URI}
-
-docker tag todo/oauth-server:latest ${REPOSITORY_URI}:oauth-server
-docker push ${REPOSITORY_URI}:oauth-server
-
-docker tag todo/user-service:latest ${REPOSITORY_URI}:user-service
-docker push ${REPOSITORY_URI}:user-service
-
-docker tag todo/api-gateway:latest ${REPOSITORY_URI}:api-gateway
-docker push ${REPOSITORY_URI}:api-gateway
-
-docker tag todo/config-server:latest ${REPOSITORY_URI}:config-server
-docker push ${REPOSITORY_URI}:config-server
-
-
-docker tag todo/eureka-server:latest ${REPOSITORY_URI}:eureka-server
-docker push ${REPOSITORY_URI}:eureka-server
-
-docker tag todo/reminder-service:latest ${REPOSITORY_URI}:reminder-service
-docker push ${REPOSITORY_URI}:reminder-service
-
-docker tag todo/admin-server:latest ${REPOSITORY_URI}:admin-server
-docker push ${REPOSITORY_URI}:admin-server
-
-
-docker tag todo/mail-service:latest ${REPOSITORY_URI}:mail-service
-docker push ${REPOSITORY_URI}:mail-service
-
-ecs-cli compose --verbose --file ./aws-compose.yml up
-
-
-
+#!/bin/bash
+set -ex
+
+loginString="$(aws ecr get-login)"
+${loginString/-e none/ }
+REPOSITORY_URI=${REPOSITORY_URI}
+
+docker tag todo/oauth-server:latest ${REPOSITORY_URI}:oauth-server
+docker push ${REPOSITORY_URI}:oauth-server
+
+docker tag todo/user-service:latest ${REPOSITORY_URI}:user-service
+docker push ${REPOSITORY_URI}:user-service
+
+docker tag todo/api-gateway:latest ${REPOSITORY_URI}:api-gateway
+docker push ${REPOSITORY_URI}:api-gateway
+
+docker tag todo/config-server:latest ${REPOSITORY_URI}:config-server
+docker push ${REPOSITORY_URI}:config-server
+
+
+docker tag todo/eureka-server:latest ${REPOSITORY_URI}:eureka-server
+docker push ${REPOSITORY_URI}:eureka-server
+
+docker tag todo/reminder-service:latest ${REPOSITORY_URI}:reminder-service
+docker push ${REPOSITORY_URI}:reminder-service
+
+docker tag todo/admin-server:latest ${REPOSITORY_URI}:admin-server
+docker push ${REPOSITORY_URI}:admin-server
+
+
+docker tag todo/mail-service:latest ${REPOSITORY_URI}:mail-service
+docker push ${REPOSITORY_URI}:mail-service
+
+ecs-cli compose --verbose --file ./aws-compose.yml up
+
+
+
diff --git a/config-server/.gitignore b/config-server/.gitignore
index b83d222..24d6437 100644
--- a/config-server/.gitignore
+++ b/config-server/.gitignore
@@ -1 +1 @@
-/target/
+/target/
diff --git a/config-server/Jenkinsfile b/config-server/Jenkinsfile
index 39e1157..409bada 100644
--- a/config-server/Jenkinsfile
+++ b/config-server/Jenkinsfile
@@ -1,16 +1,16 @@
-node {
- stage('Fetch changes') {
- git 'https://github.com/apssouza22/java-microservice.git'
- }
- stage('Build image') {
- // Run the maven build
- if (isUnix()) {
- sh "mvn -f ./config-server/pom.xml -Pdockerimage docker:build"
- } else {
- echo "Not ready for windows"
- }
- }
- stage('Deploy ECS') {
- echo "TODO deploy on AWS"
- }
-}
+node {
+ stage('Fetch changes') {
+ git 'https://github.com/apssouza22/java-microservice.git'
+ }
+ stage('Build image') {
+ // Run the maven build
+ if (isUnix()) {
+ sh "mvn -f ./config-server/pom.xml -Pdockerimage docker:build"
+ } else {
+ echo "Not ready for windows"
+ }
+ }
+ stage('Deploy ECS') {
+ echo "TODO deploy on AWS"
+ }
+}
diff --git a/config-server/README b/config-server/README
index 63550b5..0918784 100644
--- a/config-server/README
+++ b/config-server/README
@@ -1,5 +1,5 @@
-# Config server
-
-In the Config Server we have a central place to manage external properties for applications across all environments.
-We are using Spring config to deal with configuration of our services.
-
+# Config server
+
+In the Config Server we have a central place to manage external properties for applications across all environments.
+We are using Spring config to deal with configuration of our services.
+
diff --git a/config-server/nbactions.xml b/config-server/nbactions.xml
index 06a667a..111e9b0 100644
--- a/config-server/nbactions.xml
+++ b/config-server/nbactions.xml
@@ -1,46 +1,46 @@
-
-
-
- run
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.apssouza.config.Application
- java
-
-
-
- debug
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.apssouza.config.Application
- java
- true
-
-
-
- profile
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.apssouza.config.Application
- java
-
-
-
+
+
+
+ run
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
+
+
+ -classpath %classpath com.apssouza.config.Application
+ java
+
+
+
+ debug
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
+
+
+ -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.apssouza.config.Application
+ java
+ true
+
+
+
+ profile
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
+
+
+ -classpath %classpath com.apssouza.config.Application
+ java
+
+
+
diff --git a/config-server/pom.xml b/config-server/pom.xml
index f453e43..29e002f 100644
--- a/config-server/pom.xml
+++ b/config-server/pom.xml
@@ -1,155 +1,157 @@
-
-
- 4.0.0
-
- com.apssouza
- config-server
- 1
- jar
-
- config-server
- Spring Cloud Config Server suitable for use with most course labs
-
-
- org.springframework.cloud
- spring-cloud-starter-parent
- Camden.SR2
-
-
-
-
- UTF-8
- com.apssouza.config.Application
- 1.8
-
-
-
-
- org.springframework.cloud
- spring-cloud-config-server
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
- org.springframework.boot
- spring-boot-devtools
- true
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
-
-
- dockerimage
-
- todo/config-server
- src/main/resources/docker
- ${project.build.directory}/dockerimgbuild
- Dockerfile
-
-
-
-
-
- maven-resources-plugin
-
-
- copy-resources
- package
-
- copy-resources
-
-
- ${docker.build.directory}
-
-
- ${docker.image.src.root}
- false
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- copy
- package
-
- copy
-
-
-
-
- ${project.groupId}
- ${project.artifactId}
- ${project.version}
- jar
- true
- ${docker.build.directory}/application/lib
- springboot-webapp.jar
-
-
-
-
- ${docker.build.directory}
- true
- true
-
-
-
-
-
-
-
- io.fabric8
- docker-maven-plugin
- 0.19.0
-
-
- unix:///var/run/docker.sock
-
-
- ${docker.image.name}
-
-
- latest
-
- ${docker.build.directory}/${docker.file.name}
-
-
-
-
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ com.apssouza
+ config-server
+ 1
+ jar
+
+ config-server
+ Spring Cloud Config Server suitable for use with most course labs
+
+
+ org.springframework.cloud
+ spring-cloud-starter-parent
+ Camden.SR2
+
+
+
+
+ UTF-8
+ com.apssouza.config.Application
+ 1.8
+ tcp://localhost:2375
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-config-server
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ true
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
+ dockerimage
+
+ todo/config-server
+ src/main/resources/docker
+ ${project.build.directory}/dockerimgbuild
+ Dockerfile
+
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-resources
+ package
+
+ copy-resources
+
+
+ ${docker.build.directory}
+
+
+ ${docker.image.src.root}
+ false
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy
+ package
+
+ copy
+
+
+
+
+ ${project.groupId}
+ ${project.artifactId}
+ ${project.version}
+ jar
+ true
+ ${docker.build.directory}/application/lib
+ springboot-webapp.jar
+
+
+
+
+ ${docker.build.directory}
+ true
+ true
+
+
+
+
+
+
+
+ io.fabric8
+ docker-maven-plugin
+ 0.19.0
+
+
+ unix:///var/run/docker.sock
+
+
+
+ ${docker.image.name}
+
+
+ latest
+
+ ${docker.build.directory}/${docker.file.name}
+
+
+
+
+
+
+
+
+
+
diff --git a/config-server/src/main/java/com/apssouza/config/Application.java b/config-server/src/main/java/com/apssouza/config/Application.java
index 3a0bee3..cd77ebb 100644
--- a/config-server/src/main/java/com/apssouza/config/Application.java
+++ b/config-server/src/main/java/com/apssouza/config/Application.java
@@ -1,14 +1,14 @@
-package com.apssouza.config;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.config.server.EnableConfigServer;
-
-@SpringBootApplication
-@EnableConfigServer
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-}
+package com.apssouza.config;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.config.server.EnableConfigServer;
+
+@SpringBootApplication
+@EnableConfigServer
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+}
diff --git a/config-server/src/main/resources/application.yml b/config-server/src/main/resources/application.yml
index a6eb1ee..b15ecfc 100644
--- a/config-server/src/main/resources/application.yml
+++ b/config-server/src/main/resources/application.yml
@@ -1,18 +1,18 @@
----
-spring.profiles.active: native
-spring.application.name: config-server
-server.port: 8888
-eureka.client.serviceUrl.defaultZone : http://eureka:8010/eureka/,http://localhost:8011/eureka/
-
-spring:
- cloud:
- config:
- server:
- git:
- uri: https://github.com/apssouza22/java-microservice
- searchPaths: config-data
- # "native" is used when the native profile is active, for local tests with a classpath repo:
- native:
- searchLocations: classpath:offline-repository/
-
-
+---
+spring.profiles.active: native
+spring.application.name: config-server
+server.port: 8888
+eureka.client.serviceUrl.defaultZone : http://eureka:8010/eureka/,http://localhost:8011/eureka/
+
+spring:
+ cloud:
+ config:
+ server:
+ git:
+ uri: https://github.com/apssouza22/java-microservice
+ searchPaths: config-data
+ # "native" is used when the native profile is active, for local tests with a classpath repo:
+ native:
+ searchLocations: classpath:offline-repository/
+
+
diff --git a/config-server/src/main/resources/docker/Dockerfile b/config-server/src/main/resources/docker/Dockerfile
index ab30719..fe9779e 100644
--- a/config-server/src/main/resources/docker/Dockerfile
+++ b/config-server/src/main/resources/docker/Dockerfile
@@ -1,37 +1,37 @@
-FROM openjdk:8
-
-
-MAINTAINER Alexsandro
-ENV REFRESHED_AT 2017-09-17
-
-ENV TERM xterm
-ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
-
-RUN apt-get update -qq \
- && apt-get install -qqy curl wget \
- && apt-get clean \
- \
- && touch /var/log/todo.log \
- && chmod 666 /var/log/todo.log
-
-ADD application/lib/springboot-webapp.jar /app.jar
-ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
-RUN bash -c 'chmod +x wait-for-it.sh'
-
-# install Filebeat
-ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
-RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
- && dpkg -i ${FILEBEAT_VERSION} \
- && rm ${FILEBEAT_VERSION}
-
-# configure Filebeat
-ADD filebeat.yml /etc/filebeat/filebeat.yml
-
-# CA cert
-RUN mkdir -p /etc/pki/tls/certs
-ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
-
-# start Filebeat
-ADD ./start.sh /usr/local/bin/start.sh
-RUN chmod +x /usr/local/bin/start.sh
+FROM openjdk:8
+
+
+MAINTAINER Alexsandro
+ENV REFRESHED_AT 2017-09-17
+
+ENV TERM xterm
+ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
+
+RUN apt-get update -qq \
+ && apt-get install -qqy curl wget \
+ && apt-get clean \
+ \
+ && touch /var/log/todo.log \
+ && chmod 666 /var/log/todo.log
+
+ADD application/lib/springboot-webapp.jar /app.jar
+ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
+RUN bash -c 'chmod +x wait-for-it.sh'
+
+# install Filebeat
+ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
+RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
+ && dpkg -i ${FILEBEAT_VERSION} \
+ && rm ${FILEBEAT_VERSION}
+
+# configure Filebeat
+ADD filebeat.yml /etc/filebeat/filebeat.yml
+
+# CA cert
+RUN mkdir -p /etc/pki/tls/certs
+ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
+
+# start Filebeat
+ADD ./start.sh /usr/local/bin/start.sh
+RUN chmod +x /usr/local/bin/start.sh
CMD [ "/usr/local/bin/start.sh" ]
\ No newline at end of file
diff --git a/config-server/src/main/resources/docker/filebeat.yml b/config-server/src/main/resources/docker/filebeat.yml
index 09119d8..480a94e 100644
--- a/config-server/src/main/resources/docker/filebeat.yml
+++ b/config-server/src/main/resources/docker/filebeat.yml
@@ -1,30 +1,30 @@
-output:
- logstash:
- enabled: true
- hosts:
- - elk:5044
- timeout: 15
- tls:
- certificate_authorities:
- - /etc/pki/tls/certs/logstash-beats.crt
-
-filebeat:
- prospectors:
- -
- paths:
- - /var/log/syslog
- - /var/log/auth.log
- document_type: syslog
- -
- paths:
- - /var/log/spring-music.log
- document_type: log4j
- multiline:
- pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
- negate: true
- match: after
- -
- paths:
- - /usr/local/tomcat/logs/*.out
- - /usr/local/tomcat/logs/*.log
- document_type: tomcat
+output:
+ logstash:
+ enabled: true
+ hosts:
+ - elk:5044
+ timeout: 15
+ tls:
+ certificate_authorities:
+ - /etc/pki/tls/certs/logstash-beats.crt
+
+filebeat:
+ prospectors:
+ -
+ paths:
+ - /var/log/syslog
+ - /var/log/auth.log
+ document_type: syslog
+ -
+ paths:
+ - /var/log/spring-music.log
+ document_type: log4j
+ multiline:
+ pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
+ negate: true
+ match: after
+ -
+ paths:
+ - /usr/local/tomcat/logs/*.out
+ - /usr/local/tomcat/logs/*.log
+ document_type: tomcat
diff --git a/config-server/src/main/resources/docker/logstash-beats.crt b/config-server/src/main/resources/docker/logstash-beats.crt
index d9b71cf..1c86bc3 100644
--- a/config-server/src/main/resources/docker/logstash-beats.crt
+++ b/config-server/src/main/resources/docker/logstash-beats.crt
@@ -1,18 +1,18 @@
------BEGIN CERTIFICATE-----
-MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
-BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
-DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
-0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
-9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
-PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
-qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
-KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
-4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
-VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
-hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
-okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
-T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
-ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
-kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
-Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
------END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
+BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
+DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
+0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
+9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
+PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
+qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
+KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
+4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
+VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
+hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
+okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
+T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
+ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
+kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
+Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
+-----END CERTIFICATE-----
diff --git a/config-server/src/main/resources/docker/start.sh b/config-server/src/main/resources/docker/start.sh
index b68b2fb..eff4532 100644
--- a/config-server/src/main/resources/docker/start.sh
+++ b/config-server/src/main/resources/docker/start.sh
@@ -1,5 +1,4 @@
#!/bin/bash
-
curl -XPUT 'http://elk:9200/_template/filebeat?pretty' -d@/etc/filebeat/filebeat.template.json
/etc/init.d/filebeat start
-java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
+java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
\ No newline at end of file
diff --git a/config-server/src/main/resources/offline-repository/admin.yml b/config-server/src/main/resources/offline-repository/admin.yml
index 77c44e8..720da26 100644
--- a/config-server/src/main/resources/offline-repository/admin.yml
+++ b/config-server/src/main/resources/offline-repository/admin.yml
@@ -1,33 +1,33 @@
-server:
- port: 8026
-
-spring:
- application:
- name: admin
- cloud:
- config:
- enabled: false
-# tag::configuration-eureka[]
-eureka: #<1>
- instance:
- leaseRenewalIntervalInSeconds: 10
- client:
- registryFetchIntervalSeconds: 5
- serviceUrl:
- defaultZone: ${EUREKA_SERVICE_URL:http://localhost:8010}/eureka/
-
-management.security.enabled: false #<2>
-# end::configuration-eureka[]
-
-# tag::configuration-ui-hystrix[]
-spring.boot.admin.routes.endpoints: env,metrics,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,loggers,auditevents,hystrix.stream,turbine.stream,activiti
-# end::configuration-ui-hystrix[]
-
-# tag::configuration-ui-turbine[]
-spring.boot.admin.turbine:
- clusters: default
- location: turbine #<1>
-# end::configuration-ui-turbine[]
-
-logging.file: /var/log/todo.log
-
+server:
+ port: 8026
+
+spring:
+ application:
+ name: admin
+ cloud:
+ config:
+ enabled: false
+# tag::configuration-eureka[]
+eureka: #<1>
+ instance:
+ leaseRenewalIntervalInSeconds: 10
+ client:
+ registryFetchIntervalSeconds: 5
+ serviceUrl:
+ defaultZone: ${EUREKA_SERVICE_URL:http://localhost:8010}/eureka/
+
+management.security.enabled: false #<2>
+# end::configuration-eureka[]
+
+# tag::configuration-ui-hystrix[]
+spring.boot.admin.routes.endpoints: env,metrics,dump,jolokia,info,configprops,trace,logfile,refresh,flyway,liquibase,heapdump,loggers,auditevents,hystrix.stream,turbine.stream,activiti
+# end::configuration-ui-hystrix[]
+
+# tag::configuration-ui-turbine[]
+spring.boot.admin.turbine:
+ clusters: default
+ location: turbine #<1>
+# end::configuration-ui-turbine[]
+
+logging.file: /var/log/todo.log
+
diff --git a/config-server/src/main/resources/offline-repository/api-gateway.properties b/config-server/src/main/resources/offline-repository/api-gateway.properties
index a6b1191..1535d47 100644
--- a/config-server/src/main/resources/offline-repository/api-gateway.properties
+++ b/config-server/src/main/resources/offline-repository/api-gateway.properties
@@ -1,16 +1,16 @@
-server.port = 8018
-spring.application.name = api-gateway
-eureka.client.serviceUrl.defaultZone = http://eureka:8010/eureka/
-
-#database
-spring.jpa.properties.hibernate.show_sql=true
-spring.jpa.properties.hibernate.use_sql_comments=true
-spring.jpa.properties.hibernate.format_sql=true
-spring.jpa.properties.hibernate.type=trace
-
-logging.level.org.hibernate.SQL=DEBUG
-logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
-
-#spring admin
-spring.boot.admin.url=http://admin:8026,http://localhost:8026
+server.port = 8018
+spring.application.name = api-gateway
+eureka.client.serviceUrl.defaultZone = http://eureka:8010/eureka/
+
+#database
+spring.jpa.properties.hibernate.show_sql=true
+spring.jpa.properties.hibernate.use_sql_comments=true
+spring.jpa.properties.hibernate.format_sql=true
+spring.jpa.properties.hibernate.type=trace
+
+logging.level.org.hibernate.SQL=DEBUG
+logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
+
+#spring admin
+spring.boot.admin.url=http://admin:8026,http://localhost:8026
management.security.enabled= false
\ No newline at end of file
diff --git a/config-server/src/main/resources/offline-repository/eureka-server.yml b/config-server/src/main/resources/offline-repository/eureka-server.yml
index c236110..f04237b 100644
--- a/config-server/src/main/resources/offline-repository/eureka-server.yml
+++ b/config-server/src/main/resources/offline-repository/eureka-server.yml
@@ -1,60 +1,60 @@
----
-# This default profile is used when running a single instance completely standalone:
-spring:
- boot:
- admin:
- url: http://admin:8026,http://localhost:8026
- profiles: default
-
-server:
- port: 8010
-
-eureka:
- instance:
- hostname: localhost
- preferIpAddress: true
-# ipAddress: 52.50.116.215
- client:
- registerWithEureka: false
- fetchRegistry: false
- serviceUrl:
- defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
-
-# primary, secondary, and tertiary illustrate running 3 intercommunicating instances. This example has them running
-# side-by-side on localhost -- which is unrealistic in production -- but does illustrate how multiple instances collaborate.
-# Run by opening 3 separate command prompts:
-# java -jar -Dspring.profiles.active=primary target/commmon-eureka-server-1.jar
-# java -jar -Dspring.profiles.active=secondary target/commmon-eureka-server-1.jar
-# java -jar -Dspring.profiles.active=tertiary target/commmon-eureka-server-1.jar
-
----
-spring:
- profiles: primary
-server:
- port: 8011
-eureka:
- client:
- serviceUrl:
- defaultZone: http://localhost:8012/eureka, http://localhost:8013/eureka/
-
----
-spring:
- profiles: secondary
-server:
- port: 8012
-eureka:
- client:
- serviceUrl:
- defaultZone: http://localhost:8013/eureka/,http://localhost:8011/eureka/
-
----
-spring:
- profiles: tertiary
-server:
- port: 8013
-eureka:
- client:
- serviceUrl:
- defaultZone: http://localhost:8011/eureka/,http://localhost:8012/eureka/
-
+---
+# This default profile is used when running a single instance completely standalone:
+spring:
+ boot:
+ admin:
+ url: http://admin:8026,http://localhost:8026
+ profiles: default
+
+server:
+ port: 8010
+
+eureka:
+ instance:
+ hostname: localhost
+ preferIpAddress: true
+# ipAddress: 52.50.116.215
+ client:
+ registerWithEureka: false
+ fetchRegistry: false
+ serviceUrl:
+ defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
+
+# primary, secondary, and tertiary illustrate running 3 intercommunicating instances. This example has them running
+# side-by-side on localhost -- which is unrealistic in production -- but does illustrate how multiple instances collaborate.
+# Run by opening 3 separate command prompts:
+# java -jar -Dspring.profiles.active=primary target/commmon-eureka-server-1.jar
+# java -jar -Dspring.profiles.active=secondary target/commmon-eureka-server-1.jar
+# java -jar -Dspring.profiles.active=tertiary target/commmon-eureka-server-1.jar
+
+---
+spring:
+ profiles: primary
+server:
+ port: 8011
+eureka:
+ client:
+ serviceUrl:
+ defaultZone: http://localhost:8012/eureka, http://localhost:8013/eureka/
+
+---
+spring:
+ profiles: secondary
+server:
+ port: 8012
+eureka:
+ client:
+ serviceUrl:
+ defaultZone: http://localhost:8013/eureka/,http://localhost:8011/eureka/
+
+---
+spring:
+ profiles: tertiary
+server:
+ port: 8013
+eureka:
+ client:
+ serviceUrl:
+ defaultZone: http://localhost:8011/eureka/,http://localhost:8012/eureka/
+
logging.file: /var/log/todo.log
\ No newline at end of file
diff --git a/config-server/src/main/resources/offline-repository/mailer.properties b/config-server/src/main/resources/offline-repository/mailer.properties
index 29b9140..b595993 100644
--- a/config-server/src/main/resources/offline-repository/mailer.properties
+++ b/config-server/src/main/resources/offline-repository/mailer.properties
@@ -1,22 +1,22 @@
-server.port=8020
-
-spring.application.name=mailer
-
-eureka.client.serviceUrl.defaultZone = http://eureka:8010/eureka/,http://localhost:8011/eureka/
-
-#spring admin
-spring.boot.admin.url=http://admin:8026,http://localhost:8026
-management.security.enabled= false
-
-logging.file= /var/log/todo.log
-
-#spring stream
-spring.cloud.stream.default.contentType=application/json
-spring.cloud.stream.bindings.output.destination=todo-mail
-spring.cloud.stream.bindings.input.destination=todo-mail
-spring.cloud.stream.bindings.input.group=todo-mail
-spring.cloud.stream.kafka.binder.headers = type
-spring.cloud.stream.kafka.binder.brokers=kafka
-spring.cloud.stream.kafka.binder.zkNodes=zookeeper
-spring.cloud.stream.kafka.binder.defaultZkPort=2181
-spring.cloud.stream.kafka.binder.defaultBrokerPort=9092
+server.port=8020
+
+spring.application.name=mailer
+
+eureka.client.serviceUrl.defaultZone = http://eureka:8010/eureka/,http://localhost:8011/eureka/
+
+#spring admin
+spring.boot.admin.url=http://admin:8026,http://localhost:8026
+management.security.enabled= false
+
+logging.file= /var/log/todo.log
+
+#spring stream
+spring.cloud.stream.default.contentType=application/json
+spring.cloud.stream.bindings.output.destination=todo-mail
+spring.cloud.stream.bindings.input.destination=todo-mail
+spring.cloud.stream.bindings.input.group=todo-mail
+spring.cloud.stream.kafka.binder.headers = type
+spring.cloud.stream.kafka.binder.brokers=kafka
+spring.cloud.stream.kafka.binder.zkNodes=zookeeper
+spring.cloud.stream.kafka.binder.defaultZkPort=2181
+spring.cloud.stream.kafka.binder.defaultBrokerPort=9092
diff --git a/config-server/src/main/resources/offline-repository/oauth.properties b/config-server/src/main/resources/offline-repository/oauth.properties
index 4584f64..df07fe4 100644
--- a/config-server/src/main/resources/offline-repository/oauth.properties
+++ b/config-server/src/main/resources/offline-repository/oauth.properties
@@ -1,18 +1,18 @@
-server.port = 8017
-spring.application.name = oauth
-eureka.client.serviceUrl.defaultZone = http://eureka:8010/eureka/,http://localhost:8010/eureka/
-
-#database
-spring.jpa.properties.hibernate.show_sql=true
-spring.jpa.properties.hibernate.use_sql_comments=true
-spring.jpa.properties.hibernate.format_sql=true
-spring.jpa.properties.hibernate.type=trace
-
-logging.level.org.hibernate.SQL=DEBUG
-logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
-
-#spring admin
-spring.boot.admin.url=http://admin:8026,http://localhost:8026
-management.security.enabled: false
-
-logging.file= /var/log/todo.log
+server.port = 8017
+spring.application.name = oauth
+eureka.client.serviceUrl.defaultZone = http://eureka:8010/eureka/,http://localhost:8010/eureka/
+
+#database
+spring.jpa.properties.hibernate.show_sql=true
+spring.jpa.properties.hibernate.use_sql_comments=true
+spring.jpa.properties.hibernate.format_sql=true
+spring.jpa.properties.hibernate.type=trace
+
+logging.level.org.hibernate.SQL=DEBUG
+logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
+
+#spring admin
+spring.boot.admin.url=http://admin:8026,http://localhost:8026
+management.security.enabled: false
+
+logging.file= /var/log/todo.log
diff --git a/config-server/src/main/resources/offline-repository/reminder.properties b/config-server/src/main/resources/offline-repository/reminder.properties
index 9d2c246..8e7b2da 100644
--- a/config-server/src/main/resources/offline-repository/reminder.properties
+++ b/config-server/src/main/resources/offline-repository/reminder.properties
@@ -1,28 +1,28 @@
-server.port = 8015
-eureka.client.serviceUrl.defaultZone = http://eureka:8010/eureka/,http://localhost:8010/eureka/
-
-#database
-spring.jpa.properties.hibernate.show_sql=true
-spring.jpa.properties.hibernate.use_sql_comments=true
-spring.jpa.properties.hibernate.format_sql=true
-spring.jpa.properties.hibernate.type=trace
-
-logging.level.org.hibernate.SQL=DEBUG
-logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
-
-#spring admin
-spring.boot.admin.url=http://admin:8026,http://localhost:8026
-management.security.enabled= false
-
-logging.file= /var/log/todo.log
-
-#spring stream
-spring.cloud.stream.default.contentType=application/json
-spring.cloud.stream.bindings.output.destination=todo-mail
-spring.cloud.stream.bindings.input.destination=todo-mail
-spring.cloud.stream.bindings.input.group=todo-mail
-spring.cloud.stream.kafka.binder.headers = type
-spring.cloud.stream.kafka.binder.brokers=kafka
-spring.cloud.stream.kafka.binder.zkNodes=zookeeper
-spring.cloud.stream.kafka.binder.defaultZkPort=2181
+server.port = 8015
+eureka.client.serviceUrl.defaultZone = http://eureka:8010/eureka/,http://localhost:8010/eureka/
+
+#database
+spring.jpa.properties.hibernate.show_sql=true
+spring.jpa.properties.hibernate.use_sql_comments=true
+spring.jpa.properties.hibernate.format_sql=true
+spring.jpa.properties.hibernate.type=trace
+
+logging.level.org.hibernate.SQL=DEBUG
+logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
+
+#spring admin
+spring.boot.admin.url=http://admin:8026,http://localhost:8026
+management.security.enabled= false
+
+logging.file= /var/log/todo.log
+
+#spring stream
+spring.cloud.stream.default.contentType=application/json
+spring.cloud.stream.bindings.output.destination=todo-mail
+spring.cloud.stream.bindings.input.destination=todo-mail
+spring.cloud.stream.bindings.input.group=todo-mail
+spring.cloud.stream.kafka.binder.headers = type
+spring.cloud.stream.kafka.binder.brokers=kafka
+spring.cloud.stream.kafka.binder.zkNodes=zookeeper
+spring.cloud.stream.kafka.binder.defaultZkPort=2181
spring.cloud.stream.kafka.binder.defaultBrokerPort=9092
\ No newline at end of file
diff --git a/config-server/src/main/resources/offline-repository/user.properties b/config-server/src/main/resources/offline-repository/user.properties
index e76eb36..d2be367 100644
--- a/config-server/src/main/resources/offline-repository/user.properties
+++ b/config-server/src/main/resources/offline-repository/user.properties
@@ -1,18 +1,18 @@
-server.port = 8016
-spring.application.name = user
-eureka.client.serviceUrl.defaultZone = http://eureka:8010/eureka/,http://localhost:8011/eureka/
-
-#database
-spring.jpa.properties.hibernate.show_sql=true
-spring.jpa.properties.hibernate.use_sql_comments=true
-spring.jpa.properties.hibernate.format_sql=true
-spring.jpa.properties.hibernate.type=trace
-
-logging.level.org.hibernate.SQL=DEBUG
-logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
-
-#spring admin
-spring.boot.admin.url=http://admin:8026,http://localhost:8026
-management.security.enabled= false
-
-logging.file=/var/log/todo.log
+server.port = 8016
+spring.application.name = user
+eureka.client.serviceUrl.defaultZone = http://eureka:8010/eureka/,http://localhost:8011/eureka/
+
+#database
+spring.jpa.properties.hibernate.show_sql=true
+spring.jpa.properties.hibernate.use_sql_comments=true
+spring.jpa.properties.hibernate.format_sql=true
+spring.jpa.properties.hibernate.type=trace
+
+logging.level.org.hibernate.SQL=DEBUG
+logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
+
+#spring admin
+spring.boot.admin.url=http://admin:8026,http://localhost:8026
+management.security.enabled= false
+
+logging.file=/var/log/todo.log
diff --git a/config-server/src/test/java/demo/OutOfContainerTest.java b/config-server/src/test/java/demo/OutOfContainerTest.java
index 2800fc0..041e1b3 100644
--- a/config-server/src/test/java/demo/OutOfContainerTest.java
+++ b/config-server/src/test/java/demo/OutOfContainerTest.java
@@ -1,55 +1,55 @@
-package demo;
-
-import com.apssouza.config.Application;
-import static org.junit.Assert.assertTrue;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.MvcResult;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import org.springframework.web.context.WebApplicationContext;
-
-/**
- * Out-of-container test for the config server.
- * Verifies that the server serves up configuration when asked.
- * Uses "native" profile to obtain properties from local file system rather than GitHub.
- *
- * @author ken krueger
- */
-@RunWith(SpringRunner.class)
-@SpringBootTest(classes = Application.class)
-@WebAppConfiguration
-@ActiveProfiles("native") // "native" means use local classpath location rather than GitHub.
-public class OutOfContainerTest {
-
- @Autowired WebApplicationContext spring;
- MockMvc mockMvc;
-
- @Before
- public void setup() {
- mockMvc = MockMvcBuilders.webAppContextSetup(spring).build();
- }
-
- @Test
- public void propertyLoadTest() throws Exception {
-
- // To test if this config server is working, we will simulate a "testConfig" client
- // calling to get properties for its default profile. These configuration files
- // (application.yml and testConfig.yml) are on the classpath as the server is
- // running the 'native' profile:
- MvcResult result =
- mockMvc.perform(get("/eureka-server.properties"))
- .andExpect(status().isOk())
- .andReturn()
- ;
- }
-}
+package demo;
+
+import com.apssouza.config.Application;
+import static org.junit.Assert.assertTrue;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * Out-of-container test for the config server.
+ * Verifies that the server serves up configuration when asked.
+ * Uses "native" profile to obtain properties from local file system rather than GitHub.
+ *
+ * @author ken krueger
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest(classes = Application.class)
+@WebAppConfiguration
+@ActiveProfiles("native") // "native" means use local classpath location rather than GitHub.
+public class OutOfContainerTest {
+
+ @Autowired WebApplicationContext spring;
+ MockMvc mockMvc;
+
+ @Before
+ public void setup() {
+ mockMvc = MockMvcBuilders.webAppContextSetup(spring).build();
+ }
+
+ @Test
+ public void propertyLoadTest() throws Exception {
+
+ // To test if this config server is working, we will simulate a "testConfig" client
+ // calling to get properties for its default profile. These configuration files
+ // (application.yml and testConfig.yml) are on the classpath as the server is
+ // running the 'native' profile:
+ MvcResult result =
+ mockMvc.perform(get("/eureka-server.properties"))
+ .andExpect(status().isOk())
+ .andReturn()
+ ;
+ }
+}
diff --git a/docker-compose.yml b/docker-compose.yml
index 261f3be..6acb6b2 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,173 +1,191 @@
-version: '2'
-
-services:
- config:
- image: todo/config-server
- ports:
- - 8888:8888
- networks:
- - net
- hostname: config
- container_name: config
- external_links:
- - elk
- - kafka
-
- eureka:
- image: todo/eureka-server
- ports:
- - 8010:8010
- networks:
- - net
- depends_on:
- - config
- hostname: eureka
- container_name: eureka
- command: ["./wait-for-it.sh","config:8888","--timeout=100","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
-
- reminder:
- image: todo/reminder-service
- ports:
- - 8015:8015
- networks:
- - net
- depends_on:
- - eureka
- - admin
- hostname: reminder
- command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
- - kafka
-
- user:
- image: todo/user-service
- ports:
- - 8016:8016
- networks:
- - net
- depends_on:
- - eureka
- - admin
- hostname: user
- container_name: user
- command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
- - kafka
-
- oauth:
- image: todo/oauth-server
- ports:
- - 8017:8017
- networks:
- - net
- depends_on:
- - eureka
- - user
- - admin
- hostname: oauth
- container_name: oauth
- command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
-
-
- gateway:
- image: todo/api-gateway
- ports:
- - 8018:8018
- networks:
- - net
- depends_on:
- - eureka
- - admin
- hostname: gateway
- command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
-
- mail:
- image: todo/mail-service
- ports:
- - 8020:8020
- networks:
- - net
- depends_on:
- - eureka
- - admin
- hostname: mail
- container_name: mail
- command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
- - kafka
-
- admin:
- image: todo/admin-server
- depends_on:
- - eureka
- container_name: admin
- ports:
- - 8026:8026
- networks:
- - net
- environment:
- - EUREKA_SERVICE_URL=http://eureka:8010
- - EUREKA_INSTANCE_PREFER_IP_ADDRESS=true
- - LOGGING_FILE=/tmp/admin.log
- command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
- external_links:
- - elk
-
- zookeeper:
- image: wurstmeister/zookeeper
- ports:
- - 2181:2181
- networks:
- - net
- mem_limit: 925288000
- cpu_shares: 100
-
- kafka:
- image: wurstmeister/kafka
- ports:
- - 9092
- depends_on:
- - zookeeper
- environment:
- KAFKA_ADVERTISED_HOST_NAME: 172.19.0.1
- KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
- KAFKA_CREATE_TOPICS: "todo-mail:1:1"
- volumes:
- - /var/run/docker.sock:/var/run/docker.sock
- hostname: kafka
- container_name: kafka
- networks:
- - net
- mem_limit: 925288000
- cpu_shares: 100
-
- proxy:
- build: proxy/
- ports:
- - 8055:80
- networks:
- - net
- depends_on:
- - gateway
- hostname: proxy
- container_name: proxy
- command: ["./wait-for-it.sh","gateway:8018","--timeout=50","--","/usr/local/bin/start.sh"]
-
-volumes:
- todo_data:
- external: true
- todo_elk:
- external: true
-
-networks:
- net:
- driver: bridge
+version: '2'
+
+services:
+ config:
+ image: todo/config-server
+ ports:
+ - "8888:8888"
+ networks:
+ - net
+ hostname: config
+ container_name: config
+ external_links:
+ - elk
+ - kafka
+
+ eureka:
+ image: todo/eureka-server
+ ports:
+ - "8010:8010"
+ networks:
+ - net
+ depends_on:
+ - config
+ hostname: eureka
+ container_name: eureka
+ command: ["./wait-for-it.sh","config:8888","--timeout=100","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+
+ reminder:
+ image: todo/reminder-service
+ ports:
+ - "8015:8015"
+ networks:
+ - net
+ depends_on:
+ - eureka
+ - admin
+ hostname: reminder
+ container_name: reminder
+ command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+ - kafka
+
+ user:
+ image: todo/user-service
+ ports:
+ - "8016:8016"
+ networks:
+ - net
+ depends_on:
+ - eureka
+ - admin
+ hostname: user
+ container_name: user
+ command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+ - kafka
+
+ oauth:
+ image: todo/oauth-server
+ ports:
+ - "8017:8017"
+ networks:
+ - net
+ depends_on:
+ - eureka
+ - user
+ - admin
+ hostname: oauth
+ container_name: oauth
+ command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+
+
+ gateway:
+ image: todo/api-gateway
+ ports:
+ - "8018:8018"
+ networks:
+ - net
+ depends_on:
+ - eureka
+ - admin
+ hostname: gateway
+ command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+
+ mail:
+ image: todo/mail-service
+ ports:
+ - 8020:8020
+ networks:
+ - net
+ depends_on:
+ - eureka
+ - admin
+ hostname: mail
+ container_name: mail
+ command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+ - kafka
+
+ admin:
+ image: todo/admin-server
+ depends_on:
+ - eureka
+ container_name: admin
+ ports:
+ - "8026:8026"
+ networks:
+ - net
+ environment:
+ - EUREKA_SERVICE_URL=http://eureka:8010
+ - EUREKA_INSTANCE_PREFER_IP_ADDRESS=true
+ - LOGGING_FILE=/tmp/admin.log
+ command: ["./wait-for-it.sh","eureka:8010","--timeout=150","--","/usr/local/bin/start.sh"]
+ external_links:
+ - elk
+
+
+ zookeeper:
+ image: wurstmeister/zookeeper
+ ports:
+ - "2181:2181"
+ networks:
+ - net
+ mem_limit: 300m
+ cpu_shares: 70
+
+ kafka:
+ image: wurstmeister/kafka
+ ports:
+ - "9092:9092"
+ depends_on:
+ - zookeeper
+ environment:
+ KAFKA_ADVERTISED_HOST_NAME: 172.19.0.1
+ KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
+ KAFKA_CREATE_TOPICS: "todo-mail:1:1"
+ volumes:
+ - /var/run/docker.sock:/var/run/docker.sock
+ hostname: kafka
+ container_name: kafka
+ networks:
+ - net
+ mem_limit: 1200m
+ cpu_shares: 100
+
+ proxy:
+ build: proxy/
+ ports:
+ - 8055:80
+ networks:
+ - net
+ depends_on:
+ - gateway
+ hostname: proxy
+ container_name: proxy
+ command: ["./wait-for-it.sh","gateway:8018","--timeout=50","--","/usr/local/bin/start.sh"]
+
+ elk:
+ image: sebp/elk
+ ports:
+ - "5601:5601"
+ - "9200:9200"
+ - "5044:5044"
+ volumes:
+ - /var/run/docker.sock:/var/run/docker.sock
+ hostname: elk
+ container_name: elk
+ networks:
+ - net
+ mem_limit: 3000m
+ cpu_shares: 50
+
+
+volumes:
+ todo_data:
+ external: true
+ todo_elk:
+ external: true
+
+networks:
+ net:
+ driver: bridge
diff --git a/docker-orchestrate.sh b/docker-orchestrate.sh
index 553313e..5077e79 100755
--- a/docker-orchestrate.sh
+++ b/docker-orchestrate.sh
@@ -18,9 +18,9 @@ docker volume create --name todo_elk
# create bridge network for project
# ** assumes your project folder is 'todo' **
+#docker network rm todo_net
docker network create -d bridge todo_net
# build images and orchestrate start-up of containers (in this order)
# -p = --project-name
-docker-compose -p todo up
-
+docker-compose -p todo up
diff --git a/eureka-server/.gitignore b/eureka-server/.gitignore
index b83d222..24d6437 100644
--- a/eureka-server/.gitignore
+++ b/eureka-server/.gitignore
@@ -1 +1 @@
-/target/
+/target/
diff --git a/eureka-server/Jenkinsfile b/eureka-server/Jenkinsfile
index d20cb5c..c60ca94 100644
--- a/eureka-server/Jenkinsfile
+++ b/eureka-server/Jenkinsfile
@@ -1,16 +1,16 @@
-node {
- stage('Fetch changes') {
- git 'https://github.com/apssouza22/java-microservice.git'
- }
- stage('Build image') {
- // Run the maven build
- if (isUnix()) {
- sh "mvn -f ./eureka-server/pom.xml -Pdockerimage docker:build "
- } else {
- echo "Not ready for windows"
- }
- }
- stage('Deploy ECS') {
- echo "TODO deploy on AWS"
- }
-}
+node {
+ stage('Fetch changes') {
+ git 'https://github.com/apssouza22/java-microservice.git'
+ }
+ stage('Build image') {
+ // Run the maven build
+ if (isUnix()) {
+ sh "mvn -f ./eureka-server/pom.xml -Pdockerimage docker:build "
+ } else {
+ echo "Not ready for windows"
+ }
+ }
+ stage('Deploy ECS') {
+ echo "TODO deploy on AWS"
+ }
+}
diff --git a/eureka-server/README b/eureka-server/README
index 8eece85..488c203 100644
--- a/eureka-server/README
+++ b/eureka-server/README
@@ -1,4 +1,4 @@
-# Eureka server
-
-Server-side service discovery allows services to find and communicate with each other without hard coding hostname and port.
+# Eureka server
+
+Server-side service discovery allows services to find and communicate with each other without hard coding hostname and port.
The only ‘fixed point’ in such an architecture consists of a service registry with which each service has to register.
\ No newline at end of file
diff --git a/eureka-server/nbactions.xml b/eureka-server/nbactions.xml
index 7633239..1a8a429 100644
--- a/eureka-server/nbactions.xml
+++ b/eureka-server/nbactions.xml
@@ -1,17 +1,17 @@
-
-
-
- run
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath demo.Application
- java
-
-
-
+
+
+
+ run
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
+
+
+ -classpath %classpath demo.Application
+ java
+
+
+
diff --git a/eureka-server/pom.xml b/eureka-server/pom.xml
index 5da3932..60f7ced 100644
--- a/eureka-server/pom.xml
+++ b/eureka-server/pom.xml
@@ -1,150 +1,151 @@
-
-
- 4.0.0
-
- org.test
- eureka-server
- 1
- jar
-
- eureka-server
- Eureka server - service discovery
-
-
- org.springframework.cloud
- spring-cloud-starter-parent
- Camden.SR2
-
-
-
-
- UTF-8
- com.apssouza.discovery.Application
- 1.8
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-eureka-server
-
-
- de.codecentric
- spring-boot-admin-starter-client
- 1.5.4
-
-
- org.springframework.cloud
- spring-cloud-starter-config
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
-
-
-
-
-
- dockerimage
-
- todo/eureka-server
- src/main/resources/docker
- ${project.build.directory}/dockerimgbuild
- Dockerfile
-
-
-
-
-
- maven-resources-plugin
-
-
- copy-resources
- package
-
- copy-resources
-
-
- ${docker.build.directory}
-
-
- ${docker.image.src.root}
- false
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- copy
- package
-
- copy
-
-
-
-
- ${project.groupId}
- ${project.artifactId}
- ${project.version}
- jar
- true
- ${docker.build.directory}/application/lib
- springboot-webapp.jar
-
-
-
-
- ${docker.build.directory}
- true
- true
-
-
-
-
-
-
-
- io.fabric8
- docker-maven-plugin
- 0.19.0
-
-
- unix:///var/run/docker.sock
-
-
- ${docker.image.name}
-
-
- latest
-
- ${docker.build.directory}/${docker.file.name}
-
-
-
-
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ org.test
+ eureka-server
+ 1
+ jar
+
+ eureka-server
+ Eureka server - service discovery
+
+
+ org.springframework.cloud
+ spring-cloud-starter-parent
+ Camden.SR2
+
+
+
+
+ UTF-8
+ com.apssouza.discovery.Application
+ 1.8
+ tcp://localhost:2375
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka-server
+
+
+ de.codecentric
+ spring-boot-admin-starter-client
+ 1.5.4
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
+
+ dockerimage
+
+ todo/eureka-server
+ src/main/resources/docker
+ ${project.build.directory}/dockerimgbuild
+ Dockerfile
+
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-resources
+ package
+
+ copy-resources
+
+
+ ${docker.build.directory}
+
+
+ ${docker.image.src.root}
+ false
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy
+ package
+
+ copy
+
+
+
+
+ ${project.groupId}
+ ${project.artifactId}
+ ${project.version}
+ jar
+ true
+ ${docker.build.directory}/application/lib
+ springboot-webapp.jar
+
+
+
+
+ ${docker.build.directory}
+ true
+ true
+
+
+
+
+
+
+
+ io.fabric8
+ docker-maven-plugin
+ 0.19.0
+
+ unix:///var/run/docker.sock
+
+
+
+ ${docker.image.name}
+
+
+ latest
+
+ ${docker.build.directory}/${docker.file.name}
+
+
+
+
+
+
+
+
+
+
diff --git a/eureka-server/src/main/java/com/apssouza/discovery/Application.java b/eureka-server/src/main/java/com/apssouza/discovery/Application.java
index 2e0c41c..83e4de2 100644
--- a/eureka-server/src/main/java/com/apssouza/discovery/Application.java
+++ b/eureka-server/src/main/java/com/apssouza/discovery/Application.java
@@ -1,14 +1,14 @@
-package com.apssouza.discovery;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
-
-@SpringBootApplication
-@EnableEurekaServer
-public class Application {
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- }
-}
+package com.apssouza.discovery;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
+
+@SpringBootApplication
+@EnableEurekaServer
+public class Application {
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ }
+}
diff --git a/eureka-server/src/main/resources/application.yml b/eureka-server/src/main/resources/application.yml
index 6f1a5e9..b1bfc98 100644
--- a/eureka-server/src/main/resources/application.yml
+++ b/eureka-server/src/main/resources/application.yml
@@ -1,5 +1,5 @@
----
-spring:
- application:
- name: eureka-server
+---
+spring:
+ application:
+ name: eureka-server
\ No newline at end of file
diff --git a/eureka-server/src/main/resources/bootstrap.yml b/eureka-server/src/main/resources/bootstrap.yml
index b940bf4..47aefda 100644
--- a/eureka-server/src/main/resources/bootstrap.yml
+++ b/eureka-server/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
----
-spring:
- cloud:
- config:
- uri: http://config:8888
+---
+spring:
+ cloud:
+ config:
+ uri: http://config:8888
\ No newline at end of file
diff --git a/eureka-server/src/main/resources/docker/Dockerfile b/eureka-server/src/main/resources/docker/Dockerfile
index 376941d..75944dc 100644
--- a/eureka-server/src/main/resources/docker/Dockerfile
+++ b/eureka-server/src/main/resources/docker/Dockerfile
@@ -1,39 +1,39 @@
-FROM openjdk:8
-
-
-MAINTAINER Alexsandro
-ENV REFRESHED_AT 2017-09-17
-
-ENV TERM xterm
-ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
-
-RUN apt-get update -qq \
- && apt-get install -qqy curl wget \
- && apt-get clean \
- \
- && touch /var/log/todo.log \
- && chmod 666 /var/log/todo.log
-
-ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
-RUN bash -c 'chmod +x wait-for-it.sh'
-
-ADD application/lib/springboot-webapp.jar /app.jar
-
-
-# install Filebeat
-ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
-RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
- && dpkg -i ${FILEBEAT_VERSION} \
- && rm ${FILEBEAT_VERSION}
-
-# configure Filebeat
-ADD filebeat.yml /etc/filebeat/filebeat.yml
-
-# CA cert
-RUN mkdir -p /etc/pki/tls/certs
-ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
-
-# start Filebeat
-ADD ./start.sh /usr/local/bin/start.sh
-RUN chmod +x /usr/local/bin/start.sh
+FROM openjdk:8
+
+
+MAINTAINER Alexsandro
+ENV REFRESHED_AT 2017-09-17
+
+ENV TERM xterm
+ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
+
+RUN apt-get update -qq \
+ && apt-get install -qqy curl wget \
+ && apt-get clean \
+ \
+ && touch /var/log/todo.log \
+ && chmod 666 /var/log/todo.log
+
+ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
+RUN bash -c 'chmod +x wait-for-it.sh'
+
+ADD application/lib/springboot-webapp.jar /app.jar
+
+
+# install Filebeat
+ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
+RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
+ && dpkg -i ${FILEBEAT_VERSION} \
+ && rm ${FILEBEAT_VERSION}
+
+# configure Filebeat
+ADD filebeat.yml /etc/filebeat/filebeat.yml
+
+# CA cert
+RUN mkdir -p /etc/pki/tls/certs
+ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
+
+# start Filebeat
+ADD ./start.sh /usr/local/bin/start.sh
+RUN chmod +x /usr/local/bin/start.sh
CMD [ "/usr/local/bin/start.sh" ]
\ No newline at end of file
diff --git a/eureka-server/src/main/resources/docker/filebeat.yml b/eureka-server/src/main/resources/docker/filebeat.yml
index 09119d8..480a94e 100644
--- a/eureka-server/src/main/resources/docker/filebeat.yml
+++ b/eureka-server/src/main/resources/docker/filebeat.yml
@@ -1,30 +1,30 @@
-output:
- logstash:
- enabled: true
- hosts:
- - elk:5044
- timeout: 15
- tls:
- certificate_authorities:
- - /etc/pki/tls/certs/logstash-beats.crt
-
-filebeat:
- prospectors:
- -
- paths:
- - /var/log/syslog
- - /var/log/auth.log
- document_type: syslog
- -
- paths:
- - /var/log/spring-music.log
- document_type: log4j
- multiline:
- pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
- negate: true
- match: after
- -
- paths:
- - /usr/local/tomcat/logs/*.out
- - /usr/local/tomcat/logs/*.log
- document_type: tomcat
+output:
+ logstash:
+ enabled: true
+ hosts:
+ - elk:5044
+ timeout: 15
+ tls:
+ certificate_authorities:
+ - /etc/pki/tls/certs/logstash-beats.crt
+
+filebeat:
+ prospectors:
+ -
+ paths:
+ - /var/log/syslog
+ - /var/log/auth.log
+ document_type: syslog
+ -
+ paths:
+ - /var/log/spring-music.log
+ document_type: log4j
+ multiline:
+ pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
+ negate: true
+ match: after
+ -
+ paths:
+ - /usr/local/tomcat/logs/*.out
+ - /usr/local/tomcat/logs/*.log
+ document_type: tomcat
diff --git a/eureka-server/src/main/resources/docker/logstash-beats.crt b/eureka-server/src/main/resources/docker/logstash-beats.crt
index d9b71cf..1c86bc3 100644
--- a/eureka-server/src/main/resources/docker/logstash-beats.crt
+++ b/eureka-server/src/main/resources/docker/logstash-beats.crt
@@ -1,18 +1,18 @@
------BEGIN CERTIFICATE-----
-MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
-BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
-DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
-0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
-9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
-PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
-qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
-KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
-4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
-VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
-hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
-okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
-T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
-ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
-kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
-Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
------END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
+BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
+DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
+0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
+9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
+PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
+qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
+KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
+4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
+VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
+hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
+okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
+T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
+ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
+kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
+Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
+-----END CERTIFICATE-----
diff --git a/eureka-server/src/main/resources/docker/start.sh b/eureka-server/src/main/resources/docker/start.sh
index b68b2fb..eff4532 100644
--- a/eureka-server/src/main/resources/docker/start.sh
+++ b/eureka-server/src/main/resources/docker/start.sh
@@ -1,5 +1,4 @@
#!/bin/bash
-
curl -XPUT 'http://elk:9200/_template/filebeat?pretty' -d@/etc/filebeat/filebeat.template.json
/etc/init.d/filebeat start
-java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
+java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
\ No newline at end of file
diff --git a/jmx-monitoring/README b/jmx-monitoring/README
index 8bf9eb5..3f516cf 100644
--- a/jmx-monitoring/README
+++ b/jmx-monitoring/README
@@ -1,5 +1,5 @@
-# JMX monitoring module
-
-On this module we show how to export managed been easily using JMX. We implemented
-a monitoring functionality using Aspect, Annotation and JMX, with the possibility of
-enable /disable and check the values real time using any JMX client.
+# JMX monitoring module
+
+On this module we show how to export managed been easily using JMX. We implemented
+a monitoring functionality using Aspect, Annotation and JMX, with the possibility of
+enable /disable and check the values real time using any JMX client.
diff --git a/jmx-monitoring/pom.xml b/jmx-monitoring/pom.xml
index 0ae00ed..6a559bf 100644
--- a/jmx-monitoring/pom.xml
+++ b/jmx-monitoring/pom.xml
@@ -1,24 +1,24 @@
-
-
- 4.0.0
-
- jmx-monitoring
- 0.0.1-SNAPSHOT
- jar
- Jmx monitoring utilities
-
-
- parent-todo-ms
- com.apssouza
- 0.0.1-SNAPSHOT
-
-
-
-
- org.springframework.boot
- spring-boot-starter-aop
-
-
-
+
+
+ 4.0.0
+
+ jmx-monitoring
+ 0.0.1-SNAPSHOT
+ jar
+ Jmx monitoring utilities
+
+
+ parent-todo-ms
+ com.apssouza
+ 0.0.1-SNAPSHOT
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
+
+
diff --git a/jmx-monitoring/src/main/java/com/apssouza/monitoring/CallMonitoringAspect.java b/jmx-monitoring/src/main/java/com/apssouza/monitoring/CallMonitoringAspect.java
index ec29bf9..8d605fb 100644
--- a/jmx-monitoring/src/main/java/com/apssouza/monitoring/CallMonitoringAspect.java
+++ b/jmx-monitoring/src/main/java/com/apssouza/monitoring/CallMonitoringAspect.java
@@ -1,94 +1,94 @@
-package com.apssouza.monitoring;
-
-import java.lang.reflect.Method;
-import org.aspectj.lang.ProceedingJoinPoint;
-import org.aspectj.lang.annotation.Around;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.reflect.MethodSignature;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.jmx.export.annotation.ManagedAttribute;
-import org.springframework.jmx.export.annotation.ManagedOperation;
-import org.springframework.jmx.export.annotation.ManagedResource;
-import org.springframework.util.StopWatch;
-
-/**
- * Simple aspect that monitors call count and call invocation time. It uses JMX annotations and therefore can be
- * monitored using any JMX console such as the jConsole
- *
- */
-@ManagedResource(objectName = "apssouza:type=CallMonitor")
-@Aspect
-public class CallMonitoringAspect {
-
- private boolean enabled = true;
-
- private int callCount = 0;
-
- private long accumulatedCallTime = 0;
-
- private final ApplicationEventPublisher publisher;
-
- @Autowired
- public CallMonitoringAspect(ApplicationEventPublisher publisher) {
- this.publisher = publisher;
- }
-
- @ManagedAttribute
- public void setEnabled(boolean enabled) {
- this.enabled = enabled;
- }
-
- @ManagedAttribute
- public boolean isEnabled() {
- return enabled;
- }
-
- @ManagedOperation
- public void reset() {
- this.callCount = 0;
- this.accumulatedCallTime = 0;
- }
-
- @ManagedAttribute
- public int getCallCount() {
- return callCount;
- }
-
- @ManagedAttribute
- public long getCallTime() {
- if (this.callCount > 0) {
- return this.accumulatedCallTime / this.callCount;
- } else {
- return 0;
- }
- }
-
-
- @Around("@annotation(com.apssouza.monitoring.Monitored)")
- public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
- System.out.println("callend");
- Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
- if (this.enabled) {
- StopWatch sw = new StopWatch(joinPoint.toShortString());
-
- sw.start("invoke");
- try {
- return joinPoint.proceed();
- } finally {
- sw.stop();
- synchronized (this) {
- this.callCount++;
- this.accumulatedCallTime += sw.getTotalTimeMillis();
- }
- publisher.publishEvent(new MonitoringInvokedEvent(
- method.getName(),
- this.accumulatedCallTime
- ));
- }
- } else {
- return joinPoint.proceed();
- }
- }
-
-}
+package com.apssouza.monitoring;
+
+import java.lang.reflect.Method;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.jmx.export.annotation.ManagedAttribute;
+import org.springframework.jmx.export.annotation.ManagedOperation;
+import org.springframework.jmx.export.annotation.ManagedResource;
+import org.springframework.util.StopWatch;
+
+/**
+ * Simple aspect that monitors call count and call invocation time. It uses JMX annotations and therefore can be
+ * monitored using any JMX console such as the jConsole
+ *
+ */
+@ManagedResource(objectName = "apssouza:type=CallMonitor")
+@Aspect
+public class CallMonitoringAspect {
+
+ private boolean enabled = true;
+
+ private int callCount = 0;
+
+ private long accumulatedCallTime = 0;
+
+ private final ApplicationEventPublisher publisher;
+
+ @Autowired
+ public CallMonitoringAspect(ApplicationEventPublisher publisher) {
+ this.publisher = publisher;
+ }
+
+ @ManagedAttribute
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ @ManagedAttribute
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ @ManagedOperation
+ public void reset() {
+ this.callCount = 0;
+ this.accumulatedCallTime = 0;
+ }
+
+ @ManagedAttribute
+ public int getCallCount() {
+ return callCount;
+ }
+
+ @ManagedAttribute
+ public long getCallTime() {
+ if (this.callCount > 0) {
+ return this.accumulatedCallTime / this.callCount;
+ } else {
+ return 0;
+ }
+ }
+
+
+ @Around("@annotation(com.apssouza.monitoring.Monitored)")
+ public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
+ System.out.println("callend");
+ Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
+ if (this.enabled) {
+ StopWatch sw = new StopWatch(joinPoint.toShortString());
+
+ sw.start("invoke");
+ try {
+ return joinPoint.proceed();
+ } finally {
+ sw.stop();
+ synchronized (this) {
+ this.callCount++;
+ this.accumulatedCallTime += sw.getTotalTimeMillis();
+ }
+ publisher.publishEvent(new MonitoringInvokedEvent(
+ method.getName(),
+ this.accumulatedCallTime
+ ));
+ }
+ } else {
+ return joinPoint.proceed();
+ }
+ }
+
+}
diff --git a/jmx-monitoring/src/main/java/com/apssouza/monitoring/Monitored.java b/jmx-monitoring/src/main/java/com/apssouza/monitoring/Monitored.java
index c9a1c89..b1ce982 100644
--- a/jmx-monitoring/src/main/java/com/apssouza/monitoring/Monitored.java
+++ b/jmx-monitoring/src/main/java/com/apssouza/monitoring/Monitored.java
@@ -1,29 +1,29 @@
-/*
- * Copyright 2002-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.apssouza.monitoring;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author Maciej Szarlinski
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface Monitored {
-}
+/*
+ * Copyright 2002-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.apssouza.monitoring;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author Maciej Szarlinski
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface Monitored {
+}
diff --git a/jmx-monitoring/src/main/java/com/apssouza/monitoring/MonitoringConfig.java b/jmx-monitoring/src/main/java/com/apssouza/monitoring/MonitoringConfig.java
index 5bcc6e8..34072ad 100644
--- a/jmx-monitoring/src/main/java/com/apssouza/monitoring/MonitoringConfig.java
+++ b/jmx-monitoring/src/main/java/com/apssouza/monitoring/MonitoringConfig.java
@@ -1,28 +1,28 @@
-/*
- * Copyright 2002-2017 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.apssouza.monitoring;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.EnableAspectJAutoProxy;
-
-/**
- * @author Maciej Szarlinski
- */
-@Configuration
-@EnableAspectJAutoProxy
-public class MonitoringConfig {
-
-}
+/*
+ * Copyright 2002-2017 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.apssouza.monitoring;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.EnableAspectJAutoProxy;
+
+/**
+ * @author Maciej Szarlinski
+ */
+@Configuration
+@EnableAspectJAutoProxy
+public class MonitoringConfig {
+
+}
diff --git a/jmx-monitoring/src/main/java/com/apssouza/monitoring/MonitoringInvokedEvent.java b/jmx-monitoring/src/main/java/com/apssouza/monitoring/MonitoringInvokedEvent.java
index 248b7ab..accc8b1 100644
--- a/jmx-monitoring/src/main/java/com/apssouza/monitoring/MonitoringInvokedEvent.java
+++ b/jmx-monitoring/src/main/java/com/apssouza/monitoring/MonitoringInvokedEvent.java
@@ -1,26 +1,26 @@
-package com.apssouza.monitoring;
-
-/**
- *
- * @author apssouza
- */
-public class MonitoringInvokedEvent {
-
- private final long duration;
-
- private final String methodName;
-
- public MonitoringInvokedEvent(String methodName, long duration) {
- this.methodName = methodName;
- this.duration = duration;
- }
-
- public long getDuration() {
- return duration;
- }
-
- public String getMethodName() {
- return methodName;
- }
-
-}
+package com.apssouza.monitoring;
+
+/**
+ *
+ * @author apssouza
+ */
+public class MonitoringInvokedEvent {
+
+ private final long duration;
+
+ private final String methodName;
+
+ public MonitoringInvokedEvent(String methodName, long duration) {
+ this.methodName = methodName;
+ this.duration = duration;
+ }
+
+ public long getDuration() {
+ return duration;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+}
diff --git a/mail-service/.gitignore b/mail-service/.gitignore
index 2af7cef..7fdf9ae 100644
--- a/mail-service/.gitignore
+++ b/mail-service/.gitignore
@@ -1,24 +1,24 @@
-target/
-!.mvn/wrapper/maven-wrapper.jar
-
-### STS ###
-.apt_generated
-.classpath
-.factorypath
-.project
-.settings
-.springBeans
-
-### IntelliJ IDEA ###
-.idea
-*.iws
-*.iml
-*.ipr
-
-### NetBeans ###
-nbproject/private/
-build/
-nbbuild/
-dist/
-nbdist/
+target/
+!.mvn/wrapper/maven-wrapper.jar
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+nbproject/private/
+build/
+nbbuild/
+dist/
+nbdist/
.nb-gradle/
\ No newline at end of file
diff --git a/mail-service/Jenkinsfile b/mail-service/Jenkinsfile
index e50910c..8564ebb 100644
--- a/mail-service/Jenkinsfile
+++ b/mail-service/Jenkinsfile
@@ -1,16 +1,16 @@
-node {
- stage('Fetch changes') {
- git 'https://github.com/apssouza22/java-microservice.git'
- }
- stage('Build image') {
- // Run the maven build
- if (isUnix()) {
- sh "mvn -f ./mail-service/pom.xml -Pdockerimage docker:build"
- } else {
- echo "Not ready for windows"
- }
- }
- stage('Deploy ECS') {
- echo "TODO deploy on AWS"
- }
-}
+node {
+ stage('Fetch changes') {
+ git 'https://github.com/apssouza22/java-microservice.git'
+ }
+ stage('Build image') {
+ // Run the maven build
+ if (isUnix()) {
+ sh "mvn -f ./mail-service/pom.xml -Pdockerimage docker:build"
+ } else {
+ echo "Not ready for windows"
+ }
+ }
+ stage('Deploy ECS') {
+ echo "TODO deploy on AWS"
+ }
+}
diff --git a/mail-service/README b/mail-service/README
index 7d920be..1c734e2 100644
--- a/mail-service/README
+++ b/mail-service/README
@@ -1,7 +1,7 @@
-# Mail service
-
-This is a service responsible for sending emails.
-
-On this services we are using the concept of event centric. We show how to use
-Command-Query Responsibility Separation (CQRS), eventsourcing, ditributed events with
-Kafka and more.
+# Mail service
+
+This is a service responsible for sending emails.
+
+On this services we are using the concept of event centric. We show how to use
+Command-Query Responsibility Separation (CQRS), eventsourcing, ditributed events with
+Kafka and more.
diff --git a/mail-service/nbactions.xml b/mail-service/nbactions.xml
index 2cb90c2..207a09d 100644
--- a/mail-service/nbactions.xml
+++ b/mail-service/nbactions.xml
@@ -1,46 +1,46 @@
-
-
-
- run
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.apssouza.mailservice.MailserviceApplication
- java
-
-
-
- debug
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.apssouza.mailservice.MailserviceApplication
- java
- true
-
-
-
- profile
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.apssouza.mailservice.MailserviceApplication
- java
-
-
-
+
+
+
+ run
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
+
+
+ -classpath %classpath com.apssouza.mailservice.MailserviceApplication
+ java
+
+
+
+ debug
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
+
+
+ -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.apssouza.mailservice.MailserviceApplication
+ java
+ true
+
+
+
+ profile
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
+
+
+ -classpath %classpath com.apssouza.mailservice.MailserviceApplication
+ java
+
+
+
diff --git a/mail-service/pom.xml b/mail-service/pom.xml
index dcf3a22..86ccca2 100644
--- a/mail-service/pom.xml
+++ b/mail-service/pom.xml
@@ -1,157 +1,157 @@
-
-
- 4.0.0
-
- mailservice
- 0.0.1-SNAPSHOT
- jar
-
- mailservice
- The email service
-
-
- parent-todo-ms
- com.apssouza
- 0.0.1-SNAPSHOT
-
-
-
- com.apssouza.mailservice.MailserviceApplication
-
-
-
-
- com.apssouza
- todo-infra
- 0.0.1-SNAPSHOT
-
-
- org.springframework.cloud
- spring-cloud-starter-config
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
- com.h2database
- h2
-
-
-
- com.fasterxml.jackson.datatype
- jackson-datatype-jsr310
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
- true
- true
-
-
-
-
-
-
- dockerimage
-
- todo/mail-service
- src/main/resources/docker
- ${project.build.directory}/dockerimgbuild
- Dockerfile
-
-
-
-
-
- maven-resources-plugin
-
-
- copy-resources
- package
-
- copy-resources
-
-
- ${docker.build.directory}
-
-
- ${docker.image.src.root}
- false
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- copy
- package
-
- copy
-
-
-
-
- ${project.groupId}
- ${project.artifactId}
- ${project.version}
- jar
- true
- ${docker.build.directory}/application/lib
- springboot-webapp.jar
-
-
-
-
- ${docker.build.directory}
- true
- true
-
-
-
-
-
-
-
- io.fabric8
- docker-maven-plugin
- 0.19.0
-
-
- unix:///var/run/docker.sock
-
-
- ${docker.image.name}
-
-
- latest
-
- ${docker.build.directory}/${docker.file.name}
-
-
-
-
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ mailservice
+ 0.0.1-SNAPSHOT
+ jar
+
+ mailservice
+ The email service
+
+
+ parent-todo-ms
+ com.apssouza
+ 0.0.1-SNAPSHOT
+
+
+
+ com.apssouza.mailservice.MailserviceApplication
+
+
+
+
+ com.apssouza
+ todo-infra
+ 0.0.1-SNAPSHOT
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ com.h2database
+ h2
+
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ true
+ true
+
+
+
+
+
+
+ dockerimage
+
+ todo/mail-service
+ src/main/resources/docker
+ ${project.build.directory}/dockerimgbuild
+ Dockerfile
+
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-resources
+ package
+
+ copy-resources
+
+
+ ${docker.build.directory}
+
+
+ ${docker.image.src.root}
+ false
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy
+ package
+
+ copy
+
+
+
+
+ ${project.groupId}
+ ${project.artifactId}
+ ${project.version}
+ jar
+ true
+ ${docker.build.directory}/application/lib
+ springboot-webapp.jar
+
+
+
+
+ ${docker.build.directory}
+ true
+ true
+
+
+
+
+
+
+
+ io.fabric8
+ docker-maven-plugin
+ 0.19.0
+
+
+ unix:///var/run/docker.sock
+
+
+ ${docker.image.name}
+
+
+ latest
+
+ ${docker.build.directory}/${docker.file.name}
+
+
+
+
+
+
+
+
+
+
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/EventsourcingApplication.java b/mail-service/src/main/java/com/apssouza/eventsourcing/EventsourcingApplication.java
index d3e5944..196d1f2 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/EventsourcingApplication.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/EventsourcingApplication.java
@@ -1,37 +1,37 @@
-package com.apssouza.eventsourcing;
-
-import java.time.Instant;
-import java.util.UUID;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.ConfigurableApplicationContext;
-
-/**
- *
- * @author apssouza
- */
-@SpringBootApplication
-public class EventsourcingApplication {
-
- public static void main(String[] args) {
- ConfigurableApplicationContext context = SpringApplication.run(EventsourcingApplication.class, args);
-// EmailCommandHandler commandHandler = context.getBean(EmailCommandHandler.class);
-//
-// UUID randomUUID = UUID.randomUUID();
-//
-// EmailCreateCommand commandCreate = new EmailCreateCommand(randomUUID, "Alex", "apssouza22@gmail.com");
-// EmailSendCommand send = new EmailSendCommand(randomUUID, Instant.now());
-// EmailDeliveryCommand delivery = new EmailDeliveryCommand(randomUUID, Instant.now());
-// EmailDeleteCommand delete = new EmailDeleteCommand(randomUUID);
-// try {
-// commandHandler.create(commandCreate);
-// commandHandler.send(send);
-// commandHandler.delivery(delivery);
-// commandHandler.delete(delete);
-// } catch (Exception ex) {
-// Logger.getLogger(EventsourcingApplication.class.getName()).log(Level.SEVERE, null, ex);
-// }
- }
-}
+package com.apssouza.eventsourcing;
+
+import java.time.Instant;
+import java.util.UUID;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.ConfigurableApplicationContext;
+
+/**
+ *
+ * @author apssouza
+ */
+@SpringBootApplication
+public class EventsourcingApplication {
+
+ public static void main(String[] args) {
+ ConfigurableApplicationContext context = SpringApplication.run(EventsourcingApplication.class, args);
+// EmailCommandHandler commandHandler = context.getBean(EmailCommandHandler.class);
+//
+// UUID randomUUID = UUID.randomUUID();
+//
+// EmailCreateCommand commandCreate = new EmailCreateCommand(randomUUID, "Alex", "apssouza22@gmail.com");
+// EmailSendCommand send = new EmailSendCommand(randomUUID, Instant.now());
+// EmailDeliveryCommand delivery = new EmailDeliveryCommand(randomUUID, Instant.now());
+// EmailDeleteCommand delete = new EmailDeleteCommand(randomUUID);
+// try {
+// commandHandler.create(commandCreate);
+// commandHandler.send(send);
+// commandHandler.delivery(delivery);
+// commandHandler.delete(delete);
+// } catch (Exception ex) {
+// Logger.getLogger(EventsourcingApplication.class.getName()).log(Level.SEVERE, null, ex);
+// }
+ }
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/AbstractAggregate.java b/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/AbstractAggregate.java
index d9974e1..b724240 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/AbstractAggregate.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/AbstractAggregate.java
@@ -1,38 +1,38 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.apssouza.eventsourcing.aggregates;
-
-import com.apssouza.infra.AppEvent;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- *
- * @author apssouza
- */
-public abstract class AbstractAggregate implements Aggregate {
-
- protected String uuid;
-
- protected List changes = new CopyOnWriteArrayList();
-
- protected CopyOnWriteArrayList appendChange(AppEvent event) {
- CopyOnWriteArrayList listChanges = new CopyOnWriteArrayList(changes);
- listChanges.add(event);
- return listChanges;
- }
-
- @Override
- public List getUncommittedChanges() {
- return changes;
- }
-
- @Override
- public String getUuid() {
- return uuid;
- }
-
-}
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.apssouza.eventsourcing.aggregates;
+
+import com.apssouza.infra.AppEvent;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ *
+ * @author apssouza
+ */
+public abstract class AbstractAggregate implements Aggregate {
+
+ protected String uuid;
+
+ protected List changes = new CopyOnWriteArrayList();
+
+ protected CopyOnWriteArrayList appendChange(AppEvent event) {
+ CopyOnWriteArrayList listChanges = new CopyOnWriteArrayList(changes);
+ listChanges.add(event);
+ return listChanges;
+ }
+
+ @Override
+ public List getUncommittedChanges() {
+ return changes;
+ }
+
+ @Override
+ public String getUuid() {
+ return uuid;
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/Aggregate.java b/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/Aggregate.java
index 51faaea..3928513 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/Aggregate.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/Aggregate.java
@@ -1,20 +1,20 @@
-package com.apssouza.eventsourcing.aggregates;
-
-import com.apssouza.infra.AppEvent;
-import java.util.List;
-
-/**
- * The aggregate interface
- *
- * @author apssouza
- */
-public interface Aggregate {
-
- String getUuid();
-
- List getUncommittedChanges();
-
- Aggregate markChangesAsCommitted();
-
-
-}
+package com.apssouza.eventsourcing.aggregates;
+
+import com.apssouza.infra.AppEvent;
+import java.util.List;
+
+/**
+ * The aggregate interface
+ *
+ * @author apssouza
+ */
+public interface Aggregate {
+
+ String getUuid();
+
+ List getUncommittedChanges();
+
+ Aggregate markChangesAsCommitted();
+
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/EmailAggregate.java b/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/EmailAggregate.java
index 44a3aa6..8aadb59 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/EmailAggregate.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/EmailAggregate.java
@@ -1,141 +1,141 @@
-package com.apssouza.eventsourcing.aggregates;
-
-import com.apssouza.eventsourcing.commands.EmailDeleteCommand;
-import com.apssouza.eventsourcing.commands.EmailCreateCommand;
-import com.apssouza.eventsourcing.commands.EmailDeliveryCommand;
-import com.apssouza.eventsourcing.commands.EmailSendCommand;
-import com.apssouza.eventsourcing.entities.Email;
-import com.apssouza.eventsourcing.events.EmailCreatedEvent;
-import com.apssouza.eventsourcing.events.EmailDeliveredEvent;
-import com.apssouza.eventsourcing.events.EmailDeletedEvent;
-import com.apssouza.eventsourcing.events.EmailEvent;
-import com.apssouza.eventsourcing.events.EmailSentEvent;
-import com.apssouza.infra.AppEvent;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-/**
- * Email aggregate, it aggregate all events related to Email and get the final
- * state
- *
- * @author apssouza
- */
-public class EmailAggregate extends AbstractAggregate implements Aggregate {
-
- private final Email state;
-
- public EmailAggregate(String uuid, List changes) {
- this(uuid, changes, new Email());
- }
-
- public EmailAggregate(String uuid, List changes, Email state) {
- this.uuid = uuid;
- this.changes = changes;
- this.state = state;
- }
-
- public EmailAggregate create(EmailCreateCommand command) throws Exception {
- if (state.getState() != null) {
- throw new Exception("Is not possible to edit a deleted email");
- }
- return applyChange(new EmailCreatedEvent(uuid, command.getEmail()));
- }
-
- public EmailAggregate send(EmailSendCommand command) throws Exception {
- if (state.getState() == EmailState.DELETED) {
- throw new Exception("Is not possible to edit a deleted email");
- }
- return applyChange(new EmailSentEvent(
- command.getUuid(),
- getState().setState(EmailState.SENT)));
- }
-
- public EmailAggregate delivery(EmailDeliveryCommand command) throws Exception {
- if (state.getState() == EmailState.DELETED) {
- throw new Exception("Is not possible to edit a deleted email");
- }
- return applyChange(new EmailDeliveredEvent(
- command.getUuid(),
- getState().setState(EmailState.DELIVERED)
- ));
- }
-
- public EmailAggregate delete(EmailDeleteCommand command) throws Exception {
- if (state.getState() == EmailState.DELETED) {
- throw new Exception("Is not possible to delete a deleted email");
- }
- return applyChange(new EmailDeletedEvent(uuid,
- getState().setState(EmailState.DELETED)
- ));
- }
-
- private EmailAggregate apply(AppEvent event) {
- if (event instanceof EmailCreatedEvent) {
- return this.apply((EmailCreatedEvent) event);
- }
- if (event instanceof EmailSentEvent) {
- return this.apply((EmailSentEvent) event);
- }
- if (event instanceof EmailDeliveredEvent) {
- return this.apply((EmailDeliveredEvent) event);
- }
- if (event instanceof EmailDeletedEvent) {
- return this.apply((EmailDeletedEvent) event);
- }
- throw new IllegalArgumentException("Cannot handle event " + event.getClass());
-
- }
-
- private EmailAggregate apply(EmailCreatedEvent event) {
- return new EmailAggregate(uuid, changes, event.getEmail());
- }
-
- private EmailAggregate apply(EmailDeletedEvent event) {
- return new EmailAggregate(uuid, changes, event.getEmail());
- }
-
- private EmailAggregate apply(EmailSentEvent event) {
- return new EmailAggregate(uuid, changes, event.getEmail());
- }
-
- private EmailAggregate apply(EmailDeliveredEvent event) {
- return new EmailAggregate(uuid, changes, event.getEmail());
- }
-
- public static EmailAggregate from(String uuid, List history) {
-
- EmailAggregate emailAggregate = new EmailAggregate(uuid, new CopyOnWriteArrayList(), new Email());
-
- return history
- .stream()
- .reduce(emailAggregate,
- (tx, event) -> tx.applyChange(event, false),
- (t1, t2) -> {
- throw new UnsupportedOperationException();
- }
- );
- }
-
- private EmailAggregate applyChange(AppEvent event, boolean isNew) {
- final EmailAggregate item = this.apply(event);
- if (isNew) {
- return new EmailAggregate(item.getUuid(), appendChange(event), item.getState());
- } else {
- return item;
- }
- }
-
- private EmailAggregate applyChange(EmailEvent event) {
- return applyChange(event, true);
- }
-
- @Override
- public EmailAggregate markChangesAsCommitted() {
- return new EmailAggregate(uuid, new CopyOnWriteArrayList(), state);
- }
-
- public Email getState() {
- return state;
- }
-
-}
+package com.apssouza.eventsourcing.aggregates;
+
+import com.apssouza.eventsourcing.commands.EmailDeleteCommand;
+import com.apssouza.eventsourcing.commands.EmailCreateCommand;
+import com.apssouza.eventsourcing.commands.EmailDeliveryCommand;
+import com.apssouza.eventsourcing.commands.EmailSendCommand;
+import com.apssouza.eventsourcing.entities.Email;
+import com.apssouza.eventsourcing.events.EmailCreatedEvent;
+import com.apssouza.eventsourcing.events.EmailDeliveredEvent;
+import com.apssouza.eventsourcing.events.EmailDeletedEvent;
+import com.apssouza.eventsourcing.events.EmailEvent;
+import com.apssouza.eventsourcing.events.EmailSentEvent;
+import com.apssouza.infra.AppEvent;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+/**
+ * Email aggregate, it aggregate all events related to Email and get the final
+ * state
+ *
+ * @author apssouza
+ */
+public class EmailAggregate extends AbstractAggregate implements Aggregate {
+
+ private final Email state;
+
+ public EmailAggregate(String uuid, List changes) {
+ this(uuid, changes, new Email());
+ }
+
+ public EmailAggregate(String uuid, List changes, Email state) {
+ this.uuid = uuid;
+ this.changes = changes;
+ this.state = state;
+ }
+
+ public EmailAggregate create(EmailCreateCommand command) throws Exception {
+ if (state.getState() != null) {
+ throw new Exception("Is not possible to edit a deleted email");
+ }
+ return applyChange(new EmailCreatedEvent(uuid, command.getEmail()));
+ }
+
+ public EmailAggregate send(EmailSendCommand command) throws Exception {
+ if (state.getState() == EmailState.DELETED) {
+ throw new Exception("Is not possible to edit a deleted email");
+ }
+ return applyChange(new EmailSentEvent(
+ command.getUuid(),
+ getState().setState(EmailState.SENT)));
+ }
+
+ public EmailAggregate delivery(EmailDeliveryCommand command) throws Exception {
+ if (state.getState() == EmailState.DELETED) {
+ throw new Exception("Is not possible to edit a deleted email");
+ }
+ return applyChange(new EmailDeliveredEvent(
+ command.getUuid(),
+ getState().setState(EmailState.DELIVERED)
+ ));
+ }
+
+ public EmailAggregate delete(EmailDeleteCommand command) throws Exception {
+ if (state.getState() == EmailState.DELETED) {
+ throw new Exception("Is not possible to delete a deleted email");
+ }
+ return applyChange(new EmailDeletedEvent(uuid,
+ getState().setState(EmailState.DELETED)
+ ));
+ }
+
+ private EmailAggregate apply(AppEvent event) {
+ if (event instanceof EmailCreatedEvent) {
+ return this.apply((EmailCreatedEvent) event);
+ }
+ if (event instanceof EmailSentEvent) {
+ return this.apply((EmailSentEvent) event);
+ }
+ if (event instanceof EmailDeliveredEvent) {
+ return this.apply((EmailDeliveredEvent) event);
+ }
+ if (event instanceof EmailDeletedEvent) {
+ return this.apply((EmailDeletedEvent) event);
+ }
+ throw new IllegalArgumentException("Cannot handle event " + event.getClass());
+
+ }
+
+ private EmailAggregate apply(EmailCreatedEvent event) {
+ return new EmailAggregate(uuid, changes, event.getEmail());
+ }
+
+ private EmailAggregate apply(EmailDeletedEvent event) {
+ return new EmailAggregate(uuid, changes, event.getEmail());
+ }
+
+ private EmailAggregate apply(EmailSentEvent event) {
+ return new EmailAggregate(uuid, changes, event.getEmail());
+ }
+
+ private EmailAggregate apply(EmailDeliveredEvent event) {
+ return new EmailAggregate(uuid, changes, event.getEmail());
+ }
+
+ public static EmailAggregate from(String uuid, List history) {
+
+ EmailAggregate emailAggregate = new EmailAggregate(uuid, new CopyOnWriteArrayList(), new Email());
+
+ return history
+ .stream()
+ .reduce(emailAggregate,
+ (tx, event) -> tx.applyChange(event, false),
+ (t1, t2) -> {
+ throw new UnsupportedOperationException();
+ }
+ );
+ }
+
+ private EmailAggregate applyChange(AppEvent event, boolean isNew) {
+ final EmailAggregate item = this.apply(event);
+ if (isNew) {
+ return new EmailAggregate(item.getUuid(), appendChange(event), item.getState());
+ } else {
+ return item;
+ }
+ }
+
+ private EmailAggregate applyChange(EmailEvent event) {
+ return applyChange(event, true);
+ }
+
+ @Override
+ public EmailAggregate markChangesAsCommitted() {
+ return new EmailAggregate(uuid, new CopyOnWriteArrayList(), state);
+ }
+
+ public Email getState() {
+ return state;
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/EmailState.java b/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/EmailState.java
index 0756f59..2d658a8 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/EmailState.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/EmailState.java
@@ -1,16 +1,16 @@
-package com.apssouza.eventsourcing.aggregates;
-
-/**
- * Email state
- *
- * @author apssouza
- */
-public enum EmailState implements ObjectState {
- CREATED,
- SENT,
- DELIVERED,
- READ,
- FAILED,
- REPLIED,
- DELETED
-}
+package com.apssouza.eventsourcing.aggregates;
+
+/**
+ * Email state
+ *
+ * @author apssouza
+ */
+public enum EmailState implements ObjectState {
+ CREATED,
+ SENT,
+ DELIVERED,
+ READ,
+ FAILED,
+ REPLIED,
+ DELETED
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/ObjectState.java b/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/ObjectState.java
index e3364c1..fc6b990 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/ObjectState.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/aggregates/ObjectState.java
@@ -1,10 +1,10 @@
-package com.apssouza.eventsourcing.aggregates;
-
-/**
- * State object interface
- *
- * @author apssouza
- */
-public interface ObjectState {
-
-}
+package com.apssouza.eventsourcing.aggregates;
+
+/**
+ * State object interface
+ *
+ * @author apssouza
+ */
+public interface ObjectState {
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailCommandHandler.java b/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailCommandHandler.java
index c58c299..7cce345 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailCommandHandler.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailCommandHandler.java
@@ -1,77 +1,77 @@
-package com.apssouza.eventsourcing.commands;
-
-import com.apssouza.eventsourcing.aggregates.EmailAggregate;
-import com.apssouza.eventsourcing.services.EventSourcingService;
-import com.apssouza.infra.AppEvent;
-import com.apssouza.infra.EventPublisher;
-import java.util.List;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * Email command service handler. Deal with the business requirements before
- * send the command
- *
- * @author apssouza
- */
-@Service
-@Transactional
-public class EmailCommandHandler {
-
- private final EventSourcingService eventSourcingService;
-
- private final EventPublisher eventPublisher;
-
- public EmailCommandHandler(
- EventSourcingService eventSourcingService,
- EventPublisher eventPublisher
- ) {
- this.eventSourcingService = eventSourcingService;
- this.eventPublisher = eventPublisher;
- }
-
-
- public void create(EmailCreateCommand command) throws Exception {
- EmailAggregate emailAggregate = getByUUID(command.getUuid());
- emailAggregate = emailAggregate.create(command);
- List pendingEvents = emailAggregate.getUncommittedChanges();
- eventSourcingService.save(emailAggregate);
-
- pendingEvents.forEach(eventPublisher::publish);
- pendingEvents.forEach(eventPublisher::stream);
- }
-
- public void send(EmailSendCommand command) throws Exception {
- EmailAggregate emailAggregate = getByUUID(command.getUuid());
- emailAggregate = emailAggregate.send(command);
-
- List pendingEvents = emailAggregate.getUncommittedChanges();
- pendingEvents.forEach(eventPublisher::stream);
-
- eventSourcingService.save(emailAggregate);
- }
-
- public void delivery(EmailDeliveryCommand command) throws Exception {
- EmailAggregate emailAggregate = getByUUID(command.getUuid());
- emailAggregate = emailAggregate.delivery(command);
-
- List pendingEvents = emailAggregate.getUncommittedChanges();
- pendingEvents.forEach(eventPublisher::stream);
-
- eventSourcingService.save(emailAggregate);
- }
-
- public void delete(EmailDeleteCommand command) throws Exception {
- EmailAggregate emailAggregate = getByUUID(command.getUuid());
- emailAggregate.delete(command);
-
- List pendingEvents = emailAggregate.getUncommittedChanges();
- pendingEvents.forEach(eventPublisher::stream);
-
- eventSourcingService.save(emailAggregate);
- }
-
- public EmailAggregate getByUUID(String uuid) {
- return EmailAggregate.from(uuid, eventSourcingService.getRelatedEvents(uuid));
- }
-}
+package com.apssouza.eventsourcing.commands;
+
+import com.apssouza.eventsourcing.aggregates.EmailAggregate;
+import com.apssouza.eventsourcing.services.EventSourcingService;
+import com.apssouza.infra.AppEvent;
+import com.apssouza.infra.EventPublisher;
+import java.util.List;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ * Email command service handler. Deal with the business requirements before
+ * send the command
+ *
+ * @author apssouza
+ */
+@Service
+@Transactional
+public class EmailCommandHandler {
+
+ private final EventSourcingService eventSourcingService;
+
+ private final EventPublisher eventPublisher;
+
+ public EmailCommandHandler(
+ EventSourcingService eventSourcingService,
+ EventPublisher eventPublisher
+ ) {
+ this.eventSourcingService = eventSourcingService;
+ this.eventPublisher = eventPublisher;
+ }
+
+
+ public void create(EmailCreateCommand command) throws Exception {
+ EmailAggregate emailAggregate = getByUUID(command.getUuid());
+ emailAggregate = emailAggregate.create(command);
+ List pendingEvents = emailAggregate.getUncommittedChanges();
+ eventSourcingService.save(emailAggregate);
+
+ pendingEvents.forEach(eventPublisher::publish);
+ pendingEvents.forEach(eventPublisher::stream);
+ }
+
+ public void send(EmailSendCommand command) throws Exception {
+ EmailAggregate emailAggregate = getByUUID(command.getUuid());
+ emailAggregate = emailAggregate.send(command);
+
+ List pendingEvents = emailAggregate.getUncommittedChanges();
+ pendingEvents.forEach(eventPublisher::stream);
+
+ eventSourcingService.save(emailAggregate);
+ }
+
+ public void delivery(EmailDeliveryCommand command) throws Exception {
+ EmailAggregate emailAggregate = getByUUID(command.getUuid());
+ emailAggregate = emailAggregate.delivery(command);
+
+ List pendingEvents = emailAggregate.getUncommittedChanges();
+ pendingEvents.forEach(eventPublisher::stream);
+
+ eventSourcingService.save(emailAggregate);
+ }
+
+ public void delete(EmailDeleteCommand command) throws Exception {
+ EmailAggregate emailAggregate = getByUUID(command.getUuid());
+ emailAggregate.delete(command);
+
+ List pendingEvents = emailAggregate.getUncommittedChanges();
+ pendingEvents.forEach(eventPublisher::stream);
+
+ eventSourcingService.save(emailAggregate);
+ }
+
+ public EmailAggregate getByUUID(String uuid) {
+ return EmailAggregate.from(uuid, eventSourcingService.getRelatedEvents(uuid));
+ }
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailCreateCommand.java b/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailCreateCommand.java
index 61b37b7..aeee809 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailCreateCommand.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailCreateCommand.java
@@ -1,29 +1,29 @@
-package com.apssouza.eventsourcing.commands;
-
-import com.apssouza.eventsourcing.entities.Email;
-
-/**
- * Email create command
- *
- * @author apssouza
- */
-public class EmailCreateCommand {
-
- private final String uuid;
-
- private final Email email;
-
- public EmailCreateCommand(String uuid, Email email) {
- this.uuid = uuid;
- this.email = email;
- }
-
- public Email getEmail() {
- return email;
- }
-
- public String getUuid() {
- return uuid;
- }
-
-}
+package com.apssouza.eventsourcing.commands;
+
+import com.apssouza.eventsourcing.entities.Email;
+
+/**
+ * Email create command
+ *
+ * @author apssouza
+ */
+public class EmailCreateCommand {
+
+ private final String uuid;
+
+ private final Email email;
+
+ public EmailCreateCommand(String uuid, Email email) {
+ this.uuid = uuid;
+ this.email = email;
+ }
+
+ public Email getEmail() {
+ return email;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailDeleteCommand.java b/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailDeleteCommand.java
index f790231..5d1d07e 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailDeleteCommand.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailDeleteCommand.java
@@ -1,20 +1,20 @@
-package com.apssouza.eventsourcing.commands;
-
-/**
- * Email delete command
- *
- * @author apssouza
- */
-public class EmailDeleteCommand {
-
- private String uuid;
-
- public EmailDeleteCommand(String id) {
- this.uuid = id;
- }
-
- public String getUuid() {
- return uuid;
- }
-
-}
+package com.apssouza.eventsourcing.commands;
+
+/**
+ * Email delete command
+ *
+ * @author apssouza
+ */
+public class EmailDeleteCommand {
+
+ private String uuid;
+
+ public EmailDeleteCommand(String id) {
+ this.uuid = id;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailDeliveryCommand.java b/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailDeliveryCommand.java
index 08ce46d..ea5a404 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailDeliveryCommand.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailDeliveryCommand.java
@@ -1,28 +1,28 @@
-package com.apssouza.eventsourcing.commands;
-
-import java.time.Instant;
-
-/**
- * Email delivery command
- *
- * @author apssouza
- */
-public class EmailDeliveryCommand {
-
- private final String uuid;
- private final Instant instant;
-
- public EmailDeliveryCommand(String uuid, Instant instant) {
- this.uuid = uuid;
- this.instant = instant;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public Instant getInstant() {
- return instant;
- }
-
-}
+package com.apssouza.eventsourcing.commands;
+
+import java.time.Instant;
+
+/**
+ * Email delivery command
+ *
+ * @author apssouza
+ */
+public class EmailDeliveryCommand {
+
+ private final String uuid;
+ private final Instant instant;
+
+ public EmailDeliveryCommand(String uuid, Instant instant) {
+ this.uuid = uuid;
+ this.instant = instant;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public Instant getInstant() {
+ return instant;
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailSendCommand.java b/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailSendCommand.java
index 6aa4509..fc6fa70 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailSendCommand.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/commands/EmailSendCommand.java
@@ -1,34 +1,34 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.apssouza.eventsourcing.commands;
-
-import java.time.Instant;
-import java.util.UUID;
-
-/**
- * Email send command
- *
- * @author apssouza
- */
-public class EmailSendCommand {
-
- private final String uuid;
- private final Instant instant;
-
- public EmailSendCommand(String uuid, Instant instant) {
- this.uuid = uuid;
- this.instant = instant;
- }
-
- public String getUuid() {
- return uuid;
- }
-
- public Instant getInstant() {
- return instant;
- }
-
-}
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.apssouza.eventsourcing.commands;
+
+import java.time.Instant;
+import java.util.UUID;
+
+/**
+ * Email send command
+ *
+ * @author apssouza
+ */
+public class EmailSendCommand {
+
+ private final String uuid;
+ private final Instant instant;
+
+ public EmailSendCommand(String uuid, Instant instant) {
+ this.uuid = uuid;
+ this.instant = instant;
+ }
+
+ public String getUuid() {
+ return uuid;
+ }
+
+ public Instant getInstant() {
+ return instant;
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/entities/Email.java b/mail-service/src/main/java/com/apssouza/eventsourcing/entities/Email.java
index b649f65..a6387c4 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/entities/Email.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/entities/Email.java
@@ -1,110 +1,110 @@
-package com.apssouza.eventsourcing.entities;
-
-import com.apssouza.eventsourcing.aggregates.EmailState;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Version;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-
-/**
- * Email entity
- *
- * @author apssouza
- */
-@Entity
-public class Email {
-
- @Id
- @GeneratedValue
- private long id;
-
- @NotNull
- private long authId;
-
- @NotNull
- @Size(min = 2, max = 256)
- private String name;
-
- @org.hibernate.validator.constraints.Email
- @NotNull
- @Column(unique = true)
- private String email;
-
- private EmailState state;
-
- @Version
- private long version;
-
- public Email() {
- }
-
- public Email(String name, String email, EmailState state) {
- this.name = name;
- this.email = email;
- this.state = state;
- }
-
- public Email(long id, String name, String email, EmailState state) {
- this(name, email,state);
- this.id = id;
- }
-
- public EmailState getState() {
- return state;
- }
-
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public long getAuthId() {
- return authId;
- }
-
- public void setAuthId(long authId) {
- this.authId = authId;
- }
-
- public long getVersion() {
- return version;
- }
-
- public void setVersion(long version) {
- this.version = version;
- }
-
- @Override
- public String toString() {
- return "Email{" + "id=" + id + ", authId=" + authId + ", name=" + name + ", email=" + email + ", version=" + version + '}';
- }
-
- public Email setState(EmailState emailState) {
- state = emailState;
- return this;
- }
-
-}
+package com.apssouza.eventsourcing.entities;
+
+import com.apssouza.eventsourcing.aggregates.EmailState;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Version;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+
+/**
+ * Email entity
+ *
+ * @author apssouza
+ */
+@Entity
+public class Email {
+
+ @Id
+ @GeneratedValue
+ private long id;
+
+ @NotNull
+ private long authId;
+
+ @NotNull
+ @Size(min = 2, max = 256)
+ private String name;
+
+ @org.hibernate.validator.constraints.Email
+ @NotNull
+ @Column(unique = true)
+ private String email;
+
+ private EmailState state;
+
+ @Version
+ private long version;
+
+ public Email() {
+ }
+
+ public Email(String name, String email, EmailState state) {
+ this.name = name;
+ this.email = email;
+ this.state = state;
+ }
+
+ public Email(long id, String name, String email, EmailState state) {
+ this(name, email,state);
+ this.id = id;
+ }
+
+ public EmailState getState() {
+ return state;
+ }
+
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public long getAuthId() {
+ return authId;
+ }
+
+ public void setAuthId(long authId) {
+ this.authId = authId;
+ }
+
+ public long getVersion() {
+ return version;
+ }
+
+ public void setVersion(long version) {
+ this.version = version;
+ }
+
+ @Override
+ public String toString() {
+ return "Email{" + "id=" + id + ", authId=" + authId + ", name=" + name + ", email=" + email + ", version=" + version + '}';
+ }
+
+ public Email setState(EmailState emailState) {
+ state = emailState;
+ return this;
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailCreatedEvent.java b/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailCreatedEvent.java
index da9e648..4ffc39f 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailCreatedEvent.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailCreatedEvent.java
@@ -1,42 +1,42 @@
-package com.apssouza.eventsourcing.events;
-
-import com.apssouza.eventsourcing.entities.Email;
-import java.time.Instant;
-
-/**
- * Email created event
- *
- * @author apssouza
- */
-public class EmailCreatedEvent implements EmailEvent {
-
- private Email email;
-
- public EmailCreatedEvent(String uuid) {
- }
-
- protected String uuid;
-
- protected Instant when = Instant.now();
-
- @Override
- public String uuid() {
- return uuid;
- }
-
- @Override
- public Instant when() {
- return when;
- }
-
- public EmailCreatedEvent(String uuid, Email account) {
- this.email = account;
- this.uuid = uuid;
- }
-
- @Override
- public Email getEmail() {
- return email;
- }
-
-}
+package com.apssouza.eventsourcing.events;
+
+import com.apssouza.eventsourcing.entities.Email;
+import java.time.Instant;
+
+/**
+ * Email created event
+ *
+ * @author apssouza
+ */
+public class EmailCreatedEvent implements EmailEvent {
+
+ private Email email;
+
+ public EmailCreatedEvent(String uuid) {
+ }
+
+ protected String uuid;
+
+ protected Instant when = Instant.now();
+
+ @Override
+ public String uuid() {
+ return uuid;
+ }
+
+ @Override
+ public Instant when() {
+ return when;
+ }
+
+ public EmailCreatedEvent(String uuid, Email account) {
+ this.email = account;
+ this.uuid = uuid;
+ }
+
+ @Override
+ public Email getEmail() {
+ return email;
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailDeletedEvent.java b/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailDeletedEvent.java
index 91cb0ff..5d84953 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailDeletedEvent.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailDeletedEvent.java
@@ -1,50 +1,50 @@
-package com.apssouza.eventsourcing.events;
-
-import com.apssouza.eventsourcing.commands.EmailDeleteCommand;
-import com.apssouza.eventsourcing.entities.Email;
-import com.apssouza.infra.AbstractDomainEvent;
-import com.apssouza.infra.AppEvent;
-import java.time.Instant;
-
-/**
- * Email deleted event
- *
- * @author apssouza
- */
-public class EmailDeletedEvent extends AbstractDomainEvent implements EmailEvent {
-
- private final String uuid;
- private final String type = "Deleted";
- private final Instant when = Instant.now();
-
- private Email email;
-
- /**
- *
- * @param uuid
- * @param email
- */
- public EmailDeletedEvent(String uuid, Email email) {
- this.uuid = uuid;
- this.email = email;
- }
-
- @Override
- public String uuid() {
- return uuid;
- }
-
- public String type() {
- return type;
- }
-
- @Override
- public Instant when() {
- return when;
- }
-
- public Email getEmail() {
- return email;
- }
-
-}
+package com.apssouza.eventsourcing.events;
+
+import com.apssouza.eventsourcing.commands.EmailDeleteCommand;
+import com.apssouza.eventsourcing.entities.Email;
+import com.apssouza.infra.AbstractDomainEvent;
+import com.apssouza.infra.AppEvent;
+import java.time.Instant;
+
+/**
+ * Email deleted event
+ *
+ * @author apssouza
+ */
+public class EmailDeletedEvent extends AbstractDomainEvent implements EmailEvent {
+
+ private final String uuid;
+ private final String type = "Deleted";
+ private final Instant when = Instant.now();
+
+ private Email email;
+
+ /**
+ *
+ * @param uuid
+ * @param email
+ */
+ public EmailDeletedEvent(String uuid, Email email) {
+ this.uuid = uuid;
+ this.email = email;
+ }
+
+ @Override
+ public String uuid() {
+ return uuid;
+ }
+
+ public String type() {
+ return type;
+ }
+
+ @Override
+ public Instant when() {
+ return when;
+ }
+
+ public Email getEmail() {
+ return email;
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailDeliveredEvent.java b/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailDeliveredEvent.java
index b3660ee..7a43442 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailDeliveredEvent.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailDeliveredEvent.java
@@ -1,44 +1,44 @@
-package com.apssouza.eventsourcing.events;
-
-import com.apssouza.eventsourcing.entities.Email;
-import com.apssouza.infra.AbstractDomainEvent;
-import java.time.Instant;
-
-/**
- * Email delivered event
- *
- * @author apssouza
- */
-public class EmailDeliveredEvent extends AbstractDomainEvent implements EmailEvent {
-
- private final String uuid;
- private final Instant when = Instant.now();
- private final String type = "sent";
-
- private final Email email;
-
- public EmailDeliveredEvent(String uuid, Email email) {
- this.uuid = uuid;
- this.email = email;
- }
-
- @Override
- public String uuid() {
- return uuid;
- }
-
- public String type() {
- return type;
- }
-
- @Override
- public Instant when() {
- return when;
- }
-
- @Override
- public Email getEmail() {
- return email;
- }
-
-}
+package com.apssouza.eventsourcing.events;
+
+import com.apssouza.eventsourcing.entities.Email;
+import com.apssouza.infra.AbstractDomainEvent;
+import java.time.Instant;
+
+/**
+ * Email delivered event
+ *
+ * @author apssouza
+ */
+public class EmailDeliveredEvent extends AbstractDomainEvent implements EmailEvent {
+
+ private final String uuid;
+ private final Instant when = Instant.now();
+ private final String type = "sent";
+
+ private final Email email;
+
+ public EmailDeliveredEvent(String uuid, Email email) {
+ this.uuid = uuid;
+ this.email = email;
+ }
+
+ @Override
+ public String uuid() {
+ return uuid;
+ }
+
+ public String type() {
+ return type;
+ }
+
+ @Override
+ public Instant when() {
+ return when;
+ }
+
+ @Override
+ public Email getEmail() {
+ return email;
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailEvent.java b/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailEvent.java
index a843a78..5ba535f 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailEvent.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailEvent.java
@@ -1,19 +1,19 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.apssouza.eventsourcing.events;
-
-import com.apssouza.eventsourcing.entities.Email;
-import com.apssouza.infra.AppEvent;
-
-/**
- *
- * @author apssouza
- */
-public interface EmailEvent extends AppEvent{
-
- Email getEmail();
-
-}
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.apssouza.eventsourcing.events;
+
+import com.apssouza.eventsourcing.entities.Email;
+import com.apssouza.infra.AppEvent;
+
+/**
+ *
+ * @author apssouza
+ */
+public interface EmailEvent extends AppEvent{
+
+ Email getEmail();
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailSentEvent.java b/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailSentEvent.java
index ff4fdfa..24d3b21 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailSentEvent.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/events/EmailSentEvent.java
@@ -1,27 +1,27 @@
-package com.apssouza.eventsourcing.events;
-
-import com.apssouza.eventsourcing.entities.Email;
-import com.apssouza.infra.AbstractDomainEvent;
-
-/**
- * Email sent event
- *
- * @author apssouza
- */
-public class EmailSentEvent extends AbstractDomainEvent implements EmailEvent {
-
- private final String type = "sent";
-
- private Email email;
-
- public EmailSentEvent(String uuid, Email email) {
- this.uuid = uuid;
- this.email = email;
- }
-
- @Override
- public Email getEmail() {
- return email;
- }
-
-}
+package com.apssouza.eventsourcing.events;
+
+import com.apssouza.eventsourcing.entities.Email;
+import com.apssouza.infra.AbstractDomainEvent;
+
+/**
+ * Email sent event
+ *
+ * @author apssouza
+ */
+public class EmailSentEvent extends AbstractDomainEvent implements EmailEvent {
+
+ private final String type = "sent";
+
+ private Email email;
+
+ public EmailSentEvent(String uuid, Email email) {
+ this.uuid = uuid;
+ this.email = email;
+ }
+
+ @Override
+ public Email getEmail() {
+ return email;
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventDescriptor.java b/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventDescriptor.java
index 789405e..7c26216 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventDescriptor.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventDescriptor.java
@@ -1,56 +1,56 @@
-package com.apssouza.eventsourcing.eventstore;
-
-
-import javax.persistence.*;
-import java.time.Instant;
-
-@Entity(name = "event_descriptors")
-public class EventDescriptor {
-
- @Id
- @GeneratedValue(generator = "event_descriptors_seq", strategy = GenerationType.SEQUENCE)
- @SequenceGenerator(name = "event_descriptors_seq", sequenceName = "event_descriptors_seq", allocationSize = 1)
- private Long id;
-
- @Column(nullable = false, length = 600)
- private String body;
-
- @Column(nullable = false, name = "occurred_at")
- private Instant occurredAt = Instant.now();
-
- @Column(nullable = false, length = 60)
- private String type;
-
- @ManyToOne
- private EventStream eventStream;
-
- EventDescriptor(String body, Instant occurredAt, String type) {
- this.body = body;
- this.occurredAt = occurredAt;
- this.type = type;
- }
-
- private EventDescriptor() {
- }
-
- public Long getId() {
- return id;
- }
-
- public String getBody() {
- return body;
- }
-
- public Instant getOccurredAt() {
- return occurredAt;
- }
-
- public String getType() {
- return type;
- }
-
- public EventStream getEventStream() {
- return eventStream;
- }
-
-}
+package com.apssouza.eventsourcing.eventstore;
+
+
+import javax.persistence.*;
+import java.time.Instant;
+
+@Entity(name = "event_descriptors")
+public class EventDescriptor {
+
+ @Id
+ @GeneratedValue(generator = "event_descriptors_seq", strategy = GenerationType.SEQUENCE)
+ @SequenceGenerator(name = "event_descriptors_seq", sequenceName = "event_descriptors_seq", allocationSize = 1)
+ private Long id;
+
+ @Column(nullable = false, length = 600)
+ private String body;
+
+ @Column(nullable = false, name = "occurred_at")
+ private Instant occurredAt = Instant.now();
+
+ @Column(nullable = false, length = 60)
+ private String type;
+
+ @ManyToOne
+ private EventStream eventStream;
+
+ EventDescriptor(String body, Instant occurredAt, String type) {
+ this.body = body;
+ this.occurredAt = occurredAt;
+ this.type = type;
+ }
+
+ private EventDescriptor() {
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getBody() {
+ return body;
+ }
+
+ public Instant getOccurredAt() {
+ return occurredAt;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public EventStream getEventStream() {
+ return eventStream;
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventSerializer.java b/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventSerializer.java
index 93d644c..572470a 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventSerializer.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventSerializer.java
@@ -1,42 +1,42 @@
-package com.apssouza.eventsourcing.eventstore;
-
-import com.apssouza.infra.AppEvent;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-import org.springframework.stereotype.Component;
-
-import java.io.IOException;
-
-import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
-
-@Component
-public class EventSerializer {
-
- private final ObjectMapper objectMapper;
-
- public EventSerializer() {
- this.objectMapper = new ObjectMapper();
- objectMapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);
- objectMapper.registerModule(new JavaTimeModule());
- objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
- }
-
- public EventDescriptor serialize(AppEvent event) {
- try {
- return new EventDescriptor(objectMapper.writeValueAsString(event), event.when(), AppEvent.class.getCanonicalName());
- } catch (JsonProcessingException e) {
- throw new RuntimeException(e);
- }
- }
-
- public AppEvent deserialize(EventDescriptor eventDescriptor) {
- try {
- return objectMapper.readValue(eventDescriptor.getBody(), AppEvent.class);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
-}
+package com.apssouza.eventsourcing.eventstore;
+
+import com.apssouza.infra.AppEvent;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+
+import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES;
+
+@Component
+public class EventSerializer {
+
+ private final ObjectMapper objectMapper;
+
+ public EventSerializer() {
+ this.objectMapper = new ObjectMapper();
+ objectMapper.configure(FAIL_ON_UNKNOWN_PROPERTIES, false);
+ objectMapper.registerModule(new JavaTimeModule());
+ objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+ }
+
+ public EventDescriptor serialize(AppEvent event) {
+ try {
+ return new EventDescriptor(objectMapper.writeValueAsString(event), event.when(), AppEvent.class.getCanonicalName());
+ } catch (JsonProcessingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public AppEvent deserialize(EventDescriptor eventDescriptor) {
+ try {
+ return objectMapper.readValue(eventDescriptor.getBody(), AppEvent.class);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventStoreRepository.java b/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventStoreRepository.java
index 7fa9101..64bca1c 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventStoreRepository.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventStoreRepository.java
@@ -1,27 +1,27 @@
-package com.apssouza.eventsourcing.eventstore;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-
-import java.util.List;
-import java.util.Optional;
-
-import static java.util.Collections.emptyList;
-
-public interface EventStoreRepository extends JpaRepository {
-
- Optional findByAggregateUUID(String uuid);
-
- default EventStream saveEvents(String aggregateId, List events) {
- final EventStream eventStream = findByAggregateUUID(aggregateId)
- .orElseGet(() -> new EventStream(aggregateId));
- eventStream.addEvents(events);
- return save(eventStream);
- }
-
- default List getEventsForAggregate(String aggregateId) {
- return findByAggregateUUID(aggregateId)
- .map(EventStream::getEvents)
- .orElse(emptyList());
-
- }
-}
+package com.apssouza.eventsourcing.eventstore;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+import java.util.Optional;
+
+import static java.util.Collections.emptyList;
+
+public interface EventStoreRepository extends JpaRepository {
+
+ Optional findByAggregateUUID(String uuid);
+
+ default EventStream saveEvents(String aggregateId, List events) {
+ final EventStream eventStream = findByAggregateUUID(aggregateId)
+ .orElseGet(() -> new EventStream(aggregateId));
+ eventStream.addEvents(events);
+ return save(eventStream);
+ }
+
+ default List getEventsForAggregate(String aggregateId) {
+ return findByAggregateUUID(aggregateId)
+ .map(EventStream::getEvents)
+ .orElse(emptyList());
+
+ }
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventStream.java b/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventStream.java
index 547d449..caedbb5 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventStream.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/eventstore/EventStream.java
@@ -1,67 +1,67 @@
-package com.apssouza.eventsourcing.eventstore;
-
-
-import java.io.Serializable;
-import javax.persistence.*;
-import java.util.ArrayList;
-import java.util.List;
-
-import static java.util.Comparator.comparing;
-import static java.util.stream.Collectors.toList;
-import static javax.persistence.FetchType.EAGER;
-
-@Entity(name = "event_streams")
-public class EventStream implements Serializable {
-
- @Id
- @GeneratedValue(generator = "event_stream_seq", strategy = GenerationType.SEQUENCE)
- @SequenceGenerator(name = "event_stream_seq", sequenceName = "event_stream_seq", allocationSize = 1)
- private Long id;
-
- @Column(unique = true, nullable = false, name = "aggregate_uuid", length = 36)
- private String aggregateUUID;
-
- @Version
- @Column(nullable = false)
- private long version;
-
- @OneToMany(
- cascade = CascadeType.ALL,
- orphanRemoval = true,
- fetch = EAGER
- )
- private List events;
-
- public EventStream() {
- this.events = new ArrayList<>();
- }
-
- EventStream(String aggregateUUID) {
- this.events = new ArrayList<>();
- this.aggregateUUID = aggregateUUID;
- }
-
- public Long getId() {
- return id;
- }
-
- public String getAggregateUUID() {
- return aggregateUUID;
- }
-
- public long getVersion() {
- return version;
- }
-
- void addEvents(List events) {
- this.events.addAll(events);
- }
-
- List getEvents() {
- return events
- .stream()
- .sorted(comparing(EventDescriptor::getOccurredAt))
- .collect(toList());
- }
-
-}
+package com.apssouza.eventsourcing.eventstore;
+
+
+import java.io.Serializable;
+import javax.persistence.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import static java.util.Comparator.comparing;
+import static java.util.stream.Collectors.toList;
+import static javax.persistence.FetchType.EAGER;
+
+@Entity(name = "event_streams")
+public class EventStream implements Serializable {
+
+ @Id
+ @GeneratedValue(generator = "event_stream_seq", strategy = GenerationType.SEQUENCE)
+ @SequenceGenerator(name = "event_stream_seq", sequenceName = "event_stream_seq", allocationSize = 1)
+ private Long id;
+
+ @Column(unique = true, nullable = false, name = "aggregate_uuid", length = 36)
+ private String aggregateUUID;
+
+ @Version
+ @Column(nullable = false)
+ private long version;
+
+ @OneToMany(
+ cascade = CascadeType.ALL,
+ orphanRemoval = true,
+ fetch = EAGER
+ )
+ private List events;
+
+ public EventStream() {
+ this.events = new ArrayList<>();
+ }
+
+ EventStream(String aggregateUUID) {
+ this.events = new ArrayList<>();
+ this.aggregateUUID = aggregateUUID;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public String getAggregateUUID() {
+ return aggregateUUID;
+ }
+
+ public long getVersion() {
+ return version;
+ }
+
+ void addEvents(List events) {
+ this.events.addAll(events);
+ }
+
+ List getEvents() {
+ return events
+ .stream()
+ .sorted(comparing(EventDescriptor::getOccurredAt))
+ .collect(toList());
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/queries/EmailQueryObject.java b/mail-service/src/main/java/com/apssouza/eventsourcing/queries/EmailQueryObject.java
index 382056c..d5960f9 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/queries/EmailQueryObject.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/queries/EmailQueryObject.java
@@ -1,41 +1,41 @@
-package com.apssouza.eventsourcing.queries;
-
-import com.apssouza.eventsourcing.entities.Email;
-import com.apssouza.eventsourcing.events.EmailCreatedEvent;
-import com.apssouza.eventsourcing.events.EmailDeletedEvent;
-import com.apssouza.mailservice.repository.EmailRepository;
-import java.util.List;
-import org.springframework.context.event.EventListener;
-import org.springframework.stereotype.Component;
-
-/**
- * Email query service, read data from the read data source This can be
- * separated in a new service
- *
- * @author apssouza
- */
-@Component
-public class EmailQueryObject {
-
- private final EmailRepository emailRepository;
-
- public EmailQueryObject(EmailRepository emailRepository) {
- this.emailRepository = emailRepository;
- }
-
- public List all() {
- return emailRepository.findAll();
- }
-
- @EventListener
- public void updateEmail(EmailCreatedEvent event) {
- System.out.println("event= "+ event.getEmail());
- emailRepository.save(event.getEmail());
- }
-
- @EventListener
- public void updateEmail(EmailDeletedEvent event) {
- emailRepository.delete(event.getEmail());
- }
-
-}
+package com.apssouza.eventsourcing.queries;
+
+import com.apssouza.eventsourcing.entities.Email;
+import com.apssouza.eventsourcing.events.EmailCreatedEvent;
+import com.apssouza.eventsourcing.events.EmailDeletedEvent;
+import com.apssouza.mailservice.repository.EmailRepository;
+import java.util.List;
+import org.springframework.context.event.EventListener;
+import org.springframework.stereotype.Component;
+
+/**
+ * Email query service, read data from the read data source This can be
+ * separated in a new service
+ *
+ * @author apssouza
+ */
+@Component
+public class EmailQueryObject {
+
+ private final EmailRepository emailRepository;
+
+ public EmailQueryObject(EmailRepository emailRepository) {
+ this.emailRepository = emailRepository;
+ }
+
+ public List all() {
+ return emailRepository.findAll();
+ }
+
+ @EventListener
+ public void updateEmail(EmailCreatedEvent event) {
+ System.out.println("event= "+ event.getEmail());
+ emailRepository.save(event.getEmail());
+ }
+
+ @EventListener
+ public void updateEmail(EmailDeletedEvent event) {
+ emailRepository.delete(event.getEmail());
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/services/EventSourcingService.java b/mail-service/src/main/java/com/apssouza/eventsourcing/services/EventSourcingService.java
index f19fef0..0d872c4 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/services/EventSourcingService.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/services/EventSourcingService.java
@@ -1,24 +1,24 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.apssouza.eventsourcing.services;
-
-import com.apssouza.eventsourcing.aggregates.Aggregate;
-import com.apssouza.eventsourcing.eventstore.EventStream;
-import com.apssouza.infra.AppEvent;
-import java.util.List;
-
-/**
- *
- * @author apssouza
- */
-public interface EventSourcingService {
-
- Aggregate save(Aggregate aggregate) ;
-
- List getRelatedEvents(String uuid);
-
- EventStream getAggregate(String uuid);
-}
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.apssouza.eventsourcing.services;
+
+import com.apssouza.eventsourcing.aggregates.Aggregate;
+import com.apssouza.eventsourcing.eventstore.EventStream;
+import com.apssouza.infra.AppEvent;
+import java.util.List;
+
+/**
+ *
+ * @author apssouza
+ */
+public interface EventSourcingService {
+
+ Aggregate save(Aggregate aggregate) ;
+
+ List getRelatedEvents(String uuid);
+
+ EventStream getAggregate(String uuid);
+}
diff --git a/mail-service/src/main/java/com/apssouza/eventsourcing/services/EventSourcingServiceImpl.java b/mail-service/src/main/java/com/apssouza/eventsourcing/services/EventSourcingServiceImpl.java
index 2ba182f..be880a4 100644
--- a/mail-service/src/main/java/com/apssouza/eventsourcing/services/EventSourcingServiceImpl.java
+++ b/mail-service/src/main/java/com/apssouza/eventsourcing/services/EventSourcingServiceImpl.java
@@ -1,65 +1,65 @@
-package com.apssouza.eventsourcing.services;
-
-import com.apssouza.eventsourcing.aggregates.Aggregate;
-import com.apssouza.eventsourcing.eventstore.EventSerializer;
-import com.apssouza.eventsourcing.eventstore.EventStoreRepository;
-import com.apssouza.eventsourcing.eventstore.EventStream;
-import com.apssouza.infra.AppEvent;
-import java.util.List;
-import java.util.UUID;
-import static java.util.stream.Collectors.toList;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- *
- * @author apssouza
- */
-@Service
-@Transactional(readOnly = true)
-public class EventSourcingServiceImpl implements EventSourcingService{
-
- private final EventSerializer eventSerializer;
- private final EventStoreRepository eventStoreRepository;
-
- @Autowired
- public EventSourcingServiceImpl(
- EventStoreRepository eventStore,
- EventSerializer eventSerializer,
- ApplicationEventPublisher eventPublisher
- ) {
- this.eventStoreRepository = eventStore;
- this.eventSerializer = eventSerializer;
- }
-
- @Override
- @Transactional
- public Aggregate save(Aggregate aggregate) {
- final List pendingEvents = aggregate.getUncommittedChanges();
- eventStoreRepository.saveEvents(
- aggregate.getUuid(),
- pendingEvents
- .stream()
- .map(eventSerializer::serialize)
- .collect(toList())
- );
- return aggregate.markChangesAsCommitted();
- }
-
- @Override
- public List getRelatedEvents(String uuid) {
- return eventStoreRepository.getEventsForAggregate(uuid)
- .stream()
- .map(eventSerializer::deserialize)
- .collect(toList());
- }
-
- @Override
- public EventStream getAggregate(String uuid) {
- return eventStoreRepository.findByAggregateUUID(uuid)
- .orElseGet( () -> new EventStream());
- }
-
-}
+package com.apssouza.eventsourcing.services;
+
+import com.apssouza.eventsourcing.aggregates.Aggregate;
+import com.apssouza.eventsourcing.eventstore.EventSerializer;
+import com.apssouza.eventsourcing.eventstore.EventStoreRepository;
+import com.apssouza.eventsourcing.eventstore.EventStream;
+import com.apssouza.infra.AppEvent;
+import java.util.List;
+import java.util.UUID;
+import static java.util.stream.Collectors.toList;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+/**
+ *
+ * @author apssouza
+ */
+@Service
+@Transactional(readOnly = true)
+public class EventSourcingServiceImpl implements EventSourcingService{
+
+ private final EventSerializer eventSerializer;
+ private final EventStoreRepository eventStoreRepository;
+
+ @Autowired
+ public EventSourcingServiceImpl(
+ EventStoreRepository eventStore,
+ EventSerializer eventSerializer,
+ ApplicationEventPublisher eventPublisher
+ ) {
+ this.eventStoreRepository = eventStore;
+ this.eventSerializer = eventSerializer;
+ }
+
+ @Override
+ @Transactional
+ public Aggregate save(Aggregate aggregate) {
+ final List pendingEvents = aggregate.getUncommittedChanges();
+ eventStoreRepository.saveEvents(
+ aggregate.getUuid(),
+ pendingEvents
+ .stream()
+ .map(eventSerializer::serialize)
+ .collect(toList())
+ );
+ return aggregate.markChangesAsCommitted();
+ }
+
+ @Override
+ public List getRelatedEvents(String uuid) {
+ return eventStoreRepository.getEventsForAggregate(uuid)
+ .stream()
+ .map(eventSerializer::deserialize)
+ .collect(toList());
+ }
+
+ @Override
+ public EventStream getAggregate(String uuid) {
+ return eventStoreRepository.findByAggregateUUID(uuid)
+ .orElseGet( () -> new EventStream());
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/mailservice/MailserviceApplication.java b/mail-service/src/main/java/com/apssouza/mailservice/MailserviceApplication.java
index 321575a..9aa3b56 100644
--- a/mail-service/src/main/java/com/apssouza/mailservice/MailserviceApplication.java
+++ b/mail-service/src/main/java/com/apssouza/mailservice/MailserviceApplication.java
@@ -1,18 +1,18 @@
-package com.apssouza.mailservice;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.ComponentScan;
-
-@SpringBootApplication
-@ComponentScan(basePackages = {
- "com.apssouza.infra",
- "com.apssouza.eventsourcing",
- "com.apssouza.mailservice"
-})
-public class MailserviceApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(MailserviceApplication.class, args);
- }
-}
+package com.apssouza.mailservice;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+@SpringBootApplication
+@ComponentScan(basePackages = {
+ "com.apssouza.infra",
+ "com.apssouza.eventsourcing",
+ "com.apssouza.mailservice"
+})
+public class MailserviceApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(MailserviceApplication.class, args);
+ }
+}
diff --git a/mail-service/src/main/java/com/apssouza/mailservice/configurations/EventSourcingConfig.java b/mail-service/src/main/java/com/apssouza/mailservice/configurations/EventSourcingConfig.java
index b7015fd..1972289 100644
--- a/mail-service/src/main/java/com/apssouza/mailservice/configurations/EventSourcingConfig.java
+++ b/mail-service/src/main/java/com/apssouza/mailservice/configurations/EventSourcingConfig.java
@@ -1,15 +1,15 @@
-package com.apssouza.mailservice.configurations;
-
-import org.springframework.context.annotation.ComponentScan;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * Event sourcing module configuration
- *
- * @author apssouza
- */
-@ComponentScan({"com.apssouza.eventsourcing"})
-@Configuration
-public class EventSourcingConfig {
-
-}
+package com.apssouza.mailservice.configurations;
+
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Event sourcing module configuration
+ *
+ * @author apssouza
+ */
+@ComponentScan({"com.apssouza.eventsourcing"})
+@Configuration
+public class EventSourcingConfig {
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/mailservice/controllers/EmailController.java b/mail-service/src/main/java/com/apssouza/mailservice/controllers/EmailController.java
index a93c494..41ab4a9 100644
--- a/mail-service/src/main/java/com/apssouza/mailservice/controllers/EmailController.java
+++ b/mail-service/src/main/java/com/apssouza/mailservice/controllers/EmailController.java
@@ -1,27 +1,27 @@
-package com.apssouza.mailservice.controllers;
-
-import com.apssouza.eventsourcing.entities.Email;
-import com.apssouza.mailservice.repository.EmailRepository;
-import java.util.List;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- *
- * @author apssouza
- */
-@RestController
-@RequestMapping("/emails")
-public class EmailController {
-
- @Autowired
- EmailRepository repository;
-
- @GetMapping
- public List list() {
- return repository.findAll();
- }
-
-}
+package com.apssouza.mailservice.controllers;
+
+import com.apssouza.eventsourcing.entities.Email;
+import com.apssouza.mailservice.repository.EmailRepository;
+import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ *
+ * @author apssouza
+ */
+@RestController
+@RequestMapping("/emails")
+public class EmailController {
+
+ @Autowired
+ EmailRepository repository;
+
+ @GetMapping
+ public List list() {
+ return repository.findAll();
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/mailservice/controllers/NotifyController.java b/mail-service/src/main/java/com/apssouza/mailservice/controllers/NotifyController.java
index 55e03aa..b5ddaed 100644
--- a/mail-service/src/main/java/com/apssouza/mailservice/controllers/NotifyController.java
+++ b/mail-service/src/main/java/com/apssouza/mailservice/controllers/NotifyController.java
@@ -1,52 +1,52 @@
-package com.apssouza.mailservice.controllers;
-
-import com.apssouza.eventsourcing.aggregates.EmailState;
-import com.apssouza.eventsourcing.commands.EmailCommandHandler;
-import com.apssouza.eventsourcing.commands.EmailCreateCommand;
-import com.apssouza.eventsourcing.entities.Email;
-import java.util.UUID;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.function.Supplier;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.ReflectionUtils;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- *
- * @author apssouza
- */
-@RestController
-@RequestMapping("/send")
-public class NotifyController {
-
- @Autowired
- EmailCommandHandler emailCommandHandler;
-
- @GetMapping("email")
- public @ResponseBody Future sendEmail() {
- Supplier supplier = () -> {
- String uuid = UUID.randomUUID().toString();
- EmailCreateCommand command = new EmailCreateCommand(
- uuid,
- new Email("Alexsandro", "apssouza22@gmail.com", EmailState.CREATED)
- );
- Executors.newCachedThreadPool().submit(() -> {
- try {
- emailCommandHandler.create(command);
- } catch (Exception ex) {
- ReflectionUtils.rethrowRuntimeException(ex);
- }
- });
- return "Email sent successfully. - code= " + uuid;
- };
-
- return CompletableFuture.supplyAsync(supplier, Executors.newCachedThreadPool());
-
- }
-
-}
+package com.apssouza.mailservice.controllers;
+
+import com.apssouza.eventsourcing.aggregates.EmailState;
+import com.apssouza.eventsourcing.commands.EmailCommandHandler;
+import com.apssouza.eventsourcing.commands.EmailCreateCommand;
+import com.apssouza.eventsourcing.entities.Email;
+import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.function.Supplier;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.util.ReflectionUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ *
+ * @author apssouza
+ */
+@RestController
+@RequestMapping("/send")
+public class NotifyController {
+
+ @Autowired
+ EmailCommandHandler emailCommandHandler;
+
+ @GetMapping("email")
+ public @ResponseBody Future sendEmail() {
+ Supplier supplier = () -> {
+ String uuid = UUID.randomUUID().toString();
+ EmailCreateCommand command = new EmailCreateCommand(
+ uuid,
+ new Email("Alexsandro", "apssouza22@gmail.com", EmailState.CREATED)
+ );
+ Executors.newCachedThreadPool().submit(() -> {
+ try {
+ emailCommandHandler.create(command);
+ } catch (Exception ex) {
+ ReflectionUtils.rethrowRuntimeException(ex);
+ }
+ });
+ return "Email sent successfully. - code= " + uuid;
+ };
+
+ return CompletableFuture.supplyAsync(supplier, Executors.newCachedThreadPool());
+
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/mailservice/integration/reminder/EventInput.java b/mail-service/src/main/java/com/apssouza/mailservice/integration/reminder/EventInput.java
index c86c139..089f04b 100644
--- a/mail-service/src/main/java/com/apssouza/mailservice/integration/reminder/EventInput.java
+++ b/mail-service/src/main/java/com/apssouza/mailservice/integration/reminder/EventInput.java
@@ -1,48 +1,48 @@
-package com.apssouza.mailservice.integration.reminder;
-
-import com.apssouza.eventsourcing.aggregates.EmailState;
-import com.apssouza.eventsourcing.commands.EmailCommandHandler;
-import com.apssouza.eventsourcing.commands.EmailCreateCommand;
-import com.apssouza.eventsourcing.entities.Email;
-import java.time.Instant;
-import java.util.UUID;
-import org.apache.log4j.Logger;
-import org.springframework.cloud.stream.annotation.EnableBinding;
-import org.springframework.cloud.stream.annotation.StreamListener;
-import org.springframework.cloud.stream.messaging.Sink;
-import org.springframework.messaging.handler.annotation.Payload;
-
-/**
- *
- * The Stream Kafka event input
- *
- * @author apssouza
- */
-@EnableBinding(Sink.class)
-public class EventInput {
-
- Logger LOG = Logger.getLogger(EventInput.class);
-
- private final EmailCommandHandler commanderHandler;
-
- public EventInput(EmailCommandHandler commander) {
- this.commanderHandler = commander;
- }
-
-
- @StreamListener(
- target = Sink.INPUT,
- condition = "headers['type']=='TodoCreatedEvent'"
- )
- public void todoCreated(@Payload TodoCreatedEvent event) throws Exception {
- LOG.info("Todo created");
- LOG.info("when = " + event.when());
- LOG.info("todo = " + event.getTodo().toString());
-
- String uuid = UUID.randomUUID().toString();
- Email email = new Email("Alexsandro", "test"+Instant.now().getEpochSecond()+"@gmail.com", EmailState.CREATED);
- EmailCreateCommand command = new EmailCreateCommand(uuid, email);
- commanderHandler.create(command);
- }
-
-}
+package com.apssouza.mailservice.integration.reminder;
+
+import com.apssouza.eventsourcing.aggregates.EmailState;
+import com.apssouza.eventsourcing.commands.EmailCommandHandler;
+import com.apssouza.eventsourcing.commands.EmailCreateCommand;
+import com.apssouza.eventsourcing.entities.Email;
+import java.time.Instant;
+import java.util.UUID;
+import org.apache.log4j.Logger;
+import org.springframework.cloud.stream.annotation.EnableBinding;
+import org.springframework.cloud.stream.annotation.StreamListener;
+import org.springframework.cloud.stream.messaging.Sink;
+import org.springframework.messaging.handler.annotation.Payload;
+
+/**
+ *
+ * The Stream Kafka event input
+ *
+ * @author apssouza
+ */
+@EnableBinding(Sink.class)
+public class EventInput {
+
+ Logger LOG = Logger.getLogger(EventInput.class);
+
+ private final EmailCommandHandler commanderHandler;
+
+ public EventInput(EmailCommandHandler commander) {
+ this.commanderHandler = commander;
+ }
+
+
+ @StreamListener(
+ target = Sink.INPUT,
+ condition = "headers['type']=='TodoCreatedEvent'"
+ )
+ public void todoCreated(@Payload TodoCreatedEvent event) throws Exception {
+ LOG.info("Todo created");
+ LOG.info("when = " + event.when());
+ LOG.info("todo = " + event.getTodo().toString());
+
+ String uuid = UUID.randomUUID().toString();
+ Email email = new Email("Alexsandro", "test"+Instant.now().getEpochSecond()+"@gmail.com", EmailState.CREATED);
+ EmailCreateCommand command = new EmailCreateCommand(uuid, email);
+ commanderHandler.create(command);
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/mailservice/integration/reminder/ToDoDto.java b/mail-service/src/main/java/com/apssouza/mailservice/integration/reminder/ToDoDto.java
index 5a77632..f1fa812 100644
--- a/mail-service/src/main/java/com/apssouza/mailservice/integration/reminder/ToDoDto.java
+++ b/mail-service/src/main/java/com/apssouza/mailservice/integration/reminder/ToDoDto.java
@@ -1,115 +1,115 @@
-package com.apssouza.mailservice.integration.reminder;
-
-import java.util.Date;
-
-/**
- * To Do entity
- *
- * @author apssouza
- */
-public class ToDoDto implements Cloneable {
-
- public enum TodoStatus {
- DONE, PENDING
- }
-
- private long id;
-
- private String caption;
-
- private String userEmail;
-
- private String description;
-
- private Date createdat;
-
- private int priority;
-
- private TodoStatus status = TodoStatus.PENDING;
-
- private long version;
-
- public ToDoDto() {
- }
-
- public ToDoDto(String email, String caption, String description, int priority) {
- this.caption = caption;
- this.description = description;
- this.priority = priority;
- this.userEmail = email;
- }
-
- public String getUserEmail() {
- return userEmail;
- }
-
- public void setUserEmail(String userEmail) {
- this.userEmail = userEmail;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public void setCaption(String caption) {
- this.caption = caption;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public void setPriority(int priority) {
- this.priority = priority;
- }
-
- public void setVersion(long version) {
- this.version = version;
- }
-
- public void setStatus(TodoStatus status) {
- this.status = status;
- }
-
- public TodoStatus getStatus() {
- return status;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getCaption() {
- return caption;
- }
-
- public String getDescription() {
- return description;
- }
-
- public int getPriority() {
- return priority;
- }
-
- public long getVersion() {
- return version;
- }
-
- public Date getCreatedat() {
- return createdat;
- }
-
- public void setCreatedat(Date createdat) {
- this.createdat = createdat;
- }
-
- @Override
- public String toString() {
- return "ToDo{" + "id=" + id + ", caption=" + caption + ", description=" + description + ", priority=" + priority + ", done=" + status + ", version=" + version + '}';
- }
-
-}
+package com.apssouza.mailservice.integration.reminder;
+
+import java.util.Date;
+
+/**
+ * To Do entity
+ *
+ * @author apssouza
+ */
+public class ToDoDto implements Cloneable {
+
+ public enum TodoStatus {
+ DONE, PENDING
+ }
+
+ private long id;
+
+ private String caption;
+
+ private String userEmail;
+
+ private String description;
+
+ private Date createdat;
+
+ private int priority;
+
+ private TodoStatus status = TodoStatus.PENDING;
+
+ private long version;
+
+ public ToDoDto() {
+ }
+
+ public ToDoDto(String email, String caption, String description, int priority) {
+ this.caption = caption;
+ this.description = description;
+ this.priority = priority;
+ this.userEmail = email;
+ }
+
+ public String getUserEmail() {
+ return userEmail;
+ }
+
+ public void setUserEmail(String userEmail) {
+ this.userEmail = userEmail;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public void setCaption(String caption) {
+ this.caption = caption;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+
+ public void setVersion(long version) {
+ this.version = version;
+ }
+
+ public void setStatus(TodoStatus status) {
+ this.status = status;
+ }
+
+ public TodoStatus getStatus() {
+ return status;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ public long getVersion() {
+ return version;
+ }
+
+ public Date getCreatedat() {
+ return createdat;
+ }
+
+ public void setCreatedat(Date createdat) {
+ this.createdat = createdat;
+ }
+
+ @Override
+ public String toString() {
+ return "ToDo{" + "id=" + id + ", caption=" + caption + ", description=" + description + ", priority=" + priority + ", done=" + status + ", version=" + version + '}';
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/mailservice/integration/reminder/TodoCreatedEvent.java b/mail-service/src/main/java/com/apssouza/mailservice/integration/reminder/TodoCreatedEvent.java
index adf2150..10cf0ed 100644
--- a/mail-service/src/main/java/com/apssouza/mailservice/integration/reminder/TodoCreatedEvent.java
+++ b/mail-service/src/main/java/com/apssouza/mailservice/integration/reminder/TodoCreatedEvent.java
@@ -1,38 +1,38 @@
-package com.apssouza.mailservice.integration.reminder;
-
-import com.apssouza.infra.AbstractDomainEvent;
-
-/**
- * To Do created event
- *
- * @author apssouza
- */
-public class TodoCreatedEvent extends AbstractDomainEvent {
-
- private ToDoDto todo;
-
- public TodoCreatedEvent(ToDoDto todo) {
- this.todo = todo;
- }
-
- public TodoCreatedEvent() {
- }
-
- public ToDoDto getTodo() {
- return todo;
- }
-
- public void setTodo(ToDoDto todo) {
- this.todo = todo;
- }
-
- public int getPriority() {
- return this.todo.getPriority();
- }
-
- @Override
- public String toString() {
- return "TodoChangeEvent{" + "todo=" + todo.getDescription() + '}';
- }
-
-}
+package com.apssouza.mailservice.integration.reminder;
+
+import com.apssouza.infra.AbstractDomainEvent;
+
+/**
+ * To Do created event
+ *
+ * @author apssouza
+ */
+public class TodoCreatedEvent extends AbstractDomainEvent {
+
+ private ToDoDto todo;
+
+ public TodoCreatedEvent(ToDoDto todo) {
+ this.todo = todo;
+ }
+
+ public TodoCreatedEvent() {
+ }
+
+ public ToDoDto getTodo() {
+ return todo;
+ }
+
+ public void setTodo(ToDoDto todo) {
+ this.todo = todo;
+ }
+
+ public int getPriority() {
+ return this.todo.getPriority();
+ }
+
+ @Override
+ public String toString() {
+ return "TodoChangeEvent{" + "todo=" + todo.getDescription() + '}';
+ }
+
+}
diff --git a/mail-service/src/main/java/com/apssouza/mailservice/repository/EmailRepository.java b/mail-service/src/main/java/com/apssouza/mailservice/repository/EmailRepository.java
index 0fa9464..7431f17 100644
--- a/mail-service/src/main/java/com/apssouza/mailservice/repository/EmailRepository.java
+++ b/mail-service/src/main/java/com/apssouza/mailservice/repository/EmailRepository.java
@@ -1,14 +1,14 @@
-package com.apssouza.mailservice.repository;
-
-import com.apssouza.eventsourcing.entities.Email;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-/**
- *
- * @author apssouza
- */
-@Repository
-public interface EmailRepository extends JpaRepository{
-
-}
+package com.apssouza.mailservice.repository;
+
+import com.apssouza.eventsourcing.entities.Email;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ *
+ * @author apssouza
+ */
+@Repository
+public interface EmailRepository extends JpaRepository{
+
+}
diff --git a/mail-service/src/main/resources/application.properties b/mail-service/src/main/resources/application.properties
index 28c2717..1857d3e 100644
--- a/mail-service/src/main/resources/application.properties
+++ b/mail-service/src/main/resources/application.properties
@@ -1 +1 @@
-spring.application.name=mailer
+spring.application.name=mailer
diff --git a/mail-service/src/main/resources/bootstrap.yml b/mail-service/src/main/resources/bootstrap.yml
index b940bf4..47aefda 100644
--- a/mail-service/src/main/resources/bootstrap.yml
+++ b/mail-service/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
----
-spring:
- cloud:
- config:
- uri: http://config:8888
+---
+spring:
+ cloud:
+ config:
+ uri: http://config:8888
\ No newline at end of file
diff --git a/mail-service/src/main/resources/docker/Dockerfile b/mail-service/src/main/resources/docker/Dockerfile
index ab30719..fe9779e 100644
--- a/mail-service/src/main/resources/docker/Dockerfile
+++ b/mail-service/src/main/resources/docker/Dockerfile
@@ -1,37 +1,37 @@
-FROM openjdk:8
-
-
-MAINTAINER Alexsandro
-ENV REFRESHED_AT 2017-09-17
-
-ENV TERM xterm
-ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
-
-RUN apt-get update -qq \
- && apt-get install -qqy curl wget \
- && apt-get clean \
- \
- && touch /var/log/todo.log \
- && chmod 666 /var/log/todo.log
-
-ADD application/lib/springboot-webapp.jar /app.jar
-ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
-RUN bash -c 'chmod +x wait-for-it.sh'
-
-# install Filebeat
-ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
-RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
- && dpkg -i ${FILEBEAT_VERSION} \
- && rm ${FILEBEAT_VERSION}
-
-# configure Filebeat
-ADD filebeat.yml /etc/filebeat/filebeat.yml
-
-# CA cert
-RUN mkdir -p /etc/pki/tls/certs
-ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
-
-# start Filebeat
-ADD ./start.sh /usr/local/bin/start.sh
-RUN chmod +x /usr/local/bin/start.sh
+FROM openjdk:8
+
+
+MAINTAINER Alexsandro
+ENV REFRESHED_AT 2017-09-17
+
+ENV TERM xterm
+ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
+
+RUN apt-get update -qq \
+ && apt-get install -qqy curl wget \
+ && apt-get clean \
+ \
+ && touch /var/log/todo.log \
+ && chmod 666 /var/log/todo.log
+
+ADD application/lib/springboot-webapp.jar /app.jar
+ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
+RUN bash -c 'chmod +x wait-for-it.sh'
+
+# install Filebeat
+ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
+RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
+ && dpkg -i ${FILEBEAT_VERSION} \
+ && rm ${FILEBEAT_VERSION}
+
+# configure Filebeat
+ADD filebeat.yml /etc/filebeat/filebeat.yml
+
+# CA cert
+RUN mkdir -p /etc/pki/tls/certs
+ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
+
+# start Filebeat
+ADD ./start.sh /usr/local/bin/start.sh
+RUN chmod +x /usr/local/bin/start.sh
CMD [ "/usr/local/bin/start.sh" ]
\ No newline at end of file
diff --git a/mail-service/src/main/resources/docker/filebeat.yml b/mail-service/src/main/resources/docker/filebeat.yml
index 09119d8..480a94e 100644
--- a/mail-service/src/main/resources/docker/filebeat.yml
+++ b/mail-service/src/main/resources/docker/filebeat.yml
@@ -1,30 +1,30 @@
-output:
- logstash:
- enabled: true
- hosts:
- - elk:5044
- timeout: 15
- tls:
- certificate_authorities:
- - /etc/pki/tls/certs/logstash-beats.crt
-
-filebeat:
- prospectors:
- -
- paths:
- - /var/log/syslog
- - /var/log/auth.log
- document_type: syslog
- -
- paths:
- - /var/log/spring-music.log
- document_type: log4j
- multiline:
- pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
- negate: true
- match: after
- -
- paths:
- - /usr/local/tomcat/logs/*.out
- - /usr/local/tomcat/logs/*.log
- document_type: tomcat
+output:
+ logstash:
+ enabled: true
+ hosts:
+ - elk:5044
+ timeout: 15
+ tls:
+ certificate_authorities:
+ - /etc/pki/tls/certs/logstash-beats.crt
+
+filebeat:
+ prospectors:
+ -
+ paths:
+ - /var/log/syslog
+ - /var/log/auth.log
+ document_type: syslog
+ -
+ paths:
+ - /var/log/spring-music.log
+ document_type: log4j
+ multiline:
+ pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
+ negate: true
+ match: after
+ -
+ paths:
+ - /usr/local/tomcat/logs/*.out
+ - /usr/local/tomcat/logs/*.log
+ document_type: tomcat
diff --git a/mail-service/src/main/resources/docker/logstash-beats.crt b/mail-service/src/main/resources/docker/logstash-beats.crt
index d9b71cf..1c86bc3 100644
--- a/mail-service/src/main/resources/docker/logstash-beats.crt
+++ b/mail-service/src/main/resources/docker/logstash-beats.crt
@@ -1,18 +1,18 @@
------BEGIN CERTIFICATE-----
-MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
-BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
-DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
-0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
-9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
-PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
-qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
-KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
-4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
-VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
-hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
-okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
-T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
-ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
-kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
-Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
------END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
+BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
+DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
+0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
+9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
+PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
+qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
+KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
+4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
+VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
+hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
+okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
+T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
+ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
+kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
+Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
+-----END CERTIFICATE-----
diff --git a/mail-service/src/main/resources/docker/start.sh b/mail-service/src/main/resources/docker/start.sh
index 3e62f5b..9f551bb 100644
--- a/mail-service/src/main/resources/docker/start.sh
+++ b/mail-service/src/main/resources/docker/start.sh
@@ -1,5 +1,4 @@
#!/bin/bash
-
curl -XPUT 'http://elk:9200/_template/filebeat?pretty' -d@/etc/filebeat/filebeat.template.json
/etc/init.d/filebeat start
-java -Djava.security.egd=file:/dev/./urandom -jar -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n /app.jar
+java -Djava.security.egd=file:/dev/./urandom -jar -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=8000,suspend=n /app.jar
\ No newline at end of file
diff --git a/mail-service/src/test/java/com/apssouza/eventsourcing/aggregates/EmailAggregateTest.java b/mail-service/src/test/java/com/apssouza/eventsourcing/aggregates/EmailAggregateTest.java
index 0d68a7d..5e524c3 100644
--- a/mail-service/src/test/java/com/apssouza/eventsourcing/aggregates/EmailAggregateTest.java
+++ b/mail-service/src/test/java/com/apssouza/eventsourcing/aggregates/EmailAggregateTest.java
@@ -1,129 +1,129 @@
-package com.apssouza.eventsourcing.aggregates;
-
-import com.apssouza.eventsourcing.commands.EmailCreateCommand;
-import com.apssouza.eventsourcing.commands.EmailDeleteCommand;
-import com.apssouza.eventsourcing.commands.EmailSendCommand;
-import com.apssouza.eventsourcing.entities.Email;
-import com.apssouza.infra.AppEvent;
-import java.time.Instant;
-import java.util.Collections;
-import java.util.List;
-import java.util.UUID;
-import org.junit.Before;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author apssouza
- */
-public class EmailAggregateTest {
-
-
- @Before
- public void setUp() {
- }
-
- /**
- * Test of create method, of class EmailAggregate.
- */
- @Test
- public void testCreate() throws Exception {
- final Email email = new Email("alex", "alex@test.com", EmailState.CREATED);
- String uuid = UUID.randomUUID().toString();
- EmailAggregate result = getAggregateWithStateCreated(email,uuid);
-
- assertEquals(email.getEmail(), result.getState().getEmail());
- assertEquals(email.getName(), result.getState().getName());
- AppEvent event = result.getUncommittedChanges().get(0);
- assertEquals(uuid, result.getUuid());
- assertEquals(uuid, event.uuid());
- assertEquals(EmailState.CREATED, result.getState().getState());
- }
-
- /**
- * Test of send method, of class EmailAggregate.
- */
- @Test
- public void testSend() throws Exception {
- final Email email = new Email("alex", "alex@test.com", EmailState.CREATED);
- String uuid = UUID.randomUUID().toString();
- EmailAggregate aggregateWithStateCreated = getAggregateWithStateCreated(email, uuid);
- EmailSendCommand command = new EmailSendCommand(uuid, Instant.MIN);
- EmailAggregate result = aggregateWithStateCreated.send(command);
-
- assertEquals(EmailState.SENT, result.getState().getState());
- }
-
-
- /**
- * Test of from method, of class EmailAggregate.
- */
- @Test
- public void testFromWithEmptyChanges() {
- System.out.println("from");
- String uuid = "";
- List history = Collections.emptyList();
- EmailAggregate expResult = new EmailAggregate(uuid, history);
- EmailAggregate result = EmailAggregate.from(uuid, history);
- assertEquals(expResult.getState().toString(), result.getState().toString());
- assertEquals(expResult.getUncommittedChanges(), result.getUncommittedChanges());
- assertEquals(expResult.getUuid(), result.getUuid());
- }
-
- @Test
- public void testFromWithChanges() throws Exception {
- final Email email = new Email("alex", "alex@test.com", EmailState.CREATED);
- String uuid = UUID.randomUUID().toString();
- EmailAggregate expResult = getAggregateWithStateCreated(email,uuid);
-
- EmailAggregate result = EmailAggregate.from(uuid, expResult.getUncommittedChanges());
- EmailAggregate expResultCommitted = expResult.markChangesAsCommitted();
- assertEquals(expResultCommitted.getState().toString(), result.getState().toString());
- assertEquals(expResultCommitted.getUncommittedChanges(), result.getUncommittedChanges());
- assertEquals(expResultCommitted.getUuid(), result.getUuid());
- }
-
- /**
- * Test of markChangesAsCommitted method, of class EmailAggregate.
- */
- @Test
- public void testMarkChangesAsCommitted() throws Exception {
- final Email email = new Email("alex", "alex@test.com", EmailState.CREATED);
- String uuid = UUID.randomUUID().toString();
- EmailAggregate instance = getAggregateWithStateCreated(email,uuid);
- EmailAggregate result = instance.markChangesAsCommitted();
- assertFalse(instance.getUncommittedChanges().isEmpty());
- assertTrue(result.getUncommittedChanges().isEmpty());
- }
-
- /**
- * Test of delete method, of class EmailAggregate.
- */
- @Test
- public void testDelete() throws Exception {
- final Email email = new Email("alex", "alex@test.com", EmailState.CREATED);
- String uuid = UUID.randomUUID().toString();
- EmailAggregate aggregateWithStateCreated = getAggregateWithStateCreated(email, uuid);
- EmailDeleteCommand command = new EmailDeleteCommand(uuid);
- EmailAggregate result = aggregateWithStateCreated.delete(command);
-
- assertEquals(EmailState.DELETED, result.getState().getState());
- }
-
- private EmailAggregate getAggregateWithNoEvent(String uuid) {
- return EmailAggregate.from(
- uuid,
- Collections.emptyList()
- );
- }
-
- private EmailAggregate getAggregateWithStateCreated(Email email, String uuid) throws Exception {
- EmailAggregate instance = getAggregateWithNoEvent(uuid);
- return instance.create(new EmailCreateCommand(
- uuid,
- email
- ));
- }
-
-}
+package com.apssouza.eventsourcing.aggregates;
+
+import com.apssouza.eventsourcing.commands.EmailCreateCommand;
+import com.apssouza.eventsourcing.commands.EmailDeleteCommand;
+import com.apssouza.eventsourcing.commands.EmailSendCommand;
+import com.apssouza.eventsourcing.entities.Email;
+import com.apssouza.infra.AppEvent;
+import java.time.Instant;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author apssouza
+ */
+public class EmailAggregateTest {
+
+
+ @Before
+ public void setUp() {
+ }
+
+ /**
+ * Test of create method, of class EmailAggregate.
+ */
+ @Test
+ public void testCreate() throws Exception {
+ final Email email = new Email("alex", "alex@test.com", EmailState.CREATED);
+ String uuid = UUID.randomUUID().toString();
+ EmailAggregate result = getAggregateWithStateCreated(email,uuid);
+
+ assertEquals(email.getEmail(), result.getState().getEmail());
+ assertEquals(email.getName(), result.getState().getName());
+ AppEvent event = result.getUncommittedChanges().get(0);
+ assertEquals(uuid, result.getUuid());
+ assertEquals(uuid, event.uuid());
+ assertEquals(EmailState.CREATED, result.getState().getState());
+ }
+
+ /**
+ * Test of send method, of class EmailAggregate.
+ */
+ @Test
+ public void testSend() throws Exception {
+ final Email email = new Email("alex", "alex@test.com", EmailState.CREATED);
+ String uuid = UUID.randomUUID().toString();
+ EmailAggregate aggregateWithStateCreated = getAggregateWithStateCreated(email, uuid);
+ EmailSendCommand command = new EmailSendCommand(uuid, Instant.MIN);
+ EmailAggregate result = aggregateWithStateCreated.send(command);
+
+ assertEquals(EmailState.SENT, result.getState().getState());
+ }
+
+
+ /**
+ * Test of from method, of class EmailAggregate.
+ */
+ @Test
+ public void testFromWithEmptyChanges() {
+ System.out.println("from");
+ String uuid = "";
+ List history = Collections.emptyList();
+ EmailAggregate expResult = new EmailAggregate(uuid, history);
+ EmailAggregate result = EmailAggregate.from(uuid, history);
+ assertEquals(expResult.getState().toString(), result.getState().toString());
+ assertEquals(expResult.getUncommittedChanges(), result.getUncommittedChanges());
+ assertEquals(expResult.getUuid(), result.getUuid());
+ }
+
+ @Test
+ public void testFromWithChanges() throws Exception {
+ final Email email = new Email("alex", "alex@test.com", EmailState.CREATED);
+ String uuid = UUID.randomUUID().toString();
+ EmailAggregate expResult = getAggregateWithStateCreated(email,uuid);
+
+ EmailAggregate result = EmailAggregate.from(uuid, expResult.getUncommittedChanges());
+ EmailAggregate expResultCommitted = expResult.markChangesAsCommitted();
+ assertEquals(expResultCommitted.getState().toString(), result.getState().toString());
+ assertEquals(expResultCommitted.getUncommittedChanges(), result.getUncommittedChanges());
+ assertEquals(expResultCommitted.getUuid(), result.getUuid());
+ }
+
+ /**
+ * Test of markChangesAsCommitted method, of class EmailAggregate.
+ */
+ @Test
+ public void testMarkChangesAsCommitted() throws Exception {
+ final Email email = new Email("alex", "alex@test.com", EmailState.CREATED);
+ String uuid = UUID.randomUUID().toString();
+ EmailAggregate instance = getAggregateWithStateCreated(email,uuid);
+ EmailAggregate result = instance.markChangesAsCommitted();
+ assertFalse(instance.getUncommittedChanges().isEmpty());
+ assertTrue(result.getUncommittedChanges().isEmpty());
+ }
+
+ /**
+ * Test of delete method, of class EmailAggregate.
+ */
+ @Test
+ public void testDelete() throws Exception {
+ final Email email = new Email("alex", "alex@test.com", EmailState.CREATED);
+ String uuid = UUID.randomUUID().toString();
+ EmailAggregate aggregateWithStateCreated = getAggregateWithStateCreated(email, uuid);
+ EmailDeleteCommand command = new EmailDeleteCommand(uuid);
+ EmailAggregate result = aggregateWithStateCreated.delete(command);
+
+ assertEquals(EmailState.DELETED, result.getState().getState());
+ }
+
+ private EmailAggregate getAggregateWithNoEvent(String uuid) {
+ return EmailAggregate.from(
+ uuid,
+ Collections.emptyList()
+ );
+ }
+
+ private EmailAggregate getAggregateWithStateCreated(Email email, String uuid) throws Exception {
+ EmailAggregate instance = getAggregateWithNoEvent(uuid);
+ return instance.create(new EmailCreateCommand(
+ uuid,
+ email
+ ));
+ }
+
+}
diff --git a/mail-service/src/test/java/com/apssouza/eventsourcing/commands/EmailCommandHandlerTest.java b/mail-service/src/test/java/com/apssouza/eventsourcing/commands/EmailCommandHandlerTest.java
index 5b53936..62e1cc4 100644
--- a/mail-service/src/test/java/com/apssouza/eventsourcing/commands/EmailCommandHandlerTest.java
+++ b/mail-service/src/test/java/com/apssouza/eventsourcing/commands/EmailCommandHandlerTest.java
@@ -1,62 +1,62 @@
-package com.apssouza.eventsourcing.commands;
-
-import com.apssouza.eventsourcing.aggregates.Aggregate;
-import com.apssouza.eventsourcing.aggregates.EmailAggregate;
-import com.apssouza.eventsourcing.aggregates.EmailState;
-import com.apssouza.eventsourcing.entities.Email;
-import com.apssouza.eventsourcing.eventstore.EventStream;
-import com.apssouza.eventsourcing.services.EventSourcingService;
-import com.apssouza.infra.EventPublisher;
-import java.time.Instant;
-import java.util.UUID;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import static org.mockito.Mockito.verify;
-
-public class EmailCommandHandlerTest {
-
- private EventSourcingService eventSourcingService;
-
- private EventPublisher eventPublisher;
-
- private EmailCommandHandler commandHandler;
-
- @Before
- public void setUp() {
- eventSourcingService = Mockito.mock(EventSourcingService.class);
- eventPublisher = Mockito.mock(EventPublisher.class);
- commandHandler = new EmailCommandHandler(eventSourcingService, eventPublisher);
- }
-
- @Test
- public void create() throws Exception {
- String uuid = UUID.randomUUID().toString();
- EmailCreateCommand command = new EmailCreateCommand(
- uuid,
- new Email("Alexsandro", "apssouza22@gmail.com", EmailState.CREATED)
- );
- commandHandler.create(command);
- verify(eventPublisher, Mockito.times(1)).publish(Mockito.anyObject());
- verify(eventPublisher, Mockito.times(1)).stream(Mockito.anyObject());
- }
-
- @Test
- public void send() throws Exception {
- String uuid = UUID.randomUUID().toString();
- EmailSendCommand command = new EmailSendCommand(uuid, Instant.now());
- commandHandler.send(command);
- verify(eventSourcingService, Mockito.times(1)).save(Mockito.any(Aggregate.class));
- verify(eventPublisher, Mockito.times(1)).stream(Mockito.anyObject());
- }
-
- @Test
- public void getByUUID() {
- String uuid = "123";
- Mockito.when(eventSourcingService.getAggregate(Mockito.anyString()))
- .thenReturn(new EventStream());
- EmailAggregate byUUID = commandHandler.getByUUID(uuid);
- Assert.assertTrue(byUUID.getState().getEmail() == null);
- }
-}
+package com.apssouza.eventsourcing.commands;
+
+import com.apssouza.eventsourcing.aggregates.Aggregate;
+import com.apssouza.eventsourcing.aggregates.EmailAggregate;
+import com.apssouza.eventsourcing.aggregates.EmailState;
+import com.apssouza.eventsourcing.entities.Email;
+import com.apssouza.eventsourcing.eventstore.EventStream;
+import com.apssouza.eventsourcing.services.EventSourcingService;
+import com.apssouza.infra.EventPublisher;
+import java.time.Instant;
+import java.util.UUID;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import static org.mockito.Mockito.verify;
+
+public class EmailCommandHandlerTest {
+
+ private EventSourcingService eventSourcingService;
+
+ private EventPublisher eventPublisher;
+
+ private EmailCommandHandler commandHandler;
+
+ @Before
+ public void setUp() {
+ eventSourcingService = Mockito.mock(EventSourcingService.class);
+ eventPublisher = Mockito.mock(EventPublisher.class);
+ commandHandler = new EmailCommandHandler(eventSourcingService, eventPublisher);
+ }
+
+ @Test
+ public void create() throws Exception {
+ String uuid = UUID.randomUUID().toString();
+ EmailCreateCommand command = new EmailCreateCommand(
+ uuid,
+ new Email("Alexsandro", "apssouza22@gmail.com", EmailState.CREATED)
+ );
+ commandHandler.create(command);
+ verify(eventPublisher, Mockito.times(1)).publish(Mockito.anyObject());
+ verify(eventPublisher, Mockito.times(1)).stream(Mockito.anyObject());
+ }
+
+ @Test
+ public void send() throws Exception {
+ String uuid = UUID.randomUUID().toString();
+ EmailSendCommand command = new EmailSendCommand(uuid, Instant.now());
+ commandHandler.send(command);
+ verify(eventSourcingService, Mockito.times(1)).save(Mockito.any(Aggregate.class));
+ verify(eventPublisher, Mockito.times(1)).stream(Mockito.anyObject());
+ }
+
+ @Test
+ public void getByUUID() {
+ String uuid = "123";
+ Mockito.when(eventSourcingService.getAggregate(Mockito.anyString()))
+ .thenReturn(new EventStream());
+ EmailAggregate byUUID = commandHandler.getByUUID(uuid);
+ Assert.assertTrue(byUUID.getState().getEmail() == null);
+ }
+}
diff --git a/oauth-server/Jenkinsfile b/oauth-server/Jenkinsfile
index d608c7d..66bcd9a 100644
--- a/oauth-server/Jenkinsfile
+++ b/oauth-server/Jenkinsfile
@@ -1,16 +1,16 @@
-node {
- stage('Fetch changes') {
- git 'https://github.com/apssouza22/java-microservice.git'
- }
- stage('Build image') {
- // Run the maven build
- if (isUnix()) {
- sh "mvn -f ./oauth-server/pom.xml -Pdockerimage docker:build"
- } else {
- echo "Not ready for windows"
- }
- }
- stage('Deploy ECS') {
- echo "TODO deploy on AWS"
- }
-}
+node {
+ stage('Fetch changes') {
+ git 'https://github.com/apssouza22/java-microservice.git'
+ }
+ stage('Build image') {
+ // Run the maven build
+ if (isUnix()) {
+ sh "mvn -f ./oauth-server/pom.xml -Pdockerimage docker:build"
+ } else {
+ echo "Not ready for windows"
+ }
+ }
+ stage('Deploy ECS') {
+ echo "TODO deploy on AWS"
+ }
+}
diff --git a/oauth-server/README b/oauth-server/README
index d7b1ada..60debf2 100644
--- a/oauth-server/README
+++ b/oauth-server/README
@@ -1,12 +1,12 @@
-# Oauth server
-
-The OAuth server enables a third-party app to obtain limited access to an HTTP service.
-Instead of using the resource owner's credentials to access a protected resource,
-the client obtains an access token issued by this authorization server.
-
-We are issuing a token of JWT (JSON Web Token) format that defines a compact and
-self-contained way for securely transmitting information between parties as a JSON object.
-
-
-To authenticate:
+# Oauth server
+
+The OAuth server enables a third-party app to obtain limited access to an HTTP service.
+Instead of using the resource owner's credentials to access a protected resource,
+the client obtains an access token issued by this authorization server.
+
+We are issuing a token of JWT (JSON Web Token) format that defines a compact and
+self-contained way for securely transmitting information between parties as a JSON object.
+
+
+To authenticate:
curl -X POST -vu todo-app:123456 http://localhost:8017/oauth/token -H "Accept: application/json" -d "password=1234&username=apssouza22@gmail.com&grant_type=password&scope=write&client_secret=123456&client_id=todo-app"
\ No newline at end of file
diff --git a/oauth-server/pom.xml b/oauth-server/pom.xml
index b25e918..cea153e 100644
--- a/oauth-server/pom.xml
+++ b/oauth-server/pom.xml
@@ -1,216 +1,216 @@
-
-
- 4.0.0
-
- com.apssouza
- oauth2-server
- 0.0.1-SNAPSHOT
- jar
-
- Oauth server
- Oauth authentication server
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 1.5.2.RELEASE
-
-
-
-
- UTF-8
- UTF-8
- com.apssouza.BasicApplication
- 1.8
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-parent
- Camden.SR2
- pom
- import
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter
-
-
-
- org.springframework.boot
- spring-boot-starter-security
-
-
- org.springframework.security.oauth
- spring-security-oauth2
-
-
- org.springframework.security
- spring-security-jwt
-
-
- org.springframework.plugin
- spring-plugin-core
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.cloud
- spring-cloud-starter-eureka
-
-
-
- org.springframework.cloud
- spring-cloud-starter-feign
-
-
-
- org.springframework.cloud
- spring-cloud-starter-ribbon
-
-
-
- org.springframework.cloud
- spring-cloud-starter-hystrix
-
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
- org.springframework.cloud
- spring-cloud-starter-config
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
- true
- true
-
-
-
-
-
-
-
- dockerimage
-
- todo/oauth-server
- src/main/resources/docker
- ${project.build.directory}/dockerimgbuild
- Dockerfile
-
-
-
-
-
- maven-resources-plugin
-
-
- copy-resources
- package
-
- copy-resources
-
-
- ${docker.build.directory}
-
-
- ${docker.image.src.root}
- false
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- copy
- package
-
- copy
-
-
-
-
- ${project.groupId}
- ${project.artifactId}
- ${project.version}
- jar
- true
- ${docker.build.directory}/application/lib
- springboot-webapp.jar
-
-
-
-
- ${docker.build.directory}
- true
- true
-
-
-
-
-
-
-
- io.fabric8
- docker-maven-plugin
- 0.19.0
-
-
- unix:///var/run/docker.sock
-
-
- ${docker.image.name}
-
-
- latest
-
- ${docker.build.directory}/${docker.file.name}
-
-
-
-
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ com.apssouza
+ oauth2-server
+ 0.0.1-SNAPSHOT
+ jar
+
+ Oauth server
+ Oauth authentication server
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.2.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ com.apssouza.BasicApplication
+ 1.8
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-parent
+ Camden.SR2
+ pom
+ import
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+ org.springframework.security.oauth
+ spring-security-oauth2
+
+
+ org.springframework.security
+ spring-security-jwt
+
+
+ org.springframework.plugin
+ spring-plugin-core
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-feign
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-ribbon
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-hystrix
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+ true
+
+
+
+
+
+
+
+ dockerimage
+
+ todo/oauth-server
+ src/main/resources/docker
+ ${project.build.directory}/dockerimgbuild
+ Dockerfile
+
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-resources
+ package
+
+ copy-resources
+
+
+ ${docker.build.directory}
+
+
+ ${docker.image.src.root}
+ false
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy
+ package
+
+ copy
+
+
+
+
+ ${project.groupId}
+ ${project.artifactId}
+ ${project.version}
+ jar
+ true
+ ${docker.build.directory}/application/lib
+ springboot-webapp.jar
+
+
+
+
+ ${docker.build.directory}
+ true
+ true
+
+
+
+
+
+
+
+ io.fabric8
+ docker-maven-plugin
+ 0.19.0
+
+
+ unix:///var/run/docker.sock
+
+
+ ${docker.image.name}
+
+
+ latest
+
+ ${docker.build.directory}/${docker.file.name}
+
+
+
+
+
+
+
+
+
+
diff --git a/oauth-server/src/main/java/com/apssouza/BasicApplication.java b/oauth-server/src/main/java/com/apssouza/BasicApplication.java
index 5ac0f30..5edb726 100644
--- a/oauth-server/src/main/java/com/apssouza/BasicApplication.java
+++ b/oauth-server/src/main/java/com/apssouza/BasicApplication.java
@@ -1,17 +1,17 @@
-package com.apssouza;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.cloud.netflix.feign.EnableFeignClients;
-import org.springframework.cloud.netflix.hystrix.EnableHystrix;
-
-@SpringBootApplication
-@EnableHystrix
-@EnableFeignClients
-public class BasicApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(BasicApplication.class, args);
- }
-
-}
+package com.apssouza;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.netflix.feign.EnableFeignClients;
+import org.springframework.cloud.netflix.hystrix.EnableHystrix;
+
+@SpringBootApplication
+@EnableHystrix
+@EnableFeignClients
+public class BasicApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(BasicApplication.class, args);
+ }
+
+}
diff --git a/oauth-server/src/main/java/com/apssouza/auth/CustomTokenEnhancer.java b/oauth-server/src/main/java/com/apssouza/auth/CustomTokenEnhancer.java
index 2d9ee8c..35f839b 100644
--- a/oauth-server/src/main/java/com/apssouza/auth/CustomTokenEnhancer.java
+++ b/oauth-server/src/main/java/com/apssouza/auth/CustomTokenEnhancer.java
@@ -1,27 +1,27 @@
-package com.apssouza.auth;
-
-import java.util.HashMap;
-import java.util.Map;
-import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
-import org.springframework.security.oauth2.common.OAuth2AccessToken;
-import org.springframework.security.oauth2.provider.OAuth2Authentication;
-import org.springframework.security.oauth2.provider.token.TokenEnhancer;
-
-/**
- *
- * @author apssouza
- */
-public class CustomTokenEnhancer implements TokenEnhancer {
-
- @Override
- public OAuth2AccessToken enhance(
- OAuth2AccessToken accessToken,
- OAuth2Authentication authentication
- ) {
- Map additionalInfo = new HashMap<>();
- additionalInfo.put("name", authentication.getName());
- ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo);
- return accessToken;
- }
-
-}
+package com.apssouza.auth;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.springframework.security.oauth2.common.DefaultOAuth2AccessToken;
+import org.springframework.security.oauth2.common.OAuth2AccessToken;
+import org.springframework.security.oauth2.provider.OAuth2Authentication;
+import org.springframework.security.oauth2.provider.token.TokenEnhancer;
+
+/**
+ *
+ * @author apssouza
+ */
+public class CustomTokenEnhancer implements TokenEnhancer {
+
+ @Override
+ public OAuth2AccessToken enhance(
+ OAuth2AccessToken accessToken,
+ OAuth2Authentication authentication
+ ) {
+ Map additionalInfo = new HashMap<>();
+ additionalInfo.put("name", authentication.getName());
+ ((DefaultOAuth2AccessToken) accessToken).setAdditionalInformation(additionalInfo);
+ return accessToken;
+ }
+
+}
diff --git a/oauth-server/src/main/java/com/apssouza/clients/UserClient.java b/oauth-server/src/main/java/com/apssouza/clients/UserClient.java
index a1567d2..09bb128 100644
--- a/oauth-server/src/main/java/com/apssouza/clients/UserClient.java
+++ b/oauth-server/src/main/java/com/apssouza/clients/UserClient.java
@@ -1,22 +1,22 @@
-
-package com.apssouza.clients;
-
-import com.apssouza.pojos.User;
-import org.springframework.cloud.netflix.feign.FeignClient;
-import org.springframework.stereotype.Component;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-
-/**
- *
- * @author apssouza
- */
-@FeignClient("user")
-@Component
-public interface UserClient {
-
- @RequestMapping(value = "/accounts/search", method = RequestMethod.GET)
- public User getUserByEmail(@RequestParam("email") String email);
-
-}
+
+package com.apssouza.clients;
+
+import com.apssouza.pojos.User;
+import org.springframework.cloud.netflix.feign.FeignClient;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ *
+ * @author apssouza
+ */
+@FeignClient("user")
+@Component
+public interface UserClient {
+
+ @RequestMapping(value = "/accounts/search", method = RequestMethod.GET)
+ public User getUserByEmail(@RequestParam("email") String email);
+
+}
diff --git a/oauth-server/src/main/java/com/apssouza/configuration/AuthenticationConfiguration.java b/oauth-server/src/main/java/com/apssouza/configuration/AuthenticationConfiguration.java
index 393297e..6840905 100644
--- a/oauth-server/src/main/java/com/apssouza/configuration/AuthenticationConfiguration.java
+++ b/oauth-server/src/main/java/com/apssouza/configuration/AuthenticationConfiguration.java
@@ -1,39 +1,39 @@
-package com.apssouza.configuration;
-
-import com.apssouza.services.UserService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-import org.springframework.security.config.annotation.authentication.configurers.GlobalAuthenticationConfigurerAdapter;
-import org.springframework.security.core.authority.AuthorityUtils;
-import org.springframework.security.core.userdetails.User;
-import org.springframework.security.core.userdetails.UserDetailsService;
-
-/**
- * @author apssouza
- */
-@Configuration
-class AuthenticationConfiguration extends GlobalAuthenticationConfigurerAdapter {
-
- @Autowired
- UserService userService;
-
- @Override
- public void init(AuthenticationManagerBuilder auth) throws Exception {
- auth.userDetailsService(userDetailsService());
- }
-
- @Bean
- protected UserDetailsService userDetailsService() {
- return (email) -> {
- com.apssouza.pojos.User user = userService.getUserByEmail(email);
- return new User(
- user.getEmail(),
- user.getPassword(),
- true, true, true, true,
- AuthorityUtils.createAuthorityList("USER", "write")
- );
- };
- }
-}
+package com.apssouza.configuration;
+
+import com.apssouza.services.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.config.annotation.authentication.configurers.GlobalAuthenticationConfigurerAdapter;
+import org.springframework.security.core.authority.AuthorityUtils;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.security.core.userdetails.UserDetailsService;
+
+/**
+ * @author apssouza
+ */
+@Configuration
+class AuthenticationConfiguration extends GlobalAuthenticationConfigurerAdapter {
+
+ @Autowired
+ UserService userService;
+
+ @Override
+ public void init(AuthenticationManagerBuilder auth) throws Exception {
+ auth.userDetailsService(userDetailsService());
+ }
+
+ @Bean
+ protected UserDetailsService userDetailsService() {
+ return (email) -> {
+ com.apssouza.pojos.User user = userService.getUserByEmail(email);
+ return new User(
+ user.getEmail(),
+ user.getPassword(),
+ true, true, true, true,
+ AuthorityUtils.createAuthorityList("USER", "write")
+ );
+ };
+ }
+}
diff --git a/oauth-server/src/main/java/com/apssouza/configuration/JwtServerConfiguration.java b/oauth-server/src/main/java/com/apssouza/configuration/JwtServerConfiguration.java
index be3be15..e609821 100644
--- a/oauth-server/src/main/java/com/apssouza/configuration/JwtServerConfiguration.java
+++ b/oauth-server/src/main/java/com/apssouza/configuration/JwtServerConfiguration.java
@@ -1,36 +1,36 @@
-package com.apssouza.configuration;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.io.ClassPathResource;
-import org.springframework.security.oauth2.provider.token.TokenStore;
-import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
-import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
-import org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory;
-
-/**
- * Json Web token configuration.
- *
- * @author apssouza
- */
-@Configuration
-public class JwtServerConfiguration {
-
- private static final String ENC_PASSWORD = "58347105";
-
- @Bean
- public TokenStore tokenStore() {
- return new JwtTokenStore(jwtTokenEnhancer());
- }
-
- @Bean
- protected JwtAccessTokenConverter jwtTokenEnhancer() {
- KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(
- new ClassPathResource("jwt.jks"),
- ENC_PASSWORD.toCharArray()
- );
- JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
- converter.setKeyPair(keyStoreKeyFactory.getKeyPair("jwt"));
- return converter;
- }
-}
+package com.apssouza.configuration;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.security.oauth2.provider.token.TokenStore;
+import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
+import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;
+import org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory;
+
+/**
+ * Json Web token configuration.
+ *
+ * @author apssouza
+ */
+@Configuration
+public class JwtServerConfiguration {
+
+ private static final String ENC_PASSWORD = "58347105";
+
+ @Bean
+ public TokenStore tokenStore() {
+ return new JwtTokenStore(jwtTokenEnhancer());
+ }
+
+ @Bean
+ protected JwtAccessTokenConverter jwtTokenEnhancer() {
+ KeyStoreKeyFactory keyStoreKeyFactory = new KeyStoreKeyFactory(
+ new ClassPathResource("jwt.jks"),
+ ENC_PASSWORD.toCharArray()
+ );
+ JwtAccessTokenConverter converter = new JwtAccessTokenConverter();
+ converter.setKeyPair(keyStoreKeyFactory.getKeyPair("jwt"));
+ return converter;
+ }
+}
diff --git a/oauth-server/src/main/java/com/apssouza/configuration/OAuth2ServerConfiguration.java b/oauth-server/src/main/java/com/apssouza/configuration/OAuth2ServerConfiguration.java
index 42a6b60..3ed75d2 100644
--- a/oauth-server/src/main/java/com/apssouza/configuration/OAuth2ServerConfiguration.java
+++ b/oauth-server/src/main/java/com/apssouza/configuration/OAuth2ServerConfiguration.java
@@ -1,75 +1,75 @@
-package com.apssouza.configuration;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.web.servlet.FilterRegistrationBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.core.Ordered;
-import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
-import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
-import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
-import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
-import org.springframework.web.cors.CorsConfiguration;
-import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
-import org.springframework.web.filter.CorsFilter;
-
-/**
- * Oauth server configuration
- *
- * @author apssouza
- */
-@Configuration
-@EnableAuthorizationServer
-public class OAuth2ServerConfiguration extends AuthorizationServerConfigurerAdapter {
-
- @Autowired
- JwtServerConfiguration jwtServerConfiguration;
-
- @Autowired
- AuthenticationManagerBuilder authenticationManager;
-
- @Override
- public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
- clients.inMemory()
- .withClient("todo-app")
- .authorizedGrantTypes(
- "implicit", "refresh_token", "password", "authorization_code"
- )
- .authorities("USER_READ", "USER_WRITE")
- .scopes("write")
- .resourceIds("todo")
- .secret("123456");
- }
-
- @Override
- public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
- endpoints.tokenStore(jwtServerConfiguration.tokenStore())
- .tokenEnhancer(jwtServerConfiguration.jwtTokenEnhancer())
- .authenticationManager(
- (Authentication authentication) -> authenticationManager
- .getOrBuild()
- .authenticate(authentication)
- );
- }
-
- /**
- * CORS Filter
- *
- * @return Filter
- */
- @Bean
- public FilterRegistrationBean filterRegistrationBean() {
- UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
- CorsConfiguration config = new CorsConfiguration();
- config.setAllowCredentials(true);
- config.addAllowedOrigin("*");
- config.addAllowedHeader("*");
- config.addAllowedMethod("*");
- source.registerCorsConfiguration("/**", config);
- FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
- bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
- return bean;
- }
-}
+package com.apssouza.configuration;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.Ordered;
+import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer;
+import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer;
+import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+
+/**
+ * Oauth server configuration
+ *
+ * @author apssouza
+ */
+@Configuration
+@EnableAuthorizationServer
+public class OAuth2ServerConfiguration extends AuthorizationServerConfigurerAdapter {
+
+ @Autowired
+ JwtServerConfiguration jwtServerConfiguration;
+
+ @Autowired
+ AuthenticationManagerBuilder authenticationManager;
+
+ @Override
+ public void configure(ClientDetailsServiceConfigurer clients) throws Exception {
+ clients.inMemory()
+ .withClient("todo-app")
+ .authorizedGrantTypes(
+ "implicit", "refresh_token", "password", "authorization_code"
+ )
+ .authorities("USER_READ", "USER_WRITE")
+ .scopes("write")
+ .resourceIds("todo")
+ .secret("123456");
+ }
+
+ @Override
+ public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
+ endpoints.tokenStore(jwtServerConfiguration.tokenStore())
+ .tokenEnhancer(jwtServerConfiguration.jwtTokenEnhancer())
+ .authenticationManager(
+ (Authentication authentication) -> authenticationManager
+ .getOrBuild()
+ .authenticate(authentication)
+ );
+ }
+
+ /**
+ * CORS Filter
+ *
+ * @return Filter
+ */
+ @Bean
+ public FilterRegistrationBean filterRegistrationBean() {
+ UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
+ CorsConfiguration config = new CorsConfiguration();
+ config.setAllowCredentials(true);
+ config.addAllowedOrigin("*");
+ config.addAllowedHeader("*");
+ config.addAllowedMethod("*");
+ source.registerCorsConfiguration("/**", config);
+ FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
+ bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
+ return bean;
+ }
+}
diff --git a/oauth-server/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java b/oauth-server/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java
index 046da18..85d9695 100644
--- a/oauth-server/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java
+++ b/oauth-server/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java
@@ -1,14 +1,14 @@
-package com.apssouza.configuration;
-
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.context.annotation.Configuration;
-
-/**
- *
- * @author apssouza
- */
-@Configuration
-@EnableDiscoveryClient
-public class ServiceDiscoveryConfiguration {
-
-}
+package com.apssouza.configuration;
+
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ *
+ * @author apssouza
+ */
+@Configuration
+@EnableDiscoveryClient
+public class ServiceDiscoveryConfiguration {
+
+}
diff --git a/oauth-server/src/main/java/com/apssouza/pojos/User.java b/oauth-server/src/main/java/com/apssouza/pojos/User.java
index c752681..c32aeeb 100644
--- a/oauth-server/src/main/java/com/apssouza/pojos/User.java
+++ b/oauth-server/src/main/java/com/apssouza/pojos/User.java
@@ -1,48 +1,48 @@
-package com.apssouza.pojos;
-
-/**
- *
- * @author apssouza
- */
-public class User {
-
- private long id;
-
- private String email;
-
- private String password;
-
- public User() {
- }
-
- public User(long id, String email, String password) {
- this.id = id;
- this.email = email;
- this.password = password;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
-
-}
+package com.apssouza.pojos;
+
+/**
+ *
+ * @author apssouza
+ */
+public class User {
+
+ private long id;
+
+ private String email;
+
+ private String password;
+
+ public User() {
+ }
+
+ public User(long id, String email, String password) {
+ this.id = id;
+ this.email = email;
+ this.password = password;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+}
diff --git a/oauth-server/src/main/java/com/apssouza/services/UserService.java b/oauth-server/src/main/java/com/apssouza/services/UserService.java
index 0e1a78f..5346abc 100644
--- a/oauth-server/src/main/java/com/apssouza/services/UserService.java
+++ b/oauth-server/src/main/java/com/apssouza/services/UserService.java
@@ -1,14 +1,14 @@
-package com.apssouza.services;
-
-import com.apssouza.pojos.User;
-
-/**
- * User service.
- *
- * @author apssouza
- */
-public interface UserService {
-
- User getUserByEmail(String email);
-
-}
+package com.apssouza.services;
+
+import com.apssouza.pojos.User;
+
+/**
+ * User service.
+ *
+ * @author apssouza
+ */
+public interface UserService {
+
+ User getUserByEmail(String email);
+
+}
diff --git a/oauth-server/src/main/java/com/apssouza/services/UserServiceImpl.java b/oauth-server/src/main/java/com/apssouza/services/UserServiceImpl.java
index f8aad9b..880bdbc 100644
--- a/oauth-server/src/main/java/com/apssouza/services/UserServiceImpl.java
+++ b/oauth-server/src/main/java/com/apssouza/services/UserServiceImpl.java
@@ -1,29 +1,29 @@
-package com.apssouza.services;
-
-import com.apssouza.clients.UserClient;
-import com.apssouza.pojos.User;
-import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- *
- * @author apssouza
- */
-@Component
-public class UserServiceImpl implements UserService {
-
- @Autowired
- UserClient userClient;
-
- @Override
- @HystrixCommand(fallbackMethod = "getFallbackUserByEmail")
- public User getUserByEmail(String email) {
- return userClient.getUserByEmail(email);
- }
-
- public User getFallbackUserByEmail(String email) {
- return new User();
- }
-
-}
+package com.apssouza.services;
+
+import com.apssouza.clients.UserClient;
+import com.apssouza.pojos.User;
+import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ *
+ * @author apssouza
+ */
+@Component
+public class UserServiceImpl implements UserService {
+
+ @Autowired
+ UserClient userClient;
+
+ @Override
+ @HystrixCommand(fallbackMethod = "getFallbackUserByEmail")
+ public User getUserByEmail(String email) {
+ return userClient.getUserByEmail(email);
+ }
+
+ public User getFallbackUserByEmail(String email) {
+ return new User();
+ }
+
+}
diff --git a/oauth-server/src/main/resources/bootstrap.yml b/oauth-server/src/main/resources/bootstrap.yml
index b940bf4..47aefda 100644
--- a/oauth-server/src/main/resources/bootstrap.yml
+++ b/oauth-server/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
----
-spring:
- cloud:
- config:
- uri: http://config:8888
+---
+spring:
+ cloud:
+ config:
+ uri: http://config:8888
\ No newline at end of file
diff --git a/oauth-server/src/main/resources/docker/Dockerfile b/oauth-server/src/main/resources/docker/Dockerfile
index ab30719..fe9779e 100644
--- a/oauth-server/src/main/resources/docker/Dockerfile
+++ b/oauth-server/src/main/resources/docker/Dockerfile
@@ -1,37 +1,37 @@
-FROM openjdk:8
-
-
-MAINTAINER Alexsandro
-ENV REFRESHED_AT 2017-09-17
-
-ENV TERM xterm
-ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
-
-RUN apt-get update -qq \
- && apt-get install -qqy curl wget \
- && apt-get clean \
- \
- && touch /var/log/todo.log \
- && chmod 666 /var/log/todo.log
-
-ADD application/lib/springboot-webapp.jar /app.jar
-ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
-RUN bash -c 'chmod +x wait-for-it.sh'
-
-# install Filebeat
-ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
-RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
- && dpkg -i ${FILEBEAT_VERSION} \
- && rm ${FILEBEAT_VERSION}
-
-# configure Filebeat
-ADD filebeat.yml /etc/filebeat/filebeat.yml
-
-# CA cert
-RUN mkdir -p /etc/pki/tls/certs
-ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
-
-# start Filebeat
-ADD ./start.sh /usr/local/bin/start.sh
-RUN chmod +x /usr/local/bin/start.sh
+FROM openjdk:8
+
+
+MAINTAINER Alexsandro
+ENV REFRESHED_AT 2017-09-17
+
+ENV TERM xterm
+ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
+
+RUN apt-get update -qq \
+ && apt-get install -qqy curl wget \
+ && apt-get clean \
+ \
+ && touch /var/log/todo.log \
+ && chmod 666 /var/log/todo.log
+
+ADD application/lib/springboot-webapp.jar /app.jar
+ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
+RUN bash -c 'chmod +x wait-for-it.sh'
+
+# install Filebeat
+ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
+RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
+ && dpkg -i ${FILEBEAT_VERSION} \
+ && rm ${FILEBEAT_VERSION}
+
+# configure Filebeat
+ADD filebeat.yml /etc/filebeat/filebeat.yml
+
+# CA cert
+RUN mkdir -p /etc/pki/tls/certs
+ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
+
+# start Filebeat
+ADD ./start.sh /usr/local/bin/start.sh
+RUN chmod +x /usr/local/bin/start.sh
CMD [ "/usr/local/bin/start.sh" ]
\ No newline at end of file
diff --git a/oauth-server/src/main/resources/docker/filebeat.yml b/oauth-server/src/main/resources/docker/filebeat.yml
index 09119d8..480a94e 100644
--- a/oauth-server/src/main/resources/docker/filebeat.yml
+++ b/oauth-server/src/main/resources/docker/filebeat.yml
@@ -1,30 +1,30 @@
-output:
- logstash:
- enabled: true
- hosts:
- - elk:5044
- timeout: 15
- tls:
- certificate_authorities:
- - /etc/pki/tls/certs/logstash-beats.crt
-
-filebeat:
- prospectors:
- -
- paths:
- - /var/log/syslog
- - /var/log/auth.log
- document_type: syslog
- -
- paths:
- - /var/log/spring-music.log
- document_type: log4j
- multiline:
- pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
- negate: true
- match: after
- -
- paths:
- - /usr/local/tomcat/logs/*.out
- - /usr/local/tomcat/logs/*.log
- document_type: tomcat
+output:
+ logstash:
+ enabled: true
+ hosts:
+ - elk:5044
+ timeout: 15
+ tls:
+ certificate_authorities:
+ - /etc/pki/tls/certs/logstash-beats.crt
+
+filebeat:
+ prospectors:
+ -
+ paths:
+ - /var/log/syslog
+ - /var/log/auth.log
+ document_type: syslog
+ -
+ paths:
+ - /var/log/spring-music.log
+ document_type: log4j
+ multiline:
+ pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
+ negate: true
+ match: after
+ -
+ paths:
+ - /usr/local/tomcat/logs/*.out
+ - /usr/local/tomcat/logs/*.log
+ document_type: tomcat
diff --git a/oauth-server/src/main/resources/docker/logstash-beats.crt b/oauth-server/src/main/resources/docker/logstash-beats.crt
index d9b71cf..1c86bc3 100644
--- a/oauth-server/src/main/resources/docker/logstash-beats.crt
+++ b/oauth-server/src/main/resources/docker/logstash-beats.crt
@@ -1,18 +1,18 @@
------BEGIN CERTIFICATE-----
-MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
-BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
-DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
-0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
-9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
-PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
-qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
-KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
-4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
-VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
-hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
-okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
-T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
-ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
-kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
-Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
------END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
+BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
+DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
+0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
+9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
+PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
+qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
+KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
+4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
+VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
+hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
+okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
+T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
+ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
+kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
+Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
+-----END CERTIFICATE-----
diff --git a/oauth-server/src/main/resources/docker/start.sh b/oauth-server/src/main/resources/docker/start.sh
index b68b2fb..eff4532 100644
--- a/oauth-server/src/main/resources/docker/start.sh
+++ b/oauth-server/src/main/resources/docker/start.sh
@@ -1,5 +1,4 @@
#!/bin/bash
-
curl -XPUT 'http://elk:9200/_template/filebeat?pretty' -d@/etc/filebeat/filebeat.template.json
/etc/init.d/filebeat start
-java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
+java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
\ No newline at end of file
diff --git a/package-projects.sh b/package-projects.sh
index 2736fdd..8fdb0d9 100755
--- a/package-projects.sh
+++ b/package-projects.sh
@@ -1,13 +1,12 @@
#!/bin/sh
-
set -ex
mvn clean install
-mvn -f ./remainder-service/pom.xml -Pdockerimage docker:build
-mvn -f ./eureka-server/pom.xml -Pdockerimage docker:build
-mvn -f ./config-server/pom.xml -Pdockerimage docker:build
-mvn -f ./oauth-server/pom.xml -Pdockerimage docker:build
-mvn -f ./user-service/pom.xml -Pdockerimage docker:build
-mvn -f ./api-gateway/pom.xml -Pdockerimage docker:build
-mvn -f ./admin-server/pom.xml -Pdockerimage docker:build
+mvn -f ./remainder-service/pom.xml -Pdockerimage docker:build
+mvn -f ./eureka-server/pom.xml -Pdockerimage docker:build
+mvn -f ./config-server/pom.xml -Pdockerimage docker:build
+mvn -f ./oauth-server/pom.xml -Pdockerimage docker:build
+mvn -f ./user-service/pom.xml -Pdockerimage docker:build
+mvn -f ./api-gateway/pom.xml -Pdockerimage docker:build
+mvn -f ./admin-server/pom.xml -Pdockerimage docker:build
mvn -f ./mail-service/pom.xml -Pdockerimage docker:build
diff --git a/pom.xml b/pom.xml
index decdaa0..ecdc745 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,83 +1,84 @@
-
-
- 4.0.0
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 1.5.3.RELEASE
-
-
- com.apssouza
- parent-todo-ms
- 0.0.1-SNAPSHOT
- pom
- ToDo ms
- Parent for all to do microservices
-
-
- Dalston.SR1
- UTF-8
- UTF-8
- 1.8
-
-
-
- todo-infra
- mail-service
- jmx-monitoring
- config-server
- remainder-service
-
-
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
- org.springframework.cloud
- spring-cloud-starter-eureka
-
-
-
- com.fasterxml.jackson.core
- jackson-databind
-
-
-
- de.codecentric
- spring-boot-admin-starter-client
- 1.5.4
-
-
-
-
- junit
- junit
- test
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-dependencies
- ${spring-cloud.version}
- pom
- import
-
-
-
+
+
+ 4.0.0
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.3.RELEASE
+
+
+ com.apssouza
+ parent-todo-ms
+ 0.0.1-SNAPSHOT
+ pom
+ ToDo ms
+ Parent for all to do microservices
+
+
+ Dalston.SR1
+ UTF-8
+ UTF-8
+ 1.8
+ tcp://localhost:2375
+
+
+
+ todo-infra
+ mail-service
+ jmx-monitoring
+ config-server
+ remainder-service
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
+
+
+ de.codecentric
+ spring-boot-admin-starter-client
+ 1.5.4
+
+
+
+
+ junit
+ junit
+ test
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+
\ No newline at end of file
diff --git a/private.cert b/private.cert
index 333a5d6..44489b3 100644
--- a/private.cert
+++ b/private.cert
@@ -1,19 +1,19 @@
------BEGIN CERTIFICATE-----
-MIIDGTCCAgGgAwIBAgIECjQ1nzANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQGEwJE
-RTEPMA0GA1UECBMGQmVybGluMQ8wDQYDVQQHEwZCZXJsaW4xDDAKBgNVBAMTA2p3
-dDAeFw0xNzA0MDUyMDUxMzJaFw0xNzA3MDQyMDUxMzJaMD0xCzAJBgNVBAYTAkRF
-MQ8wDQYDVQQIEwZCZXJsaW4xDzANBgNVBAcTBkJlcmxpbjEMMAoGA1UEAxMDand0
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAybh3MPztT363c041gifD
-B1JKb7M/N6doCBIVJmbS1nVrCQRiVq4vcsMfTI/C6yNp4a2VF/UMuJTyy3c4iKe7
-A1jNn2dd4EBBN6ljavhQSZ6ImiSDqUF40BHs54b5ffZfzBIsNcvRPZVCt6Fs/OuX
-EaMkIesyaQxQS1xKH3gHFhWSS74MShqXDZwG/tc4CojSFTkhBPFh1/7x8XB+0UVK
-QYElIdMrSUZfNMJ+DIzphogwDbqzDoVxC1nqHDAju7x2FENtHg5Xs0UXeKFuDLfO
-WHG5z9HBSooEQnKrz/9G/Uvd6NNcXJYCgI/6MjRGlQ3MPSKMDpVHkBiK/XYw0Vs7
-DQIDAQABoyEwHzAdBgNVHQ4EFgQUFUTAZMq6dpZd54AqO3Q61a4FhsswDQYJKoZI
-hvcNAQELBQADggEBADbIFIK3QKj7zcnL3ufBg2sVEL9Jm6/HZ2j75TV0/C5G5FqF
-B86kYO6xhNBIw1NGO9kckLsgCfIaqkpE8UYhskHHQFIofMMQV2dcYCu1K6bKjFU9
-IgTELi+m10mW1nb97f30NhPREvuH/JDttCRq+EjMb9V6bETuuTUTzkOLBaJweRqW
-bIdGtWxxpx8xv9iuqeLfvWyN2c08VfdgVMR8QXLE6vh/KZOqixuVdKEScqkkC4NC
-dXc6G5tarmSDAQnHzsEXI1o9whJ4y5c37l/hRWE+UmHSdztOjZi38Duw7j8o7Irn
-i9529XjL+xAYmGeaRJxA8ql6L8GerXUTIWmWdBA=
------END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIDGTCCAgGgAwIBAgIECjQ1nzANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQGEwJE
+RTEPMA0GA1UECBMGQmVybGluMQ8wDQYDVQQHEwZCZXJsaW4xDDAKBgNVBAMTA2p3
+dDAeFw0xNzA0MDUyMDUxMzJaFw0xNzA3MDQyMDUxMzJaMD0xCzAJBgNVBAYTAkRF
+MQ8wDQYDVQQIEwZCZXJsaW4xDzANBgNVBAcTBkJlcmxpbjEMMAoGA1UEAxMDand0
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAybh3MPztT363c041gifD
+B1JKb7M/N6doCBIVJmbS1nVrCQRiVq4vcsMfTI/C6yNp4a2VF/UMuJTyy3c4iKe7
+A1jNn2dd4EBBN6ljavhQSZ6ImiSDqUF40BHs54b5ffZfzBIsNcvRPZVCt6Fs/OuX
+EaMkIesyaQxQS1xKH3gHFhWSS74MShqXDZwG/tc4CojSFTkhBPFh1/7x8XB+0UVK
+QYElIdMrSUZfNMJ+DIzphogwDbqzDoVxC1nqHDAju7x2FENtHg5Xs0UXeKFuDLfO
+WHG5z9HBSooEQnKrz/9G/Uvd6NNcXJYCgI/6MjRGlQ3MPSKMDpVHkBiK/XYw0Vs7
+DQIDAQABoyEwHzAdBgNVHQ4EFgQUFUTAZMq6dpZd54AqO3Q61a4FhsswDQYJKoZI
+hvcNAQELBQADggEBADbIFIK3QKj7zcnL3ufBg2sVEL9Jm6/HZ2j75TV0/C5G5FqF
+B86kYO6xhNBIw1NGO9kckLsgCfIaqkpE8UYhskHHQFIofMMQV2dcYCu1K6bKjFU9
+IgTELi+m10mW1nb97f30NhPREvuH/JDttCRq+EjMb9V6bETuuTUTzkOLBaJweRqW
+bIdGtWxxpx8xv9iuqeLfvWyN2c08VfdgVMR8QXLE6vh/KZOqixuVdKEScqkkC4NC
+dXc6G5tarmSDAQnHzsEXI1o9whJ4y5c37l/hRWE+UmHSdztOjZi38Duw7j8o7Irn
+i9529XjL+xAYmGeaRJxA8ql6L8GerXUTIWmWdBA=
+-----END CERTIFICATE-----
diff --git a/proxy/Dockerfile b/proxy/Dockerfile
index deccc86..f828d72 100755
--- a/proxy/Dockerfile
+++ b/proxy/Dockerfile
@@ -1,42 +1,42 @@
-# NGINX image with build artifact
-
-FROM nginx:latest
-
-MAINTAINER Gary A. Stafford
-ENV REFRESHED_AT 2016-09-17
-
-ENV GITHUB_REPO https://github.com/garystafford/spring-music/raw/build-artifacts
-ENV STATIC_FILE spring-music-static.zip
-
-RUN apt-get update -qq \
- && apt-get install -qqy curl wget unzip nano \
- && apt-get clean \
- \
- && wget -O /tmp/${STATIC_FILE} ${GITHUB_REPO}/${STATIC_FILE} \
- && unzip /tmp/${STATIC_FILE} -d /usr/share/nginx/assets/
-
-COPY default.conf /etc/nginx/conf.d/default.conf
-
-# tweak nginx image set-up, remove log symlinks
-RUN rm /var/log/nginx/access.log /var/log/nginx/error.log
-
-# install Filebeat
-ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
-RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
- && dpkg -i ${FILEBEAT_VERSION} \
- && rm ${FILEBEAT_VERSION}
-
-# configure Filebeat
-ADD filebeat.yml /etc/filebeat/filebeat.yml
-
-# CA cert
-RUN mkdir -p /etc/pki/tls/certs
-ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
-
-ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
-RUN bash -c 'chmod +x wait-for-it.sh'
-
-# start Filebeat
-ADD ./start.sh /usr/local/bin/start.sh
-RUN chmod +x /usr/local/bin/start.sh
-CMD [ "/usr/local/bin/start.sh" ]
+# NGINX image with build artifact
+
+FROM nginx:latest
+
+MAINTAINER Gary A. Stafford
+ENV REFRESHED_AT 2016-09-17
+
+ENV GITHUB_REPO https://github.com/garystafford/spring-music/raw/build-artifacts
+ENV STATIC_FILE spring-music-static.zip
+
+RUN apt-get update -qq \
+ && apt-get install -qqy curl wget unzip nano \
+ && apt-get clean \
+ \
+ && wget -O /tmp/${STATIC_FILE} ${GITHUB_REPO}/${STATIC_FILE} \
+ && unzip /tmp/${STATIC_FILE} -d /usr/share/nginx/assets/
+
+COPY default.conf /etc/nginx/conf.d/default.conf
+
+# tweak nginx image set-up, remove log symlinks
+RUN rm /var/log/nginx/access.log /var/log/nginx/error.log
+
+# install Filebeat
+ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
+RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
+ && dpkg -i ${FILEBEAT_VERSION} \
+ && rm ${FILEBEAT_VERSION}
+
+# configure Filebeat
+ADD filebeat.yml /etc/filebeat/filebeat.yml
+
+# CA cert
+RUN mkdir -p /etc/pki/tls/certs
+ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
+
+ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
+RUN bash -c 'chmod +x wait-for-it.sh'
+
+# start Filebeat
+ADD ./start.sh /usr/local/bin/start.sh
+RUN chmod +x /usr/local/bin/start.sh
+CMD [ "/usr/local/bin/start.sh" ]
diff --git a/proxy/README b/proxy/README
index d48bae1..364d456 100644
--- a/proxy/README
+++ b/proxy/README
@@ -1,4 +1,4 @@
-# Proxy server
-
-This is a Nginx proxy/ Load balance server placed in front our API Gateway in order to have a
+# Proxy server
+
+This is a Nginx proxy/ Load balance server placed in front our API Gateway in order to have a
load balance and be able of scaling our API Gateway as much as we need.
\ No newline at end of file
diff --git a/proxy/default.conf b/proxy/default.conf
index 87c57d8..bfd1e5a 100755
--- a/proxy/default.conf
+++ b/proxy/default.conf
@@ -1,43 +1,43 @@
-# Based on http://nginx.org/en/docs/http/load_balancing.html
-upstream backend {
- #ip_hash;
- server gateway:8018;
-}
-
-server {
- listen 80;
- server_name proxy;
-
- location ~* \/assets\/(css|images|js|template)\/* {
- root /usr/share/nginx/;
- expires max;
- add_header Pragma public;
- add_header Cache-Control "public, must-revalidate, proxy-revalidate";
- add_header Vary Accept-Encoding;
- access_log off;
- }
-
- location / {
- proxy_set_header Host $host;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header Host $proxy_host;
- add_header Request-Time $request_time;
- add_header Upstream-Address $upstream_addr;
- add_header Upstream-Response-Time $upstream_response_time;
- proxy_pass http://backend;
- }
-
- error_page 404 /404.html;
-
- # redirect server error pages to the static page /50x.html
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/html;
- }
-
- location /nginx_status {
- stub_status on;
- access_log off;
- }
-}
+# Based on http://nginx.org/en/docs/http/load_balancing.html
+upstream backend {
+ #ip_hash;
+ server gateway:8018;
+}
+
+server {
+ listen 80;
+ server_name proxy;
+
+ location ~* \/assets\/(css|images|js|template)\/* {
+ root /usr/share/nginx/;
+ expires max;
+ add_header Pragma public;
+ add_header Cache-Control "public, must-revalidate, proxy-revalidate";
+ add_header Vary Accept-Encoding;
+ access_log off;
+ }
+
+ location / {
+ proxy_set_header Host $host;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header Host $proxy_host;
+ add_header Request-Time $request_time;
+ add_header Upstream-Address $upstream_addr;
+ add_header Upstream-Response-Time $upstream_response_time;
+ proxy_pass http://backend;
+ }
+
+ error_page 404 /404.html;
+
+ # redirect server error pages to the static page /50x.html
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root /usr/share/nginx/html;
+ }
+
+ location /nginx_status {
+ stub_status on;
+ access_log off;
+ }
+}
diff --git a/proxy/filebeat.yml b/proxy/filebeat.yml
index 56fc606..6b7c7d0 100644
--- a/proxy/filebeat.yml
+++ b/proxy/filebeat.yml
@@ -1,21 +1,21 @@
-output:
- logstash:
- enabled: true
- hosts:
- - elk:5044
- timeout: 15
- tls:
- certificate_authorities:
- - /etc/pki/tls/certs/logstash-beats.crt
-
-filebeat:
- prospectors:
- -
- paths:
- - /var/log/syslog
- - /var/log/auth.log
- document_type: syslog
- -
- paths:
- - "/var/log/nginx/*.log"
- document_type: nginx-access
+output:
+ logstash:
+ enabled: true
+ hosts:
+ - elk:5044
+ timeout: 15
+ tls:
+ certificate_authorities:
+ - /etc/pki/tls/certs/logstash-beats.crt
+
+filebeat:
+ prospectors:
+ -
+ paths:
+ - /var/log/syslog
+ - /var/log/auth.log
+ document_type: syslog
+ -
+ paths:
+ - "/var/log/nginx/*.log"
+ document_type: nginx-access
diff --git a/proxy/logstash-beats.crt b/proxy/logstash-beats.crt
index d9b71cf..1c86bc3 100644
--- a/proxy/logstash-beats.crt
+++ b/proxy/logstash-beats.crt
@@ -1,18 +1,18 @@
------BEGIN CERTIFICATE-----
-MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
-BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
-DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
-0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
-9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
-PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
-qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
-KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
-4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
-VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
-hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
-okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
-T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
-ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
-kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
-Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
------END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
+BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
+DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
+0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
+9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
+PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
+qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
+KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
+4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
+VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
+hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
+okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
+T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
+ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
+kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
+Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
+-----END CERTIFICATE-----
diff --git a/proxy/start.sh b/proxy/start.sh
index 6139b45..f879611 100644
--- a/proxy/start.sh
+++ b/proxy/start.sh
@@ -1,6 +1,5 @@
#!/bin/bash
-
curl -XPUT 'http://elk:9200/_template/filebeat?pretty' -d@/etc/filebeat/filebeat.template.json
/etc/init.d/filebeat start
nginx
-tail -f /var/log/nginx/access.log -f /var/log/nginx/error.log
+tail -f /var/log/nginx/access.log -f /var/log/nginx/error.log
\ No newline at end of file
diff --git a/public.cert b/public.cert
index 9247da4..acc4a25 100644
--- a/public.cert
+++ b/public.cert
@@ -1,9 +1,9 @@
------BEGIN PUBLIC KEY-----
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAybh3MPztT363c041gifD
-B1JKb7M/N6doCBIVJmbS1nVrCQRiVq4vcsMfTI/C6yNp4a2VF/UMuJTyy3c4iKe7
-A1jNn2dd4EBBN6ljavhQSZ6ImiSDqUF40BHs54b5ffZfzBIsNcvRPZVCt6Fs/OuX
-EaMkIesyaQxQS1xKH3gHFhWSS74MShqXDZwG/tc4CojSFTkhBPFh1/7x8XB+0UVK
-QYElIdMrSUZfNMJ+DIzphogwDbqzDoVxC1nqHDAju7x2FENtHg5Xs0UXeKFuDLfO
-WHG5z9HBSooEQnKrz/9G/Uvd6NNcXJYCgI/6MjRGlQ3MPSKMDpVHkBiK/XYw0Vs7
-DQIDAQAB
------END PUBLIC KEY-----
+-----BEGIN PUBLIC KEY-----
+MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAybh3MPztT363c041gifD
+B1JKb7M/N6doCBIVJmbS1nVrCQRiVq4vcsMfTI/C6yNp4a2VF/UMuJTyy3c4iKe7
+A1jNn2dd4EBBN6ljavhQSZ6ImiSDqUF40BHs54b5ffZfzBIsNcvRPZVCt6Fs/OuX
+EaMkIesyaQxQS1xKH3gHFhWSS74MShqXDZwG/tc4CojSFTkhBPFh1/7x8XB+0UVK
+QYElIdMrSUZfNMJ+DIzphogwDbqzDoVxC1nqHDAju7x2FENtHg5Xs0UXeKFuDLfO
+WHG5z9HBSooEQnKrz/9G/Uvd6NNcXJYCgI/6MjRGlQ3MPSKMDpVHkBiK/XYw0Vs7
+DQIDAQAB
+-----END PUBLIC KEY-----
diff --git a/remainder-service/Jenkinsfile b/remainder-service/Jenkinsfile
index eb5593b..258bc30 100644
--- a/remainder-service/Jenkinsfile
+++ b/remainder-service/Jenkinsfile
@@ -1,16 +1,16 @@
-node {
- stage('Fetch changes') {
- git 'https://github.com/apssouza22/java-microservice.git'
- }
- stage('Build image') {
- // Run the maven build
- if (isUnix()) {
- sh "mvn -f ./remainder-service/pom.xml -Pdockerimage docker:build"
- } else {
- echo "Not ready for windows"
- }
- }
- stage('Deploy ECS') {
- echo "TODO deploy on AWS"
- }
-}
+node {
+ stage('Fetch changes') {
+ git 'https://github.com/apssouza22/java-microservice.git'
+ }
+ stage('Build image') {
+ // Run the maven build
+ if (isUnix()) {
+ sh "mvn -f ./remainder-service/pom.xml -Pdockerimage docker:build"
+ } else {
+ echo "Not ready for windows"
+ }
+ }
+ stage('Deploy ECS') {
+ echo "TODO deploy on AWS"
+ }
+}
diff --git a/remainder-service/README b/remainder-service/README
index c6a5786..5c3cc3d 100644
--- a/remainder-service/README
+++ b/remainder-service/README
@@ -1,19 +1,19 @@
-# Reminder service
-
-This is the core of our To-Do project, here we have all functionality related to the To-do.
-On this server we tried to add many cool Java things in order to make the project nicer.
-
-Here we are working with:
-Events
-EntityListeners
-AOP
-Optional, extensively
-Monitoring
-Defensive copying
-Maven Multimodules
-External messages
-Socket
-Hibernate
-Spring data
-Custom Annotations
-
+# Reminder service
+
+This is the core of our To-Do project, here we have all functionality related to the To-do.
+On this server we tried to add many cool Java things in order to make the project nicer.
+
+Here we are working with:
+Events
+EntityListeners
+AOP
+Optional, extensively
+Monitoring
+Defensive copying
+Maven Multimodules
+External messages
+Socket
+Hibernate
+Spring data
+Custom Annotations
+
diff --git a/remainder-service/pom.xml b/remainder-service/pom.xml
index 4e77cb2..8a7bd3f 100644
--- a/remainder-service/pom.xml
+++ b/remainder-service/pom.xml
@@ -1,180 +1,182 @@
-
-
- 4.0.0
-
- com.apssouza.remainder
- remainder-service
- 0.0.1-SNAPSHOT
- jar
-
- Remainder service
- Todo remainder service
-
-
- parent-todo-ms
- com.apssouza
- 0.0.1-SNAPSHOT
-
-
-
- UTF-8
- UTF-8
- com.apssouza.BasicApplication
- 1.8
-
-
-
-
- org.springframework.boot
- spring-boot-starter-websocket
-
-
-
- org.springframework.boot
- spring-boot-starter-aop
-
-
- org.springframework.boot
- spring-boot-configuration-processor
- true
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
-
- com.h2database
- h2
-
-
-
- com.apssouza
- jmx-monitoring
- 0.0.1-SNAPSHOT
-
-
-
- org.springframework.cloud
- spring-cloud-starter-config
-
-
-
- com.apssouza
- todo-infra
- 0.0.1-SNAPSHOT
-
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
- true
-
-
-
-
-
-
- dockerimage
-
- todo/reminder-service
- src/main/resources/docker
- ${project.build.directory}/dockerimgbuild
- Dockerfile
-
-
-
-
-
- maven-resources-plugin
-
-
- copy-resources
- package
-
- copy-resources
-
-
- ${docker.build.directory}
-
-
- ${docker.image.src.root}
- false
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- copy
- package
-
- copy
-
-
-
-
- ${project.groupId}
- ${project.artifactId}
- ${project.version}
- jar
- true
- ${docker.build.directory}/application/lib
- springboot-webapp.jar
-
-
-
-
- ${docker.build.directory}
- true
- true
-
-
-
-
-
-
-
- io.fabric8
- docker-maven-plugin
- 0.19.0
-
-
- unix:///var/run/docker.sock
-
-
- ${docker.image.name}
-
-
- latest
-
- ${docker.build.directory}/${docker.file.name}
-
-
-
-
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ com.apssouza.remainder
+ remainder-service
+ 0.0.1-SNAPSHOT
+ jar
+
+ Remainder service
+ Todo remainder service
+
+
+ parent-todo-ms
+ com.apssouza
+ 0.0.1-SNAPSHOT
+
+
+
+ UTF-8
+ UTF-8
+ com.apssouza.BasicApplication
+ 1.8
+ tcp://localhost:2375
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-websocket
+
+
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
+
+ org.springframework.boot
+ spring-boot-configuration-processor
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+
+ com.h2database
+ h2
+
+
+
+ com.apssouza
+ jmx-monitoring
+ 0.0.1-SNAPSHOT
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+
+ com.apssouza
+ todo-infra
+ 0.0.1-SNAPSHOT
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ true
+
+
+
+
+
+
+ dockerimage
+
+ todo/reminder-service
+ src/main/resources/docker
+ ${project.build.directory}/dockerimgbuild
+ Dockerfile
+
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-resources
+ package
+
+ copy-resources
+
+
+ ${docker.build.directory}
+
+
+ ${docker.image.src.root}
+ false
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy
+ package
+
+ copy
+
+
+
+
+ ${project.groupId}
+ ${project.artifactId}
+ ${project.version}
+ jar
+ true
+ ${docker.build.directory}/application/lib
+ springboot-webapp.jar
+
+
+
+
+ ${docker.build.directory}
+ true
+ true
+
+
+
+
+
+
+
+ io.fabric8
+ docker-maven-plugin
+ 0.19.0
+
+
+ unix:///var/run/docker.sock
+
+
+
+ ${docker.image.name}
+
+
+ latest
+
+ ${docker.build.directory}/${docker.file.name}
+
+
+
+
+
+
+
+
+
+
diff --git a/remainder-service/src/main/java/com/apssouza/BasicApplication.java b/remainder-service/src/main/java/com/apssouza/BasicApplication.java
index 67fc71f..e424e70 100644
--- a/remainder-service/src/main/java/com/apssouza/BasicApplication.java
+++ b/remainder-service/src/main/java/com/apssouza/BasicApplication.java
@@ -1,15 +1,15 @@
-package com.apssouza;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.annotation.Import;
-import com.apssouza.monitoring.MonitoringConfig;
-
-@SpringBootApplication
-@Import(MonitoringConfig.class)
-public class BasicApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(BasicApplication.class, args);
- }
-}
+package com.apssouza;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Import;
+import com.apssouza.monitoring.MonitoringConfig;
+
+@SpringBootApplication
+@Import(MonitoringConfig.class)
+public class BasicApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(BasicApplication.class, args);
+ }
+}
diff --git a/remainder-service/src/main/java/com/apssouza/annotations/ChangeEvent.java b/remainder-service/src/main/java/com/apssouza/annotations/ChangeEvent.java
index 9c79aea..ed279c1 100644
--- a/remainder-service/src/main/java/com/apssouza/annotations/ChangeEvent.java
+++ b/remainder-service/src/main/java/com/apssouza/annotations/ChangeEvent.java
@@ -1,19 +1,19 @@
-package com.apssouza.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import org.springframework.beans.factory.annotation.Qualifier;
-
-@Qualifier
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.FIELD, ElementType.TYPE})
-public @interface ChangeEvent {
-
- Type value();
-
- enum Type {
- CREATION, UPDATE;
- }
-}
+package com.apssouza.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.springframework.beans.factory.annotation.Qualifier;
+
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target({ElementType.FIELD, ElementType.TYPE})
+public @interface ChangeEvent {
+
+ Type value();
+
+ enum Type {
+ CREATION, UPDATE;
+ }
+}
diff --git a/remainder-service/src/main/java/com/apssouza/bootstrap/TodoLoader.java b/remainder-service/src/main/java/com/apssouza/bootstrap/TodoLoader.java
index 0fdb6eb..63a10f2 100644
--- a/remainder-service/src/main/java/com/apssouza/bootstrap/TodoLoader.java
+++ b/remainder-service/src/main/java/com/apssouza/bootstrap/TodoLoader.java
@@ -1,45 +1,45 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.apssouza.bootstrap;
-
-import com.apssouza.repositories.TodoRepository;
-import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.event.ContextRefreshedEvent;
-import com.apssouza.entities.ToDo;
-import org.springframework.stereotype.Component;
-
-/**
- *
- * @author apssouza
- */
-@Component
-public class TodoLoader implements ApplicationListener {
-
- private final TodoRepository todoRepository;
- private final Logger log = Logger.getLogger(this.getClass().getCanonicalName());
-
- @Autowired
- public TodoLoader(TodoRepository todoRepository) {
- this.todoRepository = todoRepository;
- }
-
-
- @Override
- public void onApplicationEvent(ContextRefreshedEvent e) {
- ToDo todo1 = new ToDo("apssouza22@gmail.com","Test caption", "description 1", 2);
- ToDo todo2 = new ToDo("gael@gmail.com","Test caption 2", "description 2", 3);
- ToDo todo3 = new ToDo("marcia@gmail.com","Test caption 3", "description 3", 2);
-
- todoRepository.save(todo1);
- todoRepository.save(todo2);
- todoRepository.save(todo3);
-
- log.info("Created the to-dos.");
- }
-
-}
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.apssouza.bootstrap;
+
+import com.apssouza.repositories.TodoRepository;
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+import com.apssouza.entities.ToDo;
+import org.springframework.stereotype.Component;
+
+/**
+ *
+ * @author apssouza
+ */
+@Component
+public class TodoLoader implements ApplicationListener {
+
+ private final TodoRepository todoRepository;
+ private final Logger log = Logger.getLogger(this.getClass().getCanonicalName());
+
+ @Autowired
+ public TodoLoader(TodoRepository todoRepository) {
+ this.todoRepository = todoRepository;
+ }
+
+
+ @Override
+ public void onApplicationEvent(ContextRefreshedEvent e) {
+ ToDo todo1 = new ToDo("apssouza22@gmail.com","Test caption", "description 1", 2);
+ ToDo todo2 = new ToDo("gael@gmail.com","Test caption 2", "description 2", 3);
+ ToDo todo3 = new ToDo("marcia@gmail.com","Test caption 3", "description 3", 2);
+
+ todoRepository.save(todo1);
+ todoRepository.save(todo2);
+ todoRepository.save(todo3);
+
+ log.info("Created the to-dos.");
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/configuration/H2DbConfiguration.java b/remainder-service/src/main/java/com/apssouza/configuration/H2DbConfiguration.java
index b9a1573..2cd7218 100644
--- a/remainder-service/src/main/java/com/apssouza/configuration/H2DbConfiguration.java
+++ b/remainder-service/src/main/java/com/apssouza/configuration/H2DbConfiguration.java
@@ -1,49 +1,49 @@
-
-package com.apssouza.configuration;
-
-
-import org.h2.server.web.WebServlet;
-import org.springframework.boot.web.servlet.ServletRegistrationBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * Configuration to enable access to the h2db console
- * @author apssouza
- */
-@Configuration
-public class H2DbConfiguration {
- @Bean
- ServletRegistrationBean h2servletRegistration(){
- ServletRegistrationBean registrationBean = new ServletRegistrationBean( new WebServlet());
- registrationBean.addUrlMappings("/console/*");
- return registrationBean;
- }
-}
-
-/**
- * If using spring security, we need to add this configuration to the
- * Spring security configuration
- */
-
-/*
-package guru.springframework.configuration;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
-
-@Configuration
-public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
-
- @Override
- protected void configure(HttpSecurity httpSecurity) throws Exception {
- httpSecurity.authorizeRequests().antMatchers("/").permitAll().and()
- .authorizeRequests().antMatchers("/console/**").permitAll();
-
- httpSecurity.csrf().disable(); //disable csrf, not recommeded to production
- httpSecurity.headers().frameOptions().disable(); //disable X-Frame-Options
- }
-
-}
+
+package com.apssouza.configuration;
+
+
+import org.h2.server.web.WebServlet;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Configuration to enable access to the h2db console
+ * @author apssouza
+ */
+@Configuration
+public class H2DbConfiguration {
+ @Bean
+ ServletRegistrationBean h2servletRegistration(){
+ ServletRegistrationBean registrationBean = new ServletRegistrationBean( new WebServlet());
+ registrationBean.addUrlMappings("/console/*");
+ return registrationBean;
+ }
+}
+
+/**
+ * If using spring security, we need to add this configuration to the
+ * Spring security configuration
+ */
+
+/*
+package guru.springframework.configuration;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+
+@Configuration
+public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
+
+ @Override
+ protected void configure(HttpSecurity httpSecurity) throws Exception {
+ httpSecurity.authorizeRequests().antMatchers("/").permitAll().and()
+ .authorizeRequests().antMatchers("/console/**").permitAll();
+
+ httpSecurity.csrf().disable(); //disable csrf, not recommeded to production
+ httpSecurity.headers().frameOptions().disable(); //disable X-Frame-Options
+ }
+
+}
*/
\ No newline at end of file
diff --git a/remainder-service/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java b/remainder-service/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java
index 0fdd9ce..47aa568 100644
--- a/remainder-service/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java
+++ b/remainder-service/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java
@@ -1,15 +1,15 @@
-package com.apssouza.configuration;
-
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * Enabling Eureka Client
- *
- * @author apssouza
- */
-@Configuration
-@EnableDiscoveryClient
-public class ServiceDiscoveryConfiguration {
-
-}
+package com.apssouza.configuration;
+
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Enabling Eureka Client
+ *
+ * @author apssouza
+ */
+@Configuration
+@EnableDiscoveryClient
+public class ServiceDiscoveryConfiguration {
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/configuration/WebSocketConfig.java b/remainder-service/src/main/java/com/apssouza/configuration/WebSocketConfig.java
index 45aefa0..eaa4be5 100644
--- a/remainder-service/src/main/java/com/apssouza/configuration/WebSocketConfig.java
+++ b/remainder-service/src/main/java/com/apssouza/configuration/WebSocketConfig.java
@@ -1,30 +1,30 @@
-package com.apssouza.configuration;
-
-import org.springframework.context.annotation.Configuration;
-import org.springframework.messaging.simp.config.MessageBrokerRegistry;
-import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
-import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
-import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
-
-/**
- * Web socket configuration.
- *
- * @author apssouza
- */
-@Configuration
-@EnableWebSocketMessageBroker
-public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
-
- @Override
- public void configureMessageBroker(MessageBrokerRegistry config) {
- config.enableSimpleBroker("/topic");
- config.setApplicationDestinationPrefixes("/app");
- }
-
- @Override
- public void registerStompEndpoints(StompEndpointRegistry registry) {
- //no withSockJS() if not working with js
- registry.addEndpoint("/socket-todos").setAllowedOrigins("*").withSockJS();
- }
-
-}
+package com.apssouza.configuration;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.messaging.simp.config.MessageBrokerRegistry;
+import org.springframework.web.socket.config.annotation.AbstractWebSocketMessageBrokerConfigurer;
+import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
+import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
+
+/**
+ * Web socket configuration.
+ *
+ * @author apssouza
+ */
+@Configuration
+@EnableWebSocketMessageBroker
+public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
+
+ @Override
+ public void configureMessageBroker(MessageBrokerRegistry config) {
+ config.enableSimpleBroker("/topic");
+ config.setApplicationDestinationPrefixes("/app");
+ }
+
+ @Override
+ public void registerStompEndpoints(StompEndpointRegistry registry) {
+ //no withSockJS() if not working with js
+ registry.addEndpoint("/socket-todos").setAllowedOrigins("*").withSockJS();
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/controllers/TodoChangesController.java b/remainder-service/src/main/java/com/apssouza/controllers/TodoChangesController.java
index dfa3536..aa1c015 100644
--- a/remainder-service/src/main/java/com/apssouza/controllers/TodoChangesController.java
+++ b/remainder-service/src/main/java/com/apssouza/controllers/TodoChangesController.java
@@ -1,28 +1,28 @@
-package com.apssouza.controllers;
-
-import com.apssouza.events.TodoChangedEvent;
-import com.apssouza.monitors.TodoStoreEventChanges;
-import java.util.List;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * Controller to get the To do changes
- *
- * @author apssouza
- */
-@RequestMapping("/todo-changes")
-@RestController
-public class TodoChangesController {
-
- @Autowired
- TodoStoreEventChanges monitor;
-
- @GetMapping
- public List expose() {
- return this.monitor.getRecentEvents();
- }
-
-}
+package com.apssouza.controllers;
+
+import com.apssouza.events.TodoChangedEvent;
+import com.apssouza.monitors.TodoStoreEventChanges;
+import java.util.List;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * Controller to get the To do changes
+ *
+ * @author apssouza
+ */
+@RequestMapping("/todo-changes")
+@RestController
+public class TodoChangesController {
+
+ @Autowired
+ TodoStoreEventChanges monitor;
+
+ @GetMapping
+ public List expose() {
+ return this.monitor.getRecentEvents();
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/controllers/TodoController.java b/remainder-service/src/main/java/com/apssouza/controllers/TodoController.java
index a81eb5d..2e31c1f 100644
--- a/remainder-service/src/main/java/com/apssouza/controllers/TodoController.java
+++ b/remainder-service/src/main/java/com/apssouza/controllers/TodoController.java
@@ -1,108 +1,108 @@
-package com.apssouza.controllers;
-
-import com.apssouza.services.TodoService;
-import com.apssouza.entities.ToDo;
-import com.apssouza.events.TodoCreatedEvent;
-import com.apssouza.exceptions.DataNotFoundException;
-import com.apssouza.infra.EventPublisher;
-import com.fasterxml.jackson.databind.JsonNode;
-import java.net.URI;
-import java.util.List;
-import java.util.Optional;
-import javax.validation.Valid;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
-
-/**
- * Controller responsible of accessing ToDo's functionalities
- *
- * @author apssouza
- */
-@RequestMapping("/todos")
-@RestController
-public class TodoController {
-
- @Autowired
- TodoService todoService;
-
- @Autowired
- EventPublisher publisher;
-
- @GetMapping
- public List all() {
- return this.todoService.all();
- }
-
- @GetMapping("search")
- public List getByUserEmail(@RequestParam("email") String email) {
- return this.todoService.getByUserEmail(email);
- }
-
- @PostMapping
- public ResponseEntity> save(@RequestBody @Valid ToDo todo, BindingResult result) {
- if (result.hasErrors()) {
- return ResponseEntity.badRequest().build();
- }
- ToDo saved = this.todoService.save(todo);
- Long id = saved.getId();
- if (id != null) {
- URI location = ServletUriComponentsBuilder
- .fromCurrentRequest().path("/{id}")
- .buildAndExpand(id).toUri();
- return ResponseEntity.created(location).build();
- }
- return ResponseEntity.noContent().build();
- }
-
- @PutMapping("{id}")
- public ResponseEntity> update(
- @PathVariable long id,
- @RequestBody @Valid ToDo toDo
- ) {
- return ResponseEntity.ok(todoService.update(id, toDo));
- }
-
- @GetMapping("{id}")
- public ResponseEntity> find(@PathVariable long id) {
- Optional findById = todoService.findById(id);
- return findById.map(todo -> {
- return ResponseEntity.ok(todo);
- }).orElseThrow(() -> new DataNotFoundException("Todo not found"));
- }
-
- @DeleteMapping("{id}")
- public ResponseEntity> delete(@PathVariable long id) {
- todoService.delete(id);
- return ResponseEntity.status(HttpStatus.OK).build();
- }
-
- @PutMapping("{id}/status")
- public ResponseEntity> statusUpdate(@PathVariable long id, @RequestBody JsonNode statusUpdate) {
- JsonNode status = statusUpdate.get("status");
- if (status == null) {
- return ResponseEntity.status(HttpStatus.BAD_REQUEST).
- header("reason", "JSON should contains field done").
- build();
- }
- ToDo todo = todoService.updateStatus(
- id,
- ToDo.TodoStatus.valueOf(status.asText())
- );
- return ResponseEntity.ok(todo);
- }
-
-}
+package com.apssouza.controllers;
+
+import com.apssouza.services.TodoService;
+import com.apssouza.entities.ToDo;
+import com.apssouza.events.TodoCreatedEvent;
+import com.apssouza.exceptions.DataNotFoundException;
+import com.apssouza.infra.EventPublisher;
+import com.fasterxml.jackson.databind.JsonNode;
+import java.net.URI;
+import java.util.List;
+import java.util.Optional;
+import javax.validation.Valid;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
+
+/**
+ * Controller responsible of accessing ToDo's functionalities
+ *
+ * @author apssouza
+ */
+@RequestMapping("/todos")
+@RestController
+public class TodoController {
+
+ @Autowired
+ TodoService todoService;
+
+ @Autowired
+ EventPublisher publisher;
+
+ @GetMapping
+ public List all() {
+ return this.todoService.all();
+ }
+
+ @GetMapping("search")
+ public List getByUserEmail(@RequestParam("email") String email) {
+ return this.todoService.getByUserEmail(email);
+ }
+
+ @PostMapping
+ public ResponseEntity> save(@RequestBody @Valid ToDo todo, BindingResult result) {
+ if (result.hasErrors()) {
+ return ResponseEntity.badRequest().build();
+ }
+ ToDo saved = this.todoService.save(todo);
+ Long id = saved.getId();
+ if (id != null) {
+ URI location = ServletUriComponentsBuilder
+ .fromCurrentRequest().path("/{id}")
+ .buildAndExpand(id).toUri();
+ return ResponseEntity.created(location).build();
+ }
+ return ResponseEntity.noContent().build();
+ }
+
+ @PutMapping("{id}")
+ public ResponseEntity> update(
+ @PathVariable long id,
+ @RequestBody @Valid ToDo toDo
+ ) {
+ return ResponseEntity.ok(todoService.update(id, toDo));
+ }
+
+ @GetMapping("{id}")
+ public ResponseEntity> find(@PathVariable long id) {
+ Optional findById = todoService.findById(id);
+ return findById.map(todo -> {
+ return ResponseEntity.ok(todo);
+ }).orElseThrow(() -> new DataNotFoundException("Todo not found"));
+ }
+
+ @DeleteMapping("{id}")
+ public ResponseEntity> delete(@PathVariable long id) {
+ todoService.delete(id);
+ return ResponseEntity.status(HttpStatus.OK).build();
+ }
+
+ @PutMapping("{id}/status")
+ public ResponseEntity> statusUpdate(@PathVariable long id, @RequestBody JsonNode statusUpdate) {
+ JsonNode status = statusUpdate.get("status");
+ if (status == null) {
+ return ResponseEntity.status(HttpStatus.BAD_REQUEST).
+ header("reason", "JSON should contains field done").
+ build();
+ }
+ ToDo todo = todoService.updateStatus(
+ id,
+ ToDo.TodoStatus.valueOf(status.asText())
+ );
+ return ResponseEntity.ok(todo);
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/controllers/TodoServiceStatisticsController.java b/remainder-service/src/main/java/com/apssouza/controllers/TodoServiceStatisticsController.java
index 92839b3..f565aeb 100644
--- a/remainder-service/src/main/java/com/apssouza/controllers/TodoServiceStatisticsController.java
+++ b/remainder-service/src/main/java/com/apssouza/controllers/TodoServiceStatisticsController.java
@@ -1,29 +1,29 @@
-package com.apssouza.controllers;
-
-import com.apssouza.monitors.TodoServiceMethodInvokedStore;
-import com.fasterxml.jackson.databind.node.JsonNodeFactory;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import java.util.LongSummaryStatistics;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-@RequestMapping("/todo-statistics")
-@RestController
-public class TodoServiceStatisticsController {
-
- @Autowired
- TodoServiceMethodInvokedStore monitor;
-
- @GetMapping
- public ObjectNode get() {
- LongSummaryStatistics statistics = monitor.getStatistics();
- return JsonNodeFactory.instance.objectNode().
- put("average-duration", statistics.getAverage()).
- put("invocation-count", statistics.getCount()).
- put("min-duration", statistics.getMin()).
- put("max-duration", statistics.getMax());
- }
-
-}
+package com.apssouza.controllers;
+
+import com.apssouza.monitors.TodoServiceMethodInvokedStore;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import java.util.LongSummaryStatistics;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RequestMapping("/todo-statistics")
+@RestController
+public class TodoServiceStatisticsController {
+
+ @Autowired
+ TodoServiceMethodInvokedStore monitor;
+
+ @GetMapping
+ public ObjectNode get() {
+ LongSummaryStatistics statistics = monitor.getStatistics();
+ return JsonNodeFactory.instance.objectNode().
+ put("average-duration", statistics.getAverage()).
+ put("invocation-count", statistics.getCount()).
+ put("min-duration", statistics.getMin()).
+ put("max-duration", statistics.getMax());
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/entities/Attachment.java b/remainder-service/src/main/java/com/apssouza/entities/Attachment.java
index 8bf9abb..4ccc43a 100644
--- a/remainder-service/src/main/java/com/apssouza/entities/Attachment.java
+++ b/remainder-service/src/main/java/com/apssouza/entities/Attachment.java
@@ -1,94 +1,94 @@
-package com.apssouza.entities;
-
-import java.util.Objects;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.ManyToOne;
-
-/**
- * To Do's Attachment entity
- *
- * @author apssouza
- */
-@Entity
-public class Attachment {
-
- @Id
- @GeneratedValue
- private Long id;
-
- private String name;
-
- private String type;
-
- @ManyToOne
- private ToDo todo;
-
- public Attachment() {
- }
-
-
- public Attachment(String name, String type) {
- this.name = name;
- this.type = type;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public ToDo getTodo() {
- return todo;
- }
-
- public void setTodo(ToDo todo) {
- this.todo = todo;
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 61 * hash + Objects.hashCode(this.id);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Attachment other = (Attachment) obj;
- if (!Objects.equals(this.id, other.id)) {
- return false;
- }
- return true;
- }
-
-}
+package com.apssouza.entities;
+
+import java.util.Objects;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+
+/**
+ * To Do's Attachment entity
+ *
+ * @author apssouza
+ */
+@Entity
+public class Attachment {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ private String name;
+
+ private String type;
+
+ @ManyToOne
+ private ToDo todo;
+
+ public Attachment() {
+ }
+
+
+ public Attachment(String name, String type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public ToDo getTodo() {
+ return todo;
+ }
+
+ public void setTodo(ToDo todo) {
+ this.todo = todo;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 61 * hash + Objects.hashCode(this.id);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Attachment other = (Attachment) obj;
+ if (!Objects.equals(this.id, other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/entities/Category.java b/remainder-service/src/main/java/com/apssouza/entities/Category.java
index e584aea..225be9a 100644
--- a/remainder-service/src/main/java/com/apssouza/entities/Category.java
+++ b/remainder-service/src/main/java/com/apssouza/entities/Category.java
@@ -1,83 +1,83 @@
-package com.apssouza.entities;
-
-import java.util.ArrayList;
-import java.util.List;
-import javax.persistence.CascadeType;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.ManyToMany;
-
-/**
- * To Do's Category entity
- *
- * @author apssouza
- */
-@Entity
-public class Category {
-
- @Id
- @GeneratedValue
- private Long id;
-
- private String name;
-
- @ManyToMany(
- mappedBy = "categories",
- cascade = {CascadeType.PERSIST, CascadeType.MERGE}
- )
- private List todos = new ArrayList<>();
-
- ;
-
- public Category(Long id, String name) {
- this.name = name;
- this.id = id;
- }
-
- public Category(String name) {
- this.name = name;
- }
-
- public Category() {
- }
-
- /**
- * Defensive copying Provide an attractive alternative to the rather
- * pathological clone method
- *
- * @param category
- * @return Category
- */
- public static Category newInstance(Category category) {
- return new Category(
- category.getId(),
- category.getName()
- );
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List getTodos() {
- return todos;
- }
-
- public void setTodos(List todos) {
- this.todos = todos;
- }
-
-}
+package com.apssouza.entities;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+
+/**
+ * To Do's Category entity
+ *
+ * @author apssouza
+ */
+@Entity
+public class Category {
+
+ @Id
+ @GeneratedValue
+ private Long id;
+
+ private String name;
+
+ @ManyToMany(
+ mappedBy = "categories",
+ cascade = {CascadeType.PERSIST, CascadeType.MERGE}
+ )
+ private List todos = new ArrayList<>();
+
+ ;
+
+ public Category(Long id, String name) {
+ this.name = name;
+ this.id = id;
+ }
+
+ public Category(String name) {
+ this.name = name;
+ }
+
+ public Category() {
+ }
+
+ /**
+ * Defensive copying Provide an attractive alternative to the rather
+ * pathological clone method
+ *
+ * @param category
+ * @return Category
+ */
+ public static Category newInstance(Category category) {
+ return new Category(
+ category.getId(),
+ category.getName()
+ );
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List getTodos() {
+ return todos;
+ }
+
+ public void setTodos(List todos) {
+ this.todos = todos;
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/entities/ToDo.java b/remainder-service/src/main/java/com/apssouza/entities/ToDo.java
index d4e9ab2..96538ac 100644
--- a/remainder-service/src/main/java/com/apssouza/entities/ToDo.java
+++ b/remainder-service/src/main/java/com/apssouza/entities/ToDo.java
@@ -1,221 +1,221 @@
-package com.apssouza.entities;
-
-import com.apssouza.monitors.ToDoEntityListener;
-import com.apssouza.validation.ValidEntity;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-import javax.persistence.Entity;
-import javax.persistence.EntityListeners;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Version;
-import com.apssouza.validation.CheckIsValid;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.FetchType;
-import javax.persistence.JoinColumn;
-import javax.persistence.JoinTable;
-import javax.persistence.ManyToMany;
-import javax.persistence.OneToMany;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-import org.hibernate.annotations.CreationTimestamp;
-import org.hibernate.annotations.Generated;
-import org.hibernate.annotations.GenerationTime;
-
-/**
- * To Do entity
- * @author apssouza
- */
-@Entity
-@CheckIsValid
-@EntityListeners(ToDoEntityListener.class)
-public class ToDo implements ValidEntity, Cloneable {
-
- public enum TodoStatus { DONE, PENDING }
-
- @Id
- @GeneratedValue
- private long id;
-
- @NotNull
- @Size(min = 2, max = 256)
- private String caption;
-
- @Column(nullable = false)
- private String userEmail;
-
- private String description;
-
- @Generated(GenerationTime.INSERT) //ALWAYS, UPDATE
- @Temporal(TemporalType.TIMESTAMP)
- private Date createdat;
-
- private int priority;
-
- private TodoStatus status = TodoStatus.PENDING;
-
- @Version
- private long version;
-
- @OneToMany(
- cascade = CascadeType.ALL,
- mappedBy = "todo",
- orphanRemoval = true,
- fetch = FetchType.EAGER
- )
- private Set files = new HashSet<>();
-
- //We shouldn’t default to CascadeType.ALL because the CascadeType.REMOVE might
- //end-up deleting more than we’re expecting even if the relation be related to other register.
- @ManyToMany(
- cascade = {CascadeType.PERSIST, CascadeType.MERGE},
- fetch = FetchType.EAGER
- )
- @JoinTable(
- name = "todo_category",
- joinColumns = {
- @JoinColumn(
- name = "todo_id",
- referencedColumnName = "id"
- )
- },
- inverseJoinColumns = {
- @JoinColumn(
- name = "category_id",
- referencedColumnName = "id"
- )
- }
- )
- private List categories = new ArrayList<>();;
-
- public ToDo() {
- }
-
- public ToDo(String email, String caption, String description, int priority) {
- this.caption = caption;
- this.description = description;
- this.priority = priority;
- this.userEmail = email;
- }
-
- public ToDo(ToDo todo, List categories, Set files, TodoStatus status) {
- this(todo.getUserEmail(), todo.getCaption(), todo.getDescription(), todo.getPriority());
- this.categories = Collections.unmodifiableList(categories);
- this.files = Collections.unmodifiableSet(files);
- this.status = status;
- }
-
- public String getUserEmail() {
- return userEmail;
- }
-
- public void setUserEmail(String userEmail) {
- this.userEmail = userEmail;
- }
-
-
- public void setCategories(List categories){
- this.categories = Collections.unmodifiableList(categories);
- }
-
- public void setAttachments(Set files){
- this.files = Collections.unmodifiableSet(files);
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public void setCaption(String caption) {
- this.caption = caption;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public void setPriority(int priority) {
- this.priority = priority;
- }
-
- public void setFiles(Set files) {
- this.files = files;
- }
-
- public void setVersion(long version) {
- this.version = version;
- }
-
-
- public void setStatus(TodoStatus status){
- this.status = status;
- }
-
- public TodoStatus getStatus(){
- return status;
- }
-
- public Long getId() {
- return id;
- }
-
- public void setId(Long id) {
- this.id = id;
- }
-
- public String getCaption() {
- return caption;
- }
-
- public String getDescription() {
- return description;
- }
-
- public int getPriority() {
- return priority;
- }
-
- @JsonIgnore
- public Set getAttachments() {
- return new HashSet<>(files);
- }
-
- @JsonIgnore
- public List getCategories() {
- return new ArrayList<>(categories);
- }
-
- public long getVersion() {
- return version;
- }
-
- public Date getCreatedat() {
- return createdat;
- }
-
- public void setCreatedat(Date createdat) {
- this.createdat = createdat;
- }
-
- @Override
- public boolean isValid() {
- if (this.priority <= 10) {
- return true;
- }
- return (this.description != null && !this.description.isEmpty());
- }
-
- @Override
- public String toString() {
- return "ToDo{" + "id=" + id + ", caption=" + caption + ", description=" + description + ", priority=" + priority + ", done=" + status + ", version=" + version + '}';
- }
-
-}
+package com.apssouza.entities;
+
+import com.apssouza.monitors.ToDoEntityListener;
+import com.apssouza.validation.ValidEntity;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.persistence.Entity;
+import javax.persistence.EntityListeners;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Version;
+import com.apssouza.validation.CheckIsValid;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
+import javax.persistence.ManyToMany;
+import javax.persistence.OneToMany;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import org.hibernate.annotations.CreationTimestamp;
+import org.hibernate.annotations.Generated;
+import org.hibernate.annotations.GenerationTime;
+
+/**
+ * To Do entity
+ * @author apssouza
+ */
+@Entity
+@CheckIsValid
+@EntityListeners(ToDoEntityListener.class)
+public class ToDo implements ValidEntity, Cloneable {
+
+ public enum TodoStatus { DONE, PENDING }
+
+ @Id
+ @GeneratedValue
+ private long id;
+
+ @NotNull
+ @Size(min = 2, max = 256)
+ private String caption;
+
+ @Column(nullable = false)
+ private String userEmail;
+
+ private String description;
+
+ @Generated(GenerationTime.INSERT) //ALWAYS, UPDATE
+ @Temporal(TemporalType.TIMESTAMP)
+ private Date createdat;
+
+ private int priority;
+
+ private TodoStatus status = TodoStatus.PENDING;
+
+ @Version
+ private long version;
+
+ @OneToMany(
+ cascade = CascadeType.ALL,
+ mappedBy = "todo",
+ orphanRemoval = true,
+ fetch = FetchType.EAGER
+ )
+ private Set files = new HashSet<>();
+
+ //We shouldn’t default to CascadeType.ALL because the CascadeType.REMOVE might
+ //end-up deleting more than we’re expecting even if the relation be related to other register.
+ @ManyToMany(
+ cascade = {CascadeType.PERSIST, CascadeType.MERGE},
+ fetch = FetchType.EAGER
+ )
+ @JoinTable(
+ name = "todo_category",
+ joinColumns = {
+ @JoinColumn(
+ name = "todo_id",
+ referencedColumnName = "id"
+ )
+ },
+ inverseJoinColumns = {
+ @JoinColumn(
+ name = "category_id",
+ referencedColumnName = "id"
+ )
+ }
+ )
+ private List categories = new ArrayList<>();;
+
+ public ToDo() {
+ }
+
+ public ToDo(String email, String caption, String description, int priority) {
+ this.caption = caption;
+ this.description = description;
+ this.priority = priority;
+ this.userEmail = email;
+ }
+
+ public ToDo(ToDo todo, List categories, Set files, TodoStatus status) {
+ this(todo.getUserEmail(), todo.getCaption(), todo.getDescription(), todo.getPriority());
+ this.categories = Collections.unmodifiableList(categories);
+ this.files = Collections.unmodifiableSet(files);
+ this.status = status;
+ }
+
+ public String getUserEmail() {
+ return userEmail;
+ }
+
+ public void setUserEmail(String userEmail) {
+ this.userEmail = userEmail;
+ }
+
+
+ public void setCategories(List categories){
+ this.categories = Collections.unmodifiableList(categories);
+ }
+
+ public void setAttachments(Set files){
+ this.files = Collections.unmodifiableSet(files);
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public void setCaption(String caption) {
+ this.caption = caption;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setPriority(int priority) {
+ this.priority = priority;
+ }
+
+ public void setFiles(Set files) {
+ this.files = files;
+ }
+
+ public void setVersion(long version) {
+ this.version = version;
+ }
+
+
+ public void setStatus(TodoStatus status){
+ this.status = status;
+ }
+
+ public TodoStatus getStatus(){
+ return status;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getCaption() {
+ return caption;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public int getPriority() {
+ return priority;
+ }
+
+ @JsonIgnore
+ public Set getAttachments() {
+ return new HashSet<>(files);
+ }
+
+ @JsonIgnore
+ public List getCategories() {
+ return new ArrayList<>(categories);
+ }
+
+ public long getVersion() {
+ return version;
+ }
+
+ public Date getCreatedat() {
+ return createdat;
+ }
+
+ public void setCreatedat(Date createdat) {
+ this.createdat = createdat;
+ }
+
+ @Override
+ public boolean isValid() {
+ if (this.priority <= 10) {
+ return true;
+ }
+ return (this.description != null && !this.description.isEmpty());
+ }
+
+ @Override
+ public String toString() {
+ return "ToDo{" + "id=" + id + ", caption=" + caption + ", description=" + description + ", priority=" + priority + ", done=" + status + ", version=" + version + '}';
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/events/TodoChangedEvent.java b/remainder-service/src/main/java/com/apssouza/events/TodoChangedEvent.java
index 59ecd3d..419c3d6 100644
--- a/remainder-service/src/main/java/com/apssouza/events/TodoChangedEvent.java
+++ b/remainder-service/src/main/java/com/apssouza/events/TodoChangedEvent.java
@@ -1,18 +1,18 @@
-package com.apssouza.events;
-
-import com.apssouza.entities.ToDo;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-
-/**
- * Interface To Do changed event
- *
- * @author apssouza
- */
-public interface TodoChangedEvent {
-
- @JsonIgnore
- int getPriority();
-
- ToDo getTodo();
-
-}
+package com.apssouza.events;
+
+import com.apssouza.entities.ToDo;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+/**
+ * Interface To Do changed event
+ *
+ * @author apssouza
+ */
+public interface TodoChangedEvent {
+
+ @JsonIgnore
+ int getPriority();
+
+ ToDo getTodo();
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/events/TodoCreatedEvent.java b/remainder-service/src/main/java/com/apssouza/events/TodoCreatedEvent.java
index 345a1ad..ccfa923 100644
--- a/remainder-service/src/main/java/com/apssouza/events/TodoCreatedEvent.java
+++ b/remainder-service/src/main/java/com/apssouza/events/TodoCreatedEvent.java
@@ -1,42 +1,42 @@
-package com.apssouza.events;
-
-import com.apssouza.annotations.ChangeEvent;
-import com.apssouza.entities.ToDo;
-import com.apssouza.infra.AbstractDomainEvent;
-
-/**
- * To Do created event
- *
- * @author apssouza
- */
-@ChangeEvent(ChangeEvent.Type.CREATION)
-public class TodoCreatedEvent extends AbstractDomainEvent implements TodoChangedEvent {
-
- private ToDo todo;
-
- public TodoCreatedEvent(ToDo todo) {
- this.todo = todo;
- }
-
- public TodoCreatedEvent() {
- }
-
- public ToDo getTodo() {
- return todo;
- }
-
- public void setTodo(ToDo todo) {
- this.todo = todo;
- }
-
- @Override
- public int getPriority() {
- return this.todo.getPriority();
- }
-
- @Override
- public String toString() {
- return "TodoChangeEvent{" + "todo=" + todo.getDescription() + '}';
- }
-
-}
+package com.apssouza.events;
+
+import com.apssouza.annotations.ChangeEvent;
+import com.apssouza.entities.ToDo;
+import com.apssouza.infra.AbstractDomainEvent;
+
+/**
+ * To Do created event
+ *
+ * @author apssouza
+ */
+@ChangeEvent(ChangeEvent.Type.CREATION)
+public class TodoCreatedEvent extends AbstractDomainEvent implements TodoChangedEvent {
+
+ private ToDo todo;
+
+ public TodoCreatedEvent(ToDo todo) {
+ this.todo = todo;
+ }
+
+ public TodoCreatedEvent() {
+ }
+
+ public ToDo getTodo() {
+ return todo;
+ }
+
+ public void setTodo(ToDo todo) {
+ this.todo = todo;
+ }
+
+ @Override
+ public int getPriority() {
+ return this.todo.getPriority();
+ }
+
+ @Override
+ public String toString() {
+ return "TodoChangeEvent{" + "todo=" + todo.getDescription() + '}';
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/events/TodoServiceMethodInvokedEvent.java b/remainder-service/src/main/java/com/apssouza/events/TodoServiceMethodInvokedEvent.java
index 2a2296e..5ce14e9 100644
--- a/remainder-service/src/main/java/com/apssouza/events/TodoServiceMethodInvokedEvent.java
+++ b/remainder-service/src/main/java/com/apssouza/events/TodoServiceMethodInvokedEvent.java
@@ -1,34 +1,34 @@
-package com.apssouza.events;
-
-/**
- * To Do service method invoked event
- *
- * @author apssouza
- */
-public class TodoServiceMethodInvokedEvent {
-
- private String methodName;
- private long duration;
-
- public TodoServiceMethodInvokedEvent(String methodName, long duration) {
- this.methodName = methodName;
- this.duration = duration;
- }
-
- public TodoServiceMethodInvokedEvent() {
- }
-
- public String getMethodName() {
- return methodName;
- }
-
- public long getDuration() {
- return duration;
- }
-
- @Override
- public String toString() {
- return "CallEvent{" + "methodName=" + methodName + ", duration=" + duration + '}';
- }
-
-}
+package com.apssouza.events;
+
+/**
+ * To Do service method invoked event
+ *
+ * @author apssouza
+ */
+public class TodoServiceMethodInvokedEvent {
+
+ private String methodName;
+ private long duration;
+
+ public TodoServiceMethodInvokedEvent(String methodName, long duration) {
+ this.methodName = methodName;
+ this.duration = duration;
+ }
+
+ public TodoServiceMethodInvokedEvent() {
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public long getDuration() {
+ return duration;
+ }
+
+ @Override
+ public String toString() {
+ return "CallEvent{" + "methodName=" + methodName + ", duration=" + duration + '}';
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/events/TodoUpdatedEvent.java b/remainder-service/src/main/java/com/apssouza/events/TodoUpdatedEvent.java
index 168ae01..bcdbf52 100644
--- a/remainder-service/src/main/java/com/apssouza/events/TodoUpdatedEvent.java
+++ b/remainder-service/src/main/java/com/apssouza/events/TodoUpdatedEvent.java
@@ -1,41 +1,41 @@
-package com.apssouza.events;
-
-import com.apssouza.annotations.ChangeEvent;
-import com.apssouza.entities.ToDo;
-import com.apssouza.infra.AbstractDomainEvent;
-
-/**
- * To Do updated event
- *
- * @author apssouza
- */
-@ChangeEvent(ChangeEvent.Type.UPDATE)
-public class TodoUpdatedEvent extends AbstractDomainEvent implements TodoChangedEvent {
-
- private ToDo todo;
-
- public TodoUpdatedEvent(ToDo todo) {
- this.todo = todo;
- }
-
- public TodoUpdatedEvent() {
- }
-
- public ToDo getTodo() {
- return todo;
- }
-
- public void setTodo(ToDo todo) {
- this.todo = todo;
- }
-
- public int getPriority() {
- return this.todo.getPriority();
- }
-
- @Override
- public String toString() {
- return "TodoChangeEvent{" + "todo=" + todo.getDescription() + '}';
- }
-
-}
+package com.apssouza.events;
+
+import com.apssouza.annotations.ChangeEvent;
+import com.apssouza.entities.ToDo;
+import com.apssouza.infra.AbstractDomainEvent;
+
+/**
+ * To Do updated event
+ *
+ * @author apssouza
+ */
+@ChangeEvent(ChangeEvent.Type.UPDATE)
+public class TodoUpdatedEvent extends AbstractDomainEvent implements TodoChangedEvent {
+
+ private ToDo todo;
+
+ public TodoUpdatedEvent(ToDo todo) {
+ this.todo = todo;
+ }
+
+ public TodoUpdatedEvent() {
+ }
+
+ public ToDo getTodo() {
+ return todo;
+ }
+
+ public void setTodo(ToDo todo) {
+ this.todo = todo;
+ }
+
+ public int getPriority() {
+ return this.todo.getPriority();
+ }
+
+ @Override
+ public String toString() {
+ return "TodoChangeEvent{" + "todo=" + todo.getDescription() + '}';
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/exceptions/DataNotFoundException.java b/remainder-service/src/main/java/com/apssouza/exceptions/DataNotFoundException.java
index e36bdd8..8c7a4ba 100644
--- a/remainder-service/src/main/java/com/apssouza/exceptions/DataNotFoundException.java
+++ b/remainder-service/src/main/java/com/apssouza/exceptions/DataNotFoundException.java
@@ -1,17 +1,17 @@
-package com.apssouza.exceptions;
-
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-/**
- * Data not found exception response 404 http status to the client
- *
- * @author Apssouza
- */
-@ResponseStatus(HttpStatus.NOT_FOUND)
-public class DataNotFoundException extends RuntimeException {
-
- public DataNotFoundException(String msg) {
- super(msg);
- }
-}
+package com.apssouza.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Data not found exception response 404 http status to the client
+ *
+ * @author Apssouza
+ */
+@ResponseStatus(HttpStatus.NOT_FOUND)
+public class DataNotFoundException extends RuntimeException {
+
+ public DataNotFoundException(String msg) {
+ super(msg);
+ }
+}
diff --git a/remainder-service/src/main/java/com/apssouza/helpers/AutowireHelper.java b/remainder-service/src/main/java/com/apssouza/helpers/AutowireHelper.java
index ea6d06c..3745905 100644
--- a/remainder-service/src/main/java/com/apssouza/helpers/AutowireHelper.java
+++ b/remainder-service/src/main/java/com/apssouza/helpers/AutowireHelper.java
@@ -1,56 +1,56 @@
-package com.apssouza.helpers;
-
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ApplicationContext;
-import org.springframework.stereotype.Component;
-
-/**
- *
- * @author apssouza
- */
-/**
- * Helper class which is able to autowire a specified class. It holds a static
- * reference to the {@link org
- * .springframework.context.ApplicationContext}.
- */
-@Component
-public final class AutowireHelper implements ApplicationContextAware {
-
- private static final AutowireHelper INSTANCE = new AutowireHelper();
-
- private static ApplicationContext applicationContext;
-
- private AutowireHelper() {
- }
-
- /**
- * Tries to autowire the specified instance of the class if one of the
- * specified beans which need to be autowired are null.
- *
- * @param classToAutowire the instance of the class which holds @Autowire
- * annotations
- * @param beansToAutowireInClass the beans which have the @Autowire
- * annotation in the specified {#classToAutowire}
- */
- public static void autowire(Object classToAutowire, Object... beansToAutowireInClass) {
- for (Object bean : beansToAutowireInClass) {
- if (bean == null) {
- applicationContext.getAutowireCapableBeanFactory().autowireBean(classToAutowire);
- return;
- }
- }
- }
-
- @Override
- public void setApplicationContext(final ApplicationContext applicationContext) {
- AutowireHelper.applicationContext = applicationContext;
- }
-
- /**
- * @return the singleton instance.
- */
- public static AutowireHelper getInstance() {
- return INSTANCE;
- }
-
-}
+package com.apssouza.helpers;
+
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.context.ApplicationContext;
+import org.springframework.stereotype.Component;
+
+/**
+ *
+ * @author apssouza
+ */
+/**
+ * Helper class which is able to autowire a specified class. It holds a static
+ * reference to the {@link org
+ * .springframework.context.ApplicationContext}.
+ */
+@Component
+public final class AutowireHelper implements ApplicationContextAware {
+
+ private static final AutowireHelper INSTANCE = new AutowireHelper();
+
+ private static ApplicationContext applicationContext;
+
+ private AutowireHelper() {
+ }
+
+ /**
+ * Tries to autowire the specified instance of the class if one of the
+ * specified beans which need to be autowired are null.
+ *
+ * @param classToAutowire the instance of the class which holds @Autowire
+ * annotations
+ * @param beansToAutowireInClass the beans which have the @Autowire
+ * annotation in the specified {#classToAutowire}
+ */
+ public static void autowire(Object classToAutowire, Object... beansToAutowireInClass) {
+ for (Object bean : beansToAutowireInClass) {
+ if (bean == null) {
+ applicationContext.getAutowireCapableBeanFactory().autowireBean(classToAutowire);
+ return;
+ }
+ }
+ }
+
+ @Override
+ public void setApplicationContext(final ApplicationContext applicationContext) {
+ AutowireHelper.applicationContext = applicationContext;
+ }
+
+ /**
+ * @return the singleton instance.
+ */
+ public static AutowireHelper getInstance() {
+ return INSTANCE;
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/integrations/socket/TodoChangeSocketNotify.java b/remainder-service/src/main/java/com/apssouza/integrations/socket/TodoChangeSocketNotify.java
index 517cea7..f3991d2 100644
--- a/remainder-service/src/main/java/com/apssouza/integrations/socket/TodoChangeSocketNotify.java
+++ b/remainder-service/src/main/java/com/apssouza/integrations/socket/TodoChangeSocketNotify.java
@@ -1,37 +1,37 @@
-package com.apssouza.integrations.socket;
-
-import com.apssouza.annotations.ChangeEvent;
-import com.apssouza.entities.ToDo;
-import com.apssouza.events.TodoChangedEvent;
-import com.apssouza.pojos.SocketOutputMessage;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import javax.websocket.EncodeException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.messaging.simp.SimpMessagingTemplate;
-import org.springframework.stereotype.Component;
-
-/**
- * Component responsible to notify socket clients.
- *
- * @author apssouza
- */
-@Component
-public class TodoChangeSocketNotify {
-
- @Autowired
- private SimpMessagingTemplate template;
-
- public void notify(TodoChangedEvent e) throws EncodeException {
- ToDo todo = e.getTodo();
- String time = new SimpleDateFormat("HH:mm").format(new Date());
- Class extends TodoChangedEvent> aClass = e.getClass();
-
- ChangeEvent annotation = aClass.getAnnotation(ChangeEvent.class);
- ChangeEvent.Type value = annotation.value();
- SocketOutputMessage socketOutputMessage = new SocketOutputMessage(todo, value.toString(), time);
- template.convertAndSend("/topic/todos", socketOutputMessage);
- }
-
-}
+package com.apssouza.integrations.socket;
+
+import com.apssouza.annotations.ChangeEvent;
+import com.apssouza.entities.ToDo;
+import com.apssouza.events.TodoChangedEvent;
+import com.apssouza.pojos.SocketOutputMessage;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.websocket.EncodeException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.messaging.simp.SimpMessagingTemplate;
+import org.springframework.stereotype.Component;
+
+/**
+ * Component responsible to notify socket clients.
+ *
+ * @author apssouza
+ */
+@Component
+public class TodoChangeSocketNotify {
+
+ @Autowired
+ private SimpMessagingTemplate template;
+
+ public void notify(TodoChangedEvent e) throws EncodeException {
+ ToDo todo = e.getTodo();
+ String time = new SimpleDateFormat("HH:mm").format(new Date());
+ Class extends TodoChangedEvent> aClass = e.getClass();
+
+ ChangeEvent annotation = aClass.getAnnotation(ChangeEvent.class);
+ ChangeEvent.Type value = annotation.value();
+ SocketOutputMessage socketOutputMessage = new SocketOutputMessage(todo, value.toString(), time);
+ template.convertAndSend("/topic/todos", socketOutputMessage);
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/integrations/socket/TodoSocketController.java b/remainder-service/src/main/java/com/apssouza/integrations/socket/TodoSocketController.java
index 7cb2101..2dca0ca 100644
--- a/remainder-service/src/main/java/com/apssouza/integrations/socket/TodoSocketController.java
+++ b/remainder-service/src/main/java/com/apssouza/integrations/socket/TodoSocketController.java
@@ -1,21 +1,21 @@
-package com.apssouza.integrations.socket;
-
-import com.apssouza.pojos.SocketOutputMessage;
-import org.springframework.messaging.handler.annotation.MessageMapping;
-import org.springframework.messaging.handler.annotation.SendTo;
-import org.springframework.stereotype.Controller;
-
-/**
- * A socket endpoint controller
- *
- * @author apssouza
- */
-@Controller
-public class TodoSocketController {
-
- @MessageMapping("/socket-todos")
- @SendTo("/topic/todos")
- public SocketOutputMessage send(SocketOutputMessage message) throws Exception {
- return message;
- }
-}
+package com.apssouza.integrations.socket;
+
+import com.apssouza.pojos.SocketOutputMessage;
+import org.springframework.messaging.handler.annotation.MessageMapping;
+import org.springframework.messaging.handler.annotation.SendTo;
+import org.springframework.stereotype.Controller;
+
+/**
+ * A socket endpoint controller
+ *
+ * @author apssouza
+ */
+@Controller
+public class TodoSocketController {
+
+ @MessageMapping("/socket-todos")
+ @SendTo("/topic/todos")
+ public SocketOutputMessage send(SocketOutputMessage message) throws Exception {
+ return message;
+ }
+}
diff --git a/remainder-service/src/main/java/com/apssouza/listeners/TodoChangedListener.java b/remainder-service/src/main/java/com/apssouza/listeners/TodoChangedListener.java
index b0eb71e..ce46511 100644
--- a/remainder-service/src/main/java/com/apssouza/listeners/TodoChangedListener.java
+++ b/remainder-service/src/main/java/com/apssouza/listeners/TodoChangedListener.java
@@ -1,31 +1,31 @@
-package com.apssouza.listeners;
-
-import com.apssouza.events.TodoChangedEvent;
-import com.apssouza.integrations.socket.TodoChangeSocketNotify;
-import com.apssouza.monitors.TodoStoreEventChanges;
-import javax.websocket.EncodeException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.event.EventListener;
-import org.springframework.stereotype.Component;
-
-/**
- * ToDo Changed listener.
- *
- * @author apssouza
- */
-@Component
-public class TodoChangedListener {
-
- @Autowired
- TodoStoreEventChanges changesMonitor;
-
- @Autowired
- TodoChangeSocketNotify socketNotify;
-
- @EventListener
- public void onTodoChange(TodoChangedEvent event) throws EncodeException {
- changesMonitor.addNewEvent(event);
- socketNotify.notify(event);
- }
-
-}
+package com.apssouza.listeners;
+
+import com.apssouza.events.TodoChangedEvent;
+import com.apssouza.integrations.socket.TodoChangeSocketNotify;
+import com.apssouza.monitors.TodoStoreEventChanges;
+import javax.websocket.EncodeException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.event.EventListener;
+import org.springframework.stereotype.Component;
+
+/**
+ * ToDo Changed listener.
+ *
+ * @author apssouza
+ */
+@Component
+public class TodoChangedListener {
+
+ @Autowired
+ TodoStoreEventChanges changesMonitor;
+
+ @Autowired
+ TodoChangeSocketNotify socketNotify;
+
+ @EventListener
+ public void onTodoChange(TodoChangedEvent event) throws EncodeException {
+ changesMonitor.addNewEvent(event);
+ socketNotify.notify(event);
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/listeners/TodoServiceMethodListener.java b/remainder-service/src/main/java/com/apssouza/listeners/TodoServiceMethodListener.java
index 5e3ca2e..0c92297 100644
--- a/remainder-service/src/main/java/com/apssouza/listeners/TodoServiceMethodListener.java
+++ b/remainder-service/src/main/java/com/apssouza/listeners/TodoServiceMethodListener.java
@@ -1,25 +1,25 @@
-package com.apssouza.listeners;
-
-import com.apssouza.events.TodoServiceMethodInvokedEvent;
-import com.apssouza.monitors.TodoServiceMethodInvokedStore;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.event.EventListener;
-import org.springframework.stereotype.Component;
-
-/**
- * TodoService method invoked listener
- *
- * @author apssouza
- */
-@Component
-public class TodoServiceMethodListener {
-
- @Autowired
- private TodoServiceMethodInvokedStore methodMonitor;
-
- @EventListener
- public void onMethodCalled(TodoServiceMethodInvokedEvent event){
- methodMonitor.addNewEvent(event);
- }
-
-}
+package com.apssouza.listeners;
+
+import com.apssouza.events.TodoServiceMethodInvokedEvent;
+import com.apssouza.monitors.TodoServiceMethodInvokedStore;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.event.EventListener;
+import org.springframework.stereotype.Component;
+
+/**
+ * TodoService method invoked listener
+ *
+ * @author apssouza
+ */
+@Component
+public class TodoServiceMethodListener {
+
+ @Autowired
+ private TodoServiceMethodInvokedStore methodMonitor;
+
+ @EventListener
+ public void onMethodCalled(TodoServiceMethodInvokedEvent event){
+ methodMonitor.addNewEvent(event);
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/monitors/ToDoEntityListener.java b/remainder-service/src/main/java/com/apssouza/monitors/ToDoEntityListener.java
index a255fc0..857ad1b 100644
--- a/remainder-service/src/main/java/com/apssouza/monitors/ToDoEntityListener.java
+++ b/remainder-service/src/main/java/com/apssouza/monitors/ToDoEntityListener.java
@@ -1,36 +1,36 @@
-package com.apssouza.monitors;
-
-import com.apssouza.entities.ToDo;
-import com.apssouza.events.TodoCreatedEvent;
-import com.apssouza.events.TodoUpdatedEvent;
-import com.apssouza.helpers.AutowireHelper;
-import com.apssouza.infra.EventPublisher;
-import javax.persistence.PostPersist;
-import javax.persistence.PostUpdate;
-import org.springframework.beans.factory.annotation.Autowired;
-
-/**
- * ToDo's entity listener
- *
- * @author apssouza
- */
-public class ToDoEntityListener {
-
- @Autowired
- private EventPublisher publisher;
-
- @PostPersist
- public void onPersist(ToDo todo) {
- //ToDoPersistenceMonitor is not a spring managed been, so we need to inject
- // publisher using this simple helper
- AutowireHelper.autowire(this, this.publisher);
- this.publisher.publish(new TodoCreatedEvent(todo));
- }
-
- @PostUpdate
- public void onUpdate(ToDo todo) {
- AutowireHelper.autowire(this, this.publisher);
- this.publisher.publish(new TodoUpdatedEvent(todo));
- }
-
-}
+package com.apssouza.monitors;
+
+import com.apssouza.entities.ToDo;
+import com.apssouza.events.TodoCreatedEvent;
+import com.apssouza.events.TodoUpdatedEvent;
+import com.apssouza.helpers.AutowireHelper;
+import com.apssouza.infra.EventPublisher;
+import javax.persistence.PostPersist;
+import javax.persistence.PostUpdate;
+import org.springframework.beans.factory.annotation.Autowired;
+
+/**
+ * ToDo's entity listener
+ *
+ * @author apssouza
+ */
+public class ToDoEntityListener {
+
+ @Autowired
+ private EventPublisher publisher;
+
+ @PostPersist
+ public void onPersist(ToDo todo) {
+ //ToDoPersistenceMonitor is not a spring managed been, so we need to inject
+ // publisher using this simple helper
+ AutowireHelper.autowire(this, this.publisher);
+ this.publisher.publish(new TodoCreatedEvent(todo));
+ }
+
+ @PostUpdate
+ public void onUpdate(ToDo todo) {
+ AutowireHelper.autowire(this, this.publisher);
+ this.publisher.publish(new TodoUpdatedEvent(todo));
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/monitors/TodoServiceMethodInvokedStore.java b/remainder-service/src/main/java/com/apssouza/monitors/TodoServiceMethodInvokedStore.java
index 9d776d8..58d20e0 100644
--- a/remainder-service/src/main/java/com/apssouza/monitors/TodoServiceMethodInvokedStore.java
+++ b/remainder-service/src/main/java/com/apssouza/monitors/TodoServiceMethodInvokedStore.java
@@ -1,38 +1,38 @@
-package com.apssouza.monitors;
-
-import com.apssouza.events.TodoServiceMethodInvokedEvent;
-import java.util.List;
-import java.util.LongSummaryStatistics;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.stream.Collectors;
-import javax.annotation.PostConstruct;
-import org.springframework.stereotype.Component;
-
-/**
- * Store TodoService method invoked.
- *
- * @author apssouza
- */
-@Component
-public class TodoServiceMethodInvokedStore {
-
- private CopyOnWriteArrayList events;
-
- @PostConstruct
- public void init() {
- this.events = new CopyOnWriteArrayList<>();
- }
-
- public void addNewEvent(TodoServiceMethodInvokedEvent event) {
- this.events.add(event);
- }
-
- public List getRecentChanges() {
- return this.events;
- }
-
- public LongSummaryStatistics getStatistics() {
- return this.events.stream().
- collect(Collectors.summarizingLong(TodoServiceMethodInvokedEvent::getDuration));
- }
-}
+package com.apssouza.monitors;
+
+import com.apssouza.events.TodoServiceMethodInvokedEvent;
+import java.util.List;
+import java.util.LongSummaryStatistics;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.stream.Collectors;
+import javax.annotation.PostConstruct;
+import org.springframework.stereotype.Component;
+
+/**
+ * Store TodoService method invoked.
+ *
+ * @author apssouza
+ */
+@Component
+public class TodoServiceMethodInvokedStore {
+
+ private CopyOnWriteArrayList events;
+
+ @PostConstruct
+ public void init() {
+ this.events = new CopyOnWriteArrayList<>();
+ }
+
+ public void addNewEvent(TodoServiceMethodInvokedEvent event) {
+ this.events.add(event);
+ }
+
+ public List getRecentChanges() {
+ return this.events;
+ }
+
+ public LongSummaryStatistics getStatistics() {
+ return this.events.stream().
+ collect(Collectors.summarizingLong(TodoServiceMethodInvokedEvent::getDuration));
+ }
+}
diff --git a/remainder-service/src/main/java/com/apssouza/monitors/TodoStoreEventChanges.java b/remainder-service/src/main/java/com/apssouza/monitors/TodoStoreEventChanges.java
index 6dc30a1..5258f22 100644
--- a/remainder-service/src/main/java/com/apssouza/monitors/TodoStoreEventChanges.java
+++ b/remainder-service/src/main/java/com/apssouza/monitors/TodoStoreEventChanges.java
@@ -1,38 +1,38 @@
-package com.apssouza.monitors;
-
-import com.apssouza.events.TodoChangedEvent;
-import java.util.List;
-import java.util.LongSummaryStatistics;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.stream.Collectors;
-import javax.annotation.PostConstruct;
-import org.springframework.stereotype.Component;
-
-/**
- * Store ToDo event changes.
- *
- * @author apssouza
- */
-@Component
-public class TodoStoreEventChanges {
-
- private CopyOnWriteArrayList events;
-
- @PostConstruct
- public void init() {
- this.events = new CopyOnWriteArrayList<>();
- }
-
- public void addNewEvent(TodoChangedEvent event) {
- this.events.add(event);
- }
-
- public List getRecentEvents() {
- return this.events;
- }
-
- public LongSummaryStatistics getStatistics() {
- return this.events.stream().
- collect(Collectors.summarizingLong(TodoChangedEvent::getPriority));
- }
-}
+package com.apssouza.monitors;
+
+import com.apssouza.events.TodoChangedEvent;
+import java.util.List;
+import java.util.LongSummaryStatistics;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.stream.Collectors;
+import javax.annotation.PostConstruct;
+import org.springframework.stereotype.Component;
+
+/**
+ * Store ToDo event changes.
+ *
+ * @author apssouza
+ */
+@Component
+public class TodoStoreEventChanges {
+
+ private CopyOnWriteArrayList events;
+
+ @PostConstruct
+ public void init() {
+ this.events = new CopyOnWriteArrayList<>();
+ }
+
+ public void addNewEvent(TodoChangedEvent event) {
+ this.events.add(event);
+ }
+
+ public List getRecentEvents() {
+ return this.events;
+ }
+
+ public LongSummaryStatistics getStatistics() {
+ return this.events.stream().
+ collect(Collectors.summarizingLong(TodoChangedEvent::getPriority));
+ }
+}
diff --git a/remainder-service/src/main/java/com/apssouza/pojos/SocketOutputMessage.java b/remainder-service/src/main/java/com/apssouza/pojos/SocketOutputMessage.java
index aec8816..f4c4909 100644
--- a/remainder-service/src/main/java/com/apssouza/pojos/SocketOutputMessage.java
+++ b/remainder-service/src/main/java/com/apssouza/pojos/SocketOutputMessage.java
@@ -1,34 +1,34 @@
-package com.apssouza.pojos;
-
-import com.apssouza.entities.ToDo;
-
-/**
- * Socket message output.
- *
- * @author apssouza
- */
-public class SocketOutputMessage {
-
- private final ToDo todo;
- private final String state;
- private final String time;
-
- public SocketOutputMessage(ToDo todo, String state, String time) {
- this.todo = todo;
- this.state = state;
- this.time = time;
- }
-
- public ToDo getTodo() {
- return todo;
- }
-
- public String getState() {
- return state;
- }
-
- public String getTime() {
- return time;
- }
-
-}
+package com.apssouza.pojos;
+
+import com.apssouza.entities.ToDo;
+
+/**
+ * Socket message output.
+ *
+ * @author apssouza
+ */
+public class SocketOutputMessage {
+
+ private final ToDo todo;
+ private final String state;
+ private final String time;
+
+ public SocketOutputMessage(ToDo todo, String state, String time) {
+ this.todo = todo;
+ this.state = state;
+ this.time = time;
+ }
+
+ public ToDo getTodo() {
+ return todo;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public String getTime() {
+ return time;
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/repositories/AttachmentRepository.java b/remainder-service/src/main/java/com/apssouza/repositories/AttachmentRepository.java
index 9483110..98fc3d9 100644
--- a/remainder-service/src/main/java/com/apssouza/repositories/AttachmentRepository.java
+++ b/remainder-service/src/main/java/com/apssouza/repositories/AttachmentRepository.java
@@ -1,14 +1,14 @@
-package com.apssouza.repositories;
-
-
-import com.apssouza.entities.Attachment;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-/**
- * @author apssouza
- */
-@Repository
-public interface AttachmentRepository extends JpaRepository {
-
-}
+package com.apssouza.repositories;
+
+
+import com.apssouza.entities.Attachment;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author apssouza
+ */
+@Repository
+public interface AttachmentRepository extends JpaRepository {
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/repositories/CategoryRepository.java b/remainder-service/src/main/java/com/apssouza/repositories/CategoryRepository.java
index 16bbb14..817db84 100644
--- a/remainder-service/src/main/java/com/apssouza/repositories/CategoryRepository.java
+++ b/remainder-service/src/main/java/com/apssouza/repositories/CategoryRepository.java
@@ -1,14 +1,14 @@
-package com.apssouza.repositories;
-
-
-import com.apssouza.entities.Category;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-/**
- * @author apssouza
- */
-@Repository
-public interface CategoryRepository extends JpaRepository {
-
-}
+package com.apssouza.repositories;
+
+
+import com.apssouza.entities.Category;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author apssouza
+ */
+@Repository
+public interface CategoryRepository extends JpaRepository {
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/repositories/TodoRepository.java b/remainder-service/src/main/java/com/apssouza/repositories/TodoRepository.java
index b01411f..0385251 100644
--- a/remainder-service/src/main/java/com/apssouza/repositories/TodoRepository.java
+++ b/remainder-service/src/main/java/com/apssouza/repositories/TodoRepository.java
@@ -1,18 +1,18 @@
-package com.apssouza.repositories;
-
-
-import com.apssouza.entities.ToDo;
-import java.util.List;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-/**
- * @author apssouza
- */
-@Repository
-public interface TodoRepository extends JpaRepository {
-
- boolean deleteById(Long id);
-
- List findByUserEmail(String email);
-}
+package com.apssouza.repositories;
+
+
+import com.apssouza.entities.ToDo;
+import java.util.List;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author apssouza
+ */
+@Repository
+public interface TodoRepository extends JpaRepository {
+
+ boolean deleteById(Long id);
+
+ List findByUserEmail(String email);
+}
diff --git a/remainder-service/src/main/java/com/apssouza/services/TodoService.java b/remainder-service/src/main/java/com/apssouza/services/TodoService.java
index 376b74e..2c4b016 100644
--- a/remainder-service/src/main/java/com/apssouza/services/TodoService.java
+++ b/remainder-service/src/main/java/com/apssouza/services/TodoService.java
@@ -1,27 +1,27 @@
-package com.apssouza.services;
-
-import com.apssouza.entities.ToDo;
-import com.apssouza.exceptions.DataNotFoundException;
-import java.util.List;
-import java.util.Optional;
-
-/**
- *
- * @author apssouza
- */
-public interface TodoService {
-
- Optional findById(long id);
-
- Boolean delete(long id) throws DataNotFoundException;
-
- List all();
-
- ToDo save(ToDo todo);
-
- ToDo updateStatus(long id, ToDo.TodoStatus status) throws DataNotFoundException;
-
- ToDo update(Long id, ToDo toDo) throws DataNotFoundException;
-
- List getByUserEmail(String email);
-}
+package com.apssouza.services;
+
+import com.apssouza.entities.ToDo;
+import com.apssouza.exceptions.DataNotFoundException;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ *
+ * @author apssouza
+ */
+public interface TodoService {
+
+ Optional findById(long id);
+
+ Boolean delete(long id) throws DataNotFoundException;
+
+ List all();
+
+ ToDo save(ToDo todo);
+
+ ToDo updateStatus(long id, ToDo.TodoStatus status) throws DataNotFoundException;
+
+ ToDo update(Long id, ToDo toDo) throws DataNotFoundException;
+
+ List getByUserEmail(String email);
+}
diff --git a/remainder-service/src/main/java/com/apssouza/services/TodoServiceImpl.java b/remainder-service/src/main/java/com/apssouza/services/TodoServiceImpl.java
index 09e0c40..9352c6c 100644
--- a/remainder-service/src/main/java/com/apssouza/services/TodoServiceImpl.java
+++ b/remainder-service/src/main/java/com/apssouza/services/TodoServiceImpl.java
@@ -1,82 +1,82 @@
-package com.apssouza.services;
-
-import com.apssouza.repositories.TodoRepository;
-import com.apssouza.entities.ToDo;
-import com.apssouza.events.TodoCreatedEvent;
-import com.apssouza.exceptions.DataNotFoundException;
-import com.apssouza.infra.EventPublisher;
-import com.apssouza.monitoring.CallMonitoringAspect;
-import com.apssouza.monitoring.Monitored;
-import java.util.List;
-import java.util.Optional;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-@Service
-public class TodoServiceImpl implements TodoService {
-
- @Autowired
- private TodoRepository todoRepository;
-
- @Autowired
- private EventPublisher publisher;
-
- @Override
- @Monitored
- public Optional findById(long id) {
- return Optional.ofNullable(this.todoRepository.findOne(id));
- }
-
- @Override
- @Monitored
- public Boolean delete(long id) throws DataNotFoundException {
- this.findById(id)
- .orElseThrow(() -> new DataNotFoundException("Not found ToDo id " + id));
-
- return this.todoRepository.deleteById(id);
- }
-
- @Override
- @Monitored
- public List all() {
- return this.todoRepository.findAll();
- }
-
- @Override
- @Monitored
- public ToDo save(ToDo todo) {
- ToDo savedTodo = this.todoRepository.save(todo);
- this.publisher.stream(new TodoCreatedEvent(savedTodo));
- return savedTodo;
-
- }
-
- @Override
- @Monitored
- public ToDo updateStatus(long id, ToDo.TodoStatus status) throws DataNotFoundException {
- return this.findById(id)
- .map((t) -> {
- t.setStatus(status);
- return todoRepository.save(t);
- }).orElseThrow(() -> new DataNotFoundException("Not found ToDo id " + id));
- }
-
- @Override
- @Monitored
- public ToDo update(Long id, ToDo toDo) throws DataNotFoundException {
- return this.findById(id)
- .map(todo -> {
- todo.setCaption(toDo.getCaption());
- todo.setDescription(toDo.getDescription());
- todo.setPriority(toDo.getPriority());
- return save(todo);
- }).orElseThrow(() -> new DataNotFoundException("User not found"));
- }
-
- @Override
- @Monitored
- public List getByUserEmail(String email) {
- return this.todoRepository.findByUserEmail(email);
- }
-
-}
+package com.apssouza.services;
+
+import com.apssouza.repositories.TodoRepository;
+import com.apssouza.entities.ToDo;
+import com.apssouza.events.TodoCreatedEvent;
+import com.apssouza.exceptions.DataNotFoundException;
+import com.apssouza.infra.EventPublisher;
+import com.apssouza.monitoring.CallMonitoringAspect;
+import com.apssouza.monitoring.Monitored;
+import java.util.List;
+import java.util.Optional;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class TodoServiceImpl implements TodoService {
+
+ @Autowired
+ private TodoRepository todoRepository;
+
+ @Autowired
+ private EventPublisher publisher;
+
+ @Override
+ @Monitored
+ public Optional findById(long id) {
+ return Optional.ofNullable(this.todoRepository.findOne(id));
+ }
+
+ @Override
+ @Monitored
+ public Boolean delete(long id) throws DataNotFoundException {
+ this.findById(id)
+ .orElseThrow(() -> new DataNotFoundException("Not found ToDo id " + id));
+
+ return this.todoRepository.deleteById(id);
+ }
+
+ @Override
+ @Monitored
+ public List all() {
+ return this.todoRepository.findAll();
+ }
+
+ @Override
+ @Monitored
+ public ToDo save(ToDo todo) {
+ ToDo savedTodo = this.todoRepository.save(todo);
+ this.publisher.stream(new TodoCreatedEvent(savedTodo));
+ return savedTodo;
+
+ }
+
+ @Override
+ @Monitored
+ public ToDo updateStatus(long id, ToDo.TodoStatus status) throws DataNotFoundException {
+ return this.findById(id)
+ .map((t) -> {
+ t.setStatus(status);
+ return todoRepository.save(t);
+ }).orElseThrow(() -> new DataNotFoundException("Not found ToDo id " + id));
+ }
+
+ @Override
+ @Monitored
+ public ToDo update(Long id, ToDo toDo) throws DataNotFoundException {
+ return this.findById(id)
+ .map(todo -> {
+ todo.setCaption(toDo.getCaption());
+ todo.setDescription(toDo.getDescription());
+ todo.setPriority(toDo.getPriority());
+ return save(todo);
+ }).orElseThrow(() -> new DataNotFoundException("User not found"));
+ }
+
+ @Override
+ @Monitored
+ public List getByUserEmail(String email) {
+ return this.todoRepository.findByUserEmail(email);
+ }
+
+}
diff --git a/remainder-service/src/main/java/com/apssouza/validation/CheckIsValid.java b/remainder-service/src/main/java/com/apssouza/validation/CheckIsValid.java
index 398340b..52912b2 100644
--- a/remainder-service/src/main/java/com/apssouza/validation/CheckIsValid.java
+++ b/remainder-service/src/main/java/com/apssouza/validation/CheckIsValid.java
@@ -1,26 +1,26 @@
-package com.apssouza.validation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-import javax.validation.Constraint;
-import javax.validation.Payload;
-
-/**
- * Check if the instance is valid.
- * @author apssouza
- */
-@Documented
-@Constraint(validatedBy = CrossCheckConstraintValidator.class)
-@Target({ElementType.TYPE})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface CheckIsValid {
-
- String message() default "Cross check failed!";
-
- Class>[] groups() default {};
-
- Class extends Payload>[] payload() default {};
-}
+package com.apssouza.validation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import javax.validation.Constraint;
+import javax.validation.Payload;
+
+/**
+ * Check if the instance is valid.
+ * @author apssouza
+ */
+@Documented
+@Constraint(validatedBy = CrossCheckConstraintValidator.class)
+@Target({ElementType.TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface CheckIsValid {
+
+ String message() default "Cross check failed!";
+
+ Class>[] groups() default {};
+
+ Class extends Payload>[] payload() default {};
+}
diff --git a/remainder-service/src/main/java/com/apssouza/validation/CrossCheckConstraintValidator.java b/remainder-service/src/main/java/com/apssouza/validation/CrossCheckConstraintValidator.java
index d517bc2..476f024 100644
--- a/remainder-service/src/main/java/com/apssouza/validation/CrossCheckConstraintValidator.java
+++ b/remainder-service/src/main/java/com/apssouza/validation/CrossCheckConstraintValidator.java
@@ -1,21 +1,21 @@
-package com.apssouza.validation;
-
-import javax.validation.ConstraintValidator;
-import javax.validation.ConstraintValidatorContext;
-
-/**
- * A constraint ToDo validator
- *
- * @author apssouza
- */
-public class CrossCheckConstraintValidator implements ConstraintValidator {
-
- @Override
- public void initialize(CheckIsValid constraintAnnotation) {
- }
-
- @Override
- public boolean isValid(ValidEntity entity, ConstraintValidatorContext context) {
- return entity.isValid();
- }
-}
+package com.apssouza.validation;
+
+import javax.validation.ConstraintValidator;
+import javax.validation.ConstraintValidatorContext;
+
+/**
+ * A constraint ToDo validator
+ *
+ * @author apssouza
+ */
+public class CrossCheckConstraintValidator implements ConstraintValidator {
+
+ @Override
+ public void initialize(CheckIsValid constraintAnnotation) {
+ }
+
+ @Override
+ public boolean isValid(ValidEntity entity, ConstraintValidatorContext context) {
+ return entity.isValid();
+ }
+}
diff --git a/remainder-service/src/main/java/com/apssouza/validation/ValidEntity.java b/remainder-service/src/main/java/com/apssouza/validation/ValidEntity.java
index 35860c6..d9e2390 100644
--- a/remainder-service/src/main/java/com/apssouza/validation/ValidEntity.java
+++ b/remainder-service/src/main/java/com/apssouza/validation/ValidEntity.java
@@ -1,12 +1,12 @@
-package com.apssouza.validation;
-
-/**
- * Valid entity interface
- *
- * @author apssouza
- */
-public interface ValidEntity {
-
- boolean isValid();
-
-}
+package com.apssouza.validation;
+
+/**
+ * Valid entity interface
+ *
+ * @author apssouza
+ */
+public interface ValidEntity {
+
+ boolean isValid();
+
+}
diff --git a/remainder-service/src/main/resources/application.properties b/remainder-service/src/main/resources/application.properties
index 3a23434..f300a6b 100644
--- a/remainder-service/src/main/resources/application.properties
+++ b/remainder-service/src/main/resources/application.properties
@@ -1,2 +1,2 @@
-spring.application.name = reminder
-logging.file=/var/log/todo.log
+spring.application.name = reminder
+logging.file=/var/log/todo.log
diff --git a/remainder-service/src/main/resources/bootstrap.yml b/remainder-service/src/main/resources/bootstrap.yml
index b940bf4..47aefda 100644
--- a/remainder-service/src/main/resources/bootstrap.yml
+++ b/remainder-service/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
----
-spring:
- cloud:
- config:
- uri: http://config:8888
+---
+spring:
+ cloud:
+ config:
+ uri: http://config:8888
\ No newline at end of file
diff --git a/remainder-service/src/main/resources/docker/Dockerfile b/remainder-service/src/main/resources/docker/Dockerfile
index ab30719..fe9779e 100644
--- a/remainder-service/src/main/resources/docker/Dockerfile
+++ b/remainder-service/src/main/resources/docker/Dockerfile
@@ -1,37 +1,37 @@
-FROM openjdk:8
-
-
-MAINTAINER Alexsandro
-ENV REFRESHED_AT 2017-09-17
-
-ENV TERM xterm
-ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
-
-RUN apt-get update -qq \
- && apt-get install -qqy curl wget \
- && apt-get clean \
- \
- && touch /var/log/todo.log \
- && chmod 666 /var/log/todo.log
-
-ADD application/lib/springboot-webapp.jar /app.jar
-ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
-RUN bash -c 'chmod +x wait-for-it.sh'
-
-# install Filebeat
-ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
-RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
- && dpkg -i ${FILEBEAT_VERSION} \
- && rm ${FILEBEAT_VERSION}
-
-# configure Filebeat
-ADD filebeat.yml /etc/filebeat/filebeat.yml
-
-# CA cert
-RUN mkdir -p /etc/pki/tls/certs
-ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
-
-# start Filebeat
-ADD ./start.sh /usr/local/bin/start.sh
-RUN chmod +x /usr/local/bin/start.sh
+FROM openjdk:8
+
+
+MAINTAINER Alexsandro
+ENV REFRESHED_AT 2017-09-17
+
+ENV TERM xterm
+ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
+
+RUN apt-get update -qq \
+ && apt-get install -qqy curl wget \
+ && apt-get clean \
+ \
+ && touch /var/log/todo.log \
+ && chmod 666 /var/log/todo.log
+
+ADD application/lib/springboot-webapp.jar /app.jar
+ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
+RUN bash -c 'chmod +x wait-for-it.sh'
+
+# install Filebeat
+ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
+RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
+ && dpkg -i ${FILEBEAT_VERSION} \
+ && rm ${FILEBEAT_VERSION}
+
+# configure Filebeat
+ADD filebeat.yml /etc/filebeat/filebeat.yml
+
+# CA cert
+RUN mkdir -p /etc/pki/tls/certs
+ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
+
+# start Filebeat
+ADD ./start.sh /usr/local/bin/start.sh
+RUN chmod +x /usr/local/bin/start.sh
CMD [ "/usr/local/bin/start.sh" ]
\ No newline at end of file
diff --git a/remainder-service/src/main/resources/docker/filebeat.yml b/remainder-service/src/main/resources/docker/filebeat.yml
index a982070..1b39ac5 100644
--- a/remainder-service/src/main/resources/docker/filebeat.yml
+++ b/remainder-service/src/main/resources/docker/filebeat.yml
@@ -1,30 +1,30 @@
-output:
- logstash:
- enabled: true
- hosts:
- - elk:5044
- timeout: 15
- tls:
- certificate_authorities:
- - /etc/pki/tls/certs/logstash-beats.crt
-
-filebeat:
- prospectors:
- -
- paths:
- - /var/log/syslog
- - /var/log/auth.log
- document_type: syslog
- -
- paths:
- - /var/log/todo.log
- document_type: log4j
- multiline:
- pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
- negate: true
- match: after
- -
- paths:
- - /usr/local/tomcat/logs/*.out
- - /usr/local/tomcat/logs/*.log
- document_type: tomcat
+output:
+ logstash:
+ enabled: true
+ hosts:
+ - elk:5044
+ timeout: 15
+ tls:
+ certificate_authorities:
+ - /etc/pki/tls/certs/logstash-beats.crt
+
+filebeat:
+ prospectors:
+ -
+ paths:
+ - /var/log/syslog
+ - /var/log/auth.log
+ document_type: syslog
+ -
+ paths:
+ - /var/log/todo.log
+ document_type: log4j
+ multiline:
+ pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
+ negate: true
+ match: after
+ -
+ paths:
+ - /usr/local/tomcat/logs/*.out
+ - /usr/local/tomcat/logs/*.log
+ document_type: tomcat
diff --git a/remainder-service/src/main/resources/docker/logstash-beats.crt b/remainder-service/src/main/resources/docker/logstash-beats.crt
index d9b71cf..1c86bc3 100644
--- a/remainder-service/src/main/resources/docker/logstash-beats.crt
+++ b/remainder-service/src/main/resources/docker/logstash-beats.crt
@@ -1,18 +1,18 @@
------BEGIN CERTIFICATE-----
-MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
-BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
-DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
-0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
-9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
-PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
-qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
-KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
-4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
-VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
-hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
-okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
-T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
-ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
-kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
-Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
------END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
+BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
+DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
+0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
+9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
+PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
+qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
+KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
+4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
+VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
+hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
+okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
+T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
+ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
+kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
+Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
+-----END CERTIFICATE-----
diff --git a/remainder-service/src/main/resources/docker/start.sh b/remainder-service/src/main/resources/docker/start.sh
index b68b2fb..eff4532 100644
--- a/remainder-service/src/main/resources/docker/start.sh
+++ b/remainder-service/src/main/resources/docker/start.sh
@@ -1,5 +1,4 @@
#!/bin/bash
-
curl -XPUT 'http://elk:9200/_template/filebeat?pretty' -d@/etc/filebeat/filebeat.template.json
/etc/init.d/filebeat start
-java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
+java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
\ No newline at end of file
diff --git a/remainder-service/src/test/java/com/apssouza/configuration/RepositoryConfiguration.java b/remainder-service/src/test/java/com/apssouza/configuration/RepositoryConfiguration.java
index 641133b..5c07615 100644
--- a/remainder-service/src/test/java/com/apssouza/configuration/RepositoryConfiguration.java
+++ b/remainder-service/src/test/java/com/apssouza/configuration/RepositoryConfiguration.java
@@ -1,20 +1,20 @@
-package com.apssouza.configuration;
-
-import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
-import org.springframework.boot.autoconfigure.domain.EntityScan;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
-import org.springframework.transaction.annotation.EnableTransactionManagement;
-
-/**
- *
- * @author apssouza
- */
-@Configuration
-@EnableAutoConfiguration
-@EnableTransactionManagement
-@EntityScan(basePackages = {"com.apssouza.entities"})
-@EnableJpaRepositories(basePackages = {"com.apssouza.repositories"})
-public class RepositoryConfiguration {
-
-}
+package com.apssouza.configuration;
+
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.domain.EntityScan;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+/**
+ *
+ * @author apssouza
+ */
+@Configuration
+@EnableAutoConfiguration
+@EnableTransactionManagement
+@EntityScan(basePackages = {"com.apssouza.entities"})
+@EnableJpaRepositories(basePackages = {"com.apssouza.repositories"})
+public class RepositoryConfiguration {
+
+}
diff --git a/remainder-service/src/test/java/com/apssouza/controllers/TodoControllerTest.java b/remainder-service/src/test/java/com/apssouza/controllers/TodoControllerTest.java
index 089ed45..3ac28bb 100644
--- a/remainder-service/src/test/java/com/apssouza/controllers/TodoControllerTest.java
+++ b/remainder-service/src/test/java/com/apssouza/controllers/TodoControllerTest.java
@@ -1,160 +1,160 @@
-package com.apssouza.controllers;
-
-import com.apssouza.BasicApplication;
-import com.apssouza.entities.Attachment;
-import com.apssouza.entities.Category;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import static org.junit.Assert.assertNotNull;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.http.MediaType;
-import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
-import org.springframework.test.context.junit4.SpringRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-import org.springframework.test.web.servlet.MockMvc;
-import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
-import org.springframework.web.context.WebApplicationContext;
-import com.apssouza.entities.ToDo;
-import com.apssouza.repositories.TodoRepository;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.List;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.is;
-import org.springframework.mock.http.MockHttpOutputMessage;
-import org.springframework.test.web.servlet.ResultActions;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
-
-/**
- *
- * @author apssouza
- */
-//@RunWith(SpringRunner.class)
-//@WebAppConfiguration
-//@SpringBootTest(classes = BasicApplication.class)
-public class TodoControllerTest {
-/*
- private MediaType contentType = new MediaType(
- MediaType.APPLICATION_JSON.getType(),
- MediaType.APPLICATION_JSON.getSubtype(),
- Charset.forName("utf8")
- );
-
- private MockMvc mockMvc;
-
- private HttpMessageConverter mappingJackson2HttpMessageConverter;
-
- private List todoList = new ArrayList<>();
-
- @Autowired
- private WebApplicationContext webApplicationContext;
-
- @Autowired
- private TodoRepository todoRepository;
-
- @Autowired
- void setConverters(HttpMessageConverter>[] converters) {
-
- this.mappingJackson2HttpMessageConverter = Arrays.asList(converters).stream()
- .filter(hmc -> hmc instanceof MappingJackson2HttpMessageConverter)
- .findAny()
- .orElse(null);
-
- assertNotNull("the JSON message converter must not be null",
- this.mappingJackson2HttpMessageConverter);
- }
-
- @Before
- public void setup() throws Exception {
- this.mockMvc = webAppContextSetup(webApplicationContext).build();
-
- this.todoRepository.deleteAllInBatch();
- ToDo toDo1 = new ToDo("apssouza22@gmail.com","caption 1", "description 1", 5);
- ToDo toDo2 = new ToDo("alex@gmail.com","caption 2", "description 2", 4);
-
- Attachment attach1 = new Attachment("planilha", "xls");
- Attachment attach2 = new Attachment("phones", "xls");
-
- Category category = new Category("work");
-
- Set files = new HashSet<>();
- files.add(attach1);
- files.add(attach2);
- ArrayList categories = new ArrayList(Arrays.asList(
- new Category[]{category})
- );
- toDo1.setAttachments(files);
- toDo1.setCategories(categories);
-
- this.todoList.add(todoRepository.save(toDo1));
- this.todoList.add(todoRepository.save(toDo2));
- List findAll = todoRepository.findAll();
- findAll.stream().forEach(t -> {
- System.out.println(t.getId() + " ====>>> ");
- t.getCategories().stream().forEach(a -> System.out.println(a.getName()));
- });
- }
-
- protected String json(Object o) throws IOException {
- MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
- this.mappingJackson2HttpMessageConverter.write(
- o,
- MediaType.APPLICATION_JSON,
- mockHttpOutputMessage
- );
- return mockHttpOutputMessage.getBodyAsString();
- }
-
- @Test
- public void todoNotFound() throws Exception {
- mockMvc.perform(get("/todos/55")
- .content(this.json(new ToDo()))
- .contentType(contentType))
- .andExpect(status().isNotFound());
- }
-
- @Test
- public void readSingleTodo() throws Exception {
- mockMvc.perform(get("/todos/" + this.todoList.get(0).getId()))
- .andExpect(status().isOk())
- .andExpect(content().contentType(contentType))
- .andExpect(jsonPath("$.id", is(this.todoList.get(0).getId().intValue())))
- .andExpect(jsonPath("$.description", is("description 1")));
- }
-
- @Test
- public void readTodos() throws Exception {
- mockMvc.perform(get("/todos"))
- .andExpect(status().isOk())
- .andExpect(content().contentType(contentType))
- .andExpect(jsonPath("$", hasSize(2)))
- .andExpect(jsonPath("$[0].id", is(this.todoList.get(0).getId().intValue())))
- .andExpect(jsonPath("$[0].caption", is(this.todoList.get(0).getCaption())))
- .andExpect(jsonPath("$[0].description", is(this.todoList.get(0).getDescription())))
- .andExpect(jsonPath("$[1].id", is(this.todoList.get(1).getId().intValue())))
- .andExpect(jsonPath("$[1].description", is(this.todoList.get(1).getDescription())));
- }
-
- @Test
- public void createTodo() throws Exception {
- String todoJson = json(new ToDo("apssouza@gmail.com","caption 1", "description 1", 6));
-
- ResultActions perform = this.mockMvc.perform(post("/todos")
- .contentType(contentType)
- .content(todoJson));
- perform.andExpect(status().isCreated());
- }
-*/
-
-}
+package com.apssouza.controllers;
+
+import com.apssouza.BasicApplication;
+import com.apssouza.entities.Attachment;
+import com.apssouza.entities.Category;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.MediaType;
+import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MockMvc;
+import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
+import org.springframework.web.context.WebApplicationContext;
+import com.apssouza.entities.ToDo;
+import com.apssouza.repositories.TodoRepository;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.List;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import org.springframework.mock.http.MockHttpOutputMessage;
+import org.springframework.test.web.servlet.ResultActions;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
+import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
+import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
+
+/**
+ *
+ * @author apssouza
+ */
+//@RunWith(SpringRunner.class)
+//@WebAppConfiguration
+//@SpringBootTest(classes = BasicApplication.class)
+public class TodoControllerTest {
+/*
+ private MediaType contentType = new MediaType(
+ MediaType.APPLICATION_JSON.getType(),
+ MediaType.APPLICATION_JSON.getSubtype(),
+ Charset.forName("utf8")
+ );
+
+ private MockMvc mockMvc;
+
+ private HttpMessageConverter mappingJackson2HttpMessageConverter;
+
+ private List todoList = new ArrayList<>();
+
+ @Autowired
+ private WebApplicationContext webApplicationContext;
+
+ @Autowired
+ private TodoRepository todoRepository;
+
+ @Autowired
+ void setConverters(HttpMessageConverter>[] converters) {
+
+ this.mappingJackson2HttpMessageConverter = Arrays.asList(converters).stream()
+ .filter(hmc -> hmc instanceof MappingJackson2HttpMessageConverter)
+ .findAny()
+ .orElse(null);
+
+ assertNotNull("the JSON message converter must not be null",
+ this.mappingJackson2HttpMessageConverter);
+ }
+
+ @Before
+ public void setup() throws Exception {
+ this.mockMvc = webAppContextSetup(webApplicationContext).build();
+
+ this.todoRepository.deleteAllInBatch();
+ ToDo toDo1 = new ToDo("apssouza22@gmail.com","caption 1", "description 1", 5);
+ ToDo toDo2 = new ToDo("alex@gmail.com","caption 2", "description 2", 4);
+
+ Attachment attach1 = new Attachment("planilha", "xls");
+ Attachment attach2 = new Attachment("phones", "xls");
+
+ Category category = new Category("work");
+
+ Set files = new HashSet<>();
+ files.add(attach1);
+ files.add(attach2);
+ ArrayList categories = new ArrayList(Arrays.asList(
+ new Category[]{category})
+ );
+ toDo1.setAttachments(files);
+ toDo1.setCategories(categories);
+
+ this.todoList.add(todoRepository.save(toDo1));
+ this.todoList.add(todoRepository.save(toDo2));
+ List findAll = todoRepository.findAll();
+ findAll.stream().forEach(t -> {
+ System.out.println(t.getId() + " ====>>> ");
+ t.getCategories().stream().forEach(a -> System.out.println(a.getName()));
+ });
+ }
+
+ protected String json(Object o) throws IOException {
+ MockHttpOutputMessage mockHttpOutputMessage = new MockHttpOutputMessage();
+ this.mappingJackson2HttpMessageConverter.write(
+ o,
+ MediaType.APPLICATION_JSON,
+ mockHttpOutputMessage
+ );
+ return mockHttpOutputMessage.getBodyAsString();
+ }
+
+ @Test
+ public void todoNotFound() throws Exception {
+ mockMvc.perform(get("/todos/55")
+ .content(this.json(new ToDo()))
+ .contentType(contentType))
+ .andExpect(status().isNotFound());
+ }
+
+ @Test
+ public void readSingleTodo() throws Exception {
+ mockMvc.perform(get("/todos/" + this.todoList.get(0).getId()))
+ .andExpect(status().isOk())
+ .andExpect(content().contentType(contentType))
+ .andExpect(jsonPath("$.id", is(this.todoList.get(0).getId().intValue())))
+ .andExpect(jsonPath("$.description", is("description 1")));
+ }
+
+ @Test
+ public void readTodos() throws Exception {
+ mockMvc.perform(get("/todos"))
+ .andExpect(status().isOk())
+ .andExpect(content().contentType(contentType))
+ .andExpect(jsonPath("$", hasSize(2)))
+ .andExpect(jsonPath("$[0].id", is(this.todoList.get(0).getId().intValue())))
+ .andExpect(jsonPath("$[0].caption", is(this.todoList.get(0).getCaption())))
+ .andExpect(jsonPath("$[0].description", is(this.todoList.get(0).getDescription())))
+ .andExpect(jsonPath("$[1].id", is(this.todoList.get(1).getId().intValue())))
+ .andExpect(jsonPath("$[1].description", is(this.todoList.get(1).getDescription())));
+ }
+
+ @Test
+ public void createTodo() throws Exception {
+ String todoJson = json(new ToDo("apssouza@gmail.com","caption 1", "description 1", 6));
+
+ ResultActions perform = this.mockMvc.perform(post("/todos")
+ .contentType(contentType)
+ .content(todoJson));
+ perform.andExpect(status().isCreated());
+ }
+*/
+
+}
diff --git a/remainder-service/src/test/java/com/apssouza/entities/TodoIT.java b/remainder-service/src/test/java/com/apssouza/entities/TodoIT.java
index 76333c4..2bb8ad1 100644
--- a/remainder-service/src/test/java/com/apssouza/entities/TodoIT.java
+++ b/remainder-service/src/test/java/com/apssouza/entities/TodoIT.java
@@ -1,58 +1,58 @@
-/*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
-package com.apssouza.entities;
-
-import com.apssouza.configuration.RepositoryConfiguration;
-import java.util.Iterator;
-import java.util.Set;
-import javax.validation.ConstraintViolation;
-import javax.validation.Validation;
-import javax.validation.Validator;
-import javax.validation.ValidatorFactory;
-import org.junit.Assert;
-import static org.junit.Assert.assertTrue;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-/**
- *
- * @author apssouza
- */
-@RunWith(SpringJUnit4ClassRunner.class)
-@SpringBootTest(classes = {RepositoryConfiguration.class})
-public class TodoIT {
-
-
- @Test
- public void validateTodoValid() {
- ToDo toDo = new ToDo("apssouza22@gmail.com","caption", "description 1", 6);
- ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
- Validator validator = factory.getValidator();
- Set> constraintViolations = validator.validate(toDo);
- assertTrue(constraintViolations.isEmpty());
- }
-
- @Test
- public void validateTodoInValid() {
- ToDo toDo = new ToDo("apssouza22@gmail.com","c", "description 1", 6);
- ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
- Validator validator = factory.getValidator();
- Set> constraintViolations = validator.validate(toDo);
-
- if (!constraintViolations.isEmpty()) {
- Iterator itr = constraintViolations.iterator();
- while (itr.hasNext()) {
- ConstraintViolation next = (ConstraintViolation)itr.next();
- Assert.assertEquals("size must be between 2 and 256", next.getMessage());
- }
- }
- }
-
-
-
-}
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.apssouza.entities;
+
+import com.apssouza.configuration.RepositoryConfiguration;
+import java.util.Iterator;
+import java.util.Set;
+import javax.validation.ConstraintViolation;
+import javax.validation.Validation;
+import javax.validation.Validator;
+import javax.validation.ValidatorFactory;
+import org.junit.Assert;
+import static org.junit.Assert.assertTrue;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/**
+ *
+ * @author apssouza
+ */
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest(classes = {RepositoryConfiguration.class})
+public class TodoIT {
+
+
+ @Test
+ public void validateTodoValid() {
+ ToDo toDo = new ToDo("apssouza22@gmail.com","caption", "description 1", 6);
+ ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
+ Validator validator = factory.getValidator();
+ Set> constraintViolations = validator.validate(toDo);
+ assertTrue(constraintViolations.isEmpty());
+ }
+
+ @Test
+ public void validateTodoInValid() {
+ ToDo toDo = new ToDo("apssouza22@gmail.com","c", "description 1", 6);
+ ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
+ Validator validator = factory.getValidator();
+ Set> constraintViolations = validator.validate(toDo);
+
+ if (!constraintViolations.isEmpty()) {
+ Iterator itr = constraintViolations.iterator();
+ while (itr.hasNext()) {
+ ConstraintViolation next = (ConstraintViolation)itr.next();
+ Assert.assertEquals("size must be between 2 and 256", next.getMessage());
+ }
+ }
+ }
+
+
+
+}
diff --git a/todo-infra/README b/todo-infra/README
index 48a1d99..aff3e70 100644
--- a/todo-infra/README
+++ b/todo-infra/README
@@ -1,4 +1,4 @@
-# Infra module
-
-This module contains common components across the services. Ex Kafka integration
- with Spring stream, events and etc
+# Infra module
+
+This module contains common components across the services. Ex Kafka integration
+ with Spring stream, events and etc
diff --git a/todo-infra/pom.xml b/todo-infra/pom.xml
index 58fc87c..60cab0e 100644
--- a/todo-infra/pom.xml
+++ b/todo-infra/pom.xml
@@ -1,36 +1,36 @@
-
-
- 4.0.0
-
- todo-infra
- 0.0.1-SNAPSHOT
- jar
-
- Module - Infra
- The common infrastructure across the system
-
- parent-todo-ms
- com.apssouza
- 0.0.1-SNAPSHOT
-
-
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-stream-binder-kafka
-
-
-
- org.springframework.cloud
- spring-cloud-stream
- 1.2.1.RELEASE
- jar
-
-
-
-
-
+
+
+ 4.0.0
+
+ todo-infra
+ 0.0.1-SNAPSHOT
+ jar
+
+ Module - Infra
+ The common infrastructure across the system
+
+ parent-todo-ms
+ com.apssouza
+ 0.0.1-SNAPSHOT
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-stream-binder-kafka
+
+
+
+ org.springframework.cloud
+ spring-cloud-stream
+ 1.2.1.RELEASE
+ jar
+
+
+
+
+
diff --git a/todo-infra/src/main/java/com/apssouza/infra/AbstractDomainEvent.java b/todo-infra/src/main/java/com/apssouza/infra/AbstractDomainEvent.java
index 2cea2ef..affc423 100644
--- a/todo-infra/src/main/java/com/apssouza/infra/AbstractDomainEvent.java
+++ b/todo-infra/src/main/java/com/apssouza/infra/AbstractDomainEvent.java
@@ -1,25 +1,25 @@
-package com.apssouza.infra;
-
-import java.time.Instant;
-
-/**
- * Abstract system event. The domain event across all services
- *
- * @author apssouza
- */
-public abstract class AbstractDomainEvent implements AppEvent {
-
- protected String uuid;
-
- protected Instant when = Instant.now();
-
- @Override
- public String uuid() {
- return uuid;
- }
-
- @Override
- public Instant when() {
- return when;
- }
-}
+package com.apssouza.infra;
+
+import java.time.Instant;
+
+/**
+ * Abstract system event. The domain event across all services
+ *
+ * @author apssouza
+ */
+public abstract class AbstractDomainEvent implements AppEvent {
+
+ protected String uuid;
+
+ protected Instant when = Instant.now();
+
+ @Override
+ public String uuid() {
+ return uuid;
+ }
+
+ @Override
+ public Instant when() {
+ return when;
+ }
+}
diff --git a/todo-infra/src/main/java/com/apssouza/infra/AppEvent.java b/todo-infra/src/main/java/com/apssouza/infra/AppEvent.java
index 49006e1..d26586d 100644
--- a/todo-infra/src/main/java/com/apssouza/infra/AppEvent.java
+++ b/todo-infra/src/main/java/com/apssouza/infra/AppEvent.java
@@ -1,17 +1,17 @@
-package com.apssouza.infra;
-
-import java.time.Instant;
-
-/**
- *
- * The application event
- *
- * @author apssouza
- */
-public interface AppEvent {
-
- String uuid();
-
- Instant when();
-
-}
+package com.apssouza.infra;
+
+import java.time.Instant;
+
+/**
+ *
+ * The application event
+ *
+ * @author apssouza
+ */
+public interface AppEvent {
+
+ String uuid();
+
+ Instant when();
+
+}
diff --git a/todo-infra/src/main/java/com/apssouza/infra/EventPublisher.java b/todo-infra/src/main/java/com/apssouza/infra/EventPublisher.java
index 69d452c..44a8b59 100644
--- a/todo-infra/src/main/java/com/apssouza/infra/EventPublisher.java
+++ b/todo-infra/src/main/java/com/apssouza/infra/EventPublisher.java
@@ -1,50 +1,50 @@
-package com.apssouza.infra;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cloud.stream.annotation.EnableBinding;
-import org.springframework.cloud.stream.messaging.Source;
-import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.messaging.Message;
-import org.springframework.messaging.MessageChannel;
-import org.springframework.messaging.support.MessageBuilder;
-import org.springframework.stereotype.Component;
-
-/**
- *
- * The project event publisher handler We are using distributed event with Kafka
- * and local event with Spring event publisher
- *
- * @author apssouza
- */
-@Component
-@EnableBinding(Source.class)
-public class EventPublisher {
-
- private final MessageChannel channel;
-
- private final ApplicationEventPublisher publisher;
-
- /**
- *
- * @param source
- * @param publisher
- */
- @Autowired
- public EventPublisher(Source source, ApplicationEventPublisher publisher) {
- this.channel = source.output();
- this.publisher = publisher;
- }
-
- public void publish(AppEvent event) {
- publisher.publishEvent(event);
- }
-
- public void stream(AppEvent event) {
- Message msg = MessageBuilder.withPayload(event)
- .setHeader("type", event.getClass().getSimpleName())
- .build();
- channel.send(msg);
- System.out.println("published");
- }
-
-}
+package com.apssouza.infra;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cloud.stream.annotation.EnableBinding;
+import org.springframework.cloud.stream.messaging.Source;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.messaging.Message;
+import org.springframework.messaging.MessageChannel;
+import org.springframework.messaging.support.MessageBuilder;
+import org.springframework.stereotype.Component;
+
+/**
+ *
+ * The project event publisher handler We are using distributed event with Kafka
+ * and local event with Spring event publisher
+ *
+ * @author apssouza
+ */
+@Component
+@EnableBinding(Source.class)
+public class EventPublisher {
+
+ private final MessageChannel channel;
+
+ private final ApplicationEventPublisher publisher;
+
+ /**
+ *
+ * @param source
+ * @param publisher
+ */
+ @Autowired
+ public EventPublisher(Source source, ApplicationEventPublisher publisher) {
+ this.channel = source.output();
+ this.publisher = publisher;
+ }
+
+ public void publish(AppEvent event) {
+ publisher.publishEvent(event);
+ }
+
+ public void stream(AppEvent event) {
+ Message msg = MessageBuilder.withPayload(event)
+ .setHeader("type", event.getClass().getSimpleName())
+ .build();
+ channel.send(msg);
+ System.out.println("published");
+ }
+
+}
diff --git a/todo-infra/tar/maven-archiver/pom.properties b/todo-infra/tar/maven-archiver/pom.properties
new file mode 100644
index 0000000..1d67f0b
--- /dev/null
+++ b/todo-infra/tar/maven-archiver/pom.properties
@@ -0,0 +1,5 @@
+#Generated by Apache Maven
+#Thu Jun 01 16:45:20 UTC 2023
+version=0.0.1-SNAPSHOT
+groupId=com.apssouza
+artifactId=todo-infra
diff --git a/todo-infra/tar/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/todo-infra/tar/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 0000000..a0a6bd2
--- /dev/null
+++ b/todo-infra/tar/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1,3 @@
+com/apssouza/infra/AbstractDomainEvent.class
+com/apssouza/infra/EventPublisher.class
+com/apssouza/infra/AppEvent.class
diff --git a/todo-infra/tar/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/todo-infra/tar/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 0000000..e15d5db
--- /dev/null
+++ b/todo-infra/tar/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1,3 @@
+/home/shantun_rubal/project/java-microservice/todo-infra/src/main/java/com/apssouza/infra/AppEvent.java
+/home/shantun_rubal/project/java-microservice/todo-infra/src/main/java/com/apssouza/infra/AbstractDomainEvent.java
+/home/shantun_rubal/project/java-microservice/todo-infra/src/main/java/com/apssouza/infra/EventPublisher.java
diff --git a/todo-infra/tar/todo-infra-0.0.1-SNAPSHOT.jar b/todo-infra/tar/todo-infra-0.0.1-SNAPSHOT.jar
new file mode 100644
index 0000000..83d2433
Binary files /dev/null and b/todo-infra/tar/todo-infra-0.0.1-SNAPSHOT.jar differ
diff --git a/user-service/Jenkinsfile b/user-service/Jenkinsfile
index 132a5d6..12f8bf4 100644
--- a/user-service/Jenkinsfile
+++ b/user-service/Jenkinsfile
@@ -1,16 +1,16 @@
-node {
- stage('Fetch changes') {
- git 'https://github.com/apssouza22/java-microservice.git'
- }
- stage('Build image') {
- // Run the maven build
- if (isUnix()) {
- sh "mvn -f ./user-service/pom.xml -Pdockerimage docker:build"
- } else {
- echo "Not ready for windows"
- }
- }
- stage('Deploy ECS') {
- echo "TODO deploy on AWS"
- }
-}
+node {
+ stage('Fetch changes') {
+ git 'https://github.com/apssouza22/java-microservice.git'
+ }
+ stage('Build image') {
+ // Run the maven build
+ if (isUnix()) {
+ sh "mvn -f ./user-service/pom.xml -Pdockerimage docker:build"
+ } else {
+ echo "Not ready for windows"
+ }
+ }
+ stage('Deploy ECS') {
+ echo "TODO deploy on AWS"
+ }
+}
diff --git a/user-service/README b/user-service/README
index a4817ef..a1d7da2 100644
--- a/user-service/README
+++ b/user-service/README
@@ -1,3 +1,3 @@
-# User service
-
-This service is responsible for dealing with users of our system, we use this service to login and user informations
+# User service
+
+This service is responsible for dealing with users of our system, we use this service to login and user informations
diff --git a/user-service/nb-configuration.xml b/user-service/nb-configuration.xml
index 5b0f1f8..b7a6ae4 100644
--- a/user-service/nb-configuration.xml
+++ b/user-service/nb-configuration.xml
@@ -1,18 +1,18 @@
-
-
-
-
-
- true
-
-
+
+
+
+
+
+ true
+
+
diff --git a/user-service/nbactions-release-profile.xml b/user-service/nbactions-release-profile.xml
index 3f010f4..578414f 100644
--- a/user-service/nbactions-release-profile.xml
+++ b/user-service/nbactions-release-profile.xml
@@ -1,46 +1,46 @@
-
-
-
- run
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.apssouza.BasicApplication
- java
-
-
-
- debug
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.apssouza.BasicApplication
- java
- true
-
-
-
- profile
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.apssouza.BasicApplication
- java
-
-
-
+
+
+
+ run
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
+
+
+ -classpath %classpath com.apssouza.BasicApplication
+ java
+
+
+
+ debug
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
+
+
+ -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath com.apssouza.BasicApplication
+ java
+ true
+
+
+
+ profile
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
+
+
+ -classpath %classpath com.apssouza.BasicApplication
+ java
+
+
+
diff --git a/user-service/nbactions.xml b/user-service/nbactions.xml
index 50f6464..b67d49b 100644
--- a/user-service/nbactions.xml
+++ b/user-service/nbactions.xml
@@ -1,48 +1,48 @@
-
-
-
- run
-
- jar
-
-
- spring-boot:run
-
-
- -noverify -XX:TieredStopAtLevel=1
- com.example.BasicApplication
- always
- .nbRestartTrigger
-
-
-
- debug
-
- jar
-
-
- spring-boot:run
-
-
- -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1
- com.example.BasicApplication
- always
- .nbRestartTrigger
- true
-
-
-
- profile
-
- jar
-
-
- process-classes
- org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
-
-
- -classpath %classpath com.example.BasicApplication
- java
-
-
-
+
+
+
+ run
+
+ jar
+
+
+ spring-boot:run
+
+
+ -noverify -XX:TieredStopAtLevel=1
+ com.example.BasicApplication
+ always
+ .nbRestartTrigger
+
+
+
+ debug
+
+ jar
+
+
+ spring-boot:run
+
+
+ -Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -noverify -XX:TieredStopAtLevel=1
+ com.example.BasicApplication
+ always
+ .nbRestartTrigger
+ true
+
+
+
+ profile
+
+ jar
+
+
+ process-classes
+ org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
+
+
+ -classpath %classpath com.example.BasicApplication
+ java
+
+
+
diff --git a/user-service/pom.xml b/user-service/pom.xml
index f9beba4..86598e5 100644
--- a/user-service/pom.xml
+++ b/user-service/pom.xml
@@ -1,205 +1,205 @@
-
-
- 4.0.0
-
- com.apssouza
- user-service
- 0.0.1-SNAPSHOT
- jar
-
- User service
- User management service
-
-
- org.springframework.boot
- spring-boot-starter-parent
- 1.5.2.RELEASE
-
-
-
-
- UTF-8
- UTF-8
- com.apssouza.BasicApplication
- 1.8
-
-
-
-
-
- org.springframework.cloud
- spring-cloud-starter-parent
- Camden.SR2
- pom
- import
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-starter
-
-
- log4j
- log4j
- 1.2.17
-
-
-
- org.springframework.boot
- spring-boot-starter-data-jpa
-
-
- org.springframework.plugin
- spring-plugin-core
-
-
- org.springframework.boot
- spring-boot-starter-web
-
-
-
- org.springframework.cloud
- spring-cloud-starter-eureka
-
-
-
- org.springframework.boot
- spring-boot-starter-actuator
-
-
-
- org.springframework.boot
- spring-boot-starter-test
- test
-
-
-
- com.h2database
- h2
-
-
-
- com.fasterxml.jackson.datatype
- jackson-datatype-jsr310
-
-
- org.springframework.cloud
- spring-cloud-starter-config
-
-
-
-
-
-
- org.springframework.boot
- spring-boot-maven-plugin
-
- true
- true
-
-
-
-
-
-
- dockerimage
-
- todo/user-service
- src/main/resources/docker
- ${project.build.directory}/dockerimgbuild
- Dockerfile
-
-
-
-
-
- maven-resources-plugin
-
-
- copy-resources
- package
-
- copy-resources
-
-
- ${docker.build.directory}
-
-
- ${docker.image.src.root}
- false
-
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-dependency-plugin
-
-
- copy
- package
-
- copy
-
-
-
-
- ${project.groupId}
- ${project.artifactId}
- ${project.version}
- jar
- true
- ${docker.build.directory}/application/lib
- springboot-webapp.jar
-
-
-
-
- ${docker.build.directory}
- true
- true
-
-
-
-
-
-
-
- io.fabric8
- docker-maven-plugin
- 0.19.0
-
-
- unix:///var/run/docker.sock
-
-
- ${docker.image.name}
-
-
- latest
-
- ${docker.build.directory}/${docker.file.name}
-
-
-
-
-
-
-
-
-
-
+
+
+ 4.0.0
+
+ com.apssouza
+ user-service
+ 0.0.1-SNAPSHOT
+ jar
+
+ User service
+ User management service
+
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 1.5.2.RELEASE
+
+
+
+
+ UTF-8
+ UTF-8
+ com.apssouza.BasicApplication
+ 1.8
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-parent
+ Camden.SR2
+ pom
+ import
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter
+
+
+ log4j
+ log4j
+ 1.2.17
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+ org.springframework.plugin
+ spring-plugin-core
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-eureka
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ com.h2database
+ h2
+
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+ true
+ true
+
+
+
+
+
+
+ dockerimage
+
+ todo/user-service
+ src/main/resources/docker
+ ${project.build.directory}/dockerimgbuild
+ Dockerfile
+
+
+
+
+
+ maven-resources-plugin
+
+
+ copy-resources
+ package
+
+ copy-resources
+
+
+ ${docker.build.directory}
+
+
+ ${docker.image.src.root}
+ false
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy
+ package
+
+ copy
+
+
+
+
+ ${project.groupId}
+ ${project.artifactId}
+ ${project.version}
+ jar
+ true
+ ${docker.build.directory}/application/lib
+ springboot-webapp.jar
+
+
+
+
+ ${docker.build.directory}
+ true
+ true
+
+
+
+
+
+
+
+ io.fabric8
+ docker-maven-plugin
+ 0.19.0
+
+
+ unix:///var/run/docker.sock
+
+
+ ${docker.image.name}
+
+
+ latest
+
+ ${docker.build.directory}/${docker.file.name}
+
+
+
+
+
+
+
+
+
+
diff --git a/user-service/src/main/java/com/apssouza/BasicApplication.java b/user-service/src/main/java/com/apssouza/BasicApplication.java
index bf48145..4cfddc7 100644
--- a/user-service/src/main/java/com/apssouza/BasicApplication.java
+++ b/user-service/src/main/java/com/apssouza/BasicApplication.java
@@ -1,13 +1,13 @@
-package com.apssouza;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-
-@SpringBootApplication
-public class BasicApplication {
-
- public static void main(String[] args) {
- SpringApplication.run(BasicApplication.class, args);
- }
-
-}
+package com.apssouza;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class BasicApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(BasicApplication.class, args);
+ }
+
+}
diff --git a/user-service/src/main/java/com/apssouza/bootstrap/UserLoader.java b/user-service/src/main/java/com/apssouza/bootstrap/UserLoader.java
index df7c15f..39b8e29 100644
--- a/user-service/src/main/java/com/apssouza/bootstrap/UserLoader.java
+++ b/user-service/src/main/java/com/apssouza/bootstrap/UserLoader.java
@@ -1,41 +1,41 @@
-package com.apssouza.bootstrap;
-
-import org.apache.log4j.Logger;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationListener;
-import org.springframework.context.event.ContextRefreshedEvent;
-import com.apssouza.entities.Account;
-import org.springframework.stereotype.Component;
-import com.apssouza.repositories.AccountRepository;
-
-/**
- * An User data loader into database
- *
- * @author apssouza
- */
-@Component
-public class UserLoader implements ApplicationListener {
-
- private final AccountRepository userRepository;
-
- private final Logger log = Logger.getLogger(this.getClass().getCanonicalName());
-
- @Autowired
- public UserLoader(AccountRepository todoRepository) {
- this.userRepository = todoRepository;
- }
-
- @Override
- public void onApplicationEvent(ContextRefreshedEvent e) {
- Account user1 = new Account("Alex lindo", "apssouza22@gmail.com", "1234");
- Account user2 = new Account("Gaekke delicia", "gaelle@meama.com", "2222");
- Account user3 = new Account("Márcia almeida", "marciapalito@hotmail.com", "2222");
-
- userRepository.save(user1);
- userRepository.save(user2);
- userRepository.save(user3);
-
- log.info("Created the todos.");
- }
-
-}
+package com.apssouza.bootstrap;
+
+import org.apache.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+import com.apssouza.entities.Account;
+import org.springframework.stereotype.Component;
+import com.apssouza.repositories.AccountRepository;
+
+/**
+ * An User data loader into database
+ *
+ * @author apssouza
+ */
+@Component
+public class UserLoader implements ApplicationListener {
+
+ private final AccountRepository userRepository;
+
+ private final Logger log = Logger.getLogger(this.getClass().getCanonicalName());
+
+ @Autowired
+ public UserLoader(AccountRepository todoRepository) {
+ this.userRepository = todoRepository;
+ }
+
+ @Override
+ public void onApplicationEvent(ContextRefreshedEvent e) {
+ Account user1 = new Account("Alex lindo", "apssouza22@gmail.com", "1234");
+ Account user2 = new Account("Gaekke delicia", "gaelle@meama.com", "2222");
+ Account user3 = new Account("Márcia almeida", "marciapalito@hotmail.com", "2222");
+
+ userRepository.save(user1);
+ userRepository.save(user2);
+ userRepository.save(user3);
+
+ log.info("Created the todos.");
+ }
+
+}
diff --git a/user-service/src/main/java/com/apssouza/configuration/H2DbConfiguration.java b/user-service/src/main/java/com/apssouza/configuration/H2DbConfiguration.java
index d09670f..08a068c 100644
--- a/user-service/src/main/java/com/apssouza/configuration/H2DbConfiguration.java
+++ b/user-service/src/main/java/com/apssouza/configuration/H2DbConfiguration.java
@@ -1,23 +1,23 @@
-
-package com.apssouza.configuration;
-
-
-import org.h2.server.web.WebServlet;
-import org.springframework.boot.web.servlet.ServletRegistrationBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * Configuration to enable access to the h2db console
- * @author apssouza
- */
-@Configuration
-public class H2DbConfiguration {
- @Bean
- ServletRegistrationBean h2servletRegistration(){
- ServletRegistrationBean registrationBean = new ServletRegistrationBean( new WebServlet());
- registrationBean.addUrlMappings("/console/*");
- return registrationBean;
- }
-}
-
+
+package com.apssouza.configuration;
+
+
+import org.h2.server.web.WebServlet;
+import org.springframework.boot.web.servlet.ServletRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Configuration to enable access to the h2db console
+ * @author apssouza
+ */
+@Configuration
+public class H2DbConfiguration {
+ @Bean
+ ServletRegistrationBean h2servletRegistration(){
+ ServletRegistrationBean registrationBean = new ServletRegistrationBean( new WebServlet());
+ registrationBean.addUrlMappings("/console/*");
+ return registrationBean;
+ }
+}
+
diff --git a/user-service/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java b/user-service/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java
index 5c8f16c..3ea07f3 100644
--- a/user-service/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java
+++ b/user-service/src/main/java/com/apssouza/configuration/ServiceDiscoveryConfiguration.java
@@ -1,15 +1,15 @@
-package com.apssouza.configuration;
-
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.context.annotation.Configuration;
-
-/**
- * Eureka service discovery client configuration
- *
- * @author apssouza
- */
-@Configuration
-@EnableDiscoveryClient
-public class ServiceDiscoveryConfiguration {
-
-}
+package com.apssouza.configuration;
+
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Eureka service discovery client configuration
+ *
+ * @author apssouza
+ */
+@Configuration
+@EnableDiscoveryClient
+public class ServiceDiscoveryConfiguration {
+
+}
diff --git a/user-service/src/main/java/com/apssouza/controllers/AccountController.java b/user-service/src/main/java/com/apssouza/controllers/AccountController.java
index 68fb2fd..a7b97ea 100644
--- a/user-service/src/main/java/com/apssouza/controllers/AccountController.java
+++ b/user-service/src/main/java/com/apssouza/controllers/AccountController.java
@@ -1,88 +1,88 @@
-package com.apssouza.controllers;
-
-import com.apssouza.entities.Account;
-import com.apssouza.exceptions.DataNotFoundException;
-import java.net.URI;
-import java.util.List;
-import java.util.Optional;
-import javax.validation.Valid;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.ResponseEntity;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
-import com.apssouza.services.AccountService;
-import org.springframework.web.bind.annotation.RequestParam;
-
-/**
- * Account's entry points
- *
- * @author apssouza
- */
-@RequestMapping("/accounts")
-@RestController
-public class AccountController {
-
- @Autowired
- AccountService userService;
-
- @Autowired
- public AccountController(
- AccountService userService
- ) {
- this.userService = userService;
- }
-
- @GetMapping
- public List all() {
- return userService.all();
- }
-
- @PostMapping
- public ResponseEntity> save(@RequestBody @Valid Account account) {
- Account saved = this.userService.save(account);
- Long id = saved.getId();
- if (id != null) {
- URI location = ServletUriComponentsBuilder
- .fromCurrentRequest().path("/{id}")
- .buildAndExpand(id).toUri();
- return ResponseEntity.created(location).build();
- }
- return ResponseEntity.noContent().build();
- }
-
- @PutMapping("{id}")
- public ResponseEntity> update(
- @PathVariable long id,
- @RequestBody @Valid Account user
- ) {
- return ResponseEntity.ok(userService.update(id, user));
- }
-
- @GetMapping("{id}")
- public ResponseEntity> find(@PathVariable long id) {
- Optional findById = userService.findById(id);
- return findById.map(todo -> {
- return ResponseEntity.ok(todo);
- }).orElseThrow(
- () -> new DataNotFoundException("user not found")
- );
- }
-
- @GetMapping("search")
- public ResponseEntity> find(@RequestParam("email") String email) {
- Optional account = userService.findByEmail(email);
- return account.map(a -> {
- return ResponseEntity.ok(a);
- }).orElseThrow(
- () -> new DataNotFoundException("user not found")
- );
- }
-
-}
+package com.apssouza.controllers;
+
+import com.apssouza.entities.Account;
+import com.apssouza.exceptions.DataNotFoundException;
+import java.net.URI;
+import java.util.List;
+import java.util.Optional;
+import javax.validation.Valid;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
+import com.apssouza.services.AccountService;
+import org.springframework.web.bind.annotation.RequestParam;
+
+/**
+ * Account's entry points
+ *
+ * @author apssouza
+ */
+@RequestMapping("/accounts")
+@RestController
+public class AccountController {
+
+ @Autowired
+ AccountService userService;
+
+ @Autowired
+ public AccountController(
+ AccountService userService
+ ) {
+ this.userService = userService;
+ }
+
+ @GetMapping
+ public List all() {
+ return userService.all();
+ }
+
+ @PostMapping
+ public ResponseEntity> save(@RequestBody @Valid Account account) {
+ Account saved = this.userService.save(account);
+ Long id = saved.getId();
+ if (id != null) {
+ URI location = ServletUriComponentsBuilder
+ .fromCurrentRequest().path("/{id}")
+ .buildAndExpand(id).toUri();
+ return ResponseEntity.created(location).build();
+ }
+ return ResponseEntity.noContent().build();
+ }
+
+ @PutMapping("{id}")
+ public ResponseEntity> update(
+ @PathVariable long id,
+ @RequestBody @Valid Account user
+ ) {
+ return ResponseEntity.ok(userService.update(id, user));
+ }
+
+ @GetMapping("{id}")
+ public ResponseEntity> find(@PathVariable long id) {
+ Optional findById = userService.findById(id);
+ return findById.map(todo -> {
+ return ResponseEntity.ok(todo);
+ }).orElseThrow(
+ () -> new DataNotFoundException("user not found")
+ );
+ }
+
+ @GetMapping("search")
+ public ResponseEntity> find(@RequestParam("email") String email) {
+ Optional account = userService.findByEmail(email);
+ return account.map(a -> {
+ return ResponseEntity.ok(a);
+ }).orElseThrow(
+ () -> new DataNotFoundException("user not found")
+ );
+ }
+
+}
diff --git a/user-service/src/main/java/com/apssouza/entities/Account.java b/user-service/src/main/java/com/apssouza/entities/Account.java
index 2957740..bcd67b6 100644
--- a/user-service/src/main/java/com/apssouza/entities/Account.java
+++ b/user-service/src/main/java/com/apssouza/entities/Account.java
@@ -1,88 +1,88 @@
-package com.apssouza.entities;
-
-import javax.persistence.Column;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-import javax.persistence.Entity;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Version;
-import org.hibernate.validator.constraints.Email;
-
-/**
- * Account Entity
- *
- * @author apssouza
- */
-@Entity
-public class Account {
-
- @Id
- @GeneratedValue
- private long id;
-
- @NotNull
- private String password;
-
- @NotNull
- @Size(min = 2, max = 256)
- private String name;
-
- @Email
- @NotNull
- @Column(unique = true)
- private String email;
-
- @Version
- private long version;
-
- public Account() {
- }
-
- public Account(String name, String email, String pass) {
- this.name = name;
- this.email = email;
- this.password = pass;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getEmail() {
- return email;
- }
-
- public void setEmail(String email) {
- this.email = email;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setAuthId(String pass) {
- this.password = pass;
- }
-
- public long getVersion() {
- return version;
- }
-
- public void setVersion(long version) {
- this.version = version;
- }
-
-}
+package com.apssouza.entities;
+
+import javax.persistence.Column;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Version;
+import org.hibernate.validator.constraints.Email;
+
+/**
+ * Account Entity
+ *
+ * @author apssouza
+ */
+@Entity
+public class Account {
+
+ @Id
+ @GeneratedValue
+ private long id;
+
+ @NotNull
+ private String password;
+
+ @NotNull
+ @Size(min = 2, max = 256)
+ private String name;
+
+ @Email
+ @NotNull
+ @Column(unique = true)
+ private String email;
+
+ @Version
+ private long version;
+
+ public Account() {
+ }
+
+ public Account(String name, String email, String pass) {
+ this.name = name;
+ this.email = email;
+ this.password = pass;
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setAuthId(String pass) {
+ this.password = pass;
+ }
+
+ public long getVersion() {
+ return version;
+ }
+
+ public void setVersion(long version) {
+ this.version = version;
+ }
+
+}
diff --git a/user-service/src/main/java/com/apssouza/exceptions/DataNotFoundException.java b/user-service/src/main/java/com/apssouza/exceptions/DataNotFoundException.java
index 51ff374..8a0e56e 100644
--- a/user-service/src/main/java/com/apssouza/exceptions/DataNotFoundException.java
+++ b/user-service/src/main/java/com/apssouza/exceptions/DataNotFoundException.java
@@ -1,17 +1,17 @@
-package com.apssouza.exceptions;
-
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.ResponseStatus;
-
-/**
- * Data not found exception. It will return the Not found HTTP status code
- *
- * @author Apssouza
- */
-@ResponseStatus(HttpStatus.NOT_FOUND)
-public class DataNotFoundException extends RuntimeException {
-
- public DataNotFoundException(String msg) {
- super(msg);
- }
-}
+package com.apssouza.exceptions;
+
+import org.springframework.http.HttpStatus;
+import org.springframework.web.bind.annotation.ResponseStatus;
+
+/**
+ * Data not found exception. It will return the Not found HTTP status code
+ *
+ * @author Apssouza
+ */
+@ResponseStatus(HttpStatus.NOT_FOUND)
+public class DataNotFoundException extends RuntimeException {
+
+ public DataNotFoundException(String msg) {
+ super(msg);
+ }
+}
diff --git a/user-service/src/main/java/com/apssouza/repositories/AccountRepository.java b/user-service/src/main/java/com/apssouza/repositories/AccountRepository.java
index 23d7071..a4741e1 100644
--- a/user-service/src/main/java/com/apssouza/repositories/AccountRepository.java
+++ b/user-service/src/main/java/com/apssouza/repositories/AccountRepository.java
@@ -1,17 +1,17 @@
-package com.apssouza.repositories;
-
-import com.apssouza.entities.Account;
-import java.util.Optional;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.stereotype.Repository;
-
-/**
- * Account interface repository
- *
- * @author apssouza
- */
-@Repository
-public interface AccountRepository extends JpaRepository {
-
- Optional findByEmail(String email);
-}
+package com.apssouza.repositories;
+
+import com.apssouza.entities.Account;
+import java.util.Optional;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Account interface repository
+ *
+ * @author apssouza
+ */
+@Repository
+public interface AccountRepository extends JpaRepository {
+
+ Optional findByEmail(String email);
+}
diff --git a/user-service/src/main/java/com/apssouza/services/AccountService.java b/user-service/src/main/java/com/apssouza/services/AccountService.java
index 99107dd..45b6775 100644
--- a/user-service/src/main/java/com/apssouza/services/AccountService.java
+++ b/user-service/src/main/java/com/apssouza/services/AccountService.java
@@ -1,26 +1,26 @@
-package com.apssouza.services;
-
-import com.apssouza.entities.Account;
-import com.apssouza.exceptions.DataNotFoundException;
-import java.util.List;
-import java.util.Optional;
-
-/**
- * Account service interface
- *
- * @author apssouza
- */
-public interface AccountService {
-
- Optional findById(long id);
-
- List all();
-
- Account save(Account user);
-
- Account update(Long id, Account user) throws DataNotFoundException;
-
- Optional findByEmail(String name);
-
- void delete(Account a);
-}
+package com.apssouza.services;
+
+import com.apssouza.entities.Account;
+import com.apssouza.exceptions.DataNotFoundException;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * Account service interface
+ *
+ * @author apssouza
+ */
+public interface AccountService {
+
+ Optional findById(long id);
+
+ List all();
+
+ Account save(Account user);
+
+ Account update(Long id, Account user) throws DataNotFoundException;
+
+ Optional findByEmail(String name);
+
+ void delete(Account a);
+}
diff --git a/user-service/src/main/java/com/apssouza/services/AccountServiceImpl.java b/user-service/src/main/java/com/apssouza/services/AccountServiceImpl.java
index a8227cf..8615e41 100644
--- a/user-service/src/main/java/com/apssouza/services/AccountServiceImpl.java
+++ b/user-service/src/main/java/com/apssouza/services/AccountServiceImpl.java
@@ -1,56 +1,56 @@
-package com.apssouza.services;
-
-import com.apssouza.entities.Account;
-import com.apssouza.exceptions.DataNotFoundException;
-import java.util.List;
-import java.util.Optional;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import com.apssouza.repositories.AccountRepository;
-
-/**
- * @see AccountService
- * @author apssouza
- */
-@Service
-public class AccountServiceImpl implements AccountService {
-
- @Autowired
- private AccountRepository accountRepository;
-
- @Override
- public Optional findById(long id) {
- return Optional.ofNullable(this.accountRepository.findOne(id));
- }
-
- @Override
- public List all() {
- return this.accountRepository.findAll();
- }
-
- @Override
- public Account save(Account user) {
- return this.accountRepository.save(user);
- }
-
- @Override
- public Account update(Long id, Account user) throws DataNotFoundException {
- return this.findById(id)
- .map(u -> {
- u.setEmail(user.getEmail());
- u.setName(user.getName());
- u.setAuthId(user.getPassword());
- return save(u);
- }).orElseThrow(() -> new DataNotFoundException("User not found"));
- }
-
- @Override
- public Optional findByEmail(String email) {
- return accountRepository.findByEmail(email);
- }
-
- @Override
- public void delete(Account a) {
- accountRepository.delete(a);
- }
-}
+package com.apssouza.services;
+
+import com.apssouza.entities.Account;
+import com.apssouza.exceptions.DataNotFoundException;
+import java.util.List;
+import java.util.Optional;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.apssouza.repositories.AccountRepository;
+
+/**
+ * @see AccountService
+ * @author apssouza
+ */
+@Service
+public class AccountServiceImpl implements AccountService {
+
+ @Autowired
+ private AccountRepository accountRepository;
+
+ @Override
+ public Optional findById(long id) {
+ return Optional.ofNullable(this.accountRepository.findOne(id));
+ }
+
+ @Override
+ public List all() {
+ return this.accountRepository.findAll();
+ }
+
+ @Override
+ public Account save(Account user) {
+ return this.accountRepository.save(user);
+ }
+
+ @Override
+ public Account update(Long id, Account user) throws DataNotFoundException {
+ return this.findById(id)
+ .map(u -> {
+ u.setEmail(user.getEmail());
+ u.setName(user.getName());
+ u.setAuthId(user.getPassword());
+ return save(u);
+ }).orElseThrow(() -> new DataNotFoundException("User not found"));
+ }
+
+ @Override
+ public Optional findByEmail(String email) {
+ return accountRepository.findByEmail(email);
+ }
+
+ @Override
+ public void delete(Account a) {
+ accountRepository.delete(a);
+ }
+}
diff --git a/user-service/src/main/resources/application.properties b/user-service/src/main/resources/application.properties
index 9b6f74e..945a5bd 100644
--- a/user-service/src/main/resources/application.properties
+++ b/user-service/src/main/resources/application.properties
@@ -1,26 +1,26 @@
-spring.application.name = user
-
-# Root logger option
-log4j.rootLogger=INFO, file, stdout
-
-# Direct log messages to a log file
-log4j.appender.file=org.apache.log4j.RollingFileAppender
-log4j.appender.file.File=/var/log/todo.log
-log4j.appender.file.MaxFileSize=10MB
-log4j.appender.file.MaxBackupIndex=10
-log4j.appender.file.layout=org.apache.log4j.PatternLayout
-log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-
-# Direct log messages to stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
-
-
-# Hibernate logging options (INFO only shows startup messages)
-# Log JDBC bind parameter runtime arguments
-
-log4j.logger.org.hibernate.SQL=debug
-log4j.logger.org.hibernate.type=trace
-log4j.logger.org.hibernate.type.descriptor.sql=trace
+spring.application.name = user
+
+# Root logger option
+log4j.rootLogger=INFO, file, stdout
+
+# Direct log messages to a log file
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+log4j.appender.file.File=/var/log/todo.log
+log4j.appender.file.MaxFileSize=10MB
+log4j.appender.file.MaxBackupIndex=10
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
+
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
+
+
+# Hibernate logging options (INFO only shows startup messages)
+# Log JDBC bind parameter runtime arguments
+
+log4j.logger.org.hibernate.SQL=debug
+log4j.logger.org.hibernate.type=trace
+log4j.logger.org.hibernate.type.descriptor.sql=trace
diff --git a/user-service/src/main/resources/bootstrap.yml b/user-service/src/main/resources/bootstrap.yml
index b940bf4..47aefda 100644
--- a/user-service/src/main/resources/bootstrap.yml
+++ b/user-service/src/main/resources/bootstrap.yml
@@ -1,6 +1,6 @@
----
-spring:
- cloud:
- config:
- uri: http://config:8888
+---
+spring:
+ cloud:
+ config:
+ uri: http://config:8888
\ No newline at end of file
diff --git a/user-service/src/main/resources/docker/Dockerfile b/user-service/src/main/resources/docker/Dockerfile
index ab30719..fe9779e 100644
--- a/user-service/src/main/resources/docker/Dockerfile
+++ b/user-service/src/main/resources/docker/Dockerfile
@@ -1,37 +1,37 @@
-FROM openjdk:8
-
-
-MAINTAINER Alexsandro
-ENV REFRESHED_AT 2017-09-17
-
-ENV TERM xterm
-ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
-
-RUN apt-get update -qq \
- && apt-get install -qqy curl wget \
- && apt-get clean \
- \
- && touch /var/log/todo.log \
- && chmod 666 /var/log/todo.log
-
-ADD application/lib/springboot-webapp.jar /app.jar
-ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
-RUN bash -c 'chmod +x wait-for-it.sh'
-
-# install Filebeat
-ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
-RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
- && dpkg -i ${FILEBEAT_VERSION} \
- && rm ${FILEBEAT_VERSION}
-
-# configure Filebeat
-ADD filebeat.yml /etc/filebeat/filebeat.yml
-
-# CA cert
-RUN mkdir -p /etc/pki/tls/certs
-ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
-
-# start Filebeat
-ADD ./start.sh /usr/local/bin/start.sh
-RUN chmod +x /usr/local/bin/start.sh
+FROM openjdk:8
+
+
+MAINTAINER Alexsandro
+ENV REFRESHED_AT 2017-09-17
+
+ENV TERM xterm
+ENV JAVA_OPTS -Djava.security.egd=file:/dev/./urandom
+
+RUN apt-get update -qq \
+ && apt-get install -qqy curl wget \
+ && apt-get clean \
+ \
+ && touch /var/log/todo.log \
+ && chmod 666 /var/log/todo.log
+
+ADD application/lib/springboot-webapp.jar /app.jar
+ADD https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh wait-for-it.sh
+RUN bash -c 'chmod +x wait-for-it.sh'
+
+# install Filebeat
+ENV FILEBEAT_VERSION=filebeat_1.2.3_amd64.deb
+RUN curl -L -O https://download.elastic.co/beats/filebeat/${FILEBEAT_VERSION} \
+ && dpkg -i ${FILEBEAT_VERSION} \
+ && rm ${FILEBEAT_VERSION}
+
+# configure Filebeat
+ADD filebeat.yml /etc/filebeat/filebeat.yml
+
+# CA cert
+RUN mkdir -p /etc/pki/tls/certs
+ADD logstash-beats.crt /etc/pki/tls/certs/logstash-beats.crt
+
+# start Filebeat
+ADD ./start.sh /usr/local/bin/start.sh
+RUN chmod +x /usr/local/bin/start.sh
CMD [ "/usr/local/bin/start.sh" ]
\ No newline at end of file
diff --git a/user-service/src/main/resources/docker/filebeat.yml b/user-service/src/main/resources/docker/filebeat.yml
index a982070..1b39ac5 100644
--- a/user-service/src/main/resources/docker/filebeat.yml
+++ b/user-service/src/main/resources/docker/filebeat.yml
@@ -1,30 +1,30 @@
-output:
- logstash:
- enabled: true
- hosts:
- - elk:5044
- timeout: 15
- tls:
- certificate_authorities:
- - /etc/pki/tls/certs/logstash-beats.crt
-
-filebeat:
- prospectors:
- -
- paths:
- - /var/log/syslog
- - /var/log/auth.log
- document_type: syslog
- -
- paths:
- - /var/log/todo.log
- document_type: log4j
- multiline:
- pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
- negate: true
- match: after
- -
- paths:
- - /usr/local/tomcat/logs/*.out
- - /usr/local/tomcat/logs/*.log
- document_type: tomcat
+output:
+ logstash:
+ enabled: true
+ hosts:
+ - elk:5044
+ timeout: 15
+ tls:
+ certificate_authorities:
+ - /etc/pki/tls/certs/logstash-beats.crt
+
+filebeat:
+ prospectors:
+ -
+ paths:
+ - /var/log/syslog
+ - /var/log/auth.log
+ document_type: syslog
+ -
+ paths:
+ - /var/log/todo.log
+ document_type: log4j
+ multiline:
+ pattern: '^[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}'
+ negate: true
+ match: after
+ -
+ paths:
+ - /usr/local/tomcat/logs/*.out
+ - /usr/local/tomcat/logs/*.log
+ document_type: tomcat
diff --git a/user-service/src/main/resources/docker/logstash-beats.crt b/user-service/src/main/resources/docker/logstash-beats.crt
index d9b71cf..1c86bc3 100644
--- a/user-service/src/main/resources/docker/logstash-beats.crt
+++ b/user-service/src/main/resources/docker/logstash-beats.crt
@@ -1,18 +1,18 @@
------BEGIN CERTIFICATE-----
-MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
-BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
-DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
-0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
-9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
-PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
-qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
-KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
-4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
-VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
-hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
-okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
-T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
-ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
-kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
-Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
------END CERTIFICATE-----
+-----BEGIN CERTIFICATE-----
+MIIC6zCCAdOgAwIBAgIJANPZwuf+5wTLMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV
+BAMMASowHhcNMTUxMjI4MTA0NTMyWhcNMjUxMjI1MTA0NTMyWjAMMQowCAYDVQQD
+DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp+jHFvhyYKiPXc7k
+0c33f2QV+1hHNyW/uwcJbp5jG82cuQ41v70Z1+b2veBW4sUlDY3yAIEOPSUD8ASt
+9m72CAo4xlwYKDvm/Sa3KJtDk0NrQiz6PPyBUFsY+Bj3xn6Nz1RW5YaP+Q1Hjnks
+PEyQu4vLgfTSGYBHLD4gvs8wDWY7aaKf8DfuP7Ov74Qlj2GOxnmiDEF4tirlko0r
+qQcvBgujCqA7rNoG+QDmkn3VrxtX8mKF72bxQ7USCyoxD4cWV2mU2HD2Maed3KHj
+KAvDAzSyBMjI+qi9IlPN5MR7rVqUV0VlSKXBVPct6NG7x4WRwnoKjTXnr3CRADD0
+4uvbQQIDAQABo1AwTjAdBgNVHQ4EFgQUVFurgDwdcgnCYxszc0dWMWhB3DswHwYD
+VR0jBBgwFoAUVFurgDwdcgnCYxszc0dWMWhB3DswDAYDVR0TBAUwAwEB/zANBgkq
+hkiG9w0BAQsFAAOCAQEAaLSytepMb5LXzOPr9OiuZjTk21a2C84k96f4uqGqKV/s
+okTTKD0NdeY/IUIINMq4/ERiqn6YDgPgHIYvQheWqnJ8ir69ODcYCpsMXIPau1ow
+T8c108BEHqBMEjkOQ5LrEjyvLa/29qJ5JsSSiULHvS917nVgY6xhcnRZ0AhuJkiI
+ARKXwpO5tqJi6BtgzX/3VDSOgVZbvX1uX51Fe9gWwPDgipnYaE/t9TGzJEhKwSah
+kNr+7RM+Glsv9rx1KcWcx4xxY3basG3/KwvsGAFPvk5tXbZ780VuNFTTZw7q3p8O
+Gk1zQUBOie0naS0afype5qFMPp586SF/2xAeb68gLg==
+-----END CERTIFICATE-----
diff --git a/user-service/src/main/resources/docker/start.sh b/user-service/src/main/resources/docker/start.sh
index b68b2fb..eff4532 100644
--- a/user-service/src/main/resources/docker/start.sh
+++ b/user-service/src/main/resources/docker/start.sh
@@ -1,5 +1,4 @@
#!/bin/bash
-
curl -XPUT 'http://elk:9200/_template/filebeat?pretty' -d@/etc/filebeat/filebeat.template.json
/etc/init.d/filebeat start
-java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
+java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
\ No newline at end of file