diff --git a/build.gradle b/build.gradle index 65c5adc..9949989 100644 --- a/build.gradle +++ b/build.gradle @@ -83,9 +83,10 @@ dependencies { implementation group: 'org.springframework.boot', name: 'spring-boot-starter-security' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-aop' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-mail' - implementation group: 'org.springframework.boot', name: 'spring-boot-starter-tomcat' + implementation group: 'org.springframework.boot', name: 'spring-boot-starter-jetty' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa' implementation group: 'org.springframework.boot', name: 'spring-boot-starter-thymeleaf' + implementation group: 'org.springframework.boot', name: 'spring-boot-starter-validation' implementation group: 'nz.net.ultraq.thymeleaf', name: 'thymeleaf-layout-dialect' implementation group: 'org.thymeleaf.extras', name: 'thymeleaf-extras-springsecurity6' implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-afterburner' @@ -95,7 +96,7 @@ dependencies { implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.5' - implementation group: 'org.liquibase', name: 'liquibase-core', version: '3.6.3' + implementation group: 'org.liquibase', name: 'liquibase-core', version: '4.27.0' implementation group: 'com.mattbertolini', name: 'liquibase-slf4j', version: '2.0.0' implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.7' @@ -106,8 +107,7 @@ dependencies { implementation group: 'org.webjars.npm', name: 'jquery.easing', version: '1.4.1' implementation group: 'org.webjars', name: 'font-awesome', version: '4.7.0' - implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.6.0' - implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.6.0' + implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.8.0' implementation group: 'net.sourceforge.htmlunit', name: 'htmlunit', version: '2.35.0' implementation group: 'xalan', name: 'xalan', version: '2.7.2' diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index f9a4bac..aaa843e 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -1,6 +1,8 @@ package ru.ulstu.conference.controller; +import io.swagger.v3.oas.annotations.Hidden; +import jakarta.validation.Valid; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.Errors; @@ -14,9 +16,7 @@ import ru.ulstu.conference.model.ConferenceFilterDto; import ru.ulstu.conference.model.ConferenceUser; import ru.ulstu.conference.service.ConferenceService; import ru.ulstu.user.model.User; -import springfox.documentation.annotations.ApiIgnore; -import javax.validation.Valid; import java.io.IOException; import java.util.ArrayList; import java.util.Calendar; @@ -29,7 +29,7 @@ import static ru.ulstu.core.controller.Navigation.REDIRECT_TO; @Controller() @RequestMapping(value = "/conferences") -@ApiIgnore +@Hidden public class ConferenceController { private final ConferenceService conferenceService; diff --git a/src/main/java/ru/ulstu/conference/model/Conference.java b/src/main/java/ru/ulstu/conference/model/Conference.java index 941f825..4ab1cfa 100644 --- a/src/main/java/ru/ulstu/conference/model/Conference.java +++ b/src/main/java/ru/ulstu/conference/model/Conference.java @@ -1,5 +1,17 @@ package ru.ulstu.conference.model; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OrderBy; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.NotBlank; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; import org.springframework.format.annotation.DateTimeFormat; @@ -11,18 +23,6 @@ import ru.ulstu.paper.model.Paper; import ru.ulstu.timeline.model.Event; import ru.ulstu.user.model.User; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.DiscriminatorValue; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; -import javax.persistence.OrderBy; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.validation.constraints.NotBlank; import java.util.ArrayList; import java.util.Comparator; import java.util.Date; diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java index 7246854..dad401b 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceDto.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceDto.java @@ -2,16 +2,16 @@ package ru.ulstu.conference.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.Size; import org.springframework.format.annotation.DateTimeFormat; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.name.NameContainer; import ru.ulstu.paper.model.Paper; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Size; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/src/main/java/ru/ulstu/conference/model/ConferenceUser.java b/src/main/java/ru/ulstu/conference/model/ConferenceUser.java index 1cc3244..978515b 100644 --- a/src/main/java/ru/ulstu/conference/model/ConferenceUser.java +++ b/src/main/java/ru/ulstu/conference/model/ConferenceUser.java @@ -2,18 +2,17 @@ package ru.ulstu.conference.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.user.model.User; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; - @Entity @Table(name = "users_conference") public class ConferenceUser extends BaseEntity { @@ -70,7 +69,6 @@ public class ConferenceUser extends BaseEntity { public ConferenceUser(User user) { this.user = user; this.deposit = Deposit.REPORT; - this.participation = Participation.INTRAMURAL; } @JsonCreator diff --git a/src/main/java/ru/ulstu/conference/repository/ConferenceRepository.java b/src/main/java/ru/ulstu/conference/repository/ConferenceRepository.java index 53a9d84..60cd728 100644 --- a/src/main/java/ru/ulstu/conference/repository/ConferenceRepository.java +++ b/src/main/java/ru/ulstu/conference/repository/ConferenceRepository.java @@ -13,7 +13,7 @@ import java.util.List; public interface ConferenceRepository extends JpaRepository, BaseRepository { @Query("SELECT c FROM Conference c LEFT JOIN c.users u WHERE (:user IS NULL OR u.user = :user) " + - "AND (YEAR(c.beginDate) = :year OR :year IS NULL) ORDER BY begin_date DESC") + "AND (YEAR(c.beginDate) = :year OR :year IS NULL) ORDER BY c.beginDate DESC") List findByUserAndYear(@Param("user") User user, @Param("year") Integer year); @Query("SELECT c FROM Conference c WHERE c.beginDate > :date") diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceNotificationService.java b/src/main/java/ru/ulstu/conference/service/ConferenceNotificationService.java index 961d369..1e54395 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceNotificationService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceNotificationService.java @@ -1,6 +1,5 @@ package ru.ulstu.conference.service; -import com.google.common.collect.ImmutableMap; import org.springframework.stereotype.Service; import ru.ulstu.conference.model.Conference; import ru.ulstu.core.util.DateUtils; @@ -57,22 +56,22 @@ public class ConferenceNotificationService { } private void sendMessageDeadline(Conference conference) { - Map variables = ImmutableMap.of("conference", conference); + Map variables = Map.of("conference", conference); sendForAllParticipants(variables, conference, TEMPLATE_DEADLINE, String.format(TITLE_DEADLINE, conference.getTitle())); } public void sendCreateNotification(Conference conference) { - Map variables = ImmutableMap.of("conference", conference); + Map variables = Map.of("conference", conference); sendForAllUsers(variables, String.format(TITLE_CREATE, conference.getTitle())); } public void updateDeadlineNotification(Conference conference) { - Map variables = ImmutableMap.of("conference", conference); + Map variables = Map.of("conference", conference); sendForAllParticipants(variables, conference, TEMPLATE_UPDATE_DEADLINES, String.format(TITLE_UPDATE_DEADLINES, conference.getTitle())); } public void updateConferencesDatesNotification(Conference conference, Date oldBeginDate, Date oldEndDate) { - Map variables = ImmutableMap.of("conference", conference, "oldBeginDate", oldBeginDate, "oldEndDate", oldEndDate); + Map variables = Map.of("conference", conference, "oldBeginDate", oldBeginDate, "oldEndDate", oldEndDate); sendForAllParticipants(variables, conference, TEMPLATE_UPDATE_DATES, String.format(TITLE_UPDATE_DATES, conference.getTitle())); } @@ -107,7 +106,7 @@ public class ConferenceNotificationService { } private void sendMessagePing(Conference conference) { - Map variables = ImmutableMap.of("conference", conference); + Map variables = Map.of("conference", conference); sendForAllParticipants(variables, conference, TEMPLATE_PING, String.format(TITLE_PING, conference.getTitle())); } } diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index 830fea1..5a085ba 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -81,7 +81,7 @@ public class ConferenceService extends BaseService { public List findAll() { - return conferenceRepository.findAll(new Sort(Sort.Direction.DESC, "beginDate")); + return conferenceRepository.findAll(Sort.by(Sort.Direction.DESC, "beginDate")); } public List findAllDto() { diff --git a/src/main/java/ru/ulstu/configuration/ApplicationProperties.java b/src/main/java/ru/ulstu/configuration/ApplicationProperties.java index 878e0b4..beef76b 100644 --- a/src/main/java/ru/ulstu/configuration/ApplicationProperties.java +++ b/src/main/java/ru/ulstu/configuration/ApplicationProperties.java @@ -1,11 +1,10 @@ package ru.ulstu.configuration; +import jakarta.validation.constraints.NotBlank; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; import org.springframework.validation.annotation.Validated; -import javax.validation.constraints.NotBlank; - @Component @ConfigurationProperties(prefix = "ng-tracker") @Validated diff --git a/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java b/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java index 5df2377..d906316 100644 --- a/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java +++ b/src/main/java/ru/ulstu/configuration/MailTemplateConfiguration.java @@ -1,10 +1,10 @@ package ru.ulstu.configuration; -import nz.net.ultraq.thymeleaf.LayoutDialect; +import nz.net.ultraq.thymeleaf.layoutdialect.LayoutDialect; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.thymeleaf.extras.springsecurity5.dialect.SpringSecurityDialect; -import org.thymeleaf.spring5.SpringTemplateEngine; +import org.thymeleaf.extras.springsecurity6.dialect.SpringSecurityDialect; +import org.thymeleaf.spring6.SpringTemplateEngine; import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver; import org.thymeleaf.templateresolver.ITemplateResolver; diff --git a/src/main/java/ru/ulstu/configuration/SecurityConfiguration.java b/src/main/java/ru/ulstu/configuration/SecurityConfiguration.java index 68bc120..ea90028 100644 --- a/src/main/java/ru/ulstu/configuration/SecurityConfiguration.java +++ b/src/main/java/ru/ulstu/configuration/SecurityConfiguration.java @@ -9,22 +9,12 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; 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.oauth2.client.CommonOAuth2Provider; +import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.oauth2.client.endpoint.DefaultAuthorizationCodeTokenResponseClient; -import org.springframework.security.oauth2.client.endpoint.OAuth2AccessTokenResponseClient; -import org.springframework.security.oauth2.client.endpoint.OAuth2AuthorizationCodeGrantRequest; -import org.springframework.security.oauth2.client.registration.ClientRegistration; -import org.springframework.security.oauth2.client.registration.ClientRegistrationRepository; -import org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository; -import org.springframework.security.oauth2.client.web.AuthorizationRequestRepository; -import org.springframework.security.oauth2.client.web.HttpSessionOAuth2AuthorizationRequestRepository; -import org.springframework.security.oauth2.core.endpoint.OAuth2AuthorizationRequest; +import org.springframework.security.web.SecurityFilterChain; import org.springframework.security.web.authentication.AuthenticationFailureHandler; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; @@ -33,18 +23,10 @@ import ru.ulstu.user.controller.UserController; import ru.ulstu.user.model.UserRoleConstants; import ru.ulstu.user.service.UserService; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - @Configuration @EnableWebSecurity -@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) -public class SecurityConfiguration extends WebSecurityConfigurerAdapter { +public class SecurityConfiguration { private final Logger log = LoggerFactory.getLogger(SecurityConfiguration.class); - private static List clients = Arrays.asList("google"); - private static final String CLIENT_PROPERTY_KEY - = "spring.security.oauth2.client.registration."; @Autowired private Environment env; @@ -75,104 +57,60 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter { this.authenticationFailureHandler = authenticationFailureHandler; } - @Override - protected void configure(HttpSecurity http) throws Exception { - http.csrf().disable(); + @Bean + public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { + http.csrf(AbstractHttpConfigurer::disable); if (applicationProperties.isDevMode()) { log.debug("Security disabled"); - http.authorizeRequests() + http.authorizeHttpRequests((authz) -> authz .anyRequest() - .permitAll(); - http.anonymous() + .permitAll() + ); + http.anonymous((anonymousCustomizer) -> anonymousCustomizer .principal("admin") - .authorities(UserRoleConstants.ADMIN); + .authorities(UserRoleConstants.ADMIN) + ); } else { log.debug("Security enabled"); - http.authorizeRequests() - .antMatchers(UserController.ACTIVATE_URL).permitAll() - .antMatchers(Constants.PASSWORD_RESET_REQUEST_PAGE).permitAll() - .antMatchers(Constants.PASSWORD_RESET_PAGE).permitAll() - .antMatchers("/users/block").permitAll() - .antMatchers(UserController.URL + UserController.REGISTER_URL).permitAll() - .antMatchers(UserController.URL + UserController.ACTIVATE_URL).permitAll() - .antMatchers(UserController.URL + UserController.PASSWORD_RESET_REQUEST_URL).permitAll() - .antMatchers(UserController.URL + UserController.PASSWORD_RESET_URL).permitAll() - .antMatchers("/swagger-ui.html").hasAuthority(UserRoleConstants.ADMIN) - .anyRequest().authenticated() - .and() - .formLogin() - .loginPage("/login") - .successHandler(authenticationSuccessHandler) - .failureHandler(authenticationFailureHandler) - .permitAll() - .and() - .logout() - .logoutSuccessHandler(logoutSuccessHandler) - .logoutSuccessUrl(Constants.LOGOUT_URL) - .invalidateHttpSession(false) - .clearAuthentication(true) - .deleteCookies(Constants.COOKIES_NAME) - .permitAll(); - http.csrf().disable(); - } - if (applicationProperties.isUseHttps()) { - http.portMapper() - .http(httpPort) - .mapsTo(httpsPort) - .and() - .requiresChannel() - .anyRequest() - .requiresSecure(); + http.authorizeHttpRequests((authz) -> authz + .requestMatchers(UserController.ACTIVATE_URL).permitAll() + .requestMatchers(Constants.PASSWORD_RESET_REQUEST_PAGE).permitAll() + .requestMatchers(Constants.PASSWORD_RESET_PAGE).permitAll() + .requestMatchers("/users/block").permitAll() + .requestMatchers(UserController.URL + UserController.REGISTER_URL).permitAll() + .requestMatchers(UserController.URL + UserController.ACTIVATE_URL).permitAll() + .requestMatchers(UserController.URL + UserController.PASSWORD_RESET_REQUEST_URL).permitAll() + .requestMatchers(UserController.URL + UserController.PASSWORD_RESET_URL).permitAll() + .requestMatchers("/swagger-ui.html").hasAuthority(UserRoleConstants.ADMIN) + .anyRequest().authenticated()) + .formLogin((formLoginCustomizer) -> formLoginCustomizer + .loginPage("/login") + .successHandler(authenticationSuccessHandler) + .failureHandler(authenticationFailureHandler) + .permitAll() + ) + .logout((logoutCustomizer) -> logoutCustomizer + .logoutSuccessHandler(logoutSuccessHandler) + .logoutSuccessUrl(Constants.LOGOUT_URL) + .invalidateHttpSession(false) + .clearAuthentication(true) + .deleteCookies(Constants.COOKIES_NAME) + .permitAll() + ); + http.csrf(AbstractHttpConfigurer::disable); } + return http.build(); } @Bean - public AuthorizationRequestRepository authorizationRequestRepository() { - return new HttpSessionOAuth2AuthorizationRequestRepository(); - } - - @Bean - public OAuth2AccessTokenResponseClient accessTokenResponseClient() { - DefaultAuthorizationCodeTokenResponseClient accessTokenResponseClient = new DefaultAuthorizationCodeTokenResponseClient(); - return accessTokenResponseClient; - } - - //@Bean - public ClientRegistrationRepository clientRegistrationRepository() { - List registrations = clients.stream() - .map(c -> getRegistration(c)) - .filter(registration -> registration != null) - .collect(Collectors.toList()); - - return new InMemoryClientRegistrationRepository(registrations); - } - - private ClientRegistration getRegistration(String client) { - String clientId = env.getProperty(CLIENT_PROPERTY_KEY + client + ".client-id"); - - if (clientId == null) { - return null; - } - - String clientSecret = env.getProperty(CLIENT_PROPERTY_KEY + client + ".client-secret"); - if (client.equals("google")) { - return CommonOAuth2Provider.GOOGLE.getBuilder(client) - .clientId(clientId) - .clientSecret(clientSecret) - .build(); - } - return null; - } - - @Override - public void configure(WebSecurity web) { - web.ignoring() - .antMatchers("/css/**") - .antMatchers("/javax.faces.resource/**") - .antMatchers("/js/**") - .antMatchers("/templates/**") - .antMatchers("/webjars/**") - .antMatchers("/img/**"); + public WebSecurityCustomizer webSecurityCustomizer() { + return (web) -> web.ignoring() + .requestMatchers("/css/**", + "/javax.faces.resource/**", + "/js/**", + "/templates/**", + "/webjars/**", + "/img/**"); } @Autowired diff --git a/src/main/java/ru/ulstu/configuration/SwaggerConfiguration.java b/src/main/java/ru/ulstu/configuration/SwaggerConfiguration.java deleted file mode 100644 index c51811e..0000000 --- a/src/main/java/ru/ulstu/configuration/SwaggerConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package ru.ulstu.configuration; - -import com.google.common.base.Predicates; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -@Configuration -@EnableSwagger2 -public class SwaggerConfiguration { - @Bean - public Docket swaggerApi() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(Predicates.not(PathSelectors.regex("/error"))) - .build(); - } -} \ No newline at end of file diff --git a/src/main/java/ru/ulstu/core/jpa/OffsetablePageRequest.java b/src/main/java/ru/ulstu/core/jpa/OffsetablePageRequest.java index 148a931..b59bf66 100644 --- a/src/main/java/ru/ulstu/core/jpa/OffsetablePageRequest.java +++ b/src/main/java/ru/ulstu/core/jpa/OffsetablePageRequest.java @@ -15,7 +15,7 @@ public class OffsetablePageRequest implements Pageable, Serializable { } public OffsetablePageRequest(long offset, int count, Sort.Direction direction, String... properties) { - this(offset, count, new Sort(direction, properties)); + this(offset, count, Sort.by(direction, properties)); } public OffsetablePageRequest(long offset, int count, Sort sort) { @@ -30,6 +30,12 @@ public class OffsetablePageRequest implements Pageable, Serializable { this.sort = sort; } + @Override + public Pageable withPage(int pageNumber) { + //TODO + return null; + } + @Override public Sort getSort() { return sort; diff --git a/src/main/java/ru/ulstu/core/model/AuthFailureHandler.java b/src/main/java/ru/ulstu/core/model/AuthFailureHandler.java index 8b6bd9d..b2b8d91 100644 --- a/src/main/java/ru/ulstu/core/model/AuthFailureHandler.java +++ b/src/main/java/ru/ulstu/core/model/AuthFailureHandler.java @@ -1,12 +1,12 @@ package ru.ulstu.core.model; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.AuthenticationFailureHandler; import org.springframework.stereotype.Component; import ru.ulstu.user.error.UserBlockedException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import java.io.IOException; @Component diff --git a/src/main/java/ru/ulstu/core/model/BaseEntity.java b/src/main/java/ru/ulstu/core/model/BaseEntity.java index a985dcc..85c8ea7 100644 --- a/src/main/java/ru/ulstu/core/model/BaseEntity.java +++ b/src/main/java/ru/ulstu/core/model/BaseEntity.java @@ -1,11 +1,12 @@ package ru.ulstu.core.model; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.MappedSuperclass; -import javax.persistence.Version; -import javax.validation.constraints.NotNull; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.Version; +import jakarta.validation.constraints.NotNull; + import java.io.Serializable; @MappedSuperclass diff --git a/src/main/java/ru/ulstu/core/repository/JpaDetachableRepositoryImpl.java b/src/main/java/ru/ulstu/core/repository/JpaDetachableRepositoryImpl.java index facc071..718974f 100644 --- a/src/main/java/ru/ulstu/core/repository/JpaDetachableRepositoryImpl.java +++ b/src/main/java/ru/ulstu/core/repository/JpaDetachableRepositoryImpl.java @@ -1,9 +1,9 @@ package ru.ulstu.core.repository; +import jakarta.persistence.EntityManager; import org.springframework.data.jpa.repository.support.JpaEntityInformation; import org.springframework.data.jpa.repository.support.SimpleJpaRepository; -import javax.persistence.EntityManager; import java.io.Serializable; public class JpaDetachableRepositoryImpl extends SimpleJpaRepository diff --git a/src/main/java/ru/ulstu/deadline/model/Deadline.java b/src/main/java/ru/ulstu/deadline/model/Deadline.java index 8edab97..e530be5 100644 --- a/src/main/java/ru/ulstu/deadline/model/Deadline.java +++ b/src/main/java/ru/ulstu/deadline/model/Deadline.java @@ -2,15 +2,15 @@ package ru.ulstu.deadline.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.persistence.Entity; +import jakarta.persistence.FetchType; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; import org.springframework.format.annotation.DateTimeFormat; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.user.model.User; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.OneToMany; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; import java.util.Date; import java.util.List; import java.util.Objects; diff --git a/src/main/java/ru/ulstu/file/model/FileData.java b/src/main/java/ru/ulstu/file/model/FileData.java index 3f97130..41e30bb 100644 --- a/src/main/java/ru/ulstu/file/model/FileData.java +++ b/src/main/java/ru/ulstu/file/model/FileData.java @@ -1,10 +1,10 @@ package ru.ulstu.file.model; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; import ru.ulstu.core.model.BaseEntity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; import java.util.Date; @Entity diff --git a/src/main/java/ru/ulstu/grant/controller/GrantController.java b/src/main/java/ru/ulstu/grant/controller/GrantController.java index 48dee8e..669dc5d 100644 --- a/src/main/java/ru/ulstu/grant/controller/GrantController.java +++ b/src/main/java/ru/ulstu/grant/controller/GrantController.java @@ -1,5 +1,7 @@ package ru.ulstu.grant.controller; +import io.swagger.v3.oas.annotations.Hidden; +import jakarta.validation.Valid; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.Errors; @@ -16,9 +18,7 @@ import ru.ulstu.grant.model.GrantDto; import ru.ulstu.grant.service.GrantService; import ru.ulstu.paper.model.PaperDto; import ru.ulstu.user.model.User; -import springfox.documentation.annotations.ApiIgnore; -import javax.validation.Valid; import java.io.IOException; import java.util.List; @@ -29,7 +29,7 @@ import static ru.ulstu.core.controller.Navigation.REDIRECT_TO; @Controller() @RequestMapping(value = "/grants") -@ApiIgnore +@Hidden public class GrantController { private final GrantService grantService; diff --git a/src/main/java/ru/ulstu/grant/model/Grant.java b/src/main/java/ru/ulstu/grant/model/Grant.java index ec6e90f..cf8171d 100644 --- a/src/main/java/ru/ulstu/grant/model/Grant.java +++ b/src/main/java/ru/ulstu/grant/model/Grant.java @@ -1,5 +1,20 @@ package ru.ulstu.grant.model; +import jakarta.persistence.CascadeType; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OrderBy; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; import ru.ulstu.core.model.BaseEntity; @@ -12,21 +27,6 @@ import ru.ulstu.project.model.Project; import ru.ulstu.timeline.model.Event; import ru.ulstu.user.model.User; -import javax.persistence.CascadeType; -import javax.persistence.DiscriminatorValue; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.OrderBy; -import javax.persistence.Table; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; diff --git a/src/main/java/ru/ulstu/grant/model/GrantDto.java b/src/main/java/ru/ulstu/grant/model/GrantDto.java index 541dae8..0c7f212 100644 --- a/src/main/java/ru/ulstu/grant/model/GrantDto.java +++ b/src/main/java/ru/ulstu/grant/model/GrantDto.java @@ -2,6 +2,7 @@ package ru.ulstu.grant.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotEmpty; import org.apache.commons.lang3.StringUtils; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.file.model.FileDataDto; @@ -10,7 +11,6 @@ import ru.ulstu.paper.model.PaperDto; import ru.ulstu.project.model.ProjectDto; import ru.ulstu.user.model.UserDto; -import javax.validation.constraints.NotEmpty; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/src/main/java/ru/ulstu/grant/service/GrantNotificationService.java b/src/main/java/ru/ulstu/grant/service/GrantNotificationService.java index 677b38f..93af783 100644 --- a/src/main/java/ru/ulstu/grant/service/GrantNotificationService.java +++ b/src/main/java/ru/ulstu/grant/service/GrantNotificationService.java @@ -1,6 +1,5 @@ package ru.ulstu.grant.service; -import com.google.common.collect.ImmutableMap; import org.springframework.stereotype.Service; import ru.ulstu.core.util.DateUtils; import ru.ulstu.grant.model.Grant; @@ -46,22 +45,22 @@ public class GrantNotificationService { } private void sendMessageDeadline(Grant grant) { - Map variables = ImmutableMap.of("grant", grant); + Map variables = Map.of("grant", grant); sendForAllAuthors(variables, grant, TEMPLATE_DEADLINE, String.format(TITLE_DEADLINE, grant.getTitle())); } public void sendCreateNotification(Grant grant) { - Map variables = ImmutableMap.of("grant", grant); + Map variables = Map.of("grant", grant); sendForAllAuthors(variables, grant, TEMPLATE_CREATE, String.format(TITLE_CREATE, grant.getTitle())); } public void sendAuthorsChangeNotification(Grant grant, Set oldAuthors) { - Map variables = ImmutableMap.of("grant", grant, "oldAuthors", oldAuthors); + Map variables = Map.of("grant", grant, "oldAuthors", oldAuthors); sendForAllAuthors(variables, grant, TEMPLATE_AUTHORS_CHANGED, String.format(TITLE_AUTHORS_CHANGED, grant.getTitle())); } public void sendLeaderChangeNotification(Grant grant, User oldLeader) { - Map variables = ImmutableMap.of("grant", grant, "oldLeader", oldLeader); + Map variables = Map.of("grant", grant, "oldLeader", oldLeader); sendForAllAuthors(variables, grant, TEMPLATE_LEADER_CHANGED, String.format(TITLE_LEADER_CHANGED, grant.getTitle())); } diff --git a/src/main/java/ru/ulstu/index/controller/IndexController.java b/src/main/java/ru/ulstu/index/controller/IndexController.java index 91b5c75..bacf283 100644 --- a/src/main/java/ru/ulstu/index/controller/IndexController.java +++ b/src/main/java/ru/ulstu/index/controller/IndexController.java @@ -1,16 +1,16 @@ package ru.ulstu.index.controller; +import io.swagger.v3.oas.annotations.Hidden; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import ru.ulstu.core.controller.AdviceController; import ru.ulstu.user.service.UserService; -import springfox.documentation.annotations.ApiIgnore; @Controller() @RequestMapping(value = "/index") -@ApiIgnore +@Hidden public class IndexController extends AdviceController { public IndexController(UserService userService) { super(userService); diff --git a/src/main/java/ru/ulstu/odin/model/OdinField.java b/src/main/java/ru/ulstu/odin/model/OdinField.java index b0d99c9..564e203 100644 --- a/src/main/java/ru/ulstu/odin/model/OdinField.java +++ b/src/main/java/ru/ulstu/odin/model/OdinField.java @@ -1,14 +1,14 @@ package ru.ulstu.odin.model; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; import ru.ulstu.core.error.OdinException; import ru.ulstu.odin.model.annotation.OdinCaption; import ru.ulstu.odin.model.annotation.OdinReadOnly; import ru.ulstu.odin.model.annotation.OdinVisible; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; diff --git a/src/main/java/ru/ulstu/odin/model/OdinStringField.java b/src/main/java/ru/ulstu/odin/model/OdinStringField.java index 498b375..d37d69f 100644 --- a/src/main/java/ru/ulstu/odin/model/OdinStringField.java +++ b/src/main/java/ru/ulstu/odin/model/OdinStringField.java @@ -1,10 +1,10 @@ package ru.ulstu.odin.model; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.Size; import ru.ulstu.odin.model.annotation.OdinString; import ru.ulstu.odin.model.annotation.OdinString.OdinStringType; -import javax.validation.constraints.Email; -import javax.validation.constraints.Size; import java.lang.reflect.Field; import static ru.ulstu.odin.model.annotation.OdinString.OdinStringType.EMAIL; diff --git a/src/main/java/ru/ulstu/paper/controller/PaperController.java b/src/main/java/ru/ulstu/paper/controller/PaperController.java index 29da57d..e2b85f2 100644 --- a/src/main/java/ru/ulstu/paper/controller/PaperController.java +++ b/src/main/java/ru/ulstu/paper/controller/PaperController.java @@ -1,5 +1,7 @@ package ru.ulstu.paper.controller; +import io.swagger.v3.oas.annotations.Hidden; +import jakarta.validation.Valid; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -21,9 +23,7 @@ import ru.ulstu.paper.model.ReferenceDto; import ru.ulstu.paper.service.LatexService; import ru.ulstu.paper.service.PaperService; import ru.ulstu.user.model.User; -import springfox.documentation.annotations.ApiIgnore; -import javax.validation.Valid; import java.io.IOException; import java.net.URLEncoder; import java.util.ArrayList; @@ -37,7 +37,7 @@ import static org.springframework.util.StringUtils.isEmpty; @Controller() @RequestMapping(value = "/papers") -@ApiIgnore +@Hidden public class PaperController { private final PaperService paperService; private final ConferenceService conferenceService; diff --git a/src/main/java/ru/ulstu/paper/controller/PaperRestController.java b/src/main/java/ru/ulstu/paper/controller/PaperRestController.java index b6dd11d..f1baad1 100644 --- a/src/main/java/ru/ulstu/paper/controller/PaperRestController.java +++ b/src/main/java/ru/ulstu/paper/controller/PaperRestController.java @@ -1,5 +1,6 @@ package ru.ulstu.paper.controller; +import jakarta.validation.Valid; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -16,7 +17,6 @@ import ru.ulstu.paper.model.PaperListDto; import ru.ulstu.paper.model.ReferenceDto; import ru.ulstu.paper.service.PaperService; -import javax.validation.Valid; import java.io.IOException; import java.util.List; diff --git a/src/main/java/ru/ulstu/paper/model/Paper.java b/src/main/java/ru/ulstu/paper/model/Paper.java index a1febdd..74141f9 100644 --- a/src/main/java/ru/ulstu/paper/model/Paper.java +++ b/src/main/java/ru/ulstu/paper/model/Paper.java @@ -1,5 +1,20 @@ package ru.ulstu.paper.model; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OrderBy; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.NotBlank; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; import ru.ulstu.conference.model.Conference; @@ -12,21 +27,6 @@ import ru.ulstu.grant.model.Grant; import ru.ulstu.timeline.model.Event; import ru.ulstu.user.model.User; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.DiscriminatorValue; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.OrderBy; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.validation.constraints.NotBlank; import java.util.ArrayList; import java.util.Comparator; import java.util.Date; diff --git a/src/main/java/ru/ulstu/paper/model/PaperDto.java b/src/main/java/ru/ulstu/paper/model/PaperDto.java index 8199d80..96d2e75 100644 --- a/src/main/java/ru/ulstu/paper/model/PaperDto.java +++ b/src/main/java/ru/ulstu/paper/model/PaperDto.java @@ -2,14 +2,14 @@ package ru.ulstu.paper.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.Size; import org.apache.commons.lang3.StringUtils; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.file.model.FileDataDto; import ru.ulstu.user.model.UserDto; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Size; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/src/main/java/ru/ulstu/paper/model/Reference.java b/src/main/java/ru/ulstu/paper/model/Reference.java index 289cdc1..e690758 100644 --- a/src/main/java/ru/ulstu/paper/model/Reference.java +++ b/src/main/java/ru/ulstu/paper/model/Reference.java @@ -1,12 +1,11 @@ package ru.ulstu.paper.model; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; import ru.ulstu.core.model.BaseEntity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; - @Entity public class Reference extends BaseEntity { diff --git a/src/main/java/ru/ulstu/paper/service/PaperNotificationService.java b/src/main/java/ru/ulstu/paper/service/PaperNotificationService.java index 5628c46..a4af8da 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperNotificationService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperNotificationService.java @@ -1,6 +1,5 @@ package ru.ulstu.paper.service; -import com.google.common.collect.ImmutableMap; import org.springframework.stereotype.Service; import ru.ulstu.core.util.DateUtils; import ru.ulstu.paper.model.Paper; @@ -46,22 +45,22 @@ public class PaperNotificationService { } private void sendMessageDeadline(Paper paper) { - Map variables = ImmutableMap.of("paper", paper); + Map variables = Map.of("paper", paper); sendForAllAuhtors(variables, paper, TEMPLATE_DEADLINE, TITLE_DEADLINE); } public void sendCreateNotification(Paper paper) { - Map variables = ImmutableMap.of("paper", paper); + Map variables = Map.of("paper", paper); sendForAllAuhtors(variables, paper, TEMPLATE_CREATE, TITLE_CREATE); } public void statusChangeNotification(Paper paper, Paper.PaperStatus oldStatus) { - Map variables = ImmutableMap.of("paper", paper, "oldStatus", oldStatus); + Map variables = Map.of("paper", paper, "oldStatus", oldStatus); sendForAllAuhtors(variables, paper, TEMPLATE_STATUS_CHANGED, TITLE_STATUS_CHANGED); } public void sendFailedNotification(Paper paper, Paper.PaperStatus oldStatus) { - Map variables = ImmutableMap.of("paper", paper, "oldStatus", oldStatus); + Map variables = Map.of("paper", paper, "oldStatus", oldStatus); sendForAllAuhtors(variables, paper, TEMPLATE_FAILED, TITLE_FAILED); } diff --git a/src/main/java/ru/ulstu/ping/model/Ping.java b/src/main/java/ru/ulstu/ping/model/Ping.java index 7118c22..5270720 100644 --- a/src/main/java/ru/ulstu/ping/model/Ping.java +++ b/src/main/java/ru/ulstu/ping/model/Ping.java @@ -1,8 +1,17 @@ package ru.ulstu.ping.model; +import jakarta.persistence.Column; +import jakarta.persistence.DiscriminatorType; +import jakarta.persistence.Entity; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; import org.hibernate.annotations.Any; -import org.hibernate.annotations.AnyMetaDef; -import org.hibernate.annotations.MetaValue; +import org.hibernate.annotations.AnyDiscriminator; +import org.hibernate.annotations.AnyDiscriminatorValue; +import org.hibernate.annotations.AnyKeyJavaClass; import org.springframework.format.annotation.DateTimeFormat; import ru.ulstu.conference.model.Conference; import ru.ulstu.core.model.BaseEntity; @@ -12,14 +21,6 @@ import ru.ulstu.paper.model.Paper; import ru.ulstu.project.model.Project; import ru.ulstu.user.model.User; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; import java.util.Date; @Entity @@ -36,20 +37,15 @@ public class Ping extends BaseEntity { @Column(name = "activity_type", insertable = false, updatable = false) private String activityType; - @Any( - metaColumn = @Column(name = "activity_type"), - fetch = FetchType.LAZY - ) - @AnyMetaDef( - idType = "integer", metaType = "string", - metaValues = { - @MetaValue(targetEntity = Conference.class, value = "CONFERENCE"), - @MetaValue(targetEntity = Paper.class, value = "PAPER"), - @MetaValue(targetEntity = Project.class, value = "PROJECT"), - @MetaValue(targetEntity = Grant.class, value = "GRANT") - } - ) + @Any + @AnyDiscriminator(DiscriminatorType.STRING) + @AnyKeyJavaClass(Integer.class) @JoinColumn(name = "activity_id") + @Column(name = "activity_type") + @AnyDiscriminatorValue(entity = Conference.class, discriminator = "CONFERENCE") + @AnyDiscriminatorValue(entity = Paper.class, discriminator = "PAPER") + @AnyDiscriminatorValue(entity = Project.class, discriminator = "PROJECT") + @AnyDiscriminatorValue(entity = Grant.class, discriminator = "GRANT") private UserActivity activity; public Ping() { diff --git a/src/main/java/ru/ulstu/ping/service/PingScheduler.java b/src/main/java/ru/ulstu/ping/service/PingScheduler.java index ca8724d..a0fc32f 100644 --- a/src/main/java/ru/ulstu/ping/service/PingScheduler.java +++ b/src/main/java/ru/ulstu/ping/service/PingScheduler.java @@ -1,6 +1,5 @@ package ru.ulstu.ping.service; -import com.google.common.collect.ImmutableMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Scheduled; @@ -15,6 +14,7 @@ import ru.ulstu.user.service.MailService; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Set; @Service @@ -51,7 +51,7 @@ public class PingScheduler { } for (PingInfo pingInfo : pingInfos) { - mailService.sendEmailFromTemplate(ImmutableMap.of("pings", pingInfo.getPings()), + mailService.sendEmailFromTemplate(Map.of("pings", pingInfo.getPings()), pingInfo.getUser(), "pingsInfoWeekEmail", PING_MAIL_SUBJECT); } } diff --git a/src/main/java/ru/ulstu/ping/service/PingService.java b/src/main/java/ru/ulstu/ping/service/PingService.java index 99ca26f..7e9ca90 100644 --- a/src/main/java/ru/ulstu/ping/service/PingService.java +++ b/src/main/java/ru/ulstu/ping/service/PingService.java @@ -28,7 +28,7 @@ public class PingService { @Transactional public Ping addPing(UserActivity activity) throws IOException { Ping newPing = new Ping(new Date(), userService.getCurrentUser()); - newPing.setActivity(activity); + //newPing.setActivity(activity); return pingRepository.save(newPing); } diff --git a/src/main/java/ru/ulstu/project/controller/ProjectController.java b/src/main/java/ru/ulstu/project/controller/ProjectController.java index 09438fd..71170c9 100644 --- a/src/main/java/ru/ulstu/project/controller/ProjectController.java +++ b/src/main/java/ru/ulstu/project/controller/ProjectController.java @@ -1,5 +1,7 @@ package ru.ulstu.project.controller; +import io.swagger.v3.oas.annotations.Hidden; +import jakarta.validation.Valid; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.Errors; @@ -16,9 +18,7 @@ import ru.ulstu.project.model.Project; import ru.ulstu.project.model.ProjectDto; import ru.ulstu.project.service.ProjectService; import ru.ulstu.user.model.User; -import springfox.documentation.annotations.ApiIgnore; -import javax.validation.Valid; import java.io.IOException; import java.util.List; import java.util.stream.Collectors; @@ -27,7 +27,7 @@ import static org.springframework.util.StringUtils.isEmpty; @Controller() @RequestMapping(value = "/projects") -@ApiIgnore +@Hidden public class ProjectController { private final ProjectService projectService; diff --git a/src/main/java/ru/ulstu/project/model/Project.java b/src/main/java/ru/ulstu/project/model/Project.java index 0ddb982..d2d6086 100644 --- a/src/main/java/ru/ulstu/project/model/Project.java +++ b/src/main/java/ru/ulstu/project/model/Project.java @@ -1,5 +1,18 @@ package ru.ulstu.project.model; +import jakarta.persistence.CascadeType; +import jakarta.persistence.DiscriminatorValue; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; import ru.ulstu.core.model.BaseEntity; @@ -11,19 +24,6 @@ import ru.ulstu.grant.model.Grant; import ru.ulstu.timeline.model.Event; import ru.ulstu.user.model.User; -import javax.persistence.CascadeType; -import javax.persistence.DiscriminatorValue; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; diff --git a/src/main/java/ru/ulstu/project/model/ProjectDto.java b/src/main/java/ru/ulstu/project/model/ProjectDto.java index d5a8345..f6884cc 100644 --- a/src/main/java/ru/ulstu/project/model/ProjectDto.java +++ b/src/main/java/ru/ulstu/project/model/ProjectDto.java @@ -2,6 +2,7 @@ package ru.ulstu.project.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotEmpty; import org.thymeleaf.util.StringUtils; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.file.model.FileDataDto; @@ -9,7 +10,6 @@ import ru.ulstu.grant.model.GrantDto; import ru.ulstu.user.model.User; import ru.ulstu.user.model.UserDto; -import javax.validation.constraints.NotEmpty; import java.util.ArrayList; import java.util.HashSet; import java.util.List; diff --git a/src/main/java/ru/ulstu/students/controller/TaskController.java b/src/main/java/ru/ulstu/students/controller/TaskController.java index 5d0f4e8..ce5bcad 100644 --- a/src/main/java/ru/ulstu/students/controller/TaskController.java +++ b/src/main/java/ru/ulstu/students/controller/TaskController.java @@ -1,5 +1,7 @@ package ru.ulstu.students.controller; +import io.swagger.v3.oas.annotations.Hidden; +import jakarta.validation.Valid; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.Errors; @@ -15,9 +17,7 @@ import ru.ulstu.students.model.TaskDto; import ru.ulstu.students.model.TaskFilterDto; import ru.ulstu.students.service.TaskService; import ru.ulstu.tags.model.Tag; -import springfox.documentation.annotations.ApiIgnore; -import javax.validation.Valid; import java.io.IOException; import java.util.List; import java.util.stream.Collectors; @@ -29,7 +29,7 @@ import static ru.ulstu.students.controller.Navigation.TASK_PAGE; @Controller() @RequestMapping(value = "/students") -@ApiIgnore +@Hidden public class TaskController { private final TaskService taskService; diff --git a/src/main/java/ru/ulstu/students/model/Scheduler.java b/src/main/java/ru/ulstu/students/model/Scheduler.java index 67005b1..33c9365 100644 --- a/src/main/java/ru/ulstu/students/model/Scheduler.java +++ b/src/main/java/ru/ulstu/students/model/Scheduler.java @@ -1,14 +1,14 @@ package ru.ulstu.students.model; +import jakarta.persistence.Entity; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; import org.springframework.format.annotation.DateTimeFormat; import ru.ulstu.core.model.BaseEntity; -import javax.persistence.Entity; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; import java.util.Date; @Entity diff --git a/src/main/java/ru/ulstu/students/model/Task.java b/src/main/java/ru/ulstu/students/model/Task.java index 4da0aa2..ddc6480 100644 --- a/src/main/java/ru/ulstu/students/model/Task.java +++ b/src/main/java/ru/ulstu/students/model/Task.java @@ -1,5 +1,19 @@ package ru.ulstu.students.model; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.OneToMany; +import jakarta.persistence.OrderBy; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.NotBlank; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; import ru.ulstu.core.model.BaseEntity; @@ -9,20 +23,6 @@ import ru.ulstu.tags.model.Tag; import ru.ulstu.timeline.model.Event; import ru.ulstu.user.model.User; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; -import javax.persistence.ManyToMany; -import javax.persistence.OneToMany; -import javax.persistence.OrderBy; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.validation.constraints.NotBlank; import java.util.ArrayList; import java.util.Collections; import java.util.Date; diff --git a/src/main/java/ru/ulstu/students/model/TaskDto.java b/src/main/java/ru/ulstu/students/model/TaskDto.java index 24ad204..120ac31 100644 --- a/src/main/java/ru/ulstu/students/model/TaskDto.java +++ b/src/main/java/ru/ulstu/students/model/TaskDto.java @@ -2,11 +2,11 @@ package ru.ulstu.students.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotEmpty; import org.apache.commons.lang3.StringUtils; import ru.ulstu.deadline.model.Deadline; import ru.ulstu.tags.model.Tag; -import javax.validation.constraints.NotEmpty; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/src/main/java/ru/ulstu/students/repository/TaskRepository.java b/src/main/java/ru/ulstu/students/repository/TaskRepository.java index af277d1..0aedfb1 100644 --- a/src/main/java/ru/ulstu/students/repository/TaskRepository.java +++ b/src/main/java/ru/ulstu/students/repository/TaskRepository.java @@ -11,16 +11,16 @@ import java.util.List; public interface TaskRepository extends JpaRepository { - @Query("SELECT t FROM Task t WHERE (t.status = :status OR :status IS NULL) AND (:tag IS NULL OR :tag MEMBER OF t.tags) ORDER BY create_date DESC") + @Query("SELECT t FROM Task t WHERE (t.status = :status OR :status IS NULL) AND (:tag IS NULL OR :tag MEMBER OF t.tags) ORDER BY t.createDate DESC") List filterNew(@Param("status") Task.TaskStatus status, @Param("tag") Tag tag); - @Query("SELECT t FROM Task t WHERE (t.status = :status OR :status IS NULL) AND (:tag IS NULL OR :tag MEMBER OF t.tags) ORDER BY create_date ASC") + @Query("SELECT t FROM Task t WHERE (t.status = :status OR :status IS NULL) AND (:tag IS NULL OR :tag MEMBER OF t.tags) ORDER BY t.createDate ASC") List filterOld(@Param("status") Task.TaskStatus status, @Param("tag") Tag tag); - @Query("SELECT t FROM Task t WHERE(:tag IS NULL OR :tag MEMBER OF t.tags) ORDER BY create_date DESC") + @Query("SELECT t FROM Task t WHERE(:tag IS NULL OR :tag MEMBER OF t.tags) ORDER BY t.createDate DESC") List findByTag(@Param("tag") Tag tag); - @Query("SELECT t FROM Task t WHERE (t.createDate >= :date) ORDER BY create_date DESC") + @Query("SELECT t FROM Task t WHERE (t.createDate >= :date) ORDER BY t.createDate DESC") List findAllYear(@Param("date") Date date); diff --git a/src/main/java/ru/ulstu/students/service/TaskService.java b/src/main/java/ru/ulstu/students/service/TaskService.java index c3b4f3a..4dbee44 100644 --- a/src/main/java/ru/ulstu/students/service/TaskService.java +++ b/src/main/java/ru/ulstu/students/service/TaskService.java @@ -55,7 +55,7 @@ public class TaskService { } public List findAll() { - return taskRepository.findAll(new Sort(Sort.Direction.DESC, "createDate")); + return taskRepository.findAll(Sort.by(Sort.Direction.DESC, "createDate")); } public List findAllDto() { diff --git a/src/main/java/ru/ulstu/tags/model/Tag.java b/src/main/java/ru/ulstu/tags/model/Tag.java index 023cfb4..82163e9 100644 --- a/src/main/java/ru/ulstu/tags/model/Tag.java +++ b/src/main/java/ru/ulstu/tags/model/Tag.java @@ -2,13 +2,13 @@ package ru.ulstu.tags.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.Size; import ru.ulstu.core.model.BaseEntity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Table; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Size; import java.util.Objects; @Entity diff --git a/src/main/java/ru/ulstu/timeline/controller/EventController.java b/src/main/java/ru/ulstu/timeline/controller/EventController.java index 2a9245c..d0ba1b1 100644 --- a/src/main/java/ru/ulstu/timeline/controller/EventController.java +++ b/src/main/java/ru/ulstu/timeline/controller/EventController.java @@ -1,5 +1,6 @@ package ru.ulstu.timeline.controller; +import jakarta.validation.Valid; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -13,7 +14,6 @@ import ru.ulstu.core.model.response.Response; import ru.ulstu.timeline.model.EventDto; import ru.ulstu.timeline.service.EventService; -import javax.validation.Valid; import java.util.List; @RestController diff --git a/src/main/java/ru/ulstu/timeline/model/Event.java b/src/main/java/ru/ulstu/timeline/model/Event.java index bf69a70..81946c2 100644 --- a/src/main/java/ru/ulstu/timeline/model/Event.java +++ b/src/main/java/ru/ulstu/timeline/model/Event.java @@ -1,5 +1,19 @@ package ru.ulstu.timeline.model; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import ru.ulstu.conference.model.Conference; import ru.ulstu.core.model.BaseEntity; import ru.ulstu.grant.model.Grant; @@ -8,20 +22,6 @@ import ru.ulstu.project.model.Project; import ru.ulstu.students.model.Task; import ru.ulstu.user.model.User; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Date; import java.util.List; diff --git a/src/main/java/ru/ulstu/timeline/model/EventDto.java b/src/main/java/ru/ulstu/timeline/model/EventDto.java index 7c3a836..cf2850f 100644 --- a/src/main/java/ru/ulstu/timeline/model/EventDto.java +++ b/src/main/java/ru/ulstu/timeline/model/EventDto.java @@ -2,6 +2,8 @@ package ru.ulstu.timeline.model; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import ru.ulstu.conference.model.ConferenceDto; import ru.ulstu.grant.model.GrantDto; import ru.ulstu.paper.model.PaperDto; @@ -9,8 +11,6 @@ import ru.ulstu.project.model.ProjectDto; import ru.ulstu.students.model.TaskDto; import ru.ulstu.user.model.UserDto; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.util.Date; import java.util.List; diff --git a/src/main/java/ru/ulstu/timeline/model/Timeline.java b/src/main/java/ru/ulstu/timeline/model/Timeline.java index 06e04bc..17bad3a 100644 --- a/src/main/java/ru/ulstu/timeline/model/Timeline.java +++ b/src/main/java/ru/ulstu/timeline/model/Timeline.java @@ -1,11 +1,11 @@ package ru.ulstu.timeline.model; +import jakarta.persistence.CascadeType; +import jakarta.persistence.Entity; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToMany; import ru.ulstu.core.model.BaseEntity; -import javax.persistence.CascadeType; -import javax.persistence.Entity; -import javax.persistence.JoinColumn; -import javax.persistence.OneToMany; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/ru/ulstu/timeline/service/EventScheduler.java b/src/main/java/ru/ulstu/timeline/service/EventScheduler.java index 7899aca..f44565c 100644 --- a/src/main/java/ru/ulstu/timeline/service/EventScheduler.java +++ b/src/main/java/ru/ulstu/timeline/service/EventScheduler.java @@ -1,6 +1,5 @@ package ru.ulstu.timeline.service; -import com.google.common.collect.ImmutableMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Scheduled; @@ -31,7 +30,7 @@ public class EventScheduler { public void sendNotifications() { List events = eventService.findByCurrentDate(); events.forEach(event -> { - Map variables = ImmutableMap.of("description", event.getDescription()); + Map variables = Map.of("description", event.getDescription()); event.getRecipients() .forEach(recipient -> mailService.sendEmailFromTemplate(variables, recipient, "eventNotification", event.getTitle())); if (event.getPeriod() == null) { diff --git a/src/main/java/ru/ulstu/user/component/IpAddressResolver.java b/src/main/java/ru/ulstu/user/component/IpAddressResolver.java index ede78de..e2dd525 100644 --- a/src/main/java/ru/ulstu/user/component/IpAddressResolver.java +++ b/src/main/java/ru/ulstu/user/component/IpAddressResolver.java @@ -1,9 +1,8 @@ package ru.ulstu.user.component; +import jakarta.servlet.http.HttpServletRequest; import org.springframework.util.StringUtils; -import javax.servlet.http.HttpServletRequest; - final class IpAddressResolver { private static final String CLIENT_IP_HEADER = "Client-IP"; private static final String FORWARDED_FOR_HEADER = "X-Forwarded-For"; diff --git a/src/main/java/ru/ulstu/user/component/UserSessionLoginHandler.java b/src/main/java/ru/ulstu/user/component/UserSessionLoginHandler.java index 75187dc..2c61dc8 100644 --- a/src/main/java/ru/ulstu/user/component/UserSessionLoginHandler.java +++ b/src/main/java/ru/ulstu/user/component/UserSessionLoginHandler.java @@ -1,5 +1,9 @@ package ru.ulstu.user.component; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.core.Authentication; @@ -9,10 +13,6 @@ import org.springframework.stereotype.Component; import ru.ulstu.configuration.Constants; import ru.ulstu.user.service.UserSessionService; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; import java.io.IOException; @Component diff --git a/src/main/java/ru/ulstu/user/component/UserSessionLogoutHandler.java b/src/main/java/ru/ulstu/user/component/UserSessionLogoutHandler.java index 606cbcd..625cf96 100644 --- a/src/main/java/ru/ulstu/user/component/UserSessionLogoutHandler.java +++ b/src/main/java/ru/ulstu/user/component/UserSessionLogoutHandler.java @@ -1,5 +1,9 @@ package ru.ulstu.user.component; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.core.Authentication; @@ -9,10 +13,6 @@ import org.springframework.stereotype.Component; import ru.ulstu.configuration.Constants; import ru.ulstu.user.service.UserSessionService; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; import java.io.IOException; @Component diff --git a/src/main/java/ru/ulstu/user/controller/UserController.java b/src/main/java/ru/ulstu/user/controller/UserController.java index 3e653fb..0d1a0af 100644 --- a/src/main/java/ru/ulstu/user/controller/UserController.java +++ b/src/main/java/ru/ulstu/user/controller/UserController.java @@ -1,5 +1,8 @@ package ru.ulstu.user.controller; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; +import jakarta.validation.Valid; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.access.annotation.Secured; @@ -29,9 +32,6 @@ import ru.ulstu.user.model.UserSessionListDto; import ru.ulstu.user.service.UserService; import ru.ulstu.user.service.UserSessionService; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; -import javax.validation.Valid; import java.util.Map; import static ru.ulstu.user.controller.UserController.URL; diff --git a/src/main/java/ru/ulstu/user/controller/UserMvcController.java b/src/main/java/ru/ulstu/user/controller/UserMvcController.java index 1207219..e0ee38e 100644 --- a/src/main/java/ru/ulstu/user/controller/UserMvcController.java +++ b/src/main/java/ru/ulstu/user/controller/UserMvcController.java @@ -1,6 +1,7 @@ package ru.ulstu.user.controller; -import com.google.common.collect.ImmutableMap; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpSession; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; @@ -17,8 +18,6 @@ import ru.ulstu.user.model.UserListDto; import ru.ulstu.user.service.UserService; import ru.ulstu.user.service.UserSessionService; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpSession; import java.util.List; import java.util.Map; @@ -65,7 +64,7 @@ public class UserMvcController extends OdinController { @ModelAttribute("allActivities") public Map getAllActivites() { - return ImmutableMap.of("PAPER", "Статьи", + return Map.of("PAPER", "Статьи", "GRANT", "Гранты", "PROJECT", "Проекты", "CONFERENCE", "Конференции"); diff --git a/src/main/java/ru/ulstu/user/model/User.java b/src/main/java/ru/ulstu/user/model/User.java index a7a51d9..4ab52eb 100644 --- a/src/main/java/ru/ulstu/user/model/User.java +++ b/src/main/java/ru/ulstu/user/model/User.java @@ -1,14 +1,24 @@ package ru.ulstu.user.model; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.JoinTable; +import jakarta.persistence.ManyToMany; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; import org.hibernate.annotations.BatchSize; import ru.ulstu.configuration.Constants; import ru.ulstu.core.model.BaseEntity; -import javax.persistence.*; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; import java.util.Collection; import java.util.Date; import java.util.HashSet; diff --git a/src/main/java/ru/ulstu/user/model/UserDto.java b/src/main/java/ru/ulstu/user/model/UserDto.java index fd139ad..076f677 100644 --- a/src/main/java/ru/ulstu/user/model/UserDto.java +++ b/src/main/java/ru/ulstu/user/model/UserDto.java @@ -1,6 +1,10 @@ package ru.ulstu.user.model; import com.fasterxml.jackson.annotation.JsonIgnore; +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; import org.springframework.util.StringUtils; import ru.ulstu.configuration.Constants; import ru.ulstu.odin.model.OdinDto; @@ -10,11 +14,11 @@ import ru.ulstu.odin.model.annotation.OdinString; import ru.ulstu.odin.model.annotation.OdinVisible; import ru.ulstu.user.controller.UserController; -import javax.validation.constraints.Email; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Pattern; -import javax.validation.constraints.Size; -import java.util.*; +import java.util.Collection; +import java.util.Date; +import java.util.LinkedHashSet; +import java.util.Objects; +import java.util.Set; import java.util.stream.Collectors; import static ru.ulstu.odin.model.annotation.OdinString.OdinStringType.PASSWORD; diff --git a/src/main/java/ru/ulstu/user/model/UserResetPasswordDto.java b/src/main/java/ru/ulstu/user/model/UserResetPasswordDto.java index 58e76ff..7d34433 100644 --- a/src/main/java/ru/ulstu/user/model/UserResetPasswordDto.java +++ b/src/main/java/ru/ulstu/user/model/UserResetPasswordDto.java @@ -1,9 +1,9 @@ package ru.ulstu.user.model; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.Size; import ru.ulstu.configuration.Constants; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.Size; import java.util.Objects; public class UserResetPasswordDto { diff --git a/src/main/java/ru/ulstu/user/model/UserRole.java b/src/main/java/ru/ulstu/user/model/UserRole.java index dac996a..12faea4 100644 --- a/src/main/java/ru/ulstu/user/model/UserRole.java +++ b/src/main/java/ru/ulstu/user/model/UserRole.java @@ -1,11 +1,11 @@ package ru.ulstu.user.model; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; @Entity @Table(name = "user_roles") diff --git a/src/main/java/ru/ulstu/user/model/UserSession.java b/src/main/java/ru/ulstu/user/model/UserSession.java index 50fec65..f8d6949 100644 --- a/src/main/java/ru/ulstu/user/model/UserSession.java +++ b/src/main/java/ru/ulstu/user/model/UserSession.java @@ -1,15 +1,15 @@ package ru.ulstu.user.model; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.validation.constraints.NotNull; import ru.ulstu.core.model.BaseEntity; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.validation.constraints.NotNull; import java.util.Date; @Entity diff --git a/src/main/java/ru/ulstu/user/service/MailService.java b/src/main/java/ru/ulstu/user/service/MailService.java index 369b459..df114ab 100644 --- a/src/main/java/ru/ulstu/user/service/MailService.java +++ b/src/main/java/ru/ulstu/user/service/MailService.java @@ -1,5 +1,7 @@ package ru.ulstu.user.service; +import jakarta.mail.MessagingException; +import jakarta.mail.internet.MimeMessage; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -10,13 +12,11 @@ import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.thymeleaf.context.Context; -import org.thymeleaf.spring5.SpringTemplateEngine; +import org.thymeleaf.spring6.SpringTemplateEngine; import ru.ulstu.configuration.ApplicationProperties; import ru.ulstu.configuration.Constants; import ru.ulstu.user.model.User; -import javax.mail.MessagingException; -import javax.mail.internet.MimeMessage; import java.nio.charset.StandardCharsets; import java.util.Map; @@ -113,7 +113,7 @@ public class MailService { sendEmailFromTemplate(user, "activationEmail", Constants.MAIL_ACTIVATE); } - public void sendPasswordResetMail(User user) throws MessagingException, MailException { + public void sendPasswordResetMail(User user) throws MailException { sendEmailFromTemplate(user, "passwordResetEmail", Constants.MAIL_RESET); } diff --git a/src/main/java/ru/ulstu/user/service/UserService.java b/src/main/java/ru/ulstu/user/service/UserService.java index 619f43b..4a79149 100644 --- a/src/main/java/ru/ulstu/user/service/UserService.java +++ b/src/main/java/ru/ulstu/user/service/UserService.java @@ -1,6 +1,6 @@ package ru.ulstu.user.service; -import com.google.common.collect.ImmutableMap; +import jakarta.mail.MessagingException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; @@ -24,8 +24,25 @@ import ru.ulstu.core.model.UserActivity; import ru.ulstu.core.model.response.PageableItems; import ru.ulstu.ping.model.Ping; import ru.ulstu.ping.service.PingService; -import ru.ulstu.user.error.*; -import ru.ulstu.user.model.*; +import ru.ulstu.user.error.UserActivationError; +import ru.ulstu.user.error.UserBlockedException; +import ru.ulstu.user.error.UserEmailExistsException; +import ru.ulstu.user.error.UserIdExistsException; +import ru.ulstu.user.error.UserIsUndeadException; +import ru.ulstu.user.error.UserLoginExistsException; +import ru.ulstu.user.error.UserNotActivatedException; +import ru.ulstu.user.error.UserNotFoundException; +import ru.ulstu.user.error.UserPasswordsNotValidOrNotMatchException; +import ru.ulstu.user.error.UserResetKeyError; +import ru.ulstu.user.error.UserSendingMailException; +import ru.ulstu.user.model.User; +import ru.ulstu.user.model.UserDto; +import ru.ulstu.user.model.UserInfoNow; +import ru.ulstu.user.model.UserListDto; +import ru.ulstu.user.model.UserResetPasswordDto; +import ru.ulstu.user.model.UserRole; +import ru.ulstu.user.model.UserRoleConstants; +import ru.ulstu.user.model.UserRoleDto; import ru.ulstu.user.repository.UserRepository; import ru.ulstu.user.repository.UserRoleRepository; import ru.ulstu.user.util.UserUtils; @@ -33,9 +50,17 @@ import ru.ulstu.utils.timetable.TimetableService; import ru.ulstu.utils.timetable.errors.TimetableClientException; import ru.ulstu.utils.timetable.model.Lesson; -import javax.mail.MessagingException; import java.text.ParseException; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; @Service @@ -258,7 +283,7 @@ public class UserService implements UserDetailsService { user = userRepository.save(user); try { mailService.sendPasswordResetMail(user); - } catch (MessagingException | MailException e) { + } catch (MailException e) { throw new UserSendingMailException(email); } log.debug("Created Reset Password Request for User: {}", user.getLogin()); @@ -356,7 +381,7 @@ public class UserService implements UserDetailsService { user.setActivated(true); userRepository.save(user); - Map variables = ImmutableMap.of("password", password, "email", email); + Map variables = Map.of("password", password, "email", email); try { mailService.sendInviteMail(variables, email); } catch (MessagingException | MailException e) { @@ -386,7 +411,7 @@ public class UserService implements UserDetailsService { userSessionService.isOnline(user)) ); } - return ImmutableMap.of("users", usersInfoNow, "error", err); + return Map.of("users", usersInfoNow, "error", err); } public Map getActivitiesPings(Integer userId, diff --git a/src/main/java/ru/ulstu/user/service/UserSessionService.java b/src/main/java/ru/ulstu/user/service/UserSessionService.java index 17a7f5b..d99aa40 100644 --- a/src/main/java/ru/ulstu/user/service/UserSessionService.java +++ b/src/main/java/ru/ulstu/user/service/UserSessionService.java @@ -33,7 +33,7 @@ public class UserSessionService { @Transactional(readOnly = true) public PageableItems getSessions(int offset, int count) { final Page page = userSessionRepository.findAll( - new OffsetablePageRequest(offset, count, new Sort(Sort.Direction.DESC, "loginTime"))); + new OffsetablePageRequest(offset, count, Sort.by(Sort.Direction.DESC, "loginTime"))); return new PageableItems<>(page.getTotalElements(), convert(page.getContent(), UserSessionListDto::new)); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8531d06..4346d0c 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -29,6 +29,7 @@ spring.datasource.username=postgres spring.datasource.password=postgres spring.jpa.hibernate.ddl-auto=validate spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false +spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect # Liquibase Settings spring.liquibase.change-log=classpath:db/changelog-master.xml spring.liquibase.drop-first=false diff --git a/src/main/resources/templates/default.html b/src/main/resources/templates/default.html index daf359a..b055513 100644 --- a/src/main/resources/templates/default.html +++ b/src/main/resources/templates/default.html @@ -78,8 +78,8 @@ -
-
+
+