commit 217cf7315d0846aa76cd9b2b669289c467f9e327
Author: Jakub Smid <jaksmid@seznam.cz>
Date:   Sun May 15 08:44:04 2022 +0200

    Added missing comments, code refactoring
    
    re #9743

diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/bibliography/Bibliography.java b/backend/src/main/java/cz/zcu/kiv/backendapi/bibliography/Bibliography.java
index 7bd92e7..8f710a3 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/bibliography/Bibliography.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/bibliography/Bibliography.java
@@ -25,6 +25,9 @@ public class Bibliography {
     @Id
     private String source;
 
+    /**
+     * Catalog item
+     */
     @ManyToOne(fetch = FetchType.LAZY)
     @Id
     @JoinColumn(name = "catalog_item_id")
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItem.java b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItem.java
index 6bc607e..125b44a 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItem.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/catalog/CatalogItem.java
@@ -63,7 +63,7 @@ public class CatalogItem {
     private String description = "";
 
     /**
-     * Bibliography
+     * Set of bibliography
      */
     @OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
     @LazyCollection(LazyCollectionOption.FALSE)
@@ -72,7 +72,7 @@ public class CatalogItem {
     private Set<Bibliography> bibliography = new LinkedHashSet<>(0);
 
     /**
-     * Countries
+     * Set of countries
      */
     @OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
     @LazyCollection(LazyCollectionOption.FALSE)
@@ -81,7 +81,7 @@ public class CatalogItem {
     private Set<Country> countries = new LinkedHashSet<>(0);
 
     /**
-     * Written forms
+     * Set of written forms
      */
     @OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
     @LazyCollection(LazyCollectionOption.FALSE)
@@ -90,7 +90,7 @@ public class CatalogItem {
     private Set<WrittenForm> writtenForms = new LinkedHashSet<>(0);
 
     /**
-     * All names
+     * Set of all names
      */
     @OneToMany(mappedBy = "catalogItem", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
     @LazyCollection(LazyCollectionOption.FALSE)
@@ -99,7 +99,7 @@ public class CatalogItem {
     private Set<CatalogItemName> allNames = new LinkedHashSet<>(0);
 
     /**
-     * Set of user roles - many-to-many relationship
+     * Set of types - many-to-many relationship
      */
     @ManyToMany(fetch = FetchType.EAGER)
     @Fetch(FetchMode.SUBSELECT)
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/config/CorsConfig.java b/backend/src/main/java/cz/zcu/kiv/backendapi/config/CorsConfig.java
index 5bdbc3f..6e42f6a 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/config/CorsConfig.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/config/CorsConfig.java
@@ -17,6 +17,7 @@ public class CorsConfig implements WebMvcConfigurer {
     public void addCorsMappings(CorsRegistry registry) {
         registry.addMapping("/**")
                 .allowedOrigins("*")
-                .allowedMethods(HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.DELETE.name(), HttpMethod.PUT.name(), HttpMethod.PATCH.name());
+                .allowedMethods(HttpMethod.GET.name(), HttpMethod.POST.name(), HttpMethod.DELETE.name(),
+                        HttpMethod.PUT.name(), HttpMethod.PATCH.name());
     }
 }
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/country/Country.java b/backend/src/main/java/cz/zcu/kiv/backendapi/country/Country.java
index 38edf49..6f0acb7 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/country/Country.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/country/Country.java
@@ -25,6 +25,9 @@ public class Country {
     @Id
     private String name;
 
+    /**
+     * Catalog item
+     */
     @ManyToOne(fetch = FetchType.LAZY)
     @Id
     @JoinColumn(name = "catalog_item_id")
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/exception/ApiExceptionHandler.java b/backend/src/main/java/cz/zcu/kiv/backendapi/exception/ApiExceptionHandler.java
index 81303e8..e220447 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/exception/ApiExceptionHandler.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/exception/ApiExceptionHandler.java
@@ -8,6 +8,9 @@ import org.springframework.validation.BindException;
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 
+/**
+ * Exception handler
+ */
 @ControllerAdvice
 public class ApiExceptionHandler {
 
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/exception/ApiRequestException.java b/backend/src/main/java/cz/zcu/kiv/backendapi/exception/ApiRequestException.java
index d43df3d..3df6219 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/exception/ApiRequestException.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/exception/ApiRequestException.java
@@ -3,10 +3,22 @@ package cz.zcu.kiv.backendapi.exception;
 import lombok.Getter;
 import org.springframework.http.HttpStatus;
 
+/**
+ * Class representing custom API request exception
+ */
 @Getter
 public class ApiRequestException extends RuntimeException {
+    /**
+     * HTTP status
+     */
     private final HttpStatus httpStatus;
 
+    /**
+     * Creates new API request exception with given message and HTTP status
+     *
+     * @param message    message
+     * @param httpStatus HTTP status
+     */
     public ApiRequestException(String message, HttpStatus httpStatus) {
         super(message);
         this.httpStatus = httpStatus;
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/external/ExternalCatalogController.java b/backend/src/main/java/cz/zcu/kiv/backendapi/external/ExternalCatalogController.java
index 53e2a54..1a667a5 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/external/ExternalCatalogController.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/external/ExternalCatalogController.java
@@ -22,6 +22,11 @@ public class ExternalCatalogController {
      */
     private final IExternalCatalogItemService externalCatalogService;
 
+    /**
+     * Updates external catalog
+     *
+     * @param file file - should contain CIGS catalog
+     */
     @PostMapping("")
     @Operation(summary = "updates external catalog")
     public void updateCatalog(@RequestParam("file") MultipartFile file) {
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/path/PathController.java b/backend/src/main/java/cz/zcu/kiv/backendapi/path/PathController.java
index b64b1f4..33bd8dc 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/path/PathController.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/path/PathController.java
@@ -3,7 +3,6 @@ package cz.zcu.kiv.backendapi.path;
 import cz.zcu.kiv.backendapi.catalog.ICatalogItemService;
 import io.swagger.v3.oas.annotations.Operation;
 import lombok.RequiredArgsConstructor;
-import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/validation/EmailValidator.java b/backend/src/main/java/cz/zcu/kiv/backendapi/validation/EmailValidator.java
index 2a20bd4..2a7c977 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/validation/EmailValidator.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/validation/EmailValidator.java
@@ -12,7 +12,7 @@ public class EmailValidator implements ConstraintValidator<ValidEmail, String> {
     /**
      * Email string pattern
      */
-    private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-+]+(.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(.[A-Za-z0-9]+)*(.[A-Za-z]{2,})$";
+    private static final String EMAIL_PATTERN = "^[_A-Za-z\\d-+]+(.[_A-Za-z\\d-]+)*@[A-Za-z\\d-]+(.[A-Za-z\\d]+)*(.[A-Za-z]{2,})$";
 
     /**
      * Email patter
diff --git a/backend/src/main/java/cz/zcu/kiv/backendapi/writtenform/WrittenForm.java b/backend/src/main/java/cz/zcu/kiv/backendapi/writtenform/WrittenForm.java
index bb8d860..017b6c6 100644
--- a/backend/src/main/java/cz/zcu/kiv/backendapi/writtenform/WrittenForm.java
+++ b/backend/src/main/java/cz/zcu/kiv/backendapi/writtenform/WrittenForm.java
@@ -25,6 +25,9 @@ public class WrittenForm {
     @Id
     private String form;
 
+    /**
+     * Catalog item
+     */
     @ManyToOne(fetch = FetchType.LAZY)
     @Id
     @JoinColumn(name = "catalog_item_id")
diff --git a/backend/src/test/java/cz/zcu/kiv/backendapi/user/UserServiceImplTest.java b/backend/src/test/java/cz/zcu/kiv/backendapi/user/UserServiceImplTest.java
index 8890cd8..37bb543 100644
--- a/backend/src/test/java/cz/zcu/kiv/backendapi/user/UserServiceImplTest.java
+++ b/backend/src/test/java/cz/zcu/kiv/backendapi/user/UserServiceImplTest.java
@@ -23,7 +23,6 @@ import java.util.Optional;
 import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
 import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.BDDMockito.given;
 import static org.mockito.Mockito.*;
 
