Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
MVN_IMAGE = "debian"
MVN_VERSION="stable-slim"
PROJECT_DIR=/home/jira

APP_OUT_PORT=8080
APP_HOST_URL="http://app"

MAIL_USER="jira4jr@gmail.com"
MAIL_PASSWORD="zdfzsrqvgimldzyj"
MAIL_HOST="smtp.gmail.com"
MAIL_PORT=587

DB_NAME="jira"
DB_USER="jira"
DB_PASSWORD="JiraRush"
DB_IMAGE="postgres"
DB_IMAGE_VERSION="latest"
DB_OUT_PORT=5432
DB_VOLUME_PATH="./data"
DB_SOURCE_URL="jdbc:postgresql://db"

NGINX_OUT_PORT=80
NGINX_IMAGE="nginx"
NGINX_IMAGE_VERSION="latest"
NGINX_CONFIG_PATH="./config/nginx.conf"
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG APP_IMAGE
FROM ${APP_IMAGE}

ARG PROJECT_DIR
RUN apt update -y \
&& apt install openjdk-17-jdk -y \
&& apt install maven -y \
&& mkdir ${PROJECT_DIR} ${PROJECT_DIR}/resources ${PROJECT_DIR}/src

ENV PROJECT_DIR=${PROJECT_DIR}
WORKDIR ${PROJECT_DIR}

COPY resources/ ./resources/
COPY src/ ./src/
COPY ./config/app-start.sh ./pom.xml ./
RUN mvn clean install -Pprod && rm -rf ./src ~/.m2

ARG APP_OUT_PORT
EXPOSE ${APP_OUT_PORT}

ENTRYPOINT ["./app-start.sh"]
41 changes: 40 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,43 @@
- https://habr.com/ru/articles/259055/

Список выполненных задач:
...
...
1. Удалить социальные сети: vk, yandex.
Удалено два класса в пакете src/main/java/com/javarush/jira/login/internal/sociallogin.
Удалены ссылка в ресурсных файлах html login и rgister.
Удалены записи в файлах data.sql и changelog.xml
Удалены регистрационные данные для полключения к сетям vk и yandex в файле application.yaml

2. Вынести чувствительную информацию в отдельный проперти файл

3. Добавлена локализация начальной страницы на русском и английском языках

4. Добавлена реализация посчета времени сколько задача находилась в статусах в
работе и тестирование.
добавлена функция REST API для вывода данной информации в секундах.
example: api/tasks/duration/{task_id}&{durationType}
(durationType=in_work || durationType=in_test)

5. Выполнен рефакторин метода
com.javarush.jira.bugtracking.attachment.FileUtil#upload в соотвествии с заданием.

6. Переделаны тесты для использования H2DB, исправлены сценарии sql в
соотвествии с особенностями работы H2DB.
Добавлены профили maven postgres и h2dbtest.

7. Добавлена возможность запуска в докер контейнерах:
- для запуска приложения: необходимо выполнить start-app-dc.sh
- создаются 3 контейнера nginx, db и app
- контейнеры nginx и app имеют доступ к внешней сети, а db - только к внутренней сети контейнеров
- Не решенная задача:
- не получилось заставить nginx нормально работать в режиме обратного прокси,
из-за этого к контейнеру аpp сделана возможность непосредственного доступа из внешней сети по порту 8080

8. Добавленs функции по работе с тэгами в задаче. Изменены классы TaskController, TaskService, TaskRepository

9. Добавлены функции по работе с задачами в задаче. Изменены классы TaskController, TaskService, TaskRepository
Функции добавления/изменения/удаления, а так же выбора тэгов по задаче. в TaskRepository добавлены методы
выборки всех задач по списку тэгов, выборки задач проекта по списку тегов. В выборку данных по Ид задачи
добавлена выборка ее тэгов.

10. Добавлены тесты для ProfileRestController
2 changes: 1 addition & 1 deletion config/_application-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ app:
host-url: http://localhost
spring:
datasource:
url: jdbc:postgresql://localhost:5432/jira
url: jdbc:postgresql://192.168.253.101:5432/jira
username: jira
password: JiraRush

3 changes: 3 additions & 0 deletions config/app-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
java -Dspring.profiles.active=prod -jar ./target/jira-1.0.jar
#while :; do echo 'Press <CTRL+C> to exit.'; sleep 1; done
29 changes: 29 additions & 0 deletions config/application.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
APP_HOST_URL=http://app
APP_HOST_PORT=8080
APP_TEST_MAIL=jira4jr@gmail.com

DATASOURCE_URL=jdbc:postgresql://db:5432/jira
DATASOURCE_USERNAME=jira
DATASOURCE_PASSWORD=JiraRush

GITHUB_CLIENT_ID=3d0d8738e65881fff266
CLIENT_SECRET=0f97031ce6178b7dfb67a6af587f37e222a16120

GOOGLE_CLIENT_ID=329113642700-f8if6pu68j2repq3ef6umd5jgiliup60.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=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

GITLAB_CLIENT_ID=b8520a3266089063c0d8261cce36971defa513f5ffd9f9b7a3d16728fc83a494
GITLAB_CLIENT_SECRET=e72c65320cf9d6495984a37b0f9cc03ec46be0bb6f071feaebbfe75168117004
GITLAB_CLIENT_NAME=GitLab
GITLAB_REDIRECT_URI="{baseUrl}/login/oauth2/code/{registrationId}"
GITLAB_AUTHORIZATION_GRANT_TYPE=authorization_code

GITLAB_AUTHORIZATION_URI=https://gitlab.com/oauth/authorize
GITLAB_TOKEN_URI=https://gitlab.com/oauth/token
GITLAB_USER_INFO_URI=https://gitlab.com/api/v4/user
GITLAB_USER_NAME_ATTRIBUTE=email

MAIL_HOST=smtp.gmail.com
MAIL_USERNAME=jira4jr@gmail.com
MAIL_PASSWORD=zdfzsrqvgimldzyj
MAIL_PORT=587
4 changes: 2 additions & 2 deletions config/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ server {

location ~ (/$|/view/|/ui/|/oauth2/) {
expires 0m;
proxy_pass http://localhost:8080;
proxy_pass http://app:8080;
proxy_connect_timeout 30s;
}
location ~ (/api/|/doc|/swagger-ui/|/v3/api-docs/) {
proxy_pass http://localhost:8080;
proxy_pass http://app:8080;
proxy_connect_timeout 150s;
}
location / {
Expand Down
59 changes: 59 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
version: "3.9"
services:
nginx:
image: "${NGINX_IMAGE}:${NGINX_IMAGE_VERSION}"
restart: "always"
ports:
- "80:${NGINX_OUT_PORT}"
volumes:
- "${NGINX_CONFIG_PATH}:/etc/nginx/conf.d/nginx.conf"
networks:
- ext_net
- int_net
depends_on:
- app
db:
image: "${DB_IMAGE}:${DB_IMAGE_VERSION}"
restart: "always"
ports:
- "5432:${DB_OUT_PORT}"
volumes:
- "${DB_VOLUME_PATH}:/var/lib/postgresql/data"
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_NAME}
networks:
- int_net
healthcheck:
test: [ "CMD-SHELL", "'pg_isready -U ${DB_USER} -d ${DB_NAME}'" ]
interval: 5s
timeout: 5s
retries: 5
app:
build:
context: .
args:
- APP_IMAGE=${MVN_IMAGE}:${MVN_VERSION}
- PROJECT_DIR=${PROJECT_DIR}
- APP_OUT_PORT=${APP_OUT_PORT}
dockerfile: Dockerfile
env_file: ./config/application.env
restart: "always"
environment:
- SPRING_DATASOURCE_URL=${DB_SOURCE_URL}:${DB_OUT_PORT}/${DB_NAME}
ports:
- "8080:${APP_OUT_PORT}"
networks:
- ext_net
- int_net
depends_on:
- db
networks:
#External network
ext_net:
#Internal-only network
int_net:
internal: true
...
17 changes: 17 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -195,5 +200,17 @@
</plugins>
</build>
</profile>
<profile>
<id>postgres</id>
<properties>
<spring.profiles.active>postgres</spring.profiles.active>
</properties>
</profile>
<profile>
<id>h2dbtest</id>
<properties>
<spring.profiles.active>h2dbtest</spring.profiles.active>
</properties>
</profile>
</profiles>
</project>
17 changes: 11 additions & 6 deletions resources/mails/email-confirmation.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html th:lang="${#locale}" lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<title>JiraRush - подтверждение почты</title>
<span th:fragment="menu">
<a href=".?lang=en">EN</a>
<a href=".?lang=ru">RU</a>
</span>
<title th:text="#{text.mailtitle}"></title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>

</head>
<body>
<p th:text="'Привет, ' + ${user.firstName} + '.'"/>
<p>Чтобы завершить настройку учетной записи и начать пользоваться JiraRush, подтвердите, что вы правильно указали вашу
электронную почту.</p>
<a th:href="${confirmationUrl}">Подтвердить почту</a>

<p th:text="'#{text.mailhello}, ' + ${user.firstName} + '.'"/>
<p>"#{text.mailconfirmation}"</p>
<a th:href="${confirmationUrl}" th:text="#{text.mailconfirm.button}"></a>
</body>
</html>
8 changes: 4 additions & 4 deletions resources/mails/password-reset.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html th:lang="${#locale}" xmlns:th="http://www.thymeleaf.org">
<head th:fragment="head">
<title>JiraRush - установить новый пароль</title>
<title th:text="#{text.resetpasswordtitle}"></title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
</head>
<body>
<p th:text="'Привет, ' + ${user.firstName} + '.'"/>
<p th:text="'Мы получили запрос на установку нового пароля JiraRush для учетной записи: ' + ${user.email} + '.'"/>
<p th:text="#{text.mailhello} + ${user.firstName} + '.'"/>
<p th:text="#{text.resetpassword} + ${user.email} + '.'"/>
<a th:href="${resetUrl}">Установить пароль</a>
</body>
</html>
5 changes: 3 additions & 2 deletions resources/view/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<!DOCTYPE html>
<html lang="ru" xmlns:th="http://www.thymeleaf.org">
<html th:lang="${#locale}" xmlns:th="http://www.thymeleaf.org">
<!--/*@thymesVar id="authUser" type="com.javarush.jira.login.AuthUser"*/-->

<th:block th:replace="~{layout/main::page(title='JiraRush: mini bugtracking system',appMain=~{::appMain})}">
<appMain>
<h1>JiraRush Home page</h1>

<h1 th:text="#{text.hometitle}"> </h1>
<div th:if="${authUser} != null">
<form action="/ui/logout" method="post">
<button class="btn btn-primary btn-lg mt-3" type="submit">Logout</button>
Expand Down
6 changes: 6 additions & 0 deletions resources/view/layout/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@

<div th:fragment="header">
<header class="fixed-top d-none d-md-block header-nav">

<nav class="navbar navbar-expand-lg navbar-dark" id="header">
<div class="container-fluid">
<div class="collapse navbar-collapse mt-2 mb-2 px-5">
<span th:fragment="menu">
<a href=".?lang=en">EN</a>
<a href=".?lang=ru">RU</a>
</span>
<ul class="navbar-nav m-auto">

<form class="d-flex" role="search">
<input aria-label="Search" class="form-control" id="header-search" placeholder="Search"
type="search">
Expand Down
8 changes: 0 additions & 8 deletions resources/view/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ <h3 class="mb-3">Sign in</h3>
type="button">
<i class="fa-brands fa-google"></i>
</a>
<a class="btn btn-primary btn-lg me-2" href="/oauth2/authorization/vk" style="padding-left: 17px; padding-right: 17px;"
type="button">
<i class="fa-brands fa-vk"></i>
</a>
<a class="btn btn-danger btn-lg me-2" href="/oauth2/authorization/yandex" style="padding-left: 21px; padding-right: 21px;"
type="button">
<i class="fa-brands fa-yandex"></i>
</a>
<a class="btn btn-dark btn-lg me-2" href="/oauth2/authorization/github" type="button">
<i class="fa-brands fa-github"></i>
</a>
Expand Down
8 changes: 0 additions & 8 deletions resources/view/unauth/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ <h3 class="mb-3">Registration</h3>
type="button">
<i class="fa-brands fa-google"></i>
</a>
<a class="btn btn-primary btn-lg me-2" href="/oauth2/authorization/vk" style="padding-left: 17px; padding-right: 17px;"
type="button">
<i class="fa-brands fa-vk"></i>
</a>
<a class="btn btn-danger btn-lg me-2" href="/oauth2/authorization/yandex" style="padding-left: 21px; padding-right: 21px;"
type="button">
<i class="fa-brands fa-yandex"></i>
</a>
<a class="btn btn-dark btn-lg me-2" href="/oauth2/authorization/github" type="button">
<i class="fa-brands fa-github"></i>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,21 @@
public class FileUtil {
private static final String ATTACHMENT_PATH = "./attachments/%s/";

public static void upload(MultipartFile multipartFile, String directoryPath, String fileName) {
public static void upload(MultipartFile multipartFile, String directoryPath, String fileName) {
if (multipartFile.isEmpty()) {
throw new IllegalRequestDataException("Select a file to upload.");
}

File dir = new File(directoryPath);
if (dir.exists() || dir.mkdirs()) {
File file = new File(directoryPath + fileName);
try (OutputStream outStream = new FileOutputStream(file)) {
Path dir = null;
try {
dir = Files.createDirectories(Paths.get(directoryPath));
} catch (IOException e) {
throw new IllegalRequestDataException("Failed to create upload path" + multipartFile.getOriginalFilename());
}
if (Files.exists(dir)) {
try (OutputStream outStream = Files.newOutputStream(Files.createFile(Paths.get(directoryPath + fileName)))) {
outStream.write(multipartFile.getBytes());
} catch (IOException ex) {
} catch (IOException e) {
throw new IllegalRequestDataException("Failed to upload file" + multipartFile.getOriginalFilename());
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/javarush/jira/bugtracking/task/Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ public class Activity extends BaseEntity implements HasAuthorId {
@Column(name = "estimate")
private Integer estimate;

@Nullable
@Column(name = "in_progress")
private LocalDateTime in_progress;

@Nullable
@Column(name = "ready_for_review")
private LocalDateTime ready_for_review;

@Nullable
@Column(name = "done")
private LocalDateTime done;

Activity(Long id, Long taskId, Long authorId) {
super(id);
this.taskId = taskId;
Expand Down
Loading