commit c1e7e3766650dc9e594d392cf8869dbbb436eccc
Author: Jakub Šmíd <biba10@students.zcu.cz>
Date:   Tue Mar 29 11:49:47 2022 +0000

    Added title page (and its modification)

diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/BackendApiApplication.java b/backend/src/main/java/cz/zcu/kiv/backendapi/BackendApiApplication.java
index 14f6c40..141f4aa 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/BackendApiApplication.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/BackendApiApplication.java
@@ -1,9 +1,10 @@
 package cz.zcu.kiv.backendapi;
 
-import java.util.logging.Logger;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 
+import java.util.logging.Logger;
+
 @SpringBootApplication
 public class BackendApiApplication {
 
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/StubController.java b/backend/src/main/java/cz/zcu/kiv/backendapi/StubController.java
index eee0df6..b4d9b68 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/StubController.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/StubController.java
@@ -1,9 +1,9 @@
 package cz.zcu.kiv.backendapi;
 
-import java.util.logging.Logger;
-import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.logging.Logger;
+
 @RestController()
 public class StubController {
 
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/alternativename/AlternativeNameRepository.java b/backend/src/main/java/cz/zcu/kiv/backendapi/alternativename/AlternativeNameRepository.java
index fe76e29..bbb7cf3 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/alternativename/AlternativeNameRepository.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/alternativename/AlternativeNameRepository.java
@@ -2,12 +2,10 @@ package cz.zcu.kiv.backendapi.alternativename;
 
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Alternative name repository
  */
 @Repository
-@Transactional(readOnly = true)
 public interface AlternativeNameRepository extends JpaRepository<AlternativeName, AlternativeName> {
 }
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/bibliography/BibliographyRepository.java b/backend/src/main/java/cz/zcu/kiv/backendapi/bibliography/BibliographyRepository.java
index 5a60cd5..cebbae0 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/bibliography/BibliographyRepository.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/bibliography/BibliographyRepository.java
@@ -2,12 +2,10 @@ package cz.zcu.kiv.backendapi.bibliography;
 
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Bibliography repository
  */
 @Repository
-@Transactional(readOnly = true)
 public interface BibliographyRepository extends JpaRepository<Bibliography, Bibliography> {
 }
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogEntryRepository.java b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogEntryRepository.java
index de5d1ff..20e5ec5 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogEntryRepository.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogEntryRepository.java
@@ -3,7 +3,6 @@ package cz.zcu.kiv.backendapi.catalog;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Set;
 import java.util.UUID;
@@ -12,7 +11,6 @@ import java.util.UUID;
  * Catalog repository
  */
 @Repository
-@Transactional(readOnly = true)
 public interface CatalogEntryRepository extends JpaRepository<CatalogEntry, UUID> {
 
     /**
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogEntryServiceImpl.java b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogEntryServiceImpl.java
index 5168f23..c8e14b0 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogEntryServiceImpl.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogEntryServiceImpl.java
@@ -4,8 +4,8 @@ import cz.zcu.kiv.backendapi.alternativename.AlternativeName;
 import cz.zcu.kiv.backendapi.bibliography.Bibliography;
 import cz.zcu.kiv.backendapi.country.Country;
 import cz.zcu.kiv.backendapi.exception.ApiRequestException;
-import cz.zcu.kiv.backendapi.type.Type;
 import cz.zcu.kiv.backendapi.type.ITypeService;
+import cz.zcu.kiv.backendapi.type.Type;
 import cz.zcu.kiv.backendapi.writtenform.WrittenForm;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/config/DataInitiator.java b/backend/src/main/java/cz/zcu/kiv/backendapi/config/DataInitiator.java
index b98a12c..169d864 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/config/DataInitiator.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/config/DataInitiator.java
@@ -1,10 +1,10 @@
 package cz.zcu.kiv.backendapi.config;
 
 import cz.zcu.kiv.backendapi.catalog.CatalogEntry;
-import cz.zcu.kiv.backendapi.type.Type;
 import cz.zcu.kiv.backendapi.catalog.CatalogEntryRepository;
 import cz.zcu.kiv.backendapi.catalog.ICatalogEntryService;
 import cz.zcu.kiv.backendapi.type.ITypeService;
+import cz.zcu.kiv.backendapi.type.Type;
 import cz.zcu.kiv.backendapi.user.UserEntity;
 import cz.zcu.kiv.backendapi.user.UserRepository;
 import lombok.RequiredArgsConstructor;
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/country/CountryRepository.java b/backend/src/main/java/cz/zcu/kiv/backendapi/country/CountryRepository.java
index 1eb9eed..408b381 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/country/CountryRepository.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/country/CountryRepository.java
@@ -2,12 +2,10 @@ package cz.zcu.kiv.backendapi.country;
 
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Country repository
  */
 @Repository
-@Transactional(readOnly = true)
 public interface CountryRepository extends JpaRepository<Country, Country> {
 }
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/security/SecurityConfig.java b/backend/src/main/java/cz/zcu/kiv/backendapi/security/SecurityConfig.java
index d688fb8..6ea5494 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/security/SecurityConfig.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/security/SecurityConfig.java
@@ -1,8 +1,8 @@
 package cz.zcu.kiv.backendapi.security;
 
-import cz.zcu.kiv.backendapi.security.jwt.JwtUtils;
 import cz.zcu.kiv.backendapi.security.jwt.JwtTokenVerifier;
 import cz.zcu.kiv.backendapi.security.jwt.JwtUsernameAndPasswordAuthenticationFilter;
+import cz.zcu.kiv.backendapi.security.jwt.JwtUtils;
 import cz.zcu.kiv.backendapi.user.Permission;
 import cz.zcu.kiv.backendapi.user.Role;
 import lombok.RequiredArgsConstructor;
@@ -12,13 +12,11 @@ import org.springframework.http.HttpMethod;
 import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
 import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
 import org.springframework.security.config.annotation.web.builders.HttpSecurity;
-import org.springframework.security.config.annotation.web.builders.WebSecurity;
 import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
 import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
 import org.springframework.security.config.http.SessionCreationPolicy;
 import org.springframework.security.core.userdetails.UserDetailsService;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
-import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint;
 
 /**
  * Security config class
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/security/jwt/JwtTokenVerifier.java b/backend/src/main/java/cz/zcu/kiv/backendapi/security/jwt/JwtTokenVerifier.java
index d91847f..fed29b1 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/security/jwt/JwtTokenVerifier.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/security/jwt/JwtTokenVerifier.java
@@ -19,7 +19,9 @@ import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
 import java.util.stream.Collectors;
 
 
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/ITitlePageService.java b/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/ITitlePageService.java
new file mode 100644
index 0000000..4161849
--- /dev/null
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/ITitlePageService.java
@@ -0,0 +1,17 @@
+package cz.zcu.kiv.backendapi.titlepage;
+
+import java.util.List;
+
+/**
+ * Title page service interface
+ */
+public interface ITitlePageService {
+    /**
+     * Returns all title pages
+     *
+     * @return list of title pages
+     */
+    List<TitlePage> getTitlePages();
+
+    void addNewTitlePage(TitlePage titlePage);
+}
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/TitlePage.java b/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/TitlePage.java
new file mode 100644
index 0000000..1621cbf
--- /dev/null
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/TitlePage.java
@@ -0,0 +1,33 @@
+package cz.zcu.kiv.backendapi.titlepage;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * Class representing title page
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@Entity
+@Table(name = "title_page")
+public class TitlePage {
+
+    /**
+     * Title – serves as ID
+     */
+    @Id
+    private String title;
+
+    /**
+     * Content of the title page
+     */
+    @Column(length = 100000)
+    private String content;
+}
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/TitlePageController.java b/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/TitlePageController.java
new file mode 100644
index 0000000..6673749
--- /dev/null
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/TitlePageController.java
@@ -0,0 +1,42 @@
+package cz.zcu.kiv.backendapi.titlepage;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * Controller for title page
+ */
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("title-page")
+public class TitlePageController {
+    /**
+     * Title page service
+     */
+    private final ITitlePageService titlePageService;
+
+    /**
+     * Returns list of all title pages
+     *
+     * @return list of all title pages
+     */
+    @GetMapping("")
+    public ResponseEntity<List<TitlePage>> getAllTitlePages() {
+        return new ResponseEntity<>(titlePageService.getTitlePages(), HttpStatus.OK);
+    }
+
+    /**
+     * Adds new title page
+     *
+     * @param titlePage title page
+     */
+    @PostMapping("")
+    public void addNewTitlePage(@RequestBody TitlePage titlePage) {
+        titlePageService.addNewTitlePage(titlePage);
+    }
+
+}
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/TitlePageRepository.java b/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/TitlePageRepository.java
new file mode 100644
index 0000000..7c31d2f
--- /dev/null
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/TitlePageRepository.java
@@ -0,0 +1,11 @@
+package cz.zcu.kiv.backendapi.titlepage;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+/**
+ * Title page repository
+ */
+@Repository
+public interface TitlePageRepository extends JpaRepository<TitlePage, String> {
+}
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/TitlePageServiceImplementation.java b/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/TitlePageServiceImplementation.java
new file mode 100644
index 0000000..06495d2
--- /dev/null
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/titlepage/TitlePageServiceImplementation.java
@@ -0,0 +1,30 @@
+package cz.zcu.kiv.backendapi.titlepage;
+
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * Title page service implementation
+ */
+@Service
+@Transactional
+@RequiredArgsConstructor
+public class TitlePageServiceImplementation implements ITitlePageService {
+    /**
+     * Title page repository
+     */
+    private final TitlePageRepository titlePageRepository;
+
+    @Override
+    public List<TitlePage> getTitlePages() {
+        return titlePageRepository.findAll();
+    }
+
+    @Override
+    public void addNewTitlePage(TitlePage titlePage) {
+        titlePageRepository.save(titlePage);
+    }
+}
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/type/TypeRepository.java b/backend/src/main/java/cz/zcu/kiv/backendapi/type/TypeRepository.java
index 28405bb..9cd64bd 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/type/TypeRepository.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/type/TypeRepository.java
@@ -2,13 +2,11 @@ package cz.zcu.kiv.backendapi.type;
 
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
 
 
 /**
  * Type repository
  */
 @Repository
-@Transactional(readOnly = true)
 public interface TypeRepository extends JpaRepository<Type, String> {
 }
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/user/UserController.java b/backend/src/main/java/cz/zcu/kiv/backendapi/user/UserController.java
index 006c5ea..6ea2fee 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/user/UserController.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/user/UserController.java
@@ -5,16 +5,14 @@ import com.auth0.jwt.JWTVerifier;
 import com.auth0.jwt.algorithms.Algorithm;
 import com.auth0.jwt.interfaces.DecodedJWT;
 import com.google.common.base.Strings;
+import cz.zcu.kiv.backendapi.exception.ApiRequestException;
 import cz.zcu.kiv.backendapi.password.PasswordDto;
 import cz.zcu.kiv.backendapi.security.jwt.JwtUtils;
-import cz.zcu.kiv.backendapi.exception.ApiRequestException;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
-import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
-import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.core.GrantedAuthority;
 import org.springframework.web.bind.annotation.*;
 import premission.PermissionDto;
@@ -54,7 +52,7 @@ public class UserController {
      *
      * @param userDto user DTO
      */
-    @PostMapping("/user/register")
+    @PostMapping("/register")
     public void registerNewUser(@RequestBody @Valid UserDto userDto) {
         userService.registerNewUser(userDto);
     }
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/user/UserEntity.java b/backend/src/main/java/cz/zcu/kiv/backendapi/user/UserEntity.java
index b0e8867..4aecd90 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/user/UserEntity.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/user/UserEntity.java
@@ -7,7 +7,10 @@ import org.springframework.security.core.GrantedAuthority;
 import org.springframework.security.core.authority.SimpleGrantedAuthority;
 import org.springframework.security.core.userdetails.UserDetails;
 
-import javax.persistence.*;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/user/UserRepository.java b/backend/src/main/java/cz/zcu/kiv/backendapi/user/UserRepository.java
index 85bc976..976fdd4 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/user/UserRepository.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/user/UserRepository.java
@@ -2,7 +2,6 @@ package cz.zcu.kiv.backendapi.user;
 
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Optional;
 
@@ -11,7 +10,6 @@ import java.util.Optional;
  * User repository
  */
 @Repository
-@Transactional(readOnly = true)
 public interface UserRepository extends JpaRepository<UserEntity, String> {
     /**
      * Returns user by email (username)
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/writtenform/WrittenFormRepository.java b/backend/src/main/java/cz/zcu/kiv/backendapi/writtenform/WrittenFormRepository.java
index 63d0c46..6089d08 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/writtenform/WrittenFormRepository.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/writtenform/WrittenFormRepository.java
@@ -2,12 +2,10 @@ package cz.zcu.kiv.backendapi.writtenform;
 
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Written form repository
  */
 @Repository
-@Transactional(readOnly = true)
 public interface WrittenFormRepository extends JpaRepository<WrittenForm, WrittenForm> {
 }
