├── README.md ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ ├── maven-wrapper.properties │ └── MavenWrapperDownloader.java ├── domain ├── src │ └── main │ │ └── java │ │ └── io │ │ └── github │ │ └── mat3e │ │ ├── DomainEventPublisher.java │ │ ├── DomainEvent.java │ │ ├── task │ │ ├── TaskRepository.java │ │ ├── vo │ │ │ ├── TaskSourceId.java │ │ │ ├── TaskCreator.java │ │ │ └── TaskEvent.java │ │ ├── TaskSnapshot.java │ │ └── Task.java │ │ └── project │ │ ├── ProjectRepository.java │ │ ├── ProjectSnapshot.java │ │ ├── ProjectStepSnapshot.java │ │ └── Project.java └── pom.xml ├── adapters ├── src │ └── main │ │ ├── resources │ │ ├── application.yml │ │ └── META-INF │ │ │ └── orm.xml │ │ └── java │ │ └── io │ │ └── github │ │ └── mat3e │ │ ├── auth │ │ ├── AuthenticationResponseDto.java │ │ ├── AuthenticationRequestDto.java │ │ ├── JwtConfigurationProperties.java │ │ ├── AuthenticationController.java │ │ ├── TokenService.java │ │ ├── AuthenticationFilter.java │ │ └── SecurityConfiguration.java │ │ ├── task │ │ ├── TaskConfiguration.java │ │ ├── TaskWarmup.java │ │ ├── SqlTaskRepository.java │ │ └── TaskController.java │ │ ├── project │ │ ├── ProjectConfiguration.java │ │ ├── ProjectEventListener.java │ │ ├── ProjectWarmup.java │ │ ├── SqlProjectRepository.java │ │ └── ProjectController.java │ │ └── SpringDomainEventPublisher.java └── pom.xml ├── monolith ├── src │ ├── test │ │ └── java │ │ │ └── io │ │ │ └── github │ │ │ └── mat3e │ │ │ └── JavaCleanArchitectureApplicationTests.java │ └── main │ │ ├── java │ │ └── io │ │ │ └── github │ │ │ └── mat3e │ │ │ └── JavaCleanArchitectureApplication.java │ │ └── resources │ │ └── Clean Architecture.postman_collection.json └── pom.xml ├── app ├── src │ └── main │ │ └── java │ │ └── io │ │ └── github │ │ └── mat3e │ │ ├── task │ │ ├── TaskQueryRepository.java │ │ ├── dto │ │ │ ├── TaskWithChangesQueryDto.java │ │ │ └── TaskDto.java │ │ ├── TaskFactory.java │ │ ├── TaskInitializer.java │ │ └── TaskFacade.java │ │ └── project │ │ ├── ProjectQueryRepository.java │ │ ├── dto │ │ ├── ProjectDeadlineDto.java │ │ ├── ProjectDto.java │ │ └── ProjectStepDto.java │ │ ├── ProjectFactory.java │ │ ├── ProjectInitializer.java │ │ └── ProjectFacade.java └── pom.xml ├── .gitignore ├── pom.xml ├── mvnw.cmd ├── mvnw └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # java-clean-architecture 2 | Clean Architecture, ports & adapters, Domain-Driven Design, CQRS 3 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/full-stack-engineering/java-clean-architecture/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /domain/src/main/java/io/github/mat3e/DomainEventPublisher.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e; 2 | 3 | public interface DomainEventPublisher { 4 | void publish(DomainEvent event); 5 | } 6 | -------------------------------------------------------------------------------- /domain/src/main/java/io/github/mat3e/DomainEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e; 2 | 3 | import java.time.Instant; 4 | 5 | public interface DomainEvent { 6 | Instant getOccurredOn(); 7 | } 8 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /adapters/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | spring: 2 | datasource: 3 | url: 'jdbc:h2:file:./todo-db' 4 | username: 'sa' 5 | password: 'pass' 6 | jpa.hibernate.ddl-auto: update 7 | jwt: 8 | secret: 'fullstackengineering9z3255CFHMcQfTjfoo09barWnZ123r4u788x1AcDdsGKaNdRgUkXp2iogithubmat3e' 9 | validity: 3600 10 | -------------------------------------------------------------------------------- /monolith/src/test/java/io/github/mat3e/JavaCleanArchitectureApplicationTests.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class JavaCleanArchitectureApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/auth/AuthenticationResponseDto.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.auth; 2 | 3 | class AuthenticationResponseDto { 4 | private final String token; 5 | 6 | AuthenticationResponseDto(String token) { 7 | this.token = token; 8 | } 9 | 10 | public String getToken() { 11 | return token; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /domain/src/main/java/io/github/mat3e/task/TaskRepository.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | interface TaskRepository { 7 | Optional findById(Integer id); 8 | 9 | Task save(Task entity); 10 | 11 | List saveAll(Iterable entities); 12 | 13 | void deleteById(Integer id); 14 | } 15 | -------------------------------------------------------------------------------- /domain/src/main/java/io/github/mat3e/task/vo/TaskSourceId.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task.vo; 2 | 3 | public class TaskSourceId { 4 | private String id; 5 | 6 | protected TaskSourceId() { 7 | } 8 | 9 | public TaskSourceId(final String id) { 10 | this.id = id; 11 | } 12 | 13 | public String getId() { 14 | return id; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/task/TaskQueryRepository.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task; 2 | 3 | import io.github.mat3e.task.dto.TaskDto; 4 | 5 | import java.util.Optional; 6 | import java.util.Set; 7 | 8 | public interface TaskQueryRepository { 9 | int count(); 10 | 11 | Optional findDtoById(Integer id); 12 | 13 | Set findBy(Class type); 14 | } 15 | -------------------------------------------------------------------------------- /domain/src/main/java/io/github/mat3e/project/ProjectRepository.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | import java.util.Optional; 4 | 5 | interface ProjectRepository { 6 | Project save(Project entity); 7 | 8 | Optional findById(Integer id); 9 | 10 | Optional findByNestedStepId(Integer id); 11 | 12 | void delete(Project.Step entity); 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/project/ProjectQueryRepository.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | import io.github.mat3e.project.dto.ProjectDto; 4 | 5 | import java.util.Optional; 6 | import java.util.Set; 7 | 8 | public interface ProjectQueryRepository { 9 | Optional findDtoById(Integer id); 10 | 11 | Set findBy(Class type); 12 | 13 | long count(); 14 | } 15 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/project/dto/ProjectDeadlineDto.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project.dto; 2 | 3 | import java.time.ZonedDateTime; 4 | 5 | public class ProjectDeadlineDto { 6 | private ZonedDateTime deadline; 7 | 8 | public ZonedDateTime getDeadline() { 9 | return deadline; 10 | } 11 | 12 | void setDeadline(ZonedDateTime deadline) { 13 | this.deadline = deadline; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/task/dto/TaskWithChangesQueryDto.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task.dto; 2 | 3 | import javax.validation.constraints.NotNull; 4 | import java.time.ZonedDateTime; 5 | 6 | public interface TaskWithChangesQueryDto { 7 | int getId(); 8 | 9 | @NotNull 10 | String getDescription(); 11 | 12 | boolean isDone(); 13 | 14 | ZonedDateTime getDeadline(); 15 | 16 | int getChangesCount(); 17 | } 18 | -------------------------------------------------------------------------------- /monolith/src/main/java/io/github/mat3e/JavaCleanArchitectureApplication.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class JavaCleanArchitectureApplication { 8 | public static void main(String[] args) { 9 | SpringApplication.run(JavaCleanArchitectureApplication.class, args); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/task/TaskConfiguration.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task; 2 | 3 | import io.github.mat3e.DomainEventPublisher; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | @Configuration 8 | class TaskConfiguration { 9 | @Bean 10 | TaskFacade taskFacade(final TaskRepository taskRepository, final DomainEventPublisher publisher) { 11 | return new TaskFacade(new TaskFactory(), taskRepository, publisher); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/task/TaskFactory.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task; 2 | 3 | import io.github.mat3e.task.dto.TaskDto; 4 | 5 | class TaskFactory { 6 | Task from(final TaskDto source) { 7 | return Task.restore(new TaskSnapshot( 8 | source.getId(), 9 | source.getDescription(), 10 | source.isDone(), 11 | source.getDeadline(), 12 | 0, 13 | source.getAdditionalComment(), 14 | null 15 | )); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/project/ProjectConfiguration.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | import io.github.mat3e.task.TaskFacade; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | @Configuration 8 | class ProjectConfiguration { 9 | @Bean 10 | ProjectFacade projectFacade(final ProjectRepository projectRepository, final TaskFacade taskFacade) { 11 | return new ProjectFacade(new ProjectFactory(), projectRepository, taskFacade); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/auth/AuthenticationRequestDto.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.auth; 2 | 3 | class AuthenticationRequestDto { 4 | private String username; 5 | private String password; 6 | 7 | public String getUsername() { 8 | return username; 9 | } 10 | 11 | void setUsername(String username) { 12 | this.username = username; 13 | } 14 | 15 | public String getPassword() { 16 | return password; 17 | } 18 | 19 | void setPassword(String password) { 20 | this.password = password; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | HELP.md 3 | !**/src/main/** 4 | !**/src/test/** 5 | 6 | *.db 7 | 8 | ### Gradle ### 9 | .gradle 10 | !gradle/wrapper/gradle-wrapper.jar 11 | 12 | ### Maven ### 13 | target/ 14 | !.mvn/wrapper/maven-wrapper.jar 15 | 16 | ### STS ### 17 | .apt_generated 18 | .classpath 19 | .factorypath 20 | .project 21 | .settings 22 | .springBeans 23 | .sts4-cache 24 | 25 | ### IntelliJ IDEA ### 26 | .idea 27 | *.iws 28 | *.iml 29 | *.ipr 30 | 31 | ### NetBeans ### 32 | /nbproject/private/ 33 | /nbbuild/ 34 | /dist/ 35 | /nbdist/ 36 | /.nb-gradle/ 37 | build/ 38 | 39 | ### VS Code ### 40 | .vscode/ 41 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/project/ProjectEventListener.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | import io.github.mat3e.task.vo.TaskEvent; 4 | import org.springframework.context.event.EventListener; 5 | import org.springframework.stereotype.Service; 6 | 7 | @Service 8 | class ProjectEventListener { 9 | private final ProjectFacade facade; 10 | 11 | ProjectEventListener(final ProjectFacade facade) { 12 | this.facade = facade; 13 | } 14 | 15 | @EventListener 16 | // warning: must be synchronous in current design 17 | public void on(TaskEvent event) { 18 | facade.handle(event); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/SpringDomainEventPublisher.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e; 2 | 3 | import org.springframework.context.ApplicationEventPublisher; 4 | import org.springframework.stereotype.Service; 5 | 6 | @Service 7 | public class SpringDomainEventPublisher implements DomainEventPublisher { 8 | private final ApplicationEventPublisher innerPublisher; 9 | 10 | public SpringDomainEventPublisher(final ApplicationEventPublisher innerPublisher) { 11 | this.innerPublisher = innerPublisher; 12 | } 13 | 14 | @Override 15 | public void publish(final DomainEvent event) { 16 | innerPublisher.publishEvent(event); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/auth/JwtConfigurationProperties.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.auth; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | import org.springframework.context.annotation.Configuration; 5 | 6 | @Configuration 7 | @ConfigurationProperties("jwt") 8 | class JwtConfigurationProperties { 9 | private String secret; 10 | private long validity; 11 | 12 | String getSecret() { 13 | return secret; 14 | } 15 | 16 | void setSecret(String secret) { 17 | this.secret = secret; 18 | } 19 | 20 | long getValidity() { 21 | return validity; 22 | } 23 | 24 | void setValidity(long validity) { 25 | this.validity = validity; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/task/TaskWarmup.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task; 2 | 3 | import org.springframework.context.ApplicationListener; 4 | import org.springframework.context.event.ContextRefreshedEvent; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | class TaskWarmup implements ApplicationListener { 9 | private final TaskInitializer initializer; 10 | 11 | TaskWarmup(final TaskRepository taskRepository, final TaskQueryRepository taskQueryRepository) { 12 | this.initializer = new TaskInitializer(taskRepository, taskQueryRepository); 13 | } 14 | 15 | @Override 16 | public void onApplicationEvent(final ContextRefreshedEvent event) { 17 | initializer.init(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/task/TaskInitializer.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task; 2 | 3 | import java.time.ZonedDateTime; 4 | 5 | class TaskInitializer { 6 | private final TaskRepository taskRepository; 7 | private final TaskQueryRepository taskQueryRepository; 8 | 9 | TaskInitializer(final TaskRepository taskRepository, final TaskQueryRepository taskQueryRepository) { 10 | this.taskRepository = taskRepository; 11 | this.taskQueryRepository = taskQueryRepository; 12 | } 13 | 14 | void init() { 15 | if (taskQueryRepository.count() == 0) { 16 | taskRepository.save(Task.restore( 17 | new TaskSnapshot(0, "Example task", false, ZonedDateTime.now(), 0, null, null) 18 | )); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /domain/src/main/java/io/github/mat3e/task/vo/TaskCreator.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task.vo; 2 | 3 | import java.time.ZonedDateTime; 4 | 5 | public class TaskCreator { 6 | private final TaskSourceId id; 7 | private final String description; 8 | private final ZonedDateTime deadline; 9 | 10 | public TaskCreator(final TaskSourceId id, final String description, final ZonedDateTime deadline) { 11 | this.id = id; 12 | this.description = description; 13 | this.deadline = deadline; 14 | } 15 | 16 | public TaskSourceId getId() { 17 | return id; 18 | } 19 | 20 | public String getDescription() { 21 | return description; 22 | } 23 | 24 | public ZonedDateTime getDeadline() { 25 | return deadline; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/project/ProjectWarmup.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | import org.springframework.context.ApplicationListener; 4 | import org.springframework.context.event.ContextRefreshedEvent; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | class ProjectWarmup implements ApplicationListener { 9 | private final ProjectInitializer initializer; 10 | 11 | ProjectWarmup(final ProjectRepository projectRepository, final ProjectQueryRepository projectQueryRepository) { 12 | this.initializer = new ProjectInitializer(projectRepository, projectQueryRepository); 13 | } 14 | 15 | @Override 16 | public void onApplicationEvent(final ContextRefreshedEvent event) { 17 | initializer.init(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /domain/src/main/java/io/github/mat3e/project/ProjectSnapshot.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | class ProjectSnapshot { 7 | private int id; 8 | private String name; 9 | private final Set steps = new HashSet<>(); 10 | 11 | public ProjectSnapshot() { 12 | } 13 | 14 | ProjectSnapshot(final int id, final String name, final Set steps) { 15 | this.id = id; 16 | this.name = name; 17 | this.steps.addAll(steps); 18 | } 19 | 20 | int getId() { 21 | return this.id; 22 | } 23 | 24 | String getName() { 25 | return this.name; 26 | } 27 | 28 | Set getSteps() { 29 | return this.steps; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | engineering.full-stack 6 | java-clean-architecture 7 | 0.0.1-SNAPSHOT 8 | java-clean-architecture 9 | Parent of Clean Architecture course example project. 10 | 11 | pom 12 | 13 | 14 | monolith 15 | domain 16 | app 17 | adapters 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/project/ProjectFactory.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | import io.github.mat3e.project.dto.ProjectDto; 4 | 5 | import java.util.stream.Collectors; 6 | 7 | class ProjectFactory { 8 | Project from(ProjectDto source) { 9 | return Project.restore(new ProjectSnapshot( 10 | source.getId(), 11 | source.getName(), 12 | source.getSteps().stream() 13 | .map(stepDto -> new ProjectStepSnapshot( 14 | stepDto.getId(), 15 | stepDto.getDescription(), 16 | stepDto.getDaysToProjectDeadline(), 17 | false, 18 | false 19 | ) 20 | ).collect(Collectors.toSet()) 21 | )); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/project/ProjectInitializer.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | import java.util.Set; 4 | 5 | class ProjectInitializer { 6 | private final ProjectRepository projectRepository; 7 | private final ProjectQueryRepository projectQueryRepository; 8 | 9 | ProjectInitializer(final ProjectRepository projectRepository, final ProjectQueryRepository projectQueryRepository) { 10 | this.projectRepository = projectRepository; 11 | this.projectQueryRepository = projectQueryRepository; 12 | } 13 | 14 | void init() { 15 | if (projectQueryRepository.count() == 0) { 16 | projectRepository.save(Project.restore(new ProjectSnapshot( 17 | 0, 18 | "ExampleProject", 19 | Set.of( 20 | new ProjectStepSnapshot(0, "First", -3), 21 | new ProjectStepSnapshot(0, "Second", -2), 22 | new ProjectStepSnapshot(0, "Third", 0) 23 | ) 24 | ))); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/project/dto/ProjectDto.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project.dto; 2 | 3 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 4 | 5 | import java.util.List; 6 | 7 | @JsonDeserialize(as = ProjectDto.DeserializationImpl.class) 8 | public interface ProjectDto { 9 | static ProjectDto create(final int id, final String name, final List steps) { 10 | return new DeserializationImpl(id, name, steps); 11 | } 12 | 13 | int getId(); 14 | 15 | String getName(); 16 | 17 | List getSteps(); 18 | 19 | class DeserializationImpl implements ProjectDto { 20 | private final int id; 21 | private final String name; 22 | private final List steps; 23 | 24 | DeserializationImpl(final int id, final String name, final List steps) { 25 | this.id = id; 26 | this.name = name; 27 | this.steps = steps; 28 | } 29 | 30 | @Override 31 | public int getId() { 32 | return id; 33 | } 34 | 35 | @Override 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | @Override 41 | public List getSteps() { 42 | return steps; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /domain/src/main/java/io/github/mat3e/project/ProjectStepSnapshot.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | class ProjectStepSnapshot { 4 | private int id; 5 | private String description; 6 | private int daysToProjectDeadline; 7 | private boolean hasCorrespondingTask; 8 | private boolean correspondingTaskDone; 9 | 10 | public ProjectStepSnapshot() { 11 | } 12 | 13 | ProjectStepSnapshot(final int id, final String description, final int daysToProjectDeadline) { 14 | this(id, description, daysToProjectDeadline, false, false); 15 | } 16 | 17 | ProjectStepSnapshot(final int id, final String description, final int daysToProjectDeadline, final boolean hasCorrespondingTask, final boolean correspondingTaskDone) { 18 | this.id = id; 19 | this.description = description; 20 | this.daysToProjectDeadline = daysToProjectDeadline; 21 | this.hasCorrespondingTask = hasCorrespondingTask; 22 | this.correspondingTaskDone = correspondingTaskDone; 23 | } 24 | 25 | int getId() { 26 | return this.id; 27 | } 28 | 29 | String getDescription() { 30 | return this.description; 31 | } 32 | 33 | int getDaysToProjectDeadline() { 34 | return this.daysToProjectDeadline; 35 | } 36 | 37 | boolean hasCorrespondingTask() { 38 | return hasCorrespondingTask; 39 | } 40 | 41 | boolean isCorrespondingTaskDone() { 42 | return correspondingTaskDone; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/project/dto/ProjectStepDto.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project.dto; 2 | 3 | import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 4 | 5 | import javax.validation.constraints.NotNull; 6 | 7 | @JsonDeserialize(as = ProjectStepDto.DeserializationImpl.class) 8 | public interface ProjectStepDto { 9 | static ProjectStepDto create(final int id, final String description, final int daysToProjectDeadline) { 10 | return new DeserializationImpl(id, description, daysToProjectDeadline); 11 | } 12 | 13 | int getId(); 14 | 15 | @NotNull String getDescription(); 16 | 17 | int getDaysToProjectDeadline(); 18 | 19 | class DeserializationImpl implements ProjectStepDto { 20 | private final int id; 21 | private final String description; 22 | private final int daysToProjectDeadline; 23 | 24 | DeserializationImpl(final int id, final String description, final int daysToProjectDeadline) { 25 | this.id = id; 26 | this.description = description; 27 | this.daysToProjectDeadline = daysToProjectDeadline; 28 | } 29 | 30 | @Override 31 | public int getId() { 32 | return id; 33 | } 34 | 35 | @Override 36 | public String getDescription() { 37 | return description; 38 | } 39 | 40 | @Override 41 | public int getDaysToProjectDeadline() { 42 | return daysToProjectDeadline; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /domain/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.6.RELEASE 9 | 10 | 11 | engineering.full-stack 12 | domain 13 | 0.0.1-SNAPSHOT 14 | domain 15 | Example project for a Clean Architecture course - domain. 16 | 17 | 18 | 11 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-test 29 | test 30 | 31 | 32 | org.junit.vintage 33 | junit-vintage-engine 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /domain/src/main/java/io/github/mat3e/task/TaskSnapshot.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task; 2 | 3 | import io.github.mat3e.task.vo.TaskSourceId; 4 | 5 | import java.time.ZonedDateTime; 6 | 7 | class TaskSnapshot { 8 | private int id; 9 | private String description; 10 | private boolean done; 11 | private ZonedDateTime deadline; 12 | private int changesCount; 13 | private String additionalComment; 14 | private TaskSourceId sourceId; 15 | 16 | protected TaskSnapshot() { 17 | } 18 | 19 | TaskSnapshot( 20 | final int id, String description, 21 | final boolean done, 22 | final ZonedDateTime deadline, 23 | final int changesCount, 24 | final String additionalComment, 25 | final TaskSourceId sourceId 26 | ) { 27 | this.id = id; 28 | this.description = description; 29 | this.done = done; 30 | this.deadline = deadline; 31 | this.changesCount = changesCount; 32 | this.additionalComment = additionalComment; 33 | this.sourceId = sourceId; 34 | } 35 | 36 | int getId() { 37 | return this.id; 38 | } 39 | 40 | String getDescription() { 41 | return this.description; 42 | } 43 | 44 | boolean getDone() { 45 | return this.done; 46 | } 47 | 48 | ZonedDateTime getDeadline() { 49 | return this.deadline; 50 | } 51 | 52 | int getChangesCount() { 53 | return this.changesCount; 54 | } 55 | 56 | String getAdditionalComment() { 57 | return this.additionalComment; 58 | } 59 | 60 | TaskSourceId getSourceId() { 61 | return sourceId; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/auth/AuthenticationController.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.auth; 2 | 3 | import org.springframework.http.ResponseEntity; 4 | import org.springframework.security.authentication.AuthenticationManager; 5 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 6 | import org.springframework.security.core.Authentication; 7 | import org.springframework.security.core.userdetails.UserDetails; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.RequestBody; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | @RestController 14 | @RequestMapping("/authenticate") 15 | class AuthenticationController { 16 | private final AuthenticationManager authenticationManager; 17 | private final TokenService tokenService; 18 | 19 | AuthenticationController(AuthenticationManager authenticationManager, TokenService tokenService) { 20 | this.authenticationManager = authenticationManager; 21 | this.tokenService = tokenService; 22 | } 23 | 24 | @PostMapping 25 | ResponseEntity createToken(@RequestBody AuthenticationRequestDto authRequest) { 26 | Authentication auth = authenticationManager.authenticate( 27 | new UsernamePasswordAuthenticationToken( 28 | authRequest.getUsername(), 29 | authRequest.getPassword() 30 | ) 31 | ); 32 | var user = (UserDetails) auth.getPrincipal(); 33 | return ResponseEntity.ok(new AuthenticationResponseDto(tokenService.generateNewToken(user))); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/task/SqlTaskRepository.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task; 2 | 3 | import org.springframework.data.repository.Repository; 4 | 5 | import java.util.List; 6 | import java.util.Optional; 7 | import java.util.stream.StreamSupport; 8 | 9 | import static java.util.stream.Collectors.toList; 10 | 11 | interface SqlTaskRepository extends Repository { 12 | Optional findById(Integer id); 13 | 14 | S save(S entity); 15 | 16 | List saveAll(Iterable entities); 17 | 18 | void deleteById(Integer id); 19 | } 20 | 21 | interface SqlTaskQueryRepository extends TaskQueryRepository, Repository { 22 | } 23 | 24 | @org.springframework.stereotype.Repository 25 | class TaskRepositoryImpl implements TaskRepository { 26 | private final SqlTaskRepository repository; 27 | 28 | TaskRepositoryImpl(final SqlTaskRepository repository) { 29 | this.repository = repository; 30 | } 31 | 32 | @Override 33 | public Optional findById(final Integer id) { 34 | return repository.findById(id).map(Task::restore); 35 | } 36 | 37 | @Override 38 | public Task save(final Task entity) { 39 | return Task.restore(repository.save(entity.getSnapshot())); 40 | } 41 | 42 | @Override 43 | public List saveAll(final Iterable entities) { 44 | return repository.saveAll( 45 | StreamSupport.stream(entities.spliterator(), false) 46 | .map(Task::getSnapshot) 47 | .collect(toList()) 48 | ).stream() 49 | .map(Task::restore) 50 | .collect(toList()); 51 | } 52 | 53 | @Override 54 | public void deleteById(final Integer id) { 55 | repository.deleteById(id); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.6.RELEASE 9 | 10 | 11 | engineering.full-stack 12 | app 13 | 0.0.1-SNAPSHOT 14 | app 15 | Example project for a Clean Architecture course - app. 16 | 17 | 18 | 11 19 | 20 | 21 | 22 | 23 | engineering.full-stack 24 | domain 25 | ${project.version} 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-validation 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-starter-web 35 | 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-test 40 | test 41 | 42 | 43 | org.junit.vintage 44 | junit-vintage-engine 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /domain/src/main/java/io/github/mat3e/task/vo/TaskEvent.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task.vo; 2 | 3 | import io.github.mat3e.DomainEvent; 4 | 5 | import java.time.Instant; 6 | import java.time.ZonedDateTime; 7 | import java.util.Optional; 8 | 9 | public class TaskEvent implements DomainEvent { 10 | public enum State { 11 | DONE, UNDONE, UPDATED, DELETED, CREATED 12 | } 13 | 14 | private final Instant occurredOn; 15 | private final TaskSourceId id; 16 | private final State state; 17 | private final Data data; 18 | 19 | public TaskEvent(final TaskSourceId id, final State state) { 20 | this(id, state, null); 21 | } 22 | 23 | public TaskEvent(final TaskSourceId id, final State state, final Data data) { 24 | this.id = id; 25 | this.state = state; 26 | this.data = data; 27 | this.occurredOn = Instant.now(); 28 | } 29 | 30 | @Override 31 | public Instant getOccurredOn() { 32 | return occurredOn; 33 | } 34 | 35 | public Optional getSourceId() { 36 | return Optional.ofNullable(id); 37 | } 38 | 39 | public State getState() { 40 | return state; 41 | } 42 | 43 | public Optional getData() { 44 | return Optional.ofNullable(data); 45 | } 46 | 47 | public static class Data { 48 | private final String description; 49 | private final ZonedDateTime deadline; 50 | private final String additionalComment; 51 | 52 | public Data(final String description, final ZonedDateTime deadline, final String additionalComment) { 53 | this.description = description; 54 | this.deadline = deadline; 55 | this.additionalComment = additionalComment; 56 | } 57 | 58 | public String getDescription() { 59 | return description; 60 | } 61 | 62 | public ZonedDateTime getDeadline() { 63 | return deadline; 64 | } 65 | 66 | public String getAdditionalComment() { 67 | return additionalComment; 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/auth/TokenService.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.auth; 2 | 3 | import io.jsonwebtoken.Claims; 4 | import io.jsonwebtoken.Jwts; 5 | import io.jsonwebtoken.SignatureAlgorithm; 6 | import io.jsonwebtoken.security.Keys; 7 | import org.springframework.security.core.userdetails.UserDetails; 8 | import org.springframework.stereotype.Service; 9 | 10 | import java.security.Key; 11 | import java.util.Date; 12 | import java.util.Map; 13 | 14 | @Service 15 | class TokenService { 16 | private final JwtConfigurationProperties properties; 17 | 18 | TokenService(JwtConfigurationProperties properties) { 19 | this.properties = properties; 20 | } 21 | 22 | String getUsernameFromToken(String token) { 23 | return getAllClaimsFromToken(token).getSubject(); 24 | } 25 | 26 | String generateNewToken(UserDetails userDetails) { 27 | Map claims = Map.of(); // e.g. roles 28 | return Jwts.builder() 29 | .setClaims(claims) 30 | .setSubject(userDetails.getUsername()) 31 | .setIssuedAt(new Date(System.currentTimeMillis())) 32 | .setExpiration(new Date(System.currentTimeMillis() + properties.getValidity() * 1000)) 33 | .signWith(key(), SignatureAlgorithm.HS512) 34 | .compact(); 35 | } 36 | 37 | boolean isValidForUser(String token, UserDetails userDetails) { 38 | String username = getUsernameFromToken(token); 39 | return !isTokenExpired(token) && username.equals(userDetails.getUsername()); 40 | } 41 | 42 | private Boolean isTokenExpired(String token) { 43 | return getAllClaimsFromToken(token) 44 | .getExpiration() 45 | .before(new Date()); 46 | } 47 | 48 | private Claims getAllClaimsFromToken(String token) { 49 | return Jwts.parserBuilder() 50 | .setSigningKey(key()) 51 | .build() 52 | .parseClaimsJws(token) 53 | .getBody(); 54 | } 55 | 56 | private Key key() { 57 | return Keys.hmacShaKeyFor(properties.getSecret().getBytes()); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/project/SqlProjectRepository.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | import org.springframework.data.jpa.repository.Query; 4 | import org.springframework.data.repository.Repository; 5 | import org.springframework.data.repository.query.Param; 6 | 7 | import java.util.Optional; 8 | 9 | interface SqlProjectRepository extends Repository { 10 | ProjectSnapshot save(ProjectSnapshot entity); 11 | 12 | Optional findById(Integer id); 13 | 14 | @Query( 15 | value = "select distinct * from projects p join project_steps s on p.id = s.project_id where s.id = :id", 16 | nativeQuery = true 17 | ) 18 | Optional findWithNestedStepId(@Param("id") Integer id); 19 | } 20 | 21 | interface SqlProjectQueryRepository extends ProjectQueryRepository, Repository { 22 | } 23 | 24 | interface SqlProjectStepRepository extends Repository { 25 | void deleteById(int id); 26 | } 27 | 28 | @org.springframework.stereotype.Repository 29 | class ProjectRepositoryImpl implements ProjectRepository { 30 | private final SqlProjectRepository repository; 31 | private final SqlProjectStepRepository stepRepository; 32 | 33 | ProjectRepositoryImpl(final SqlProjectRepository repository, final SqlProjectStepRepository stepRepository) { 34 | this.repository = repository; 35 | this.stepRepository = stepRepository; 36 | } 37 | 38 | @Override 39 | public Project save(final Project entity) { 40 | return Project.restore(repository.save(entity.getSnapshot())); 41 | } 42 | 43 | @Override 44 | public Optional findById(final Integer id) { 45 | return repository.findById(id).map(Project::restore); 46 | } 47 | 48 | @Override 49 | public Optional findByNestedStepId(final Integer id) { 50 | return repository.findWithNestedStepId(id).map(Project::restore); 51 | } 52 | 53 | @Override 54 | public void delete(final Project.Step entity) { 55 | stepRepository.deleteById(entity.getSnapshot().getId()); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /monolith/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.6.RELEASE 9 | 10 | 11 | engineering.full-stack 12 | monolith 13 | 0.0.1-SNAPSHOT 14 | monolith 15 | Spring app - example project for a Clean Architecture course. 16 | 17 | 18 | 11 19 | 20 | 21 | 22 | 23 | engineering.full-stack 24 | adapters 25 | ${project.version} 26 | 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter 31 | 32 | 33 | org.springframework.boot 34 | spring-boot-configuration-processor 35 | true 36 | 37 | 38 | 39 | org.springframework.boot 40 | spring-boot-starter-test 41 | test 42 | 43 | 44 | org.junit.vintage 45 | junit-vintage-engine 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | org.springframework.boot 55 | spring-boot-maven-plugin 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/task/TaskController.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task; 2 | 3 | import io.github.mat3e.task.dto.TaskDto; 4 | import io.github.mat3e.task.dto.TaskWithChangesQueryDto; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.web.bind.annotation.DeleteMapping; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PathVariable; 9 | import org.springframework.web.bind.annotation.PostMapping; 10 | import org.springframework.web.bind.annotation.PutMapping; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RestController; 14 | 15 | import java.net.URI; 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | @RestController 20 | @RequestMapping("/tasks") 21 | class TaskController { 22 | private final TaskFacade taskFacade; 23 | private final TaskQueryRepository taskQueryRepository; 24 | 25 | TaskController(final TaskFacade taskFacade, final TaskQueryRepository taskQueryRepository) { 26 | this.taskFacade = taskFacade; 27 | this.taskQueryRepository = taskQueryRepository; 28 | } 29 | 30 | @GetMapping 31 | List list() { 32 | return new ArrayList<>(taskQueryRepository.findBy(TaskDto.class)); 33 | } 34 | 35 | @GetMapping(params = "changes") 36 | List listWithChanges() { 37 | return new ArrayList<>(taskQueryRepository.findBy(TaskWithChangesQueryDto.class)); 38 | } 39 | 40 | @GetMapping("/{id}") 41 | ResponseEntity get(@PathVariable int id) { 42 | return taskQueryRepository.findDtoById(id) 43 | .map(ResponseEntity::ok) 44 | .orElse(ResponseEntity.notFound().build()); 45 | } 46 | 47 | @PutMapping("/{id}") 48 | ResponseEntity update(@PathVariable int id, @RequestBody TaskDto toUpdate) { 49 | if (id != toUpdate.getId() && toUpdate.getId() != 0) { 50 | throw new IllegalStateException("Id in URL is different than in body: " + id + " and " + toUpdate.getId()); 51 | } 52 | taskFacade.save(toUpdate.withId(id)); 53 | return ResponseEntity.noContent().build(); 54 | } 55 | 56 | @PostMapping 57 | ResponseEntity create(@RequestBody TaskDto toCreate) { 58 | TaskDto result = taskFacade.save(toCreate); 59 | return ResponseEntity.created(URI.create("/" + result.getId())).body(result); 60 | } 61 | 62 | @DeleteMapping("/{id}") 63 | ResponseEntity delete(@PathVariable int id) { 64 | taskFacade.delete(id); 65 | return ResponseEntity.noContent().build(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/auth/AuthenticationFilter.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.auth; 2 | 3 | import org.springframework.http.HttpHeaders; 4 | import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; 5 | import org.springframework.security.core.context.SecurityContextHolder; 6 | import org.springframework.security.core.userdetails.UserDetails; 7 | import org.springframework.security.core.userdetails.UserDetailsService; 8 | import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; 9 | import org.springframework.web.filter.OncePerRequestFilter; 10 | 11 | import javax.servlet.FilterChain; 12 | import javax.servlet.ServletException; 13 | import javax.servlet.http.HttpServletRequest; 14 | import javax.servlet.http.HttpServletResponse; 15 | import java.io.IOException; 16 | import java.util.Optional; 17 | 18 | class AuthenticationFilter extends OncePerRequestFilter { 19 | private static final String BEARER = "Bearer "; 20 | 21 | private final UserDetailsService userDetailsService; 22 | private final TokenService tokenService; 23 | 24 | AuthenticationFilter(UserDetailsService userDetailsService, TokenService tokenService) { 25 | this.userDetailsService = userDetailsService; 26 | this.tokenService = tokenService; 27 | } 28 | 29 | @Override 30 | protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { 31 | Optional.ofNullable( 32 | request.getHeader(HttpHeaders.AUTHORIZATION) 33 | ).filter(authHeader -> authHeader.startsWith(BEARER)) 34 | .map(authHeader -> authHeader.substring(BEARER.length())) 35 | .ifPresent(token -> { 36 | if (SecurityContextHolder.getContext().getAuthentication() != null) { 37 | return; 38 | } 39 | String username = tokenService.getUsernameFromToken(token); 40 | UserDetails userDetails = userDetailsService.loadUserByUsername(username); 41 | if (tokenService.isValidForUser(token, userDetails)) { 42 | var authentication = new UsernamePasswordAuthenticationToken( 43 | userDetails, 44 | null, 45 | userDetails.getAuthorities() 46 | ); 47 | authentication.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); 48 | SecurityContextHolder.getContext().setAuthentication(authentication); 49 | } 50 | }); 51 | filterChain.doFilter(request, response); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/task/TaskFacade.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task; 2 | 3 | import io.github.mat3e.DomainEventPublisher; 4 | import io.github.mat3e.task.dto.TaskDto; 5 | import io.github.mat3e.task.vo.TaskCreator; 6 | import io.github.mat3e.task.vo.TaskEvent; 7 | 8 | import java.util.Collection; 9 | import java.util.List; 10 | 11 | import static java.util.stream.Collectors.toList; 12 | 13 | public class TaskFacade { 14 | private final TaskFactory taskFactory; 15 | private final TaskRepository taskRepository; 16 | private final DomainEventPublisher publisher; 17 | 18 | TaskFacade(final TaskFactory taskFactory, final TaskRepository taskRepository, final DomainEventPublisher publisher) { 19 | this.taskFactory = taskFactory; 20 | this.taskRepository = taskRepository; 21 | this.publisher = publisher; 22 | } 23 | 24 | public List createTasks(Collection sources) { 25 | return taskRepository.saveAll(sources.stream() 26 | .map(Task::createFrom) 27 | .collect(toList()) 28 | ).stream().map(this::toDto) 29 | .collect(toList()); 30 | } 31 | 32 | TaskDto save(TaskDto toSave) { 33 | return toDto(taskRepository.save( 34 | taskRepository.findById(toSave.getId()).map(existingTask -> { 35 | if (existingTask.getSnapshot().getDone() != toSave.isDone()) { 36 | publisher.publish(existingTask.toggle()); 37 | } 38 | publisher.publish(existingTask.updateInfo( 39 | toSave.getDescription(), 40 | toSave.getDeadline(), 41 | toSave.getAdditionalComment() 42 | )); 43 | return existingTask; 44 | }).orElseGet(() -> taskFactory.from(toSave)) 45 | )); 46 | } 47 | 48 | void delete(int id) { 49 | taskRepository.findById(id) 50 | .ifPresent(task -> { 51 | taskRepository.deleteById(id); 52 | publisher.publish(new TaskEvent( 53 | task.getSnapshot().getSourceId(), 54 | TaskEvent.State.DELETED, 55 | null 56 | )); 57 | }); 58 | } 59 | 60 | private TaskDto toDto(Task task) { 61 | var snap = task.getSnapshot(); 62 | return TaskDto.builder() 63 | .withId(snap.getId()) 64 | .withDescription(snap.getDescription()) 65 | .withDone(snap.getDone()) 66 | .withDeadline(snap.getDeadline()) 67 | .withAdditionalComment(snap.getAdditionalComment()) 68 | .build(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /adapters/src/main/resources/META-INF/orm.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | XML Mapping file 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 |
37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /domain/src/main/java/io/github/mat3e/task/Task.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task; 2 | 3 | import io.github.mat3e.task.vo.TaskCreator; 4 | import io.github.mat3e.task.vo.TaskEvent; 5 | import io.github.mat3e.task.vo.TaskSourceId; 6 | 7 | import java.time.ZonedDateTime; 8 | 9 | class Task { 10 | static Task restore(TaskSnapshot snapshot) { 11 | return new Task( 12 | snapshot.getId(), 13 | snapshot.getDescription(), 14 | snapshot.getDone(), 15 | snapshot.getDeadline(), 16 | snapshot.getChangesCount(), 17 | snapshot.getAdditionalComment(), 18 | snapshot.getSourceId() 19 | ); 20 | } 21 | 22 | static Task createFrom(final TaskCreator source) { 23 | return new Task( 24 | 0, 25 | source.getDescription(), 26 | false, 27 | source.getDeadline(), 28 | 0, 29 | null, 30 | source.getId() 31 | ); 32 | } 33 | 34 | private int id; 35 | private String description; 36 | private boolean done; 37 | private ZonedDateTime deadline; 38 | private int changesCount; 39 | private String additionalComment; 40 | private TaskSourceId sourceId; 41 | 42 | private Task( 43 | final int id, 44 | final String description, 45 | final boolean done, 46 | final ZonedDateTime deadline, 47 | final int changesCount, 48 | final String additionalComment, 49 | final TaskSourceId sourceId 50 | ) { 51 | this.id = id; 52 | this.description = description; 53 | this.done = done; 54 | this.deadline = deadline; 55 | this.changesCount = changesCount; 56 | this.additionalComment = additionalComment; 57 | this.sourceId = sourceId; 58 | } 59 | 60 | TaskSnapshot getSnapshot() { 61 | return new TaskSnapshot( 62 | id, 63 | description, 64 | done, 65 | deadline, 66 | changesCount, 67 | additionalComment, 68 | sourceId 69 | ); 70 | } 71 | 72 | TaskEvent toggle() { 73 | done = !done; 74 | ++changesCount; 75 | return new TaskEvent(sourceId, done ? TaskEvent.State.DONE : TaskEvent.State.UNDONE, null); 76 | } 77 | 78 | TaskEvent updateInfo(String description, ZonedDateTime deadline, String additionalComment) { 79 | // rules, e.g. cannot be updated when done 80 | this.description = description; 81 | this.deadline = deadline; 82 | this.additionalComment = additionalComment; 83 | return new TaskEvent( 84 | sourceId, 85 | TaskEvent.State.UPDATED, 86 | new TaskEvent.Data(description, deadline, additionalComment) 87 | ); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/project/ProjectController.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | import io.github.mat3e.project.dto.ProjectDeadlineDto; 4 | import io.github.mat3e.project.dto.ProjectDto; 5 | import io.github.mat3e.task.dto.TaskDto; 6 | import org.springframework.http.ResponseEntity; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.PutMapping; 12 | import org.springframework.web.bind.annotation.RequestBody; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RestController; 15 | 16 | import java.net.URI; 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | @RestController 21 | @RequestMapping("/projects") 22 | class ProjectController { 23 | private final ProjectFacade projectFacade; 24 | private final ProjectQueryRepository projectQueryRepository; 25 | 26 | ProjectController(final ProjectFacade projectFacade, final ProjectQueryRepository projectQueryRepository) { 27 | this.projectFacade = projectFacade; 28 | this.projectQueryRepository = projectQueryRepository; 29 | } 30 | 31 | @GetMapping 32 | List list() { 33 | return new ArrayList<>(projectQueryRepository.findBy(ProjectDto.class)); 34 | } 35 | 36 | @GetMapping("/{id}") 37 | ResponseEntity get(@PathVariable int id) { 38 | return projectQueryRepository.findDtoById(id) 39 | .map(ResponseEntity::ok) 40 | .orElse(ResponseEntity.notFound().build()); 41 | } 42 | 43 | @PutMapping("/{id}") 44 | public ResponseEntity update(@PathVariable int id, @RequestBody ProjectDto toUpdate) { 45 | if (id != toUpdate.getId()) { 46 | throw new IllegalStateException("Id in URL is different than in body: " + id + " and " + (toUpdate.getId() == 0 ? "empty" : toUpdate.getId())); 47 | } 48 | projectFacade.save(toUpdate); 49 | return ResponseEntity.noContent().build(); 50 | } 51 | 52 | @PostMapping 53 | ResponseEntity create(@RequestBody ProjectDto toCreate) { 54 | ProjectDto result = projectFacade.save(toCreate); 55 | return ResponseEntity.created(URI.create("/" + result.getId())).body(result); 56 | } 57 | 58 | @PostMapping("/{id}/tasks") 59 | List createTasks(@PathVariable int id, @RequestBody ProjectDeadlineDto deadlineDto) { 60 | return projectFacade.createTasks(id, deadlineDto.getDeadline()); 61 | } 62 | 63 | @ExceptionHandler(IllegalStateException.class) 64 | ResponseEntity handleClientError(IllegalStateException e) { 65 | return ResponseEntity.badRequest().body(e.getMessage()); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /adapters/src/main/java/io/github/mat3e/auth/SecurityConfiguration.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.auth; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.security.authentication.AuthenticationManager; 6 | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; 7 | import org.springframework.security.config.annotation.web.builders.HttpSecurity; 8 | import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; 9 | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; 10 | import org.springframework.security.config.http.SessionCreationPolicy; 11 | import org.springframework.security.core.authority.SimpleGrantedAuthority; 12 | import org.springframework.security.core.userdetails.User; 13 | import org.springframework.security.core.userdetails.UserDetailsService; 14 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 15 | import org.springframework.security.crypto.password.PasswordEncoder; 16 | import org.springframework.security.provisioning.InMemoryUserDetailsManager; 17 | import org.springframework.security.web.authentication.AnonymousAuthenticationFilter; 18 | 19 | import java.util.Set; 20 | 21 | @EnableWebSecurity 22 | class SecurityConfiguration extends WebSecurityConfigurerAdapter { 23 | private final TokenService tokenService; 24 | 25 | SecurityConfiguration(TokenService tokenService) { 26 | this.tokenService = tokenService; 27 | } 28 | 29 | @Autowired 30 | void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { 31 | auth.userDetailsService(userDetailsService()) 32 | .passwordEncoder(passwordEncoder()); 33 | } 34 | 35 | @Override 36 | protected void configure(HttpSecurity http) throws Exception { 37 | http.csrf().disable() 38 | .authorizeRequests() 39 | .antMatchers("/authenticate") 40 | .permitAll() 41 | .anyRequest() 42 | .authenticated() 43 | .and() 44 | .addFilterBefore(new AuthenticationFilter(userDetailsService(), tokenService), AnonymousAuthenticationFilter.class) 45 | .sessionManagement() 46 | .sessionCreationPolicy(SessionCreationPolicy.STATELESS); 47 | } 48 | 49 | @Bean 50 | @Override 51 | protected UserDetailsService userDetailsService() { 52 | return new InMemoryUserDetailsManager( 53 | new User( 54 | "user", 55 | passwordEncoder().encode("user"), 56 | Set.of() 57 | ), 58 | new User( 59 | "admin", 60 | passwordEncoder().encode("admin"), 61 | Set.of(new SimpleGrantedAuthority("ADMIN")) 62 | ) 63 | ); 64 | } 65 | 66 | @Bean 67 | PasswordEncoder passwordEncoder() { 68 | return new BCryptPasswordEncoder(); 69 | } 70 | 71 | @Bean 72 | @Override 73 | public AuthenticationManager authenticationManagerBean() throws Exception { 74 | return super.authenticationManagerBean(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/task/dto/TaskDto.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.task.dto; 2 | 3 | import javax.validation.constraints.NotNull; 4 | import java.time.ZonedDateTime; 5 | import java.util.Objects; 6 | 7 | public class TaskDto { 8 | static public Builder builder() { 9 | return new Builder(); 10 | } 11 | 12 | private final int id; 13 | @NotNull 14 | private final String description; 15 | private final boolean done; 16 | private final ZonedDateTime deadline; 17 | private final String additionalComment; 18 | 19 | public TaskDto(final int id, final @NotNull String description, final boolean done, final ZonedDateTime deadline, final String additionalComment) { 20 | this.id = id; 21 | this.description = description; 22 | this.done = done; 23 | this.deadline = deadline; 24 | this.additionalComment = additionalComment; 25 | } 26 | 27 | public int getId() { 28 | return id; 29 | } 30 | 31 | public String getDescription() { 32 | return description; 33 | } 34 | 35 | public boolean isDone() { 36 | return done; 37 | } 38 | 39 | public ZonedDateTime getDeadline() { 40 | return deadline; 41 | } 42 | 43 | public String getAdditionalComment() { 44 | return additionalComment; 45 | } 46 | 47 | public TaskDto withId(final int id) { 48 | return new TaskDto(id, description, done, deadline, additionalComment); 49 | } 50 | 51 | public static class Builder { 52 | private int id; 53 | @NotNull 54 | private String description; 55 | private boolean done; 56 | private ZonedDateTime deadline; 57 | private String additionalComment; 58 | 59 | public Builder withId(int id) { 60 | this.id = id; 61 | return this; 62 | } 63 | 64 | public Builder withDescription(@NotNull String description) { 65 | this.description = description; 66 | return this; 67 | } 68 | 69 | public Builder withDone(boolean done) { 70 | this.done = done; 71 | return this; 72 | } 73 | 74 | public Builder withDeadline(ZonedDateTime deadline) { 75 | this.deadline = deadline; 76 | return this; 77 | } 78 | 79 | public Builder withAdditionalComment(String additionalComment) { 80 | this.additionalComment = additionalComment; 81 | return this; 82 | } 83 | 84 | public TaskDto build() { 85 | return new TaskDto(id, description, done, deadline, additionalComment); 86 | } 87 | } 88 | 89 | @Override 90 | public boolean equals(final Object o) { 91 | if (this == o) return true; 92 | if (!(o instanceof TaskDto)) return false; 93 | final TaskDto that = (TaskDto) o; 94 | return id == that.id && 95 | done == that.done && 96 | description.equals(that.description) && 97 | Objects.equals(deadline, that.deadline) && 98 | Objects.equals(additionalComment, that.additionalComment); 99 | } 100 | 101 | @Override 102 | public int hashCode() { 103 | return Objects.hash(id, description, done, deadline, additionalComment); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /adapters/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.6.RELEASE 9 | 10 | 11 | engineering.full-stack 12 | adapters 13 | 0.0.1-SNAPSHOT 14 | adapters 15 | Example project for a Clean Architecture course - adapters. 16 | 17 | 18 | 11 19 | 20 | 21 | 22 | 23 | engineering.full-stack 24 | app 25 | ${project.version} 26 | 27 | 28 | engineering.full-stack 29 | domain 30 | ${project.version} 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-data-jpa 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-validation 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-security 44 | 45 | 46 | org.springframework.boot 47 | spring-boot-starter-web 48 | 49 | 50 | org.springframework.boot 51 | spring-boot-configuration-processor 52 | true 53 | 54 | 55 | io.jsonwebtoken 56 | jjwt-api 57 | 0.11.1 58 | 59 | 60 | io.jsonwebtoken 61 | jjwt-impl 62 | 0.11.1 63 | runtime 64 | 65 | 66 | io.jsonwebtoken 67 | jjwt-jackson 68 | 0.11.1 69 | runtime 70 | 71 | 72 | 73 | com.h2database 74 | h2 75 | runtime 76 | 77 | 78 | org.springframework.boot 79 | spring-boot-starter-test 80 | test 81 | 82 | 83 | org.junit.vintage 84 | junit-vintage-engine 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /app/src/main/java/io/github/mat3e/project/ProjectFacade.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | import io.github.mat3e.project.dto.ProjectDto; 4 | import io.github.mat3e.project.dto.ProjectStepDto; 5 | import io.github.mat3e.task.TaskFacade; 6 | import io.github.mat3e.task.dto.TaskDto; 7 | import io.github.mat3e.task.vo.TaskCreator; 8 | import io.github.mat3e.task.vo.TaskEvent; 9 | import io.github.mat3e.task.vo.TaskSourceId; 10 | 11 | import java.time.ZonedDateTime; 12 | import java.util.List; 13 | import java.util.Set; 14 | 15 | import static java.util.stream.Collectors.toList; 16 | 17 | public class ProjectFacade { 18 | private final ProjectFactory projectFactory; 19 | private final ProjectRepository projectRepository; 20 | private final TaskFacade taskFacade; 21 | 22 | ProjectFacade(final ProjectFactory projectFactory, final ProjectRepository projectRepository, final TaskFacade taskFacade) { 23 | this.projectFactory = projectFactory; 24 | this.projectRepository = projectRepository; 25 | this.taskFacade = taskFacade; 26 | } 27 | 28 | public void handle(TaskEvent event) { 29 | event.getSourceId() 30 | .map(TaskSourceId::getId) 31 | .map(Integer::parseInt) 32 | .ifPresent(stepId -> { 33 | switch (event.getState()) { 34 | case DONE: 35 | case DELETED: 36 | updateStep(stepId, true); 37 | break; 38 | case UNDONE: 39 | updateStep(stepId, false); 40 | break; 41 | case UPDATED: 42 | default: 43 | break; 44 | } 45 | } 46 | ); 47 | } 48 | 49 | void updateStep(int stepId, boolean done) { 50 | projectRepository.findByNestedStepId(stepId) 51 | .ifPresent(project -> { 52 | project.updateStep(stepId, done); 53 | projectRepository.save(project); 54 | }); 55 | } 56 | 57 | public ProjectDto save(ProjectDto dtoToSave) { 58 | if (dtoToSave.getId() != 0) { 59 | return toDto(saveWithId(dtoToSave)); 60 | } 61 | if (dtoToSave.getSteps().stream().anyMatch(step -> step.getId() != 0)) { 62 | throw new IllegalStateException("Cannot add project with existing steps"); 63 | } 64 | return toDto(projectRepository.save(projectFactory.from(dtoToSave))); 65 | } 66 | 67 | private Project saveWithId(ProjectDto dtoToSave) { 68 | return projectRepository.findById(dtoToSave.getId()).map(existingProject -> { 69 | Project toSave = projectFactory.from(dtoToSave); 70 | Set removedSteps = existingProject.modifySteps(toSave.getSnapshot().getSteps()); 71 | projectRepository.save(existingProject); 72 | removedSteps.forEach(projectRepository::delete); 73 | return existingProject; 74 | }).orElseGet(() -> projectRepository.save(projectFactory.from(dtoToSave))); 75 | } 76 | 77 | List createTasks(int projectId, ZonedDateTime projectDeadline) { 78 | return projectRepository.findById(projectId).map(project -> { 79 | Set taskSources = project.convertToTasks(projectDeadline); 80 | projectRepository.save(project); 81 | return taskFacade.createTasks(taskSources); 82 | }).orElseThrow(() -> new IllegalArgumentException("No project found with id: " + projectId)); 83 | } 84 | 85 | private ProjectDto toDto(Project project) { 86 | var snap = project.getSnapshot(); 87 | return ProjectDto.create(snap.getId(), snap.getName(), snap.getSteps().stream().map(this::toDto).collect(toList())); 88 | } 89 | 90 | private ProjectStepDto toDto(ProjectStepSnapshot step) { 91 | return ProjectStepDto.create(step.getId(), step.getDescription(), step.getDaysToProjectDeadline()); 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /domain/src/main/java/io/github/mat3e/project/Project.java: -------------------------------------------------------------------------------- 1 | package io.github.mat3e.project; 2 | 3 | import io.github.mat3e.task.vo.TaskCreator; 4 | import io.github.mat3e.task.vo.TaskSourceId; 5 | 6 | import java.time.ZonedDateTime; 7 | import java.util.HashSet; 8 | import java.util.Set; 9 | 10 | import static java.util.stream.Collectors.toSet; 11 | 12 | class Project { 13 | static Project restore(ProjectSnapshot snapshot) { 14 | return new Project(snapshot.getId(), snapshot.getName(), snapshot.getSteps()); 15 | } 16 | 17 | private final int id; 18 | private final String name; 19 | private final Set steps = new HashSet<>(); 20 | 21 | private Project(final int id, final String name, final Set steps) { 22 | this.id = id; 23 | this.name = name; 24 | modifySteps(steps); 25 | } 26 | 27 | ProjectSnapshot getSnapshot() { 28 | return new ProjectSnapshot(id, name, steps.stream().map(Step::getSnapshot).collect(toSet())); 29 | } 30 | 31 | Set convertToTasks(final ZonedDateTime projectDeadline) { 32 | if (steps.stream().anyMatch(step -> step.hasCorrespondingTask && !step.correspondingTaskDone)) { 33 | throw new IllegalStateException("There are still some undone tasks from a previous project instance!"); 34 | } 35 | Set result = steps.stream() 36 | .map(step -> new TaskCreator( 37 | new TaskSourceId(String.valueOf(step.id)), 38 | step.description, 39 | projectDeadline.plusDays(step.daysToProjectDeadline) 40 | ) 41 | ).collect(toSet()); 42 | // FIXME: we are not sure here if task was REALLY created; there should be a dedicated event for that 43 | steps.forEach(step -> { 44 | step.hasCorrespondingTask = true; 45 | step.correspondingTaskDone = false; 46 | }); 47 | return result; 48 | } 49 | 50 | void updateStep(final int stepId, final boolean taskDone) { 51 | steps.stream() 52 | .filter(step -> step.id == stepId) 53 | .forEach(step -> step.correspondingTaskDone = taskDone); 54 | } 55 | 56 | Set modifySteps(final Set stepSnapshots) { 57 | Set stepsToRemove = new HashSet<>(); 58 | steps.forEach(existingStep -> stepSnapshots.stream() 59 | .filter(potentialOverride -> existingStep.id == potentialOverride.getId()) 60 | .findFirst() 61 | .ifPresentOrElse( 62 | overridingStep -> { 63 | existingStep.description = overridingStep.getDescription(); 64 | existingStep.daysToProjectDeadline = overridingStep.getDaysToProjectDeadline(); 65 | }, 66 | () -> stepsToRemove.add(existingStep) 67 | ) 68 | ); 69 | stepsToRemove.forEach(this::removeStep); 70 | stepSnapshots.stream() 71 | .filter(newStep -> steps.stream() 72 | .noneMatch(existingStep -> existingStep.id == newStep.getId()) 73 | ).map(Step::restore) 74 | .collect(toSet()) 75 | // collecting first to allow multiple id=0 76 | .forEach(this::addStep); 77 | // can be converted to internal domain event, e.g. removed ids 78 | return stepsToRemove; 79 | } 80 | 81 | private void addStep(Step step) { 82 | steps.add(step); 83 | } 84 | 85 | private void removeStep(Step step) { 86 | steps.remove(step); 87 | } 88 | 89 | static class Step { 90 | static Step restore(ProjectStepSnapshot snapshot) { 91 | return new Step( 92 | snapshot.getId(), 93 | snapshot.getDescription(), 94 | snapshot.getDaysToProjectDeadline(), 95 | snapshot.hasCorrespondingTask(), 96 | snapshot.isCorrespondingTaskDone() 97 | ); 98 | } 99 | 100 | private int id; 101 | private String description; 102 | private int daysToProjectDeadline; 103 | private boolean hasCorrespondingTask; 104 | private boolean correspondingTaskDone; 105 | 106 | private Step(final int id, final String description, final int daysToProjectDeadline, final boolean hasCorrespondingTask, final boolean correspondingTaskDone) { 107 | this.id = id; 108 | this.description = description; 109 | this.daysToProjectDeadline = daysToProjectDeadline; 110 | this.hasCorrespondingTask = hasCorrespondingTask; 111 | this.correspondingTaskDone = correspondingTaskDone; 112 | } 113 | 114 | ProjectStepSnapshot getSnapshot() { 115 | return new ProjectStepSnapshot(id, description, daysToProjectDeadline, hasCorrespondingTask, correspondingTaskDone); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /monolith/src/main/resources/Clean Architecture.postman_collection.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": { 3 | "_postman_id": "4164838d-429b-4b8b-88f8-1ddd62656b7e", 4 | "name": "Clean Architecture", 5 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" 6 | }, 7 | "item": [ 8 | { 9 | "name": "authenticate", 10 | "event": [ 11 | { 12 | "listen": "test", 13 | "script": { 14 | "id": "15d048c9-d8e6-4374-b3ec-df0f0dc44cf0", 15 | "exec": [ 16 | "pm.globals.set(\"jwt\", pm.response.json().token);" 17 | ], 18 | "type": "text/javascript" 19 | } 20 | } 21 | ], 22 | "request": { 23 | "method": "POST", 24 | "header": [], 25 | "body": { 26 | "mode": "raw", 27 | "raw": "{\n\t\"username\": \"user\",\n\t\"password\": \"user\"\n}", 28 | "options": { 29 | "raw": { 30 | "language": "json" 31 | } 32 | } 33 | }, 34 | "url": { 35 | "raw": "http://localhost:8080/authenticate", 36 | "protocol": "http", 37 | "host": [ 38 | "localhost" 39 | ], 40 | "port": "8080", 41 | "path": [ 42 | "authenticate" 43 | ] 44 | } 45 | }, 46 | "response": [] 47 | }, 48 | { 49 | "name": "get projects", 50 | "request": { 51 | "auth": { 52 | "type": "bearer", 53 | "bearer": [ 54 | { 55 | "key": "token", 56 | "value": "{{jwt}}", 57 | "type": "string" 58 | } 59 | ] 60 | }, 61 | "method": "GET", 62 | "header": [], 63 | "url": { 64 | "raw": "http://localhost:8080/projects", 65 | "protocol": "http", 66 | "host": [ 67 | "localhost" 68 | ], 69 | "port": "8080", 70 | "path": [ 71 | "projects" 72 | ] 73 | } 74 | }, 75 | "response": [] 76 | }, 77 | { 78 | "name": "get project with id", 79 | "request": { 80 | "auth": { 81 | "type": "bearer", 82 | "bearer": [ 83 | { 84 | "key": "token", 85 | "value": "{{jwt}}", 86 | "type": "string" 87 | } 88 | ] 89 | }, 90 | "method": "GET", 91 | "header": [], 92 | "url": { 93 | "raw": "http://localhost:8080/projects/1", 94 | "protocol": "http", 95 | "host": [ 96 | "localhost" 97 | ], 98 | "port": "8080", 99 | "path": [ 100 | "projects", 101 | "1" 102 | ] 103 | } 104 | }, 105 | "response": [] 106 | }, 107 | { 108 | "name": "put project with steps with id", 109 | "request": { 110 | "auth": { 111 | "type": "bearer", 112 | "bearer": [ 113 | { 114 | "key": "token", 115 | "value": "{{jwt}}", 116 | "type": "string" 117 | } 118 | ] 119 | }, 120 | "method": "PUT", 121 | "header": [], 122 | "body": { 123 | "mode": "raw", 124 | "raw": "{\n \"id\": 1,\n \"name\": \"Example project\",\n \"steps\": [\n {\n \"id\": 1,\n \"description\": \"First\",\n \"daysToProjectDeadline\": -4\n },\n {\n \"id\": 2,\n \"description\": \"Second\",\n \"daysToProjectDeadline\": -2\n },\n {\n \"id\": 3,\n \"description\": \"Third\",\n \"daysToProjectDeadline\": 0\n }\n ]\n}", 125 | "options": { 126 | "raw": { 127 | "language": "json" 128 | } 129 | } 130 | }, 131 | "url": { 132 | "raw": "http://localhost:8080/projects/1", 133 | "protocol": "http", 134 | "host": [ 135 | "localhost" 136 | ], 137 | "port": "8080", 138 | "path": [ 139 | "projects", 140 | "1" 141 | ] 142 | } 143 | }, 144 | "response": [] 145 | }, 146 | { 147 | "name": "put project with less steps", 148 | "request": { 149 | "auth": { 150 | "type": "bearer", 151 | "bearer": [ 152 | { 153 | "key": "token", 154 | "value": "{{jwt}}", 155 | "type": "string" 156 | } 157 | ] 158 | }, 159 | "method": "PUT", 160 | "header": [], 161 | "body": { 162 | "mode": "raw", 163 | "raw": "{\n \"id\": 1,\n \"name\": \"Example project\",\n \"steps\": [\n {\n \"id\": 1,\n \"description\": \"First\",\n \"daysToProjectDeadline\": -4\n },\n {\n \"id\": 2,\n \"description\": \"Second\",\n \"daysToProjectDeadline\": -2\n }\n ]\n}", 164 | "options": { 165 | "raw": { 166 | "language": "json" 167 | } 168 | } 169 | }, 170 | "url": { 171 | "raw": "http://localhost:8080/projects/1", 172 | "protocol": "http", 173 | "host": [ 174 | "localhost" 175 | ], 176 | "port": "8080", 177 | "path": [ 178 | "projects", 179 | "1" 180 | ] 181 | } 182 | }, 183 | "response": [] 184 | }, 185 | { 186 | "name": "put project with more steps", 187 | "request": { 188 | "auth": { 189 | "type": "bearer", 190 | "bearer": [ 191 | { 192 | "key": "token", 193 | "value": "{{jwt}}", 194 | "type": "string" 195 | } 196 | ] 197 | }, 198 | "method": "PUT", 199 | "header": [], 200 | "body": { 201 | "mode": "raw", 202 | "raw": "{\n \"id\": 1,\n \"name\": \"Example project\",\n \"steps\": [\n {\n \"id\": 1,\n \"description\": \"First\",\n \"daysToProjectDeadline\": -4\n },\n {\n \"id\": 2,\n \"description\": \"Second\",\n \"daysToProjectDeadline\": -2\n },\n {\n \t\"description\": \"Another\",\n \t\"daysToProjectDeadline\": 0\n }\n ]\n}", 203 | "options": { 204 | "raw": { 205 | "language": "json" 206 | } 207 | } 208 | }, 209 | "url": { 210 | "raw": "http://localhost:8080/projects/1", 211 | "protocol": "http", 212 | "host": [ 213 | "localhost" 214 | ], 215 | "port": "8080", 216 | "path": [ 217 | "projects", 218 | "1" 219 | ] 220 | }, 221 | "description": "no id" 222 | }, 223 | "response": [] 224 | }, 225 | { 226 | "name": "put project with new id", 227 | "request": { 228 | "auth": { 229 | "type": "bearer", 230 | "bearer": [ 231 | { 232 | "key": "token", 233 | "value": "{{jwt}}", 234 | "type": "string" 235 | } 236 | ] 237 | }, 238 | "method": "PUT", 239 | "header": [], 240 | "body": { 241 | "mode": "raw", 242 | "raw": "{\n\t\"id\": 5,\n \"name\": \"Example project\",\n \"steps\": [\n {\n \"description\": \"First\",\n \"daysToProjectDeadline\": -4\n },\n {\n \"description\": \"Second\",\n \"daysToProjectDeadline\": -2\n },\n {\n \"description\": \"Third\",\n \"daysToProjectDeadline\": 0\n }\n ]\n}", 243 | "options": { 244 | "raw": { 245 | "language": "json" 246 | } 247 | } 248 | }, 249 | "url": { 250 | "raw": "http://localhost:8080/projects/5", 251 | "protocol": "http", 252 | "host": [ 253 | "localhost" 254 | ], 255 | "port": "8080", 256 | "path": [ 257 | "projects", 258 | "5" 259 | ] 260 | } 261 | }, 262 | "response": [] 263 | }, 264 | { 265 | "name": "put project", 266 | "request": { 267 | "auth": { 268 | "type": "bearer", 269 | "bearer": [ 270 | { 271 | "key": "token", 272 | "value": "{{jwt}}", 273 | "type": "string" 274 | } 275 | ] 276 | }, 277 | "method": "PUT", 278 | "header": [], 279 | "body": { 280 | "mode": "raw", 281 | "raw": "{\n \"id\": 5,\n \"name\": \"Example project 2\",\n \"steps\": [\n {\n \"id\": 9,\n \"description\": \"First\",\n \"daysToProjectDeadline\": -4\n },\n {\n \"id\": 10,\n \"description\": \"Second\",\n \"daysToProjectDeadline\": 0\n }\n ]\n}", 282 | "options": { 283 | "raw": { 284 | "language": "json" 285 | } 286 | } 287 | }, 288 | "url": { 289 | "raw": "http://localhost:8080/projects/5", 290 | "protocol": "http", 291 | "host": [ 292 | "localhost" 293 | ], 294 | "port": "8080", 295 | "path": [ 296 | "projects", 297 | "5" 298 | ] 299 | }, 300 | "description": "many modifications" 301 | }, 302 | "response": [] 303 | }, 304 | { 305 | "name": "post project", 306 | "request": { 307 | "auth": { 308 | "type": "bearer", 309 | "bearer": [ 310 | { 311 | "key": "token", 312 | "value": "{{jwt}}", 313 | "type": "string" 314 | } 315 | ] 316 | }, 317 | "method": "POST", 318 | "header": [], 319 | "body": { 320 | "mode": "raw", 321 | "raw": "{\n \"name\": \"Example project 3\",\n \"steps\": [\n {\n \"description\": \"First\",\n \"daysToProjectDeadline\": -2\n },\n {\n \"description\": \"Second\",\n \"daysToProjectDeadline\": 0\n }\n ]\n}", 322 | "options": { 323 | "raw": { 324 | "language": "json" 325 | } 326 | } 327 | }, 328 | "url": { 329 | "raw": "http://localhost:8080/projects", 330 | "protocol": "http", 331 | "host": [ 332 | "localhost" 333 | ], 334 | "port": "8080", 335 | "path": [ 336 | "projects" 337 | ] 338 | } 339 | }, 340 | "response": [] 341 | }, 342 | { 343 | "name": "post project with steps with id", 344 | "request": { 345 | "auth": { 346 | "type": "bearer", 347 | "bearer": [ 348 | { 349 | "key": "token", 350 | "value": "{{jwt}}", 351 | "type": "string" 352 | } 353 | ] 354 | }, 355 | "method": "POST", 356 | "header": [], 357 | "body": { 358 | "mode": "raw", 359 | "raw": "{\n \"name\": \"Example project 3\",\n \"steps\": [\n {\n \"id\": 9,\n \"description\": \"First\",\n \"daysToProjectDeadline\": -4\n },\n {\n \"id\": 10,\n \"description\": \"Second\",\n \"daysToProjectDeadline\": 0\n }\n ]\n}", 360 | "options": { 361 | "raw": { 362 | "language": "json" 363 | } 364 | } 365 | }, 366 | "url": { 367 | "raw": "http://localhost:8080/projects", 368 | "protocol": "http", 369 | "host": [ 370 | "localhost" 371 | ], 372 | "port": "8080", 373 | "path": [ 374 | "projects" 375 | ] 376 | } 377 | }, 378 | "response": [] 379 | }, 380 | { 381 | "name": "post project tasks", 382 | "request": { 383 | "auth": { 384 | "type": "bearer", 385 | "bearer": [ 386 | { 387 | "key": "token", 388 | "value": "{{jwt}}", 389 | "type": "string" 390 | } 391 | ] 392 | }, 393 | "method": "POST", 394 | "header": [], 395 | "body": { 396 | "mode": "raw", 397 | "raw": "{\n \"deadline\": \"2022-03-04T23:59:59.999+02:00[Europe/Warsaw]\"\n}", 398 | "options": { 399 | "raw": { 400 | "language": "json" 401 | } 402 | } 403 | }, 404 | "url": { 405 | "raw": "http://localhost:8080/projects/5/tasks", 406 | "protocol": "http", 407 | "host": [ 408 | "localhost" 409 | ], 410 | "port": "8080", 411 | "path": [ 412 | "projects", 413 | "5", 414 | "tasks" 415 | ] 416 | } 417 | }, 418 | "response": [] 419 | }, 420 | { 421 | "name": "get tasks", 422 | "request": { 423 | "auth": { 424 | "type": "bearer", 425 | "bearer": [ 426 | { 427 | "key": "token", 428 | "value": "{{jwt}}", 429 | "type": "string" 430 | } 431 | ] 432 | }, 433 | "method": "GET", 434 | "header": [], 435 | "url": { 436 | "raw": "http://localhost:8080/tasks", 437 | "protocol": "http", 438 | "host": [ 439 | "localhost" 440 | ], 441 | "port": "8080", 442 | "path": [ 443 | "tasks" 444 | ] 445 | } 446 | }, 447 | "response": [] 448 | }, 449 | { 450 | "name": "get tasks with changes", 451 | "request": { 452 | "auth": { 453 | "type": "bearer", 454 | "bearer": [ 455 | { 456 | "key": "token", 457 | "value": "{{jwt}}", 458 | "type": "string" 459 | } 460 | ] 461 | }, 462 | "method": "GET", 463 | "header": [], 464 | "url": { 465 | "raw": "http://localhost:8080/tasks?changes", 466 | "protocol": "http", 467 | "host": [ 468 | "localhost" 469 | ], 470 | "port": "8080", 471 | "path": [ 472 | "tasks" 473 | ], 474 | "query": [ 475 | { 476 | "key": "changes", 477 | "value": null 478 | } 479 | ] 480 | } 481 | }, 482 | "response": [] 483 | }, 484 | { 485 | "name": "get task with id", 486 | "request": { 487 | "auth": { 488 | "type": "bearer", 489 | "bearer": [ 490 | { 491 | "key": "token", 492 | "value": "{{jwt}}", 493 | "type": "string" 494 | } 495 | ] 496 | }, 497 | "method": "GET", 498 | "header": [], 499 | "url": { 500 | "raw": "http://localhost:8080/tasks/2", 501 | "protocol": "http", 502 | "host": [ 503 | "localhost" 504 | ], 505 | "port": "8080", 506 | "path": [ 507 | "tasks", 508 | "2" 509 | ] 510 | } 511 | }, 512 | "response": [] 513 | }, 514 | { 515 | "name": "put task", 516 | "request": { 517 | "auth": { 518 | "type": "bearer", 519 | "bearer": [ 520 | { 521 | "key": "token", 522 | "value": "{{jwt}}", 523 | "type": "string" 524 | } 525 | ] 526 | }, 527 | "method": "PUT", 528 | "header": [], 529 | "body": { 530 | "mode": "raw", 531 | "raw": "{\n \"id\": 2,\n \"description\": \"Second\",\n \"done\": true,\n \"deadline\": \"2022-03-04T22:59:59.999+01:00\",\n \"additionalComment\": null\n}", 532 | "options": { 533 | "raw": { 534 | "language": "json" 535 | } 536 | } 537 | }, 538 | "url": { 539 | "raw": "http://localhost:8080/tasks/2", 540 | "protocol": "http", 541 | "host": [ 542 | "localhost" 543 | ], 544 | "port": "8080", 545 | "path": [ 546 | "tasks", 547 | "2" 548 | ] 549 | } 550 | }, 551 | "response": [] 552 | }, 553 | { 554 | "name": "put task with new id", 555 | "request": { 556 | "auth": { 557 | "type": "bearer", 558 | "bearer": [ 559 | { 560 | "key": "token", 561 | "value": "{{jwt}}", 562 | "type": "string" 563 | } 564 | ] 565 | }, 566 | "method": "PUT", 567 | "header": [], 568 | "body": { 569 | "mode": "raw", 570 | "raw": "{\n \"id\": 10,\n \"description\": \"Second\",\n \"done\": true,\n \"deadline\": \"2022-03-04T22:59:59.999+01:00\",\n \"additionalComment\": null\n}", 571 | "options": { 572 | "raw": { 573 | "language": "json" 574 | } 575 | } 576 | }, 577 | "url": { 578 | "raw": "http://localhost:8080/tasks/10", 579 | "protocol": "http", 580 | "host": [ 581 | "localhost" 582 | ], 583 | "port": "8080", 584 | "path": [ 585 | "tasks", 586 | "10" 587 | ] 588 | } 589 | }, 590 | "response": [] 591 | }, 592 | { 593 | "name": "post task", 594 | "request": { 595 | "auth": { 596 | "type": "bearer", 597 | "bearer": [ 598 | { 599 | "key": "token", 600 | "value": "{{jwt}}", 601 | "type": "string" 602 | } 603 | ] 604 | }, 605 | "method": "POST", 606 | "header": [], 607 | "body": { 608 | "mode": "raw", 609 | "raw": "{\n \"description\": \"Second\",\n \"done\": true,\n \"deadline\": \"2022-03-04T22:59:59.999+01:00\",\n \"additionalComment\": null\n}", 610 | "options": { 611 | "raw": { 612 | "language": "json" 613 | } 614 | } 615 | }, 616 | "url": { 617 | "raw": "http://localhost:8080/tasks", 618 | "protocol": "http", 619 | "host": [ 620 | "localhost" 621 | ], 622 | "port": "8080", 623 | "path": [ 624 | "tasks" 625 | ] 626 | } 627 | }, 628 | "response": [] 629 | }, 630 | { 631 | "name": "delete task", 632 | "request": { 633 | "auth": { 634 | "type": "bearer", 635 | "bearer": [ 636 | { 637 | "key": "token", 638 | "value": "{{jwt}}", 639 | "type": "string" 640 | } 641 | ] 642 | }, 643 | "method": "DELETE", 644 | "header": [], 645 | "url": { 646 | "raw": "http://localhost:8080/tasks/5", 647 | "protocol": "http", 648 | "host": [ 649 | "localhost" 650 | ], 651 | "port": "8080", 652 | "path": [ 653 | "tasks", 654 | "5" 655 | ] 656 | } 657 | }, 658 | "response": [] 659 | } 660 | ], 661 | "protocolProfileBehavior": {} 662 | } --------------------------------------------------------------------------------